akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdlib.h>

using namespace std;

int d[8][2] = {
	{-1, -1},
	{-1, 0},
	{-1, 1},
	{0, -1},
	{0, 1},
	{1, -1},
	{1, 0},
	{1, 1}
};

int search(int **a, int x, int y, int n, int k)
{
	if(x < 0 || y < 0 || x == n || y == n || a[x][y] == 0){
		return 0;
	} else {
		return (search(a, (x+d[k][0]), (y+d[k][1]), n, k) + 1);
	}
}

int main(int argc, char **argv)
{
	int **a, n, i, j, k, tmp, c, cnt = 0;
	
	while(1){
		cin >> tmp;
		if(tmp == 0){
			break;
		}
		n = tmp;
		a = (int **)calloc(n, sizeof(int));
		for(i = 0; i < n; i++){
			a[i] = (int *)calloc(n, sizeof(int));
			for(j = 0; j < n; j++){
				scanf("%1d", &a[i][j]);
			}
		}
			
		for(i = 0, c = 0; i < n; i++){
			for(j = 0; j < n; j++){
				if(a[i][j] == 1){
					for(k = 0, tmp = 1; k < 8; k++, tmp = 1){
						tmp += search(a, i+d[k][0], j+d[k][1], n, k);			
						if(c < tmp){
							c = tmp;
						}
					}
				}
			}
		}
		
		cout << c << endl;
		for(i = 0; i < n; i++){
			free(a[i]);
		}
		free(a);
		n = 0;
	}
	
	return 0;
}

Measured memory_bytes: 1208
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
const ll MOD=100000007;
const ll INF=1000000101001;
int main(){
int n;cin>>n;
bool ok=false;
for(int i=1;i<=9;i++){
    for(int j=1;j<=9;j++){
        if(i*j==n)ok=true;
    }
}
if(ok)cout << "Yes" << endl;
else cout << "No" << endl;
}

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

#define ll long long int

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

  vector<string> s(n);
  for(int i = 0; i < n; i++) {
    cin >> s[i];
    sort(s[i].begin(), s[i].end());
  }
  sort(s.begin(), s.end());

  ll ans = 0;
  ll count = 1;
  for(int i = 0; i < n - 1; i++) {
    if(s[i].compare(s[i + 1]) == 0) count++;
    if(s[i].compare(s[i + 1]) != 0 || i == n - 2) {
      if(count >= 2) {
        ans += count * (count - 1) / 2;
      }
      count = 1;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 7296
#include <stdio.h>

int main()
{
	int n,
		A[2],B[2],	/*{ \ü«Éµ½J[hÉ©ê½ , ¾_ }*/
		i;
	
	while(scanf("%d",&n),n!=0){
		A[1] = 0;
		B[1] = 0;
		for(i=0;i<n;i++){
			scanf("%d %d",&A[0],&B[0]);
			if(A[0] == B[0]){
				A[1] += A[0];
				B[1] += B[0];
			} else if(A[0] > B[0]){
				A[1] += A[0] + B[0];
			} else{					/*B[0] > A[0]*/
				B[1] += A[0] + B[0];
			}
		}
		printf("%d %d\n",A[1],B[1]);
	}
	
	return 0;
}

Measured memory_bytes: 0
import sys
input = sys.stdin.readline

def func(num, need_height, heights):
    answer= 0
    for i in range(num):
        if(heights[i]>=need_height):
            answer += 1

    print(answer)


def main():
    n,k = [int(i) for i in input().split()] 
    h = list(map(int, input().split()))
    func(n,k,h)
    
# main関数呼び出し
if __name__ == "__main__":
    main() 

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int d = max({a, b, c}) * 3 - (a + b + c);
    cout << (d % 2 ? d + 3 : d) / 2 << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
	int k;
	cin >> k;
	for (int z = 0; z < k; z++) {
		int c, a, n, sum = 0;
		cin >> c >> a >> n;
		while (c > 0 && a > 0 && n > 0) {
			c--;
			a--;
			n--;
			sum++;
		}
		while (c > 1 && a > 0) {
			a--;
			c -= 2;
			sum++;
		}
		while (c > 2) {
			c -= 3;
			sum++;
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 3080
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, A, B;
  cin >> N >> A >> B;
  ll po = N / (A + B);
  ll yo = N % (A + B);
  ll ans = po * A + min(yo, A);
  cout << ans << endl;
  return 0;
}


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


int main(){
  int y,m,d;
  char x,u;
  cin>>y>>x>>m>>u>>d;
  if(y<2019){
    cout << "Heisei" << endl;
    return 0;
  }
  if(y == 2019 && m<5){
    cout << "Heisei" << endl;
    return 0;
  }
  else cout <<"TBD"  << endl;
}


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

int main(){
    int cnt;
    string s;
    bool judge;
    map <char,bool> j;
    j['a']=j['q']=j['z']=j['w']=j['s']=j['x']=j['e']=j['c']=j['d']=j['r']=j['f']=j['v']=j['t']=j['g']=j['b'] = true;
    j['u']=j['j']=j['m']=j['y']=j['h']=j['n']=j['i']=j['k']=j['o']=j['l']=j['p'] = false;
    while(1){
        cnt = 0;
        cin >> s;
        if(s[0] == '#') break;
        judge = j[s[0]];
        for(int i=1;i<s.size();i++){
            if(judge != j[s[i]]){
                cnt++;
                judge = j[s[i]];
            }
        }
        cout << cnt << endl;
    }
}

Measured memory_bytes: 1184
#include<stdio.h>
int main(void){
  int n;
  scanf("%d",&n);
  char s[n];
  scanf("%s",&s);
  int sum=0;
  for(int i=0;i<n-1;i++){
    if(s[i]!=s[i+1])sum++;
  }
printf("%d",sum+1);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
    
    int res=0;
    for (int i=A; i<=B; i++) {
        string s = to_string(i);
        bool flg=true;
        for (int j=0; j<s.size()/2; j++) {
            if (s[j] == s[s.size()-j-1]) flg = true && flg;
            else flg = false && flg;
        }
        if (flg == true) res++;
    }
    
    cout << res << endl;
}


Measured memory_bytes: 256
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#endif
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
char pre;int ans=0,n;
int main(){
	cin>>n;getchar();pre=getchar();ans=1;
	for(int i=1;i<n;i++){
		char ch=getchar();
		if(ch!=pre){
			pre=ch;ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) sort((a).rbegin(), (a).rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define ALL(a) a.begin(), a.end()
typedef long long ll;
using namespace std;

int D, G;
vector<pair<int, int>> A(10);
vector<bool> V(10);
int ans = 1E9;

void clc() {

    int sum   = 0;
    int count = 0;
    REP(i, D) {
        if (V[i] == true) {
            sum += 100 * (i + 1) * A[i].first + A[i].second;
            count += A[i].first;
        }
    }
    for (int i = D - 1; i >= 0; i--) {
        if (V[i] == false) {
            REP(j, A[i].first - 1) {
                if (sum < G) {
                    sum += 100 * (i + 1);
                    count++;
                }
            }
        }
        if (sum >= G)
            break;
    }
    if (sum >= G)
        ans = min(ans, count);
}

void dfs(int depth) {
    if (depth == D) {
        clc();
        depth = 0;
    } else {
        REP(i, 2) {
            V[depth] = i;
            dfs(depth + 1);
        }
    }
}

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

    cin >> D >> G;
    REP(i, D) {
        int a, b;
        cin >> a >> b;
        A[i].first  = a;
        A[i].second = b;
    }

    dfs(0);

    cout << ans << endl;

    return 0;
}

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

int main(void){
    int h, w;
    cin >> h >> w;
    vector<vector<char>> a(h, vector<char>(w));
    vector<bool> d_h(h), d_w(w);
    rep(i, h){
        rep(j, w){
            cin >> a.at(i).at(j);
            if(a.at(i).at(j) == '#') d_h.at(i) = true;
        }
    }
    rep(j, w){
        rep(i, h){
            cin >> a.at(i).at(j);
            if(a.at(i).at(j) == '#') d_w.at(j) = true;
        }
    }

    rep(i, h){
        if(!d_h.at(i)) continue;
        rep(j, w){
            if(!d_w.at(j)) continue;
            cout << a.at(i).at(j);
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        HashMap<Integer, ArrayList<Integer>> map = new HashMap<>();
        for (int i = 0; i < m; i++) {
            int v = scanner.nextInt();
            int e = scanner.nextInt();
            map.putIfAbsent(v,new ArrayList<>());
            map.get(v).add(e);
        }
        int[] dp = new int[n+1];
        Arrays.fill(dp,-1);
        for(int i : map.keySet()){
            path(map,i,dp);
        }
        int longestPath=0;
        for(int i : dp)
            longestPath = Math.max(longestPath,i);
        System.out.println(longestPath);

    }
    private static int path(HashMap<Integer, ArrayList<Integer>> map ,int n ,int[] dp){
        if(!map.containsKey(n)) {
            dp[n]=0;
            return 0;
        }
        if(dp[n] !=-1)
            return dp[n];
        int longestPath=0;
        for(int i : map.get(n)){
            longestPath = Math.max(longestPath,path(map,i,dp));
        }
        return dp[n]=longestPath+1;
    }
}


Measured memory_bytes: 82916
#include <stdlib.h>
int main(void){
  int n=0,m=0,k=0,i;
  int a[10000];
  scanf("%d %d",&n,&m);
  
  for(i=0;i<m;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<m;i++){
    k+=a[i];
  }
  if((n-k)>=0){
    printf("%d",n-k);
  }else{
    printf("-1");
  }
  return 0;
}

  

  


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

char s[101000];
int n=1e5+7, a[101000], b[101000];

void gao(int *a){
    cin>>s+1;
    for (int i=1;i<=n;++i)
        a[i]=a[i-1]+s[i]-'A'+1;
}

int main(){
    gao(a); gao(b);
    int q, x, y, u, v;
    for (cin>>q;q--;){
        cin>>x>>y>>u>>v;
        puts((a[y]-a[x-1])%3==(b[v]-b[u-1])%3? "YES": "NO");
    }
}

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

int main(){
  int N;
  cin >> N;
  vector<long> A(N);
  vector<long> B(N);
  for(int i=0; i<N; i++){
    cin >> A[i] >> B[i];
  }
  long ans=0;
  for(int i=N-1; i>=0; i--){
    A[i]+=ans;
    if(A[i]%B[i]==0) continue;
    ans+=B[i]-A[i]%B[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#-swank
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))
(defmacro dp (name args memo-size &body body)
  (let ((memo (gensym)))
    `(let ((,memo (make-array ,memo-size :initial-element nil)))
       (defun ,name ,args
         (or (aref ,memo ,@args)
             (setf (aref ,memo ,@args)
                   ,@body))))))

(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
        (cons (subseq str 0 pos)
              (split x (subseq str (+ pos size))))
        (list str))))

(defmacro collect-times (time body)
  `(loop repeat ,time collect ,body))

(defun read-times (time)
  (collect-times time (read)))

(defun binary-search (l r f &aux (m (ash (+ l r) -1)))
  "f の結果がtになる最小の値を見つけます"
  (if (= l r)
      l
      (if (funcall f m)
          (binary-search l m f)
          (binary-search (1+ m) r f))))

(defmacro aif (expr then else)
    `(let ((it ,expr))
       ,then
       ,else))

(defun main (x)
  (max 1
       (loop for i from 2 to x
             maximize
             (loop for j from 2
                   maximize 1
                   while (<= (expt i j) x)
                   maximize (expt i j)))))

#-swank
(princ (main (read)))


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

int main(){
  long double a, b, x;
  cin >> a >> b >> x;
  long double tmp = (2*a*a*b-2*x)/a/a/a;
  long double tmp2 = 2*x/a/b;
  if(a*a*b<=2*x){
    cout << fixed << setprecision(10) << atan(tmp)*180.0/(atan(1.0)*4.0);
  }else{
    cout << fixed << setprecision(10) << atan(b/tmp2)*180.0/(atan(1.0)*4.0);
  }
  return 0;
}

Measured memory_bytes: 256
N, X, Y = list(map(int,input().split()))
X -= 1
Y -= 1
out = [0]*N
for i in range(N-1):
  for j in range(i+1,N):
    out[min(j-i, abs(i-X)+1+abs(j-Y))] += 1
for i in range(1,N):
  print(out[i])

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

int main()
{
    string s;
    cin >> s;
    int n;
    cin >> n;
    for (int c = 0; c < n; c++)
    {
        string func;
        cin >> func;
        if (func == "print")
        {
            int a, b;
            cin >> a >> b;
            for (int i = a; i <= b; i++)
            {
                cout << s[i];
            }
            cout << endl;
        }
        else if (func == "reverse")
        {
            int a, b;
            string s_tmp = "";
            cin >> a >> b;
            for (int i = 0; i < s.size(); i++)
            {
                if (a <= i && i <= b)
                {
                    s_tmp += s[a + b - i];
                }
                else
                {
                    s_tmp += s[i];
                }
            }
            s = s_tmp;
        }
        else
        {
            int a, b;
            string s_rep, s_tmp;
            cin >> a >> b >> s_rep;
            for (int i = 0; i < s.size(); i++)
            {
                if (a <= i && i <= b)
                {
                    s_tmp += s_rep[i - a];
                }
                else
                {
                    s_tmp += s[i];
                }
            }
            s = s_tmp;
        }
    }
    return 0;
}


Measured memory_bytes: 3220
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main() {
	int N;	cin >> N;
	vector<int> a(N);
	int alice = 0, bob = 0;
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}
	sort(a.rbegin(), a.rend());
	for (int i = 0; i < N; ++i) {
		if (i % 2 == 0) {
			alice += a[i];
		}
		else {
			bob += a[i];
		}
	}
	cout << alice - bob << endl;
	cin >> N;
	return 0;
}

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

int d[7];

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

  for(int i = 0; i < n; i++)
  {
    double buf;
    cin >> buf;
    if(buf < 165)
      d[1]++;
    else if(buf < 170)
      d[2]++;
    else if(buf < 175)
      d[3]++;
    else if(buf < 180)
      d[4]++;
    else if(buf < 185)
      d[5]++;
    else
      d[6]++;
  }
  for(int i = 1; i <= 6; i++)
  {
    cout << i << ':';
    for(int j = 0; j < d[i]; j++)
      cout << '*';
    cout << endl;
  }
}

Measured memory_bytes: 1232
{-# LANGUAGE BangPatterns #-}
 
module Main
  ( main
  )
where
 
import           Control.Applicative
import           Control.Monad
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.List
import           Data.Maybe
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as MV
import           Control.Monad.ST
 
parse = fst . fromJust
parseInt = parse . BS.readInt
parseInteger = parse . BS.readInteger
readInt = parseInt <$> BS.getLine
readInteger = parseInteger <$> BS.getLine
readIntList = map parseInt . BS.words <$> BS.getLine
readIntegerList = map parseInteger . BS.words <$> BS.getLine
 
main = do
  [h, w] <- readIntegerList
  let a = (w + 1) `div` 2
      b = w - a
      c = (h + 1) `div` 2
      d = h - c
  print $ if h == 1 || w == 1 then 1 else a * c + b * d

Measured memory_bytes: 380
#include <stdio.h>

int main(){
  int a,b,x,y,i,ans=0;

  scanf("%d%d",&a,&b);

  if(a==b){
    printf("%d\n",a);
    return 0;
  }
  else if(a>b){
    x = b;
    y = a%b;
  }
  else if(b>a){
    y = b%a;
    x = a;
  }
  
  for(i=1;i<=y;i++){
    if(x%i==0 && y%i==0)ans=i;
  }

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

  return 0;
}



Measured memory_bytes: 2084
/*
    Created by Ezio112
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll;
typedef vector<ll> vll;
ll inf(1e18);
#define mod ll(1e9+7)
//#define mod ll(998244353)
#define ff first
#define ss second
ll power(ll a,ll b)
{
	if(!b)
		return 1;
	ll dp=power(a,b/2)%mod;
	
	if(b&1) return (((dp*dp)%mod)*a)%mod;
	
	return (dp*dp)%mod;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll test=1;
    //cin>>test;

    while(test--)
    {	
		int ar[5];
		
		for(int i=0;i<5;++i)
			cin>>ar[i];
		for(int i=0;i<5;++i)
		if(ar[i]==0) 
		cout<<i+1;
		
	}
	return 0;
}


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

int main() {
  int A,B,C,K;
  string ans = "No";
  cin >> A >> B >> C >> K;
  
  rep(i,K){
    if(A<B && B<C) {
      ans = "Yes";
      break;
    }
    if(A>=B) {
      B = B*2;
    } else if(B>=C) {
      C = C*2;
    } 
  }
  if(A<B && B<C) {
      ans = "Yes";
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3624
#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 n, m, k;
  cin >> n >> m >> k;
  vector<int> a(n);
  vector<int> b(m);
  rep(i,n) cin >> a[i];
  rep(i,m) cin >> b[i];
  ll t = 0;
  rep(i,m) t += b[i];
  int j = m;
  int ans = 0;
  rep(i,n+1) {
    while (j > 0 && t > k) {
      --j;
      t -= b[j];
    }
    if (t > k) break;
    ans = max(ans, i+j);
    if (i == n) break;
    t += a[i];
  }
  cout << ans << endl;
  return 0;
}


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

import static java.lang.Integer.*;
import static java.lang.Long.parseLong;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter prnt = new PrintWriter(System.out);
        StringTokenizer st;
        int N = parseInt(read.readLine());
        long[] arr = new long[N];
        st = new StringTokenizer(read.readLine());
        for (int i = 0; i < N; i++) {
            arr[i] = parseLong(st.nextToken());
        }
        prnt.println(getSum(arr, N));
        prnt.close();
    }

    static long getSum(long[] arr, int N) {
        long mod = (long) (1e9 + 7);
        long Sum = 0;
        long[] preixSum = new long[N];
        preixSum[0] = arr[0];
        for (int i = 1; i < N; i++) {
            preixSum[i] += (preixSum[i - 1] + arr[i]);
        }
        for (int i = 0; i < (N - 1); i++) {
            Sum += ((arr[i] % mod) * ((preixSum[N - 1] - preixSum[i]) % mod)) % mod;
            Sum %= mod;
        }
        return Sum % mod;
    }
}


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

const int N = 405;
long long dp[N][N];
int a[N];
long long sum[N];
const long long INF = 1e18+8;

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

    for (int i=1; i<=n; i++)    cin>>a[i];
    for (int i=1; i<=n; i++)    sum[i] = sum[i-1] + a[i];

    for (int len = 2; len<=n; len++) {
        for (int l=1; l+len-1<=n; l++) {
            int r = l+len-1;
            dp[l][r] = INF;
            for (int i=l; i<r; i++)
                dp[l][r] = min(dp[l][r], dp[l][i]+dp[i+1][r]+sum[r]-sum[l-1]);
//            cout<<l<<" "<<r<<" "<<dp[l][r]<<endl;
        }
    }
    cout<<dp[1][n]<<endl;
}


Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>

int d()
{
    int n, x, y;
    std::cin >> n >> x >> y;
    
    std::vector<int> len(n, 0);
    
    for(int i = 1; i <= n - 1; i++)
    {
        for(int k = i + 1; k <= n; k++)
        {
            int myLen = k - i;
            if((i < x && k < x) || (y < i && y < k))
            {
                len[myLen]++;
            }
            else
            {
                int myLen2 = std::abs(x - i) + std::abs(y - k) + 1;
                if(myLen2 < myLen)
                {
                    myLen = myLen2;
                }
                len[myLen]++;
            }
        }
    }
    
    for(int i = 1; i < n; i++)
    {
        std::cout << len[i] << std::endl;
    }
    
    return 0;
}


int main(int argc, const char * argv[])
{
    d();
    return 0;
}

Measured memory_bytes: 256
import Data.Char
import Data.Maybe
import Control.Applicative

orda :: Int
orda = ord 'a'
numOfAlp :: Int
numOfAlp = 26

charDiff :: Char -> Char -> Int
charDiff c0 c1 = let d = ord c0 - ord c1 in if d < 0 then d+numOfAlp else d

shiftChar :: Int -> Char -> Char
shiftChar n = chr . (+ orda) . (`mod` numOfAlp) . (+n) . subtract orda . ord

estimateShift :: String -> Int
estimateShift str =
        let _words = map (filter isAlpha) .  words $ str
            theCands = filter ((==3) . length) _words
            thisCands = filter ((==4) . length) _words
            theEst = estWith "the" theCands
            thisEst = estWith "this"  thisCands
            thatEst = estWith "that" thisCands
            in
                head $ catMaybes [theEst,thisEst,thatEst]

estWith :: String -> [String] -> Maybe Int
estWith word source = let
    shape = wordShape word
    in
        case filter ((== shape) . wordShape) source of
            [] -> Nothing
            (x:_) -> Just (ord (head x) - ord (head word))

decode :: Int -> String -> String
decode n = map (\c -> if isAlpha c then f c else c) where f = shiftChar n

wordShape :: String -> [Int]
wordShape [] = []
wordShape [_] = []
wordShape (x:xs) = map (charDiff x) xs

main = do
    str <- lines <$> getContents
    mapM_ (\l -> do
                let n = estimateShift l
                putStrLn . decode (-n) $ l
                ) str

Measured memory_bytes: 3708
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] s = new int[n];
		int max = 0;
		for (int i = 0; i < s.length; i++) {
			s[i] = scanner.nextInt();
			max+=s[i];
		}
		Arrays.sort(s);
		for (int i = 0; i < s.length; i++) {
			if(max%10==0){
				if (s[i]%10!=0){
					max -= s[i];
					System.out.println(max);
					return;
				}
			}else{
				System.out.println(max);
				return;
			}
		}
		System.out.println(0);
	}
}

Measured memory_bytes: 22612
#include <iostream>
int main() {
    int n, t;
    std::cin >> n;
    t = n / 3600;
    std::cout << t << ':';
    n -= t * 3600;
    t = n / 60;
    n -= t * 60;
    std::cout << t << ':' << n << std::endl;
}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;


template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    // y=x+w
    bool merge(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    // y-x
    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};





int main(){
    ll i,j;
    ll n,m;
    cin>>n>>m;
    UnionFind<ll> uf(n);

    for(i=0;i<m;i++){
        ll l,r,d;
        cin>>l>>r>>d;
        l--;
        r--;
        if(uf.issame(l,r)){
            if(uf.diff(l,r)!=d){
                cout<<"No"<<endl;
                return 0;
            } 
        }
        uf.merge(l,r,d);

    }

    cout<<"Yes"<<endl;



    return 0;
}

Measured memory_bytes: 1792
package main

import "fmt"

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	var n, m, x int
	fmt.Scan(&n, &m, &x)

	lc, rc := 0, 0
	for i := 0; i < m; i++ {
		var a int
		fmt.Scan(&a)
		if a < x {
			lc++
		} else {
			rc++
		}
	}
	fmt.Println(min(lc, rc))
}


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

namespace AtCoder {
    class Program {
        static void Main() {
            long[] args = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            long n = args[0], k = args[1];
            ModInt count = 0;
            for(long i = k; i <= n + 1; i++) {
                long min = (i - 1) * i / 2;
                long max = (n + n + 1 - i) * i / 2;
                count += max - min + 1;
            }
            Console.WriteLine((int) count);
        }
    }

    struct ModInt {
        const int MOD = 1000000007;
        long value;
        public ModInt(long value) => this.value = value;
        public static implicit operator ModInt(long a) => new ModInt(a % MOD + (a < 0 ? MOD : 0));
        public static explicit operator int(ModInt a) => (int) a.value;
        public static ModInt operator +(ModInt a, ModInt b) => a.value + b.value;
    }
}

Measured memory_bytes: 28236
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF 1e9

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

    int ans = 0;
    int now = 1;
    while (now < b)
    {
        now = now - 1 + a;
        ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(void)
{
  int num;
  int kau;

  cin >> num >> kau;
  
//  cout << num << ' ' << kau << '\n' ;
  
  vector<int> kakaku;
  
  for(int i = 0; i < num; i++) {
    int tmp;
    cin >> tmp;
    kakaku.push_back(tmp);
  }
  
  sort(kakaku.begin(), kakaku.end());

  /*
    for(int i = 0; i < num; i++) {
    cout << kakaku[i] << '\n';
  }
	*/
  
  int sum = 0;
  for(int i = 0; i < kau; i++) {
    sum += kakaku[i];
  }
  
  
  
    // 出力
    cout << sum;
    return 0;
}


Measured memory_bytes: 3620
S = list(input())
if len(S)>3:
    if S[0] == "Y":
        if S[1] == "A":
            if S[2] == "K":
                if S[3] == "I":
                    print("Yes")
                else:
                    print("No")
            else:
                print("No")
        else:
            print("No")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3060
N = int(input())

monster_list = list(map(int,input().split()))

tmp = monster_list[0]

def gcd(x,y):
    if y == 0:
        return x
    else:
        return gcd(y,x % y)

for i in range(len(monster_list)):
    if i == 0:
        continue
    else:
        if(tmp >= monster_list[i]):
            tmp = gcd(tmp,monster_list[i])
        else:
            tmp = gcd(monster_list[i],tmp)
print(tmp)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
#define forn(i,a,b)for(int i=(a),_b=(b);i<=_b;i++)
#define fore(i,b,a)for(int i=(b),_a=(a);i>=_a;i--)
#define rep(i,n)for(int i=0,_n=n;i<n;i++)
#define ll long long
#define pii pair<int,int>
#define vi vector<int>
#define vpii vector<pii>
#define m_p make_pair
#define re return
#define pb push_back
#define si set<int>
#define ld long double
#define X first
#define Y second
#define st string
#define ull unsigned long long
#define mod 1000000007
#define INF 1000000007
#define x1 XZVJDFADSPFOE
#define y1 GASDIJSLDAEJF
#define x2 DFDAJKVOHKWIW
#define y2 PSFSAODSXVNMQ
#define LLINF 0x3f3f3f3f3f3f3f3fLL
using namespace std;
inline void read(int &x)
{
	short negative=1;
    x=0;
    char c=getchar();
    while(c<'0' || c>'9')
    {
		if(c=='-')
			negative=-1;
		c=getchar();
	}
    while(c>='0' && c<='9')
        x=(x<<3)+(x<<1)+(c^48),c=getchar();
    x*=negative;
}
ll quickpower(ll n,ll k){
	ll ans=1;
	while(k){
		if(k%2){
			ans*=n;
			ans%=mod;
		}
		n*=n;
		n%=mod;
		k/=2;
	}
	return ans;
}
string int_to_string(int n)
{
	string s="";
	while(n)
	{
		int now=n%10;
		s+=now+'0';
		n/=10;
	}
	reverse(s.begin(),s.end());
	return s;
}
int string_to_int(string s)
{
	int n=0;
	rep(i,s.size())
	{
		n*=10;
		n+=s[i]-'0';
	}
	return n;
}
int main()
{
	ios::sync_with_stdio(0);
	//think twice,code once
	string s;
	cin>>s;
	int ans=0;
	rep(i,3)
	{
		if(s[i]=='R')
		{
			int res;
			int j=i+1;
			for(;j<3;j++)
				if(s[j]=='S')break; 
			res=j-i;
			ans=max(ans,res);
			i=j-1; 
		} 
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;


int main() {
	int N, K;
	cin >> N >> K;
	vector<int>A(N);
	int maxsize = 0;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		maxsize = max(A[i], maxsize);
	}

	int l = 0;
	int r = maxsize;
	while (r - 1 > l) {
		int x = (l + r) / 2;
		int count = 0;
		for (int i = 0; i < N; ++i) {
			count += A[i] / x;
			if (0 != A[i] % x) {
				count++;
			}
		}
		if (count > N + K) {
			l = x;
		}
		else {
			r = x;
		}
	}
	cout << r << endl;
	return 0;
}

Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int gcd_initial, sum = 0;
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=n; j++)
        {
            gcd_initial = __gcd(i,j);
            for (int k=1; k<=n; k++)
            {
                sum += __gcd(gcd_initial, k);
            }
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3636
package main

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

var dp [3000]int
var s int

const MOD int = 1e9 + 7

func main() {
	readVariables()
	dp[0] = 1
	for i := 1; i <= s; i++ {
		for j := 3; i-j >= 0; j++ {
			dp[i] += dp[i-j]
			dp[i] %= MOD
		}
	}
	fmt.Println(dp[s])
}

func readVariables() {
	s = nextInt()

}

/* Template */

var scanner *bufio.Scanner

func init() {
	Max := 1001001
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 0, Max), Max)
	scanner.Split(bufio.ScanWords)
}

//nextInt converts next token from stdin and returns integer value.
//nextInt panics when conversion into an integer fails.
func nextInt() int {
	if !scanner.Scan() {
		panic("No more token.")
	}
	num, err := strconv.Atoi(scanner.Text())
	if err != nil {
		panic("nextInt(): cannot convert to int: " + scanner.Text())
	}
	return num
}

func nextStr() string {
	if !scanner.Scan() {
		panic("No more token.")
	}
	return scanner.Text()
}

// MinInt returns minimum argument
func MinInt(x, y int) int {
	if x < y {
		return x
	} else {
		return y
	}
}

//MaxInt returns maximum argument
func MaxInt(x, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

//AbsInt returns |x| for x
func AbsInt(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

//ModPow calculates integer power with modulo operation
//if modulo <= 1, it powers w/o module operation
//if base < 0, return value might be negative too.
func ModPow(base, exponent, modulo int) (result int) {
	result = 1
	for exponent > 0 {
		if exponent%2 == 1 {
			result *= base
			if modulo > 1 {
				result %= modulo
			}
		}
		base *= base
		if modulo > 1 {
			base %= modulo
		}
		exponent /= 2
	}
	return
}

//Gcd
func Gcd(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = gcd(result, vals[i])
	}
	return
}

func gcd(x, y int) int {
	x, y = AbsInt(x), AbsInt(y)
	for y > 0 {
		x, y = y, x%y
	}
	return x
}

//Lcm
func Lcm(vals ...int) (result int) {
	if len(vals) == 0 {
		return
	}
	result = vals[0]
	for i := 1; i < len(vals); i++ {
		result = lcm(result, vals[i])
	}
	return
}

func lcm(x, y int) int {
	return x * y / gcd(x, y)
}


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

int main() {
	int K;
	string S,OutPut;

	cin >> K;
	cin >> S;

	if (S.size() <= K) {
		OutPut = S;
	}
	else if (S.size() > K) {
		OutPut=S.erase(K);
		OutPut=OutPut + "...";
	}

	cout << OutPut << endl;

	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=x*10+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x>=10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int k,int mod){
	int res=1,bas=x;
	while(k){
		if(k&1) res=1ll*res*bas%mod;
		bas=1ll*bas*bas%mod,k>>=1;
	}
	return res;
}
const int N = 2e5+5,mod = 1e9+7;
it add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
it mul(int x,int y){return 1ll*x*y%mod;}
il inc(int &x,int y){x=add(x,y);}
int n,m,k,ans,fac[N],ifac[N];
it C(int n,int m){return mul(mul(ifac[n-m],ifac[m]),fac[n]);}
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n),read(m),read(k),fac[0]=1;
	for(ri i=1;i<=n*m;++i) fac[i]=mul(fac[i-1],i);
	ifac[n*m]=qpow(fac[n*m],mod-2,mod);
	for(ri i=n*m-1;i>=0;--i) ifac[i]=mul(ifac[i+1],i+1);
	for(ri i=1;i<=n-1;++i) inc(ans,mul(mul(mul(m,m),n-i),i));
	for(ri i=1;i<=m-1;++i) inc(ans,mul(mul(mul(n,n),m-i),i));
	print(mul(ans,C(n*m-2,k-2)));
	return 0;
}

Measured memory_bytes: 1792
n,m=map(int,input().split())

li=[list(map(int,input().split())) for i in range(n)]
lj=[list(map(int,input().split())) for i in range(m)]

for i in range(n):
    li_distance=[abs(lj[j][0]-li[i][0])+abs(lj[j][1]-li[i][1]) for j in range(m)]
    print(li_distance.index(min(li_distance))+1)
    

Measured memory_bytes: 3060
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
ll INF = 1000000000;

int main() {
  //
  ll n, x;
  cin >> n >> x;
  vl a(n);
  rep(i, n) cin >> a[i];
  ll ans = 0;
  REP(i, 1, n) {
    ll sum = a[i - 1] + a[i];
    // cout << i << "=" << a[i - 1] << "+" << a[i] << "," << sum << endl;
    ll subtract = max(0LL, sum - x);
    ans += subtract;
    a[i] -= min(subtract, a[i]);
    // cout << i << ":" << subtract << endl;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <ctype.h>

int main(void)
{
    int i, a, b, flag=1;
    char s[12];

    scanf("%d%d", &a, &b);
    scanf("%s", s);

    if (s[a]!='-') {
        printf("No\n");
        return 0;
    }

    for (i=0; i<a+b+1; i++) {
        if (i==a) continue;

        if (!isdigit(s[i])) {
            flag = 0;
            break;
        }
    }

    if (flag==1)    printf("Yes\n");
    else            printf("No\n");

    return 0;
}

Measured memory_bytes: 128
program main
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int32):: n,i,a

    read*, n
    do i=1,n
        read*, a
        if (btest(a,0)) then
            print'(a)', "first"
            stop
        end if
    end do
    print'(a)', "second"
end program main

Measured memory_bytes: 2904
import java.util.Scanner;

public class Main {
        public static void main(String[] args) {
                Scanner scan = new Scanner(System.in);

                int N = scan.nextInt();

                if (N%10 == 2 || N%10 == 4 || N%10 == 5 || N%10 == 7 || N%10 == 9) {
                	System.out.println("hon");
                } else if (N%10 == 0 || N%10 == 1 || N%10 == 6 || N%10 == 8) {
                	System.out.println("pon");
                } else {
                	System.out.println("bon");
                }
        }
}

Measured memory_bytes: 35756
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
int p=1000000007,add=2001;
int n,a[200005],b[200005],fac[8005],inv[8005],f[4005][4005],ans;
inline int ksm(int a,int b){
	int res=1;
	while(b){
		if(b&1)res=(ll)res*a%p;
		a=(ll)a*a%p;b>>=1;
	}
	return res;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d%d",a+i,b+i);
		++f[add-a[i]][add-b[i]];
	}
	fac[0]=1;
	for(int i=1;i<=8000;++i)fac[i]=(ll)fac[i-1]*i%p;
	inv[8000]=ksm(fac[8000],p-2);
	for(int i=7999;~i;--i)inv[i]=(ll)inv[i+1]*(i+1)%p;
	for(int i=1;i<=4001;++i)
		for(int j=1;j<=4001;++j)
			f[i][j]=((f[i][j]+f[i-1][j])%p+f[i][j-1])%p;
	for(int i=1;i<=n;++i){
		ans=(ans+f[add+a[i]][add+b[i]])%p;
		ans=(ans-(ll)fac[(a[i]+b[i])<<1]*inv[a[i]<<1]%p*inv[b[i]<<1]%p+p)%p;
	}
	ans=(ll)ans*500000004%p;
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VECINT;
typedef vector<ll> VECLL;

int main() {
  int N;cin>>N;
  VECINT DS(N);
  REP(i,N) cin>>DS[i];

  int ans = 0;
  REP(i,N-1) {
    FOR(j,i+1,N) {
      ans += DS[i]*DS[j];
    }
  }
  OUT(ans);

  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
	int stu[30] = {0}, n;

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

	for(int i=0; i<30; i++){
		if(stu[i] == 0)
			cout << i+1 << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
char a[101],b[101],c[101];
int main()
{
	cin>>a>>b;
	int na,nb;
	cin>>na>>nb;
	cin>>c;
	if(strcmp(a,c)==0)na--;
	else nb--;
	cout<<na<<" "<<nb;
	return 0;
}

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

using namespace std;
typedef unsigned long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

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

	int N;
	cin >> N;
	vector<ll> A(N+1);
	for(int i = 0; i <= N; ++i) cin >> A[i];
	if(N == 0) return cout << (A[0]==1 ? 1 : -1) << endl, 0;
	if(A[0] > 0) return cout << "-1\n", 0;
	vector<ll> ma(N+1);
	ma[0] = 1;
	for(int i = 1; i <= N; ++i) {
		ll m2 = (ma[i-1] <= INT64_MAX/2) ? 2*ma[i-1] : INT64_MAX;
		if(m2 < A[i]) return cout << "-1\n", 0;
		ma[i] = m2 - A[i];
	}
	ll res = ma[N] = A[N];
	for(int i = N-1; i >= 0; --i) {
		ma[i] = min(ma[i], ma[i+1]) + A[i];
		res += ma[i];
	}
	cout << res << "\n";

	return 0;
}

Measured memory_bytes: 4756
#include<bits/stdc++.h>
using namespace std;
int n,dat[2000004],K,n_=1;
void upd(int id,int x){
	while(1){
		dat[id]=max(dat[id],x);
		if(id==0)return;
		id=(id-1)/2;
	}
}
int got(int l,int r,int id,int a,int b){
	if(r<a||b<l)return 0;
	if(a<=l&&r<=b)return dat[id];
	return max(got(l,(l+r)/2,id*2+1,a,b),got((l+r)/2+1,r,id*2+2,a,b));
}
int main(){
	cin>>n>>K;
	while(n_<3e5+1)n_<<=1;
	for(int i=0;i<n;i++){
		int x;cin>>x;
		int cur=got(0,n_-1,0,x-K,x+K)+1;
		upd(x+n_-1,cur);
	}
	cout<<got(0,n_-1,0,0,3e5);
}

Measured memory_bytes: 6008
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue
typedef priority_queue<int> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    ll N;
    cin>>N;
    vll count(100001,0);
    ll total=0;
    for(ll i=0;i<N;i++){
        ll a;
        cin>>a;
        count[a]++;
        total+=a;
    }
    ll Q;
    cin>>Q;
    for(ll i=0;i<Q;i++){
        ll b,c;
        cin>>b>>c;
        total+=(c-b)*count[b];
        count[c]+=count[b];
        count[b]=0;
        cout<<total<<endl;
    }
}

Measured memory_bytes: 4032
import sys
#import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ri()
S = rs()

def check(length):
    s = set()
    for i in range(N - 2*length + 1):
        s.add(S[i:i+length])
        if S[i+length:i+2*length] in s:
            return True
    return False

right = N // 2 + 1
left = 0
while right > left + 1:
    mid = (right + left) // 2
    if check(mid):
        left = mid
    else:
        right = mid

print(left)


Measured memory_bytes: 6388
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b;
  cin >> n >> a >> b;
  int turn = 0; //0:alice 1:borys
  int chk = 1;
  if((b-a)%2==0)cout << "Alice"<<endl;
  else cout <<"Borys" <<endl;
}


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


			

int main(){
	
	string S;
	cin>>S;
	int cnt =0;
	
	for(int i=0;i<S.size();i++){
		if(S[i]=='o')cnt++;
	}
	cnt+=15-S.size();
	
	if(cnt>=8)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	
	return 0;
}

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

#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

ll N;
int a[100011];

int main(){
    cin>>N;
    rep(i,N){
        ll x;cin>>x;
        a[i]=x;
    }

    ll ans=0;
    for(int i=0;i<N;i++){
        ans += a[i]/2;
        a[i] = a[i]%2;

        if(a[i]==1 and a[i+1]>0){
            a[i]=0;
            a[i+1]--;
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define N 210
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
int n;
char C[N];

int mem[N][N][N],used[N][N][N];
int dfs(int idx,int num,int num2){
  if(num < 0 || num2 < 0) return 0;
  if(idx == n) return (idx-num == 0) * (num2 == 0);
  if(used[idx][num][num2]++) return mem[idx][num][num2];
  int res = 0; 
  if(C[idx] == 'U'){
    res = dfs(idx+1,num,num2+1);
    res += num2 * dfs(idx+1,num+1,num2);
  }
  if(C[idx] == 'D'){
    if(idx - num > 0 )res = (idx - num) * num2 * dfs(idx+1,num+2,num2-1);
    res += (idx - num) * dfs(idx+1,num+1,num2);
  }
  return mem[idx][num][num2] = res %mod;
}

signed main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>C[i];
    if(C[i] == '-')n--,i--;
  }
  cout<<dfs(0,0,0)<<endl;
  return 0;
}

Measured memory_bytes: 38000