akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define f first
#define s second
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
/*
ll dx[8]={-1,-1,-1,0,0,1,1,1};
ll dy[8]={-1,0,1,-1,1,-1,0,1};
bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}
*/
int main()
{
     ll n,t=0,x=0,y=0,t1,cnt=0,a,b;
     cin>>n;
     for(int i=0;i<n;i++)
     {
         cin>>t1>>a>>b;
         ll diff=abs(a-x)+abs(b-y);
         t=t1-t;
         if(diff>t)
         cnt=10;
         if((t-diff)%2)
         cnt=10;
         x=a,y=b,t=t1;
     }
     if(cnt==10)
        cout<<"No"<<endl;
     else
        cout<<"Yes"<<endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string s;
    cin >> s;
    vector<string> w = {"Sunny", "Cloudy", "Rainy"};
    if (s == w[0]) cout << w[1] << endl;
    if (s == w[1]) cout << w[2] << endl;
    if (s == w[2]) cout << w[0] << endl;
}

Measured memory_bytes: 256
/*Author SHUBH AGRAWAL  */

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pu push  //  adds the value to the last of the queue 
#define lld long long int
#define ins insert /// used in set to insert the values 
#define adv advance  /// used to increment the iterator
#define mp make_pair
#define fi first
#define se second
#define all(c) c.begin(),c.end()
#define PI 3.1415926
//a power n mod p

#define vl  vector<long long int >
#define vpl vector< pair<lld ,lld> >
#define vvl vector<vector<lld> > 

long long int modp(lld a,lld p,lld n)
{
    int d[100];
    int i,j,k,l;
    if(n==0) return 1;
    for(i=0;n>=1;i++)
    {
        d[i]=n%2;
        n/=2;
    }
    l=i;
    long long int e=1;
    if(d[0]==1) e*=(a%p);
    for(i=1;i<l;i++)
    {
        a*=a;
        a=a%p;
        if(d[i]==1) 
        {
            e*=a;
            e=e%p;
        }
    }
    return e%p;
}
lld modInverse(lld n, lld p) 
{ 
    return modp(n, p, p-2); 
}

long long int nCrModPFermat(lld n, lld r,lld p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
    
    // Fill factorial array so that we 
    // can find all factorial of r, n 
    // and n-r 
    lld fac[n+1]; 
    fac[0] = 1; 
    for (lld i=1 ; i<=n; i++) 
        fac[i] = fac[i-1]*i%p; 
  
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
}


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


lld l,r,mid,ans;
lld n,m,i,j,k;
lld x,y,d;

void solve()
{
    cin>>n;
    if(n%2==0) 
    {
        cout<<"0.50000000000";
    }
    else 
    {
        double x= (n/2+1.0);
     //   printf("%0.9f\n",x);   
        x/=(n);
        printf("%0.9f",x);
    }

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lld t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 384
#!/mnt/c/Users/moiki/bash/env/bin/python
S = input()
T = input()
n = len(T)
from collections import defaultdict

diff_s_to_t = {}
diff_t_to_s = {}
same = set()

for i in range(n):
    if S[i] == T[i]:
        same.add(S[i])

for i in range(n):
    if S[i] != T[i] and not S[i] in diff_s_to_t:
        diff_s_to_t[S[i]] = T[i]
        diff_t_to_s[T[i]] = S[i] 

for i in range(n):
    if S[i] != T[i] and  S[i] in diff_s_to_t:
        if diff_s_to_t[S[i]] != T[i]: # atesaki tigau
            print("No")
            exit(0)


for i in range(n):
    if S[i]==T[i] and S[i] in diff_t_to_s: # same and diff
        print("No")
        exit(0)

S,T = T,S
diff_s_to_t = {}
diff_t_to_s = {}
same = set()
for i in range(n):
    if S[i] == T[i]:
        same.add(S[i])

for i in range(n):
    if S[i] != T[i] and not S[i] in diff_s_to_t:
        diff_s_to_t[S[i]] = T[i]
        diff_t_to_s[T[i]] = S[i] 

for i in range(n):
    if S[i] != T[i] and  S[i] in diff_s_to_t:
        if diff_s_to_t[S[i]] != T[i]: # atesaki tigau
            print("No")
            exit(0)


for i in range(n):
    if S[i]==T[i] and S[i] in diff_t_to_s: # same and diff
        print("No")
        exit(0)


print("Yes")
exit(0)


Measured memory_bytes: 43580
D, N = map(int, input().split())
if N == 100:
    if D == 0:
        print(101)
    elif D == 1:
        print(100 * 101)
    elif D == 2:
        print(10000 * 101)
else:
    if D == 0:
        print(N)
    elif D == 1:
        print(100 * N)
    elif D == 2:
        print(10000 * N)

Measured memory_bytes: 3060
def bisect_left(array, i):
    __bisect_array = array
    def _bisect_left(i, left, right):
        n = right - left + 1
        mid = (left+right) // 2
        if n == 1:
            if __bisect_array[mid] < i:
                return 1
            else:
                return 0
        if i <= __bisect_array[mid]:
            return _bisect_left(i,left,mid)
        else:
            return (mid-left+1) + _bisect_left(i,mid+1,right)
    return _bisect_left(i, 0, len(array)-1)

def bisect_right(array, i):
    __bisect_array = array
    def _bisect_right(i, left, right):
        n = right - left + 1
        mid = (right+left) // 2
        if n == 1:
            if i < __bisect_array[mid] :
                return 0
            else:
                return 1
        if __bisect_array[mid] <= i:
            return  (mid-left+1) + _bisect_right(i,mid+1,right)
        else:
           return _bisect_right(i,left,mid)
    return _bisect_right(i, 0, len(array)-1)

N = int(input())
L = []
for _ in range(3):
    l = list(map(int,input().split()))
    L.append(sorted(l))
ans = 0
for x in L[1]:
    n = bisect_left(L[0],x)
    m = bisect_right(L[2],x)
    m = N - m
    ans += n*m
print(ans)

Measured memory_bytes: 24992
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.nextLine());
		String[] strA = sc.nextLine().split(" ");
		int ans = 0;
		for(int i=0; i<N; i++) {
			ans += half(Integer.parseInt(strA[i]), 0);
		}
		System.out.println(ans);
		sc.close();
	}

	private static int half(int num, int count) {
		if(num % 2 == 0) {
			count++;
			count = half(num / 2, count);
		}
		return count;
	}
}

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

int search(int A[], int n, int key) {
    int i = 0;
    A[n] = key;
    while (A[i] != key) i++;
    return i != n;
}

int main() {
    int n = 0, q = 0, A[10000 + 1], key, sum = 0;
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> A[i];
    
    cin >> q;
    for (int i = 0; i < q; ++i) {
        cin >> key;
        if (search(A, n, key)) sum++;
    }
    
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3120
N, T = map(int, input().split(' '))
A = list(map(int, input().split(' ')))

submax = 0
amin=A[0]
total = 0
for i in range(N):
    if A[i] < amin:
        amin = A[i]
    sub = A[i]-amin
    if sub == submax:
        total += 1
    if sub > submax:
        total = 1
        submax = sub

print(total)


Measured memory_bytes: 15020
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
#define all(x) x.begin(),x.end()
#define fi first
#define se second
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓


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

    ll n,k;
    cin>>n>>k;
    ll num = n/k;

    if(n-num*k==0){
        cout<<n-num*k<<endl;
    }else if(n-num*k>0){
        ll ans=abs(n - num*k -k);
        if(ans>n-num*k){
            cout<<n-num*k<<endl;
        }else{
            cout<<ans<<endl;
        }
    }
    
}

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n, d = LI()
d2 = d**2
ans = 0
for i in range(n):
    x, y = LI()
    if x**2 + y**2 <= d2:
        ans += 1
print(ans)

Measured memory_bytes: 68820
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int mod=1e9+7;
const int maxn=2e5+7;
ll qpow(ll a,ll b)
{
  ll ans=1;
  while(b)
  {
    if(b&1)
      ans=ans*a%mod;
    a=a*a%mod;
    b>>=1;
  }
  return ans;
}
ll C(ll a,ll b)
{
  ll ans=1;
  for(int i=1;i<=a;i++)
  {
    ans=ans*i%mod;
  }
  ll res=1;
  for(int i=1;i<=b;i++)
    res=res*i%mod;
    ll ant=1;
  for(int i=1;i<=a-b;i++)
  {
    ant=ant*i%mod;
  }
  ans=ans*qpow(res,mod-2)%mod*qpow(ant,mod-2)%mod;
    return ans;
}
int main()
{
   ios::sync_with_stdio(0); cin.tie(0);
   int n,m;
   cin>>n>>m;
   int a=0;
   n=max(a,n-2*m);
   cout<<n<<endl;
}


Measured memory_bytes: 256
#include <iomanip>
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
#define vec vector<long long int>
#define fi first
#define se second
#define pb push_back
int main()
{

    ll n;
    cin >> n;
    ll ans = 1;
    ll a = 1;
    ll c = 1;

    for (ll i = 0; i < n; i++)
    {
        ans = ((ans % mod) * 10) % mod;
        a = ((a % mod) * 9) % mod;
        c = ((c % mod) * 8) % mod;
    }
    a = ((a % mod) * 2 % mod) % mod;
    ll q = ((ans % mod) - (a % mod)) % mod;
    ll p = ((q % mod) + (c % mod)) % mod;
    cout << (p + mod) % mod;
}

Measured memory_bytes: 3624
fun main(args: Array<String>) {
    val (A, B, C, K) = readLine()!!.split(" ").map { it.toInt() }

    if (A > K) {
        println(K)
        return
    }

    val point = A
    var cardCount = K - A
    if (B > cardCount) {
        println(point)
        return
    }

    cardCount -= B
    if (C > cardCount) {
        println(point - cardCount)
    } else {
        println(point - C)
    }
}


Measured memory_bytes: 36344
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int N;
	ll A[100010];
	cin >> N;
	int count = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		if (A[i] % 2 == 1) count++;
	}
	if (count % 2 == 0) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 1532
C = [[int(i) for i in input().split()] for _ in range(3)]

B = C[0]
A = [0, C[1][0] - B[0], C[2][0] - B[0]]

for i in range(3):
    for j in range(3):
        if C[i][j] != A[i] + B[j]:
            print("No")
            quit()
print("Yes")

Measured memory_bytes: 3060
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<algorithm>

using namespace std;
typedef long long LL;

const int MX=100011;

LL x,k;int q;
LL r[MX];
struct Func{
	LL k,b,L,R;//A=min(X,max(0,kt+b+a)),in[L,R]
	Func(int _k=0,int _b=0,int _L=0,int _R=0):k(_k),b(_b),L(_L),R(_R){}
	inline LL V(LL a,LL t){return min(x,max(0LL,k*t+b+min(R,max(L,a))));}
}f[MX];

int main(){
	scanf("%lld%lld",&x,&k);
	for(int i=1;i<=k;i++)scanf("%lld",&r[i]);
	int K=-1;
	Func cur(K,0,0,x);
	f[0]=cur;
	for(int i=1;i<=k;i++){
		LL vl=f[i-1].V(f[i-1].L,r[i]),vr=f[i-1].V(f[i-1].R,r[i]);
		K=-K;
		if(vl>0&&vr<x){
			f[i]=cur=Func(K,vl-f[i-1].L-K*r[i],f[i-1].L,f[i-1].R);
		}else if(vr<x&&vr>0){
			f[i]=cur=Func(K,vr-f[i-1].R-K*r[i],f[i-1].R-vr,f[i-1].R);
		}else if(vl>0&&vl<x){
			f[i]=cur=Func(K,vl-f[i-1].L-K*r[i],f[i-1].L,f[i-1].L+x-vl);
		}else{//(vl==vr)
			f[i]=cur=Func(K,vl-K*r[i],0,0);
		}
	}
	scanf("%d",&q);
	for(int i=1;i<=q;i++){
		LL t,a;scanf("%lld%lld",&t,&a);
		printf("%lld\n",f[upper_bound(r,r+k+1,t)-r-1].V(a,t));
	}
	return 0;
}


Measured memory_bytes: 4992
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = []
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});

reader.on('line', (line) => {
  lines.push(line);
});

reader.on('close', () => {
 var nmx = lines[0].split(' ');
 var n = Number(nmx[0]);
 var m = Number(nmx[1]);
 var x = Number(nmx[2]);
 var a = lines[1].split(' ');
 var ncost = 0;
 var scost = 0;
 var compare = [];
 a = a.map(function(str) { return Number(str)});

 for(i=x; i<n; i++){
  
   if(a.indexOf(i) != -1){
     ncost++;
   }
 }
 
 for(i=x; i>0; i--){
  
   if(a.indexOf(i) != -1){
     scost++;
   }
 }

 // console.log(ncost);
 compare.push(scost);
 compare.push(ncost);

 var min = Math.min(...compare);

 console.log(min);
 
});

Measured memory_bytes: 21320
#include<bits/stdc++.h>
using namespace std;
#define LL long long
int n,a[200005];
LL d;
struct data{
	LL h,x;
}w[200005];
LL ans;
queue<data>Q;
bool cmp(data a,data b){
	return a.x<b.x;
}
int main(){
	LL n;
	scanf("%lld",&n);
	LL cnt=1;
	while(n){
		ans+=cnt;
		cnt<<=1;
		n>>=1;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    # popするため逆順にしておく
    A=[list(map(lambda x:int(x)-1,input().split())) for _ in range(n)]
    for i in range(n): A[i].reverse()
    stack=[]

    def check(i):
        if(not A[i]): return
        j=A[i][-1]
        if(A[j][-1]==i):
            stack.append((min(i,j),max(i,j)))

    # calculate
    for i in range(n): check(i)
    day=0
    while(stack):
        day+=1
        stack=list(set(stack)) # uniqueを取る
        prev,stack=stack,[]
        for i,j in prev:
            A[i].pop(); A[j].pop()
        for i,j in prev:
            check(i); check(j)
    print(-1 if(any(A[i] for i in range(n))) else day)
resolve()

Measured memory_bytes: 67932
/**********************************************
*   UPDATE CONDITION & OVERFLOW CONDITION     *
**********************************************/

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

#define pi 3.1415926535
#define endl "\n"
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define ll long long
#define llu unsigned long long
#define pb push_back
#define mp make_pair
#define tc int t; cin>>t; while(t--)
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define rf(i,n,a) for(int i=n-1 ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define get(a,n) f(i,0,n) cin >> a[i];
#define show(a,n) f(i,0,n) cout << a[i] << " "; cout << endl;
#define fast ios:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const long long int inf64 = 1e18;
const int mod = inf + 7;
const int N = 2e5 + 10;

int main()
{
    fast;
    ll n, ans = 0;
    cin >> n;
    map<ll, ll> mp;
    for(ll i=1;i<=n;i++)
    {
        ll x;
        cin >> x;

        ans += mp[i-x];

        mp[i+x]++;
    }

    cout << ans;
}



Measured memory_bytes: 26308
icase=0
if icase==0:
    a,b,c,d=map(int,input().split())
    if a<=c:
        if b<c:
            print(0)
        else:
            if d<=b:
                print(d-c)
            else:
                print(b-c)
    else:
        if d<a:
            print(0)
        else:
            if b<=d:
                print(b-a)
            else:
                print(d-a)

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()

using namespace std;

namespace Dump {
#define dump(...) Dump::print(#__VA_ARGS__, __VA_ARGS__)
static std::vector<string> dumpKey;
static string dumpKeyBuf;

void print() { cerr << endl; }
template <class Head, class... Tail> void print(Head &&head, Tail &&... tail) {
  if (dumpKey.empty()) {
    dumpKeyBuf = head;
    dumpKeyBuf.erase(std::remove_if(dumpKeyBuf.begin(), dumpKeyBuf.end(),
                                    [](char c) { return c == ' '; }),
                     dumpKeyBuf.end());

    std::istringstream stream(dumpKeyBuf);
    string field;
    while (std::getline(stream, field, ','))
      dumpKey.push_back(field);

    reverse(dumpKey.begin(), dumpKey.end());
  } else {
    cerr << dumpKey.back() << ":" << head << "  ";
    dumpKey.pop_back();
  }
  Dump::print(std::move(tail)...);
}
}

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<long long> vll;
typedef vector<unsigned long long> vull;
typedef pair<int, int> pii; // p.first p.second

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

void solve(string S) {
  REP(i, S.size() - 1) {
    if (S[i] == 'A' && S[i + 1] == 'C') {
      cout << "Yes" << endl;
      return;
    }
  }
  cout << "No" << endl;
}

int main() {
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  solve(S);
  return 0;
}


Measured memory_bytes: 256
N = int(input())
alphabets = {i: chr(i + 96) for i in range(1, 26)}
alphabets[0] = 'z'

queue = []
if N <= 26:
    print(alphabets[N])
else:
    while N > 0:
        queue.insert(0, alphabets[N % 26])
        N -= 1
        N //= 26

    print(''.join(queue))

Measured memory_bytes: 61780
import java.util.*;
class Main {
    public static void main(String[]$) {
        Scanner c=new Scanner(System.in);
        char[] x=c.next().toCharArray();
        int s=0,a=0;
        for(char t:x){
            a++;
            if(t=='S')s++;
            else if(s>0){
                s--;
                a-=2;
            }
        }
        System.out.print(a);
    }
}

Measured memory_bytes: 26276
#include <iostream>
#include<vector>
#include<iomanip>
#include <cstring>
#include<algorithm>
using namespace std;
typedef long double ld;
#define rep(i,n) for(int i = 0;i <n;i++)
ld dp[310][310][310]; int n,m;
ld rec(int c1, int c2, int c3) {
	if (dp[c1][c2][c3] != -1) return dp[c1][c2][c3];
	if (c1 == c2 && c2 == c3 && c3 == 0) return 0.0;
	ld res = 0.0;
	if (c1 > 0) res += rec(c1 - 1, c2, c3)*c1;
	if (c2 > 0)res += rec(c1 + 1, c2 - 1, c3)*c2;
	if (c3 > 0)res += rec(c1, c2 + 1, c3 - 1)*c3;
	res += (ld)n;
	res *= (ld)1.0 / (c1 + c2 + c3);
	return dp[c1][c2][c3]=res;
}
int main(){
	cin >> n; vector<int> a(3,0);
	rep(i, n) {
		cin >> m;a[m - 1]++;
	}rep(i, 310) rep(j, 310) rep(k, 310) dp[i][j][k] = -1;
	cout << fixed << setprecision(10) << rec(a[0], a[1], a[2]) << endl;
}

Measured memory_bytes: 469288
#include<bits/stdc++.h>
using namespace std;
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL); \
    cout.tie(NULL)
#define inc(x, y, i) for (int i = x; i <= y; i++)
#define dec(x, y, i) for (int i = x; i >= y; i--)
#define repeat(n) for (int i = 0; i<n;i++)

#define ll long long
#define ld long double
#define ull unsigned long long
#define infl LONG_MAX
#define infi INT_MAX
#define nl cout<<'\n'

#define all(v) v.begin(),v.end()
#define vi vector<int>
#define pb push_back
#define pii pair<int,int>
#define mkpr make_pair
#define pq priority_queue

/*void show(auto a)  //for debugging we often need to see the array
{
    for(auto i: a) cout << i << " ";
    cout << endl; // a must be vector
}
void printAr(int a[],int n)  // print the array
{
    for(int *i = a; i!=a+n; ++i)cout << *i << " ";
    cout << endl;
}*/

const int N = 2e5+2;
//int a[N],cum[N];
int n;

int main()
{
    fastio;
    int n,m,x,k;
    cin >> n >> m >> k;
    vi v,u;
    repeat(n){cin >> x;v.push_back(x);}
    repeat(m){cin >> x;u.push_back(x);}
    vi cum_u,cum_v;
    cum_v.push_back(v[0]);
    ll t;
    for(int i = 1;i < n;i++){
        t = cum_v[i-1];
        t = t + v[i];
        if(t > 1e9+2)t = INT_MAX;
        cum_v.push_back(t);
    }
    cum_u.push_back(u[0]);
    for(int i = 1;i<m;i++){
        t = cum_u[i-1];
        t = t + u[i];
        if(t > 1e9+2)t = INT_MAX;
        cum_u.push_back(t);
    }
    //show(cum_u);
    //show(cum_v);
    int ans = upper_bound(all(cum_v),k)-cum_v.begin();
    int cur;
    for(int i = 0;i < m;i++){
        cur = upper_bound(all(cum_v),max(k-cum_u[i],0))-cum_v.begin();
        if(cum_u[i] <=k)
        ans = max(ans,i+1+cur);
        //cout << "i = " << i << " cur = " << cur << endl;
    }
    cout << ans << endl;
    //cout << upper_bound(all(cum_v),150)-cum_v.begin() << endl;
}


Measured memory_bytes: 7180
import sys

input = sys.stdin.buffer.readline

from bisect import bisect_left
from bisect import bisect_right

N = int(input())

A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))
num_a = 0
num_c = 0
res = 0
pre_b = -1


for b in B:
    if b == pre_b:
        res += num_a * num_c
        continue
    num_a = bisect_left(A, b) # a < b となるAの要素数
    pre_num_c = bisect_right(C, b)
    num_c = N - pre_num_c # c > b となるAの要素数
    res += num_a * num_c
    pre_b = b
print(res)



Measured memory_bytes: 21600
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math

    #inf = 10**17
    mod = 10**9 + 7

    # 素因数分解
    def prime_decomp(n):
        i = 2
        res = []
        while i ** 2 <= n:
            while n % i==0:
                n //= i
                res.append(i)
            i += 1
        if n > 1:
            res.append(n)
        return res
        # 素因数のリストを返す(0, 1は空)

    # aの逆元を求める
    def inv(a, mod=mod):
        return pow(a, mod-2, mod)

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


    lcm = [0]*(max(a)+1)
    for i in a:
        l = prime_decomp(i)
        c = Counter(l)
        for k, v in c.items():
            if lcm[k] < v:
                lcm[k] = v
    
    b = 1
    for i in range(len(lcm)):
        if lcm[i] != 0:
            b *= pow(i, lcm[i], mod)
    
    if n == 1:
        print(1)
    else:
        res = 0
        for i in a:
            res += inv(i)
        print(res*b%mod)

if __name__ == '__main__':
    main()

Measured memory_bytes: 59608
class Vector:
    __slots__ = ['x', 'y']

    def __init__(self, x, y):
        self.x, self.y = x, y

    def __add__(self, other):
        return self.__class__(self.x + other.x, self.y + other.y)

    def __sub__(self, other):
        return self.__class__(self.x - other.x, self.y - other.y)

    def __mul__(self, x):
        return self.__class__(self.x * x, self.y * x)

    def __truediv__(self, x):
        return self.__class__(self.x / x, self.y / x)

    def norm(self):
        return (self.x ** 2 + self.y ** 2) ** 0.5


def dot(u, v):
    return u.x * v.x + u.y * v.y


x1, y1, x2, y2 = map(float, input().split())
p1, p2 = Vector(x1, y1), Vector(x2, y2)
n = (p2 - p1) / (p2 - p1).norm()

q = int(input())

for _ in range(q):
    p = Vector(*map(float, input().split()))
    p_new = p1 + n * dot(p - p1, n)
    print(p_new.x, p_new.y)



Measured memory_bytes: 5668
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
using namespace std;

int main() {

	string S, T;
	cin >> S >> T;

	// 文字列 S が存在するかどうかのフラグ
	bool jdg = false;

	int ib = 0;

	// 文字列 T の探索
	for (int i = S.length() - T.length(); i >= 0; i--) {
		jdg = true;
		// 文字列Tと一致するかどうかの探索
		for (int j = 0; j < T.length(); j++) {
			if (S[i + j] == '?') {
				continue;
			}
			else if (S[i + j] != T[j]) {
				jdg = false;
				break;
			}
		}
		if (jdg == true) {
			ib = i;
			break;
		}
	}

	if (jdg == true) {
		// 文字列 S の探索
		for (int i = 0; i < S.length(); i++) {
			if (S[i] == '?') {
				S[i] = 'a';
			}
		}
		for (int i = ib; i < ib + T.length(); i++) {
			S[i] = T[i - ib];
		}

		cout << S << endl;
	}
	else {
		cout << "UNRESTORABLE" << endl;
	}

	return 0;
}



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

namespace BOrdinaryNumber
{
    class Program
    {
        static void Main(string[] args)
        {
            // 入力の取得
            var n = int.Parse(Console.ReadLine());
            var pArray = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var answer = 0;
            for (var i = 1; i < n - 1; i++)
            {
                if ((pArray[i - 1] < pArray[i] && pArray[i] < pArray[i + 1]) ||
                    (pArray[i - 1] > pArray[i] && pArray[i] > pArray[i + 1]))
                {
                    answer++;
                }
            }

            // 解答の出力
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 13268
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

bool only(string S){
    bool res=true;
    rep(i,S.size()-1) if(S[i]!=S[i+1]) res=false;
    return res;
}

int main(void){
    string S;
    cin >> S;
    int N=S.length();
    int ans=INF;
    int alf[26]={};
    rep(i,N) alf[S[i]-'a']++;
    rep(i,26){
        if(alf[i]==0) continue;
        char c='a'+i;
        string s=S;
        int cnt=0;
        while(!only(s)){
            string nw;
            rep(j,s.size()-1){
                if(s[j]==c || s[j+1]==c) nw+=c;
                else nw+='0';
            }
            cnt++;
            s=nw;
        }
        ans=min(ans,cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <climits>
#define ll long long
#define MAX 25 * 1e13
#define N  200010

#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define MP(A,B) make_pair(A,B)
#define PB(X) push_back(X)
#define EB(X) emplace_back(X)
#define REP(i,a) for(int i=0;i<(a);++i)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()
#define VI vector<int>;

using namespace std;
int MOD = 1000000007;


ll gcd(ll a,ll b){
  if( b == 0 ) return a;
  return gcd(b,a%b);
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vector<int> sub(n+1);
  REP(i,n-1) {
    int boss;
    cin >> boss;
    int p = i + 2;
    sub[boss]++;
  }
  REP(i,n) {
    int p = i + 1;
    cout << sub[p] << endl;
  }

  return 0;
}



Measured memory_bytes: 3616
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	a := make([]int, n)
	for i := range a {
		a[i] = scanInt()
	}
	sort.Ints(a)
	if a[0] == 0 {
		fmt.Println(0)
		return
	}

	ans := 1
	for _, v := range a {
		if v > 1000000000000000000/ans {
			fmt.Println(-1)
			return
		}
		ans *= v
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5920
dic = {}
n = int(input())
for i in range(n):
  name, num = input().split()
  num = int(num)
  l = len(name)
  if (l, name) in dic:
    dic[(l, name)] += num
  else:
    dic[(l, name)] = num
dic = sorted(dic.items())
for d in dic:
  print(d[0][1], d[1])


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

int main()
{

	int N;
	cin >> N;

	deque<int> list,ansb;

	list.resize(N);
	//ansb.resize(N);
	for (size_t i = 0; i < N; i++)
	{
		cin >> list[i];
	}

	bool f = false;
	if (N % 2 == 0)
		f = true;
	for (size_t i = 0; i < N; i++,f = !f)
	{
		/// 偶数は後ろから始める
		if (f)
			ansb.push_back(list[i]);
		/// 奇数は前から始める．
		else
			ansb.push_front(list[i]);

	}

	for (size_t i = 0; i < N; i++)
	{
		cout << ansb[i] << " ";
	}
	cout << endl;



	return 0;
}

Measured memory_bytes: 3840
def list_check(list1, list2):
    return set(list1).issubset(list2)

a = list()
for _ in range(3):
    a.extend(list(map(int, input().split())))

lists = []

bingo = []
N = int(input())
for _ in range(N):
    b = int(input())
    if b in a:
        idx = a.index(b)
        bingo.append(idx)
        

for i in [0,1,2]:
    l = [i,i+3, i+6]
    lists.append(l)

for i in [0,3,6]:
    l = [i,i+1, i+2]
    lists.append(l)

lists.append([0,4,8])
lists.append([2,4,6])


for li in lists:    
    if list_check(li, bingo):
        print('Yes')
        exit()

print('No')

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

int main()
{
	string m, n, o, p;
	cin >> m >> n >> o;
	
	p += toupper(m[0]);
	p += toupper(n[0]);
	p += toupper(o[0]);
	
	cout << p;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
bool ok(ll a, ll b, ll c){
    if(a == b || b == c){
        return false;
    }
    if(a + b <= c){
        return false;
    }else{
        return true;
    }
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n ;
    ll a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    ll ans = 0;
    sort(a, a+n);
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                if(ok(a[i], a[j], a[k])) ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3612
#include <stdio.h>
int main(void)
{
	int x,a,b;
	scanf("%d %d %d", &x, &a, &b);
	if(a>=b)
	printf("delicious\n");
	else if(a*-1+b<=x)
	printf("safe\n");
	else
	printf("dangerous\n");
	
	return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N];
		for (int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
		}
		long answer = gcd(a[0], a[1]);
		for (int i = 0; i < N; i++) {
			answer = gcd(answer, a[i]);
		}
		System.out.println(answer);
	}
	public static long gcd(long div, long div2) {
		if (div2 == 0) {
			return div;
		}
		return gcd(div2, div%div2);
	}
}

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

int main()
{
    int n;
    ll k;
    int q;
    cin >> n >> k >> q; 
    int a;
    vector<int> table(n,0);
    rep(i,q){
        cin >> a;
        a--;
        table[a]++;
    }

    rep(i,n){
        if(table[i] > q-k) cout << "Yes" << endl;
        else cout << "No" << endl;
    }


    return 0;

}

Measured memory_bytes: 3752
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath> 
using namespace std;
#define ll long long
const int maxn = 1e6 + 10;

ll MOD = 1e9+7;
ll a[ maxn ];
ll n;

int main ( void ) {
	cin >> n;
	ll flag = 1;
	ll ans = 1;
	if ( n % 2 == 0 ) {  
		for ( ll i = 0 ; i < n ; i++ ) {
			ll x;
			cin >> x;
			a [ x ]++;
			if ( x >= n || x % 2 == 0 || a [ x ] > 2 ) {
				flag = 0;
				cout << "0" << endl;
				break;
			}
			if ( a [ x ] == 1 ) {
				ans = ans * 2 % MOD;
			}
		}
	} else { 
		for ( ll i = 0 ; i < n ; i++ ) {
			ll x;
			cin >> x;
			a [ x ]++;
			if ( x >= n || x % 2 == 1 || a [ 0 ] > 1 || a [ x ] > 2 ) {
				flag = 0;
				cout << "0" << endl;
				break;
			}
			if ( x != 0 && a [ x ] == 1 ) {
				ans = ans * 2 % MOD;
			}
		}
	}

	if ( flag )
		cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4344
#include <bits/stdc++.h>
using namespace std;
int dmax(int x,int y,int z){
  if(x>=y && x>=z){
    return x;
  }
  else if(y>=x && y>=z){
    return y;
  }
  else if(z>=x && z>=y){
    return z;
  }
}
int main() {
  int a,b;
  cin >> a>> b;
  int ans;
  ans =dmax(a+b,a-b,a*b);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
#include <climits>
#include <queue>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define FOR(i, a, b) for(ll i=(a); i < (ll)(b); ++i)
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;}

int main(){
	string s;
	cin >> s;
	int n = s.size();
	
	REP(i,n-1){
		if(s[i]==s[i+1]){
			cout << i+1 << " " << i+2<<endl;
			return 0;
		}
		
		if(i<=n-2 && s[i]==s[i+2]){
			cout << i+1 << " " << i+3<<endl;
			return 0;
		}
	}
	
	cout << "-1 -1\n";
	
	
	return 0;
}

Measured memory_bytes: 3736
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int i, n, bc = 0, bp, tp, tcnt = 1;
		n = sc.nextInt();
		int[] tcal = new int[n];
		bp = sc.nextInt();
		tp = sc.nextInt();
		bc = sc.nextInt();
		for(i = 0; i < n; i++) tcal[i] = sc.nextInt();
		int sump = bp; int sumc = bc;
		int best = sumc / sump;
		Arrays.sort(tcal);
		for(i = n-1; i >= 0; i--) {
			sumc += tcal[i];
			sump = bp + tp*tcnt;
			tcnt++;
			int dpc = sumc / sump;
			if(best <= dpc) best = dpc;
			else break;
		}
		System.out.println(best);
	}
}

Measured memory_bytes: 18132
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

//defines
typedef long long ll;

using namespace std;

double pi=1.57079632679489661923;
ll modu=1e9+7;

ll t=1,n=1,q;

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

    string s;
    cin>>s;
    if(s[0]=='R' && s[1]=='R' && s[2]=='R') cout<<3<<endl;
    else if( (s[0]=='R' && s[1]=='R' && s[2]!='R') || (s[0]!='R' && s[1]=='R' && s[2]=='R')  ) cout<<2<<endl;
    else if(s[0]=='S' && s[1]=='S' && s[2]=='S') cout<<0<<endl;
    else cout<<1<<endl;
}


Measured memory_bytes: 3640
import java.util.*;

public class Main 
{
    public static void main(String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(b%a==0)
          System.out.print(a+b);
      	else
          System.out.print(b-a);
        sc.close();
    }
}


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

int main(){
  int L;
  std::cin >> L;

  double Edge =(double) L / 3;

  //double Volume = pow(Edge,3);
  //std::cout << Volume << std::endl;
  std::cout << std::fixed << std::setprecision(12) << pow(Edge,3) << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int MAXM = 50;
int cnt[MAXM];

int cal(LL x) {
    int cnt = -1;
    while (x) {
          cnt++;
          x >>= 1;
    }
    return cnt;
}

int main() {
    LL N, K;
    scanf("%lld %lld", &N, &K);
    for (int i = 0; i < N; i++) {
        LL tmp;
        scanf("%lld", &tmp);
        for (int j = 0; j < MAXM; j++)
            if (((LL)1 << j) & tmp) cnt[j]++;
    }
    LL ans = 0;
    for (int i = MAXM - 1; i >= 0; i--) {
        LL cur = (LL)1 << i;
        if (cur > K) ans += cnt[i] * ((LL)1 << i);
        else {
           int cnt0 = N - cnt[i];
           if (cnt[i] >= cnt0) ans += cnt[i] * ((LL)1 << i);
           else {
              ans += cnt0 * ((LL)1 << i);
              K -= cur;
           }
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
n = int(input())
cnt = 0
t,x,y = 0,0,0
for i in range(n):
  nt, nx, ny  = map(int, input().split())
  if abs(nx-x)+abs(ny-y) <= nt-t and t%2 == (x+y)%2:
    cnt += 1
  t,x,y = nt,nx,ny
print("Yes" if cnt == n else "No")

Measured memory_bytes: 3060
n = int(input())
a = [int(input()) for _ in range(n)]
a = sorted(a)
res = a[-1]-a[0]
minn,maxx = a[0],a[-1]
for i in range(1,n//2):
    res += maxx - a[i]
    res += a[-1-i] - minn
    minn,maxx = a[i],a[-1-i]
if n%2==1:
    res += max(abs(maxx-a[n//2]),abs(minn-a[n//2]))
print(res)


Measured memory_bytes: 8284
import java.util.*;
import java.io.*;

public class Main
{
    static class Reader {
		BufferedReader br;
		StringTokenizer st;
 
		public Reader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
 
		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
 
		int nextInt() {
			return Integer.parseInt(next());
		}
 
		long nextLong() {
			return Long.parseLong(next());
		}
 
		double nextDouble() {
			return Double.parseDouble(next());
		}
 
		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
 
	}
    static class Ele implements Comparable<Ele> 
    {  
        public int x,y;  
        Ele(int x,int y) 
        {  
            this.x=x;this.y=y; 
        }  
        public int compareTo(Ele ob) {  
        if(ob.x!=x)return x-ob.x;
        return this.y-ob.y;  
        }   
    }
    int a[][];int b[][];
    
    long gcd(long a,long b)
    {
        long min=Math.min(a,b);
        long max=Math.max(a,b);
        while (max%min!=0)
        {
            a=max%min;
            max=min;min=a;
        }
        return min;
    }
	public static void main(String[] args) throws IOException 
	{
		Reader sc=new Reader();//Solution G=new Solution();
		PrintWriter o = new PrintWriter(System.out);
		int t=1;
		//int t=sc.nextInt();
		
		int n,m,y0,x0,y1,x1,x2,y2,s0,s2;long a[],b[],in[],in1[];
		long k,s,l;boolean b1[],b2;String s1[],ss;int mod=(int)1e9+7;
		//long l;long a[]; 
		ArrayList<ArrayList<Integer>> ll=new ArrayList<>();
		ArrayList<Integer> a1=new ArrayList<>();
		ArrayList<Integer> a2=new ArrayList<>();
		ArrayList<Integer> a3=new ArrayList<>();
		ArrayDeque<Integer> deq=new ArrayDeque<>();
		TreeSet<Integer> h0=new TreeSet<>();
		TreeSet<Integer> h1=new TreeSet<>();
		HashMap<Integer,Integer> h=new HashMap<>();
		try{
		while (t-->0)
		{
		    n=sc.nextInt();a=new long[n];k=0;l=0;s=0;b=new long[n];
		    for (int i=0;i<n;i++)
		    {
		        a[i]=sc.nextInt();
		    }
		    for (int i=0;i<n;i++)
		    {
		        b[n-i-1]=s;
		        s=(s+a[n-i-1])%mod;
		    }
		    //o.println(Arrays.toString(a)+" "+Arrays.toString(b));
		    for (int i=0;i<n;i++)
		    {
		        k=(a[i]*b[i])%mod;
		        l=(l+k)%mod;
		        
		    }
		    o.println(l);
		    //o.println();
		    //o.println();
		    //o.println(h);
		    //o.println(x2);
		    //o.println();
		    h0.clear();ll.clear();a1.clear();a2.clear();h1.clear();
		}
		}
		catch (Throwable e)
		{
		    e.printStackTrace();
		}
		//o.println("HI");
		
        o.flush();
        o.close();
	}
} 

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

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

using ll = long long;
using ull = unsigned long long;

int main() {
  stack<int> stk;
  string s;
  while (cin >> s) {
    if (s == "+") {
      int a = stk.top(); stk.pop();
      int b = stk.top(); stk.pop();
      stk.push(b + a);
    } else if (s == "-") {
      int a = stk.top(); stk.pop();
      int b = stk.top(); stk.pop();
      stk.push(b - a);
    } else if (s == "*") {
      int a = stk.top(); stk.pop();
      int b = stk.top(); stk.pop();
      stk.push(b * a);
    } else {
      stk.push(stoi(s));
    }
  } 
  cout << stk.top() << endl;
  return 0;
}



Measured memory_bytes: 3164
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define um unordered_map
#define MAX 100000
using namespace std;

um<int,list<int>> l;
int dp[MAX+1];

int dfs(int src)
{
    if(dp[src]!=-1)
    return dp[src];
    
    int ans=0;
    bool leaf=1;
    for(auto node:l[src])
    {
        leaf=0;
        ans=max(ans,dfs(node));
    }
    return dp[src]=(leaf?0:1+ans);
}
int main() {
    
    int n,m;
    cin>>n>>m;
    while(m--)
    {
        int x,y;
        cin>>x>>y;
        l[x].pb(y);
    }
    for(int i=1;i<=n;i++)
    {
        dp[i]=-1;
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        ans=max(ans,dfs(i));
    }
    cout<<ans;
}


Measured memory_bytes: 15236
package main

import (
	"fmt"
	"os"
	"strconv"
)

func main() {
	var n1 string
	fmt.Scan(&n1)
	n2, _ := strconv.Atoi(n1)

	cnt := 0
	list := make([]int, n2)
	for i :=0; i < n2; i++ {
		var c int
		fmt.Scan(&c)
		list[i] = c
	}

	for {
		for i, v := range list {
			if  v % 2  != 0 {
				fmt.Println(cnt)
				os.Exit(0)
			}
			list[i] = v/2
		}
		cnt++
	}
}


Measured memory_bytes: 512
class _in{struct my_iterator{int it;const bool rev;explicit constexpr my_iterator(int it_, bool rev=false):it(it_),rev(rev){}constexpr int operator*(){return it;}constexpr bool operator!=(my_iterator& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const my_iterator i,n;public:explicit constexpr _in(int n):i(0),n(n){}explicit constexpr _in(int i,int n):i(i,n<i),n(n){}constexpr const my_iterator& begin(){return i;}constexpr const my_iterator& end(){return n;}};

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

const int INF = 1e9;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int N;
    while(cin >> N && N) {
        vector<string> city(N);
        for(auto& x : city) cin >> x;

        vector<vector<int>> str_comp(N, vector<int>(N, 0));
        for(int i : _in(N)) for(int j : _in(N)) if(i != j) {
            str_comp[i][j] = city[j].size();
            for(int len : _in(min(city[i].size(), city[j].size()), 0))
              if(city[j].substr(0, len) == city[i].substr(city[i].size() - len, len)) {
                  str_comp[i][j] -= len;
                  break;
              }

            if(city[i].size() >= city[j].size())
              for(int s : _in(city[i].size() - city[j].size()))
                if(city[i].substr(s, city[j].size()) == city[j]) {
                    str_comp[i][j] = 0;
                    break;
                }
        }
        
        vector<vector<int>> dp(1 << N, vector<int>(N, INF));
        for(int i : _in(N)) dp[1 << i][i] = city[i].size();
        for(int S : _in(1 << N)) for(int i : _in(N))
          for(int j : _in(N)) if(!(S & (1 << j))) {
              if(str_comp[i][j] == 0) 
                dp[S | (1 << j)][i] = min(dp[S | (1 << j)][i], dp[S][i]);
              else
                dp[S | (1 << j)][j] = min(dp[S | (1 << j)][j], dp[S][i] + str_comp[i][j]);
          }

        int S = (1 << N) - 1;
        cout << *min_element(dp[S].begin(), dp[S].end()) << endl;
    }
    return 0;
}

Measured memory_bytes: 4392
#include <stdio.h>
#include <algorithm>
long long n, m, x, ans;
long long a[2000];
long long dp[2001];
long long e[2001];
int main() {
	scanf("%lld", &n);
	for (long long i = 0; i < n; i++) {
		scanf("%lld", a + i);
		a[i] = a[i] * 10000 + i;
	}
	std::sort(a, a + n);
	for (long long i = n - 1; i >= 0; i--) {
		for (long long j = 0; j <= m; j++) {
			x = a[i] / 10000 * (a[i] % 10000 - j);
			if (e[j + 1] < x + dp[j])e[j + 1] = x + dp[j];
			x = a[i] / 10000 * (n - 1 - m + j - a[i] % 10000);
			if (e[j] < x + dp[j])e[j] = x + dp[j];
		}
		for (long long j = 0; j <= m + 1; j++) {
			dp[j] = e[j];
			e[j] = 0;
		}
		m++;
	}
	for (long long i = 0; i <= n; i++) {
		if (dp[i] > ans)ans = dp[i];
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 1784
#include<bits/stdc++.h>
using namespace std;
long long n,m,s[200000],a[200000];
int main()
{
   cin>>n;
   for(int i=2; i<=n; i++)
   {
       cin>>a[i];
       s[a[i]]++;
   }
   for(int i=1; i<=n; i++)
   {
       cout<<s[i]<<endl;
   }
}

Measured memory_bytes: 6720