akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define YY cout << "Yes" << endl;
#define NN cout << "No" << endl;
#define ve vector
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
// *max_element(all(d))
// priority_queue<int,vector<int>,greater<int>>
int solve(){
  ll x;
  cin >> x;
  ll ans = 0;
  ans += (x / 500) * 1000;
  x %= 500;
  cout << ans + (x / 5) * 5 << endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}


Measured memory_bytes: 256
n=int(input())
a,b = [int(i) for i in input().split()]
p = sorted([int(i) for i in input().split()])

t,c = 0,0
q=[0,0,0]

while (len(p)>c):
    q[0] += 1 if p[c]>0 and p[c]<=a else 0
    q[1] += 1 if p[c]>a and p[c]<=b else 0
    q[2] += 1 if p[c]>b and p[c]<=20 else 0
    c+=1

print(min(q))

Measured memory_bytes: 3064
using System;

namespace ABC105C_cs
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var x = new IntegerNumber(n);
            Console.WriteLine(x.BaseMinus2Number());
        }
    }
    public class IntegerNumber
    {
        private readonly int v;

        public IntegerNumber(int v)
        {
            this.v = v;
        }

        public string BaseMinus2Number()
        {
            if (v == 0)
            {
                return "0";
            }

            int n = v;
            string ans = "";
            while (n != 0)
            {
                if (n % 2 == 0)
                {
                    ans = "0" + ans;
                }
                else
                {
                    n--;
                    ans = "1" + ans;
                }
                n = n / -2;
            }
            return ans;
        }
    }

}


Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
#define int long long
vector<pair<int, int>>v;
signed main() {
	int n, m; cin >> n >> m;
	for (int i = 0; i < n; i++) {
		int a, b; cin >> a >> b;
		v.push_back(make_pair(a, b));
	}
	sort(v.begin(), v.end());
	int cost = 0, cnt = 0, i = 0;
	while (cnt < m) {
		pair<int, int>p = v[i]; i++;
		if (cnt + p.second >= m) {
			cout << cost + (m - cnt)*p.first << endl;
			return 0;
		}
		else {
			cost += p.first*p.second;
			cnt += p.second;
		}
	}
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >>n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end(),greater<int>());
  a[0]/=2;
  int sum=0;
  for(int i=0;i<n;i++){
    sum+=a[i];
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 256
n , a= map(int , input().split())
arr = list(map(int , input().split()))
dp = [ [[ 0 for j in range(0 , a*(n+2))] for k in range(0 , n+2)] for i in range(0,n+2)]
dp[0][0][0]=1
b=[0 for i in range(0 , n+1)]
for i in range(0 , n):
	b[i+1]=arr[i]
for i in range(1 , n+1):
	for j in range(0 , i+1):
		for k in range(0 , a*(n)+2):
			if k<b[i]:
				dp[i][j][k]=dp[i-1][j][k]
			else:
				dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-1][k-b[i]]
tot = 0
for i in range(1 , n+1):
	tot = tot + dp[n][i][(i)*a]
print(tot)

Measured memory_bytes: 129768
def read():
    n = int(input().strip())
    p = list(map(int, input().strip().split()))
    return n, p


def solve(n, p):
    count = 0
    for i in range(1, n-1):
        if p[i-1] <= p[i] and p[i] <= p[i+1]:
            count += 1
        elif p[i+1] <= p[i] and p[i] <= p[i-1]:
            count += 1
    return count


if __name__ == '__main__':
    inputs = read()
    print('%d' % solve(*inputs))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

const int mod = 1000000007;
struct mint {
  ll x;  // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint& operator+=(const mint a) {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const {
    if(!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if(t & 1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint& operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }
mint fact(int n) {
  if(n == 1 || n == 0) return 1;
  mint res = n;
  return res * fact(n - 1);
}

mint dp[100010][15];

int main() {
  string s;
  cin >> s;
  ll n = s.size();
  dp[0][0] = 1;
  rep(i, n) rep(j, 13) {
    if(s[i] == '?') {
      rep(k, 10) {
        ll nj = (j * 10 + k) % 13;
        dp[i + 1][nj] += dp[i][j];
      }
    } else {
      ll d = s[i] - '0';
      ll nj = (j * 10 + d) % 13;
      dp[i + 1][nj] += dp[i][j];
    }
  }
  cout << dp[n][5] << endl;
}

Measured memory_bytes: 15440
from heapq import heapify,heappop,heappush
from math import ceil

def solve(A,N,K):
    ans_max,ans_min = max(A),1

    if cutable(A,N,K,1):
        return 1

    while True:
        if cutable(A,N,K,(ans_max+ans_min)//2):
            if ans_max > (ans_max+ans_min)//2:
                ans_max = (ans_max+ans_min)//2
            else:
                return ans_max
        else:
            if ans_min < (ans_max+ans_min)//2:
                ans_min = (ans_max+ans_min)//2
            else:
                return ans_max

def cutable(A,N,K,div):
    #K回までの切断で全部を長さdiv以下にできるかどうか
    cnt = 0
    for i in range(N):
        cnt += A[i]//div
        if A[i] % div == 0:
            cnt -= 1
        if cnt > K:
            return False

    return True

def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))

    ans = solve(A,N,K)
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 31036
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  ll n, a, b;
  cin >> n >> a >> b;
  if(a > b || (n == 1 && a != b)){
    cout << 0 << endl;
    return 0;
  }
  ll ansmx = a + b*(n-1);
  ll ansmn = a*(n-1) + b;
  ll ans = ansmx - ansmn + 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
# include <iostream>
using namespace std;
string a;
int s;
void work (void)
{
	int i;
	for (i=0;i<=5;i++)
	if (a[i]=='1')
	s++;
	cout<<s;
}
int main (void)
{
	cin>>a;
	work ();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <math.h>
using namespace std;
typedef long long int lli;
const long long int MaxN=200005;
const lli mod=1e9+7;
#define fst first
#define snd second
#define mp make_pair
const float pi=3.1415926535897932384626433832795028;
	lli mcd(lli a,lli b){
		if(a==0)return b;
		return mcd(b%a,a);
	}
	lli arr[MaxN];

	void solve(){
		lli N,M,i,j,p,q,s=0,res=0;
		cin>>N>>M;
		for(i=0;i<M;i++){
			cin>>p>>q;
			arr[p]+=1;
			arr[q+1]-=1;
		}
		for(i=1;i<=N;i++){
			s+=arr[i];
			if(s==M){
				res+=1;
			}
		}
		cout<<res;
	}
int main(){
	cin.tie(0),ios_base::sync_with_stdio(0);
	lli i,t;
	t=1;
	for(i=1;i<=t;i++){
		solve();
	}
}

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

int main() {
  long N, M, X, y, a = 0, b = 0, ans = 0;
  cin >> N >> M >> X;
  
  for (int i = 0; i < M; i++) {
    cin >> y;
    if (y < X) a++;
    else b++;
  }
  
  if (a < b) ans = a;
  else ans = b;
  
  cout << ans << endl;
}

Measured memory_bytes: 3584
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Contest.C
{
	class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			Scanner cin = new Scanner();

			int n = cin.nextInt();
			string s = cin.next();
			char now = ' ';
			long ans = 0;
			for (int i = 0; i < n; i++)
			{
				if (s[i] != now) ans++;
				now = s[i];
			}
			Console.WriteLine(ans);

			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return next();
			i = 0;
			return s[i++];
		}

		public int nextInt()
		{
			return int.Parse(next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextInt() + add;
			}
			return Array;
		}

		public long nextLong()
		{
			return long.Parse(next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextLong() + add;
			}
			return Array;
		}

		public double nextDouble()
		{
			return double.Parse(next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextDouble() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 11744
s = input()
n = len(s)

def is_agct(c):
    return c == 'A' or c == 'G' or c == 'T' or c == 'C'

def find_agct(s, l):
    n = len(s)
    while (l < n and not is_agct(s[l])):
        l = l + 1
    return l

ans = 0

l = find_agct(s, 0)
r = l + 1
while (l < n):
    while (r < n and is_agct(s[r])):
        r = r + 1
    ans = max(ans, r - l)
    l = find_agct(s, r)
    r = l + 1

print(ans)

Measured memory_bytes: 3064
N, M = map(int, input().split())
a = [0] * M
b = [0] * M
for i in range(M):
    a[i], b[i] = map(int, input().split())

ans = 0

for i in range(M):
    brid = [[] for _ in range(N)]
    check = [0] * N
    for j in range(M):
        if j != i:
            brid[a[j]-1].append(b[j]-1)
            brid[b[j]-1].append(a[j]-1)
#    print(brid)


    stack = []
    for j in range(len(brid[0])):
        stack.append(brid[0][j])
        check[brid[0][j]] == 1
    
    while len(stack) != 0 :
        x = stack.pop(-1)
        for j in range(len(brid[x])):
            if check[brid[x][j]] == 0:
                stack.append(brid[x][j])
                check[brid[x][j]] = 1
    
#    print(check)

    if check.count(1) != len(check):
        ans += 1


print(ans)


Measured memory_bytes: 3064
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 998244353;

int powM(int x, int n){
    if(n == 0){
        return 1;
    }
    if(n % 2 == 0){
        return powM(x * x % MOD, n / 2);
    }
    return powM(x, n-1) * x % MOD;
}

int factM(int n){
    static vector<int> t = {1};

    if((int)t.size() > n){
        return t[n];
    }

    for(int i = t.size(); i <= n; i++){
        t.push_back(t[i-1] * i % MOD);
    }
    return t[n];
}

class combination{
    private:
        vector<int> t;

    public:
        combination(int n): t(n+1){
            t[n] = powM(factM(n), MOD-2);

            for(int i = n-1; i >= 0; i--){
                t[i] = t[i+1] * (i+1) % MOD;
            }
        }

        int comb(int n, int k){
            if(n < k || n < 0 || k < 0){
                return 0;
            }
            return factM(n) * t[k] % MOD * t[n-k] % MOD;
        }

        int getInv(int n){
            return t[n];
        }
};

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

    int k, n;
    cin >> k >> n;

    combination c(4000);

    for(int t = 2; t <= 2 * k; t++){
        int ans = 0;
        int p = 0;
        for(int i = 1; i <= t / 2; i++){
            if(t - i <= k && i != t - i){
                p++;
            }
        }

        rep(q, p+1){
            int tmp = c.comb(p, q) * powM(2, q) % MOD;

            if(t % 2 != 0){
                //(n - 2 * p + q) H (n - q)
                tmp = tmp * c.comb(k-2*p+n-1, n-q) % MOD;
            }else{
                //(n - 2 * p - 1 + q) H (n - q)
                //(n - 2 * p - 1 + q) H (n - q - 1)
                int x = c.comb(k-2*p+n-2, n-q) + c.comb(k-2*p+n-3, n-q-1) % MOD;
                tmp = tmp * x % MOD;
            }
            ans = (ans + tmp) % MOD;
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <stack> // s.top()
#include <bitset>
#include <queue> // s.front()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define print(x) cout<<(x)<<endl
#define INF10 10000000000
#define INF5 100000
#define EPS 1e-10
#define MOD 1000000007


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

	sort(d.begin(), d.end());

	int cnt = 0;
	for (int i = 0; i < N-1; i++) {
		if (d[i] != d[i + 1])cnt++;

	}
	print(cnt+1);

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    vector<int>a(N);
    for (int i=0;i<N+1;i++)cin>>a[i];
    int minv,maxv;
    sort(a.begin(),a.end());
    minv=a.at(0);
    reverse(a.begin(),a.end());
    maxv=a.at(0);

    cout<<maxv-minv<<endl;
}

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


int main(){
  int n;
  cin >> n;
  vector<vector<int>> g(n);
  for(int i=0;i<n;++i){
    int id,k;
    cin >> id >> k;
    id--;
    for(int j=0;j<k;++j){
      int v;
      cin >> v;
      v--;
      g[id].push_back(v);
    }
  }
  vector<int> dist(n,-1);
  queue<int> que;
  dist[0]=0;
  que.push(0);
  while(!que.empty()){
    int v=que.front();
    que.pop();
    for(auto nv : g[v]){
      if(dist[nv]!=-1)continue;
      dist[nv]=dist[v]+1;
      que.push(nv);
    }
  }
  for(int i=0;i<n;++i){
    cout << i+1 << " " << dist[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 3172
X,N = map(int,input().split())
if N != 0:
  num = list(map(int,input().split()))
  num.sort()
b = 1000
if N == 0:
  print(X)
else:
  for i in range(N):
    a = abs(int(num[i])-X)
    if a <= b:
      b = a
      ans = int(num[i]) - b
  low = ans
  high = ans
  while low in num:
    low -= 1
  
  while high in num:
    high += 1
  loo = abs(low-ans)
  hii = abs(high-ans)
  if loo > hii:
    print(high)
  else:
    print(low)

Measured memory_bytes: 61948
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
typedef long long ll;
using namespace std;
int r, g, b;
void ChooseIntegers() {
	int a, b, c;
	cin >> a >> b >> c;
	bool rems[101];
	fill(rems, rems + 100, false);
	int ta = a;
	while (!rems[ta % b]) {
		ta %= b;
		rems[ta] = true;
		if (ta == c) {
			cout << "YES" << endl;
			return;
		}
		ta += a;

	}
	cout << "NO" << endl;
}

int main() {
	ChooseIntegers();
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <string>

int main() {
  std::int_fast64_t h, w;
  std::cin >> h >> w;
  for (std::int_fast64_t i = 0; i < h; ++i) {
    std::string s;
    std::cin >> s;
    std::cout << s << std::endl;
    std::cout << s << std::endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000

int main(){
  int i, j, n, q, l,m,r, count=0, S[MAX],T[MAX];

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

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

  for(i=0;i<q;i++){
    l=0;
    r=n;
    m=(l+r)/2;
    while(l <+ r){
      m=(l+r)/2;
      if(T[i] == S[m]){
        count++;
        break;
      }else if(T[i] > S[m]){
        l = m+1;
      }else if(T[i] < S[m]){
        r = m;
      }
    }

  }


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

  return 0;
}



Measured memory_bytes: 2264
#include <bits/stdc++.h>
using namespace std;
const long double PI = acos(-1);
typedef long long ll;
typedef pair<int64_t,int64_t> pll;
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};
#define INF (2147483647)
#define mod (1000000007)
#define limit (7368791)
#define rep(i,a,b) for (int64_t i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define ALL(a) begin(a),end(a)
#define sz(s) (s).size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second

#define MAXV 1010
#define MAXE 2010
int V,E,r;
struct edge{int from,to,cost;};
vector<edge>G(MAXE);
vector<ll> l(MAXV,INF);//from ss to v

bool bellman(){
    l[r]=0;
    REP(i,V)REP(i,E){
        if(l[G[i].from]==INF)continue;
        if(l[G[i].to]>l[G[i].from]+G[i].cost)
            l[G[i].to]=l[G[i].from]+G[i].cost;

    }
    REP(i,E)if(l[G[i].to]>l[G[i].from]+G[i].cost&&l[G[i].from]!=INF)return false;
    return true;
}

void solve()
{
    cin>>V>>E>>r;
    REP(i,E){
        int x,y,d;cin>>x>>y>>d;
        G[i]={x,y,d};
    }
    if(!bellman()){cout<<"NEGATIVE CYCLE"<<endl;return;}
    REP(i,V){if(l[i]>=INF)cout<<"INF"<<endl;else cout<<l[i]<<endl;}
}

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



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

typedef long long LL;

template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar.size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}


int main(int argc, char const* argv[])
{
    int a,b,x;
    cin >> a >> b >> x;

    if ((b - (x-a) >= 0) && (a <= x)) {
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}


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

int A, B, C, D;

int nigeru(int x, int y, int isSrc) {
	int cost = 0;
	if (x < A) cost += A - x;
	if (C < x) cost += x - C;
	if (y < B) cost += B - y;
	if (D < y) cost += y - D;
	if (isSrc && cost > 0) cost--;
	return cost;
}

int main(void) {
	int N;
	while (scanf("%d", &N) == 1 && N > 0) {
		int X[128], Y[128];
		int i;
		int mikakosi = 0;
		if (scanf("%d%d%d%d", &A, &B, &C, &D) != 4) return 1;
		for (i = 0; i <= N; i++) {
			if (scanf("%d%d", &X[i], &Y[i]) != 2) return 1;
		}
		for (i = 1; i <= N; i++) {
			int naka = abs(X[i - 1] - X[i]) + abs(Y[i - 1] - Y[i]);
			int simakaze = nigeru(X[i - 1], Y[i - 1], 1) + nigeru(X[i], Y[i], 0);
			mikakosi += naka < simakaze ? naka : simakaze;
		}
		printf("%d\n", mikakosi);
	}
	return 0;
}



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

typedef long long ll; 
typedef pair<int,int > pp;

 
#define sz(x) (int)x.size() 
#define PI acos(-1)
int const N=5e5;
int  mod = 998244353,oo = 1e9;
ll OO = 3e18;

pp aa[N];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=0;i<n;i++)cin>>aa[i].first,aa[i].second=i;
	sort(aa,aa+n);
	for(int i=0;i<n;i++)cout<<aa[i].second+1<<' ';
	return 0;
}



Measured memory_bytes: 1664
#include <iostream>
#include <set>
#include <list>
#include <utility>
#include <queue>
#include <memory>
#include <cstring>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>

using namespace std; 

int
main(int argc, char const *argv[])
{
    int64_t a, p;
    cin >> a >> p;
    auto ans = ((a * 3) + p)/2;
    cout << ans << endl;
    return 0;
}
 


Measured memory_bytes: 256
t[3600];w,h,c,z;f(x,i){for(t[x]=0;i;t[x+=";;x>x:="[--i]-60]&&f(x,8));}main(i){for(;scanf("%d%d",&w,&h)*h;printf("%d\n",c)){for(i=++h;--i;)for(c=w;c;)scanf("%d",i*60+c--+t);for(;!i?i=w,--h:1;)t[z=h*60+i--]&&++c-f(z,8);}}

Measured memory_bytes: 0
# -*- coding: utf-8 -*-
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for i in range(A + 1):
    for j in range(B + 1):
        for k in range(C + 1):
            if 500*i + 100*j + 50*k == X:
                ans += 1
print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = Integer.parseInt(sc.next());
		int A = Integer.parseInt(sc.next());
		sc.close();

		if(H <= A) {
			System.out.println(1);
		}else {
			if(H % A == 0) {
				System.out.println(H / A);
			}else {
				System.out.println(H / A + 1);
			}
		}
	}
}

Measured memory_bytes: 21844
#include<stdio.h>

int main(){
	char str[25];
	scanf("%[^\n]", str);
	
	for(int i = 0; str[i] != '\0'; i++){
		if(str[i] == ','){
			
			str[i] = ' ';
		}
	}
	
	printf("%s\n", str);
	
	return 0;
}

Measured memory_bytes: 1600
#include<iostream>
#include<string>
#include<string.h>
using namespace std;
char str[100005];
int main(){
	scanf("%s",str);
    int N=strlen(str);
    if(str[0]==str[N-1]){
        if(N%2==0){
            printf("First\n");
        }
        else{
        	printf("Second\n");
        }
    }
    else{
        if(N%2==0){
        	printf("Second\n");
        }
        else{
        	printf("First\n");
        }
    }
    //AC!
    return 0;
}

Measured memory_bytes: 384
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/* libmod {{{*/
struct ModCalc(N) if (isIntegral!N) {
 public:
  N mod(N n) const {
    const x = n%m;
    return x < 0? x+m: x;
  }
  N inv(N a) const {
    N b = m, u = 1, v = 0;
    while (b) {
      const t = a / b;
      a -= t*b; swap(a, b);
      u -= t*v; swap(u, v);
    }
    return mod(u);
  }

  N add(N l, N r) const {
    return mod(mod(l) + mod(r));
  }
  N sub(N l, N r) const {
    return mod(mod(l) - mod(r));
  }
  N mul(N l, N r) const {
    return mod(mod(l) * mod(r));
  }
  N div(N l, N r) const {
    assert(r != 0);
    return mod(mod(l) * inv(mod(r)));
  }

  N m = 1000000007;
}
/*}}}*/

/+---test
3
2 3 4
---+/
/+---test
5
12 12 12 12 12
---+/
/+---test
3
1000000 999999 999998
---+/

enum M = ModCalc!long();

BigInt gcdm(BigInt a, BigInt b) {
  if (a < b) swap(a, b);

  auto r = a%b;
  while (r) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}

void main(string[] args) {
  const N = readln.chomp.to!long;
  const A = readln.split.map!(to!long).array;

  BigInt z = 1;
  foreach (x; A) {
    z = z / gcdm(BigInt(x), z) * x;
  }

  long ans;
  foreach (x; A) {
    ans = M.add(M.div((z%M.m).to!long, x), ans);
  }
  ans.writeln;
}


Measured memory_bytes: 52092
#include <stdio.h>

int main(void)

{
	char num[1001];
	int i=0;
	int sum=1;
	while(sum!=0){
	sum=0;
	i=0;
	scanf("%c",&num[i]);
	while(num[i]!='\n'){
	 i++;
	 scanf("%c",&num[i]);
	}
	num[i]='\0';
	i=0;
	while(num[i]!='\0'){
	 sum+=num[i]-'0'; 
	 i++;
	}
	if(sum!=0){
	printf("%d\n",sum);
	}
	}
	return 0;
}
	
	

Measured memory_bytes: 536
//============================================================================
// Name        : AOL.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;

int main() {
    int a[101][101];
	int r;
	int c;
    cin>>r>>c;
    int d;
	int e;
    for(int i=1; i<r+1; i++){
		for(int j=1; j<c+1; j++){
			cin>>a[i][j];
		}
	}


	for(int i=1; i<r+1; i++){
		d=0;
		for(int j=1; j<c+1; j++){
			cout<<a[i][j] <<" ";
			d+=a[i][j];
		}
		cout<<d<<endl;
	}
	for(int j=1; j<c+1; j++){
		d=0;
		for(int i=1; i<r+1; i++){
			d+=a[i][j];
		}
			cout<<d<<" ";
	}
    e=0;
	for(int j=1; j<c+1; j++){
		d=0;
		for(int i=1; i<r+1; i++){
			d+=a[i][j];
		}
        e+=d;
	}
	cout<<e<<endl;
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
#include<utility>
#include<algorithm>
using namespace std;
typedef pair<int, int> P;
const int MAX_N = 100000;
const int MAX_V = 1000000000;
int N;
int X[MAX_N];
int L[MAX_N];
void input(){
scanf("%d", &N);
for(int i = 0; i < N; ++i){
scanf("%d%d", X + i, L + i);
}
}
P ps[MAX_N];
int solve(){
for(int i = 0; i < N; ++i){
ps[i] = P(X[i] + L[i], X[i] - L[i]);
}
sort(ps, ps + N);
int cur = -MAX_V;
int ans = 0;
for(int i = 0; i < N; ++i){
if(cur <= ps[i].second){
ans++;
cur = ps[i].first;
}
}
return ans;
}
int main(){
input();
int ans = solve();
printf("%d\n", ans);
return 0;
}

Measured memory_bytes: 1792
/*
 Author: LargeDumpling
 Email: LargeDumpling@qq.com
 Edit History:
	2018-04-28	File created.
*/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
const int MAXN=350;
const unsigned long long mod=1000000007;
char str[MAXN][MAXN];
unsigned long long r[MAXN][MAXN],c[MAXN][MAXN],P[MAXN];
int n,ans=0;
int get(int x) { return (x+2*n)%n; }
unsigned long long get_hash_r(int i,int x)
{
	if(x==0) return r[i][n-1];
	else return ((r[i][n-1]-r[i][x-1]*P[n-x]%mod+mod)%mod*P[x]%mod+r[i][x-1])%mod;
}
unsigned long long get_hash_c(int i,int x)
{
	if(x==0) return c[i][n-1];
	else return ((c[i][n-1]-c[i][x-1]*P[n-x]%mod+mod)%mod*P[x]%mod+c[i][x-1])%mod;
}
bool check(int A,int B)
{
	for(int i=0;i<n;i++)
		if(get_hash_r((i+A)%n,B)!=get_hash_c((i+B)%n,A))
			return false;
	return true;
}
int main()
{
	P[0]=1;
	P[1]=23;
	for(int i=1;i<MAXN;i++)
		P[i]=P[i-1]*P[1]%mod;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%s",str[i]);
		r[i][0]=str[i][0];
		for(int j=1;j<n;j++)
			r[i][j]=(r[i][j-1]*P[1]%mod+str[i][j])%mod;
	}
	for(int i=0;i<n;i++)
	{
		c[i][0]=str[0][i];
		for(int j=1;j<n;j++)
			c[i][j]=(c[i][j-1]*P[1]%mod+str[j][i])%mod;
	}
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			if(check(i,j))
				ans++;
	printf("%d",ans);
	fclose(stdin);
	fclose(stdout);
	return 0;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define f first
#define s second


signed main()
{
int n,ans=0;
cin>>n;
for(int i=1;i<=n;i++)
{
    int x;
    cin>>x;
    if(i%2!=0 && x%2!=0)
        ans++;
}
cout<<ans<<endl;
}

Measured memory_bytes: 3620
n = int(input())
a = list(map(int,input().split()))

mod = 10**9 + 7

lis = [0] * n

for i in a: lis[i] += 1

for i in range(1,n):
	if lis[i] % 2 == 1:
		print(0)
		exit()
		
print(pow(2, n//2, mod))


Measured memory_bytes: 53172
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    c0=list(map(int,input().split()))
    c1=list(map(int,input().split()))
    c2=list(map(int,input().split()))
    a=[0]*3
    b=[0]*3
    b[0]=c0[0]
    b[1]=c1[0]
    b[2]=c2[0]
    a[1]=c0[1]-b[0]
    a[2]=c0[2]-b[0]
    if a[1]+b[1]==c1[1] and a[1]+b[2]==c2[1] and\
            a[2]+b[1]==c1[2] and a[2]+b[2]==c2[2]:
        print('Yes')
    else:
        print('No')

resolve()

Measured memory_bytes: 38384
let split str delim =
  let rec doit s acc =
    match
      try Some (String.index s delim)
      with _ -> None
    with
    | None -> s :: acc
    | Some i ->
        let s1 = String.sub s 0 i in
        let s2 = String.sub s (i + 1) (String.length s - String.length s1 - 1) in
        doit s2 (s1 :: acc)
  in
  List.rev (doit str [])

let print_rectangle h w =
  for _ = 1 to h do
    for _ = 1 to w do
      print_char '#'
    done;
    print_newline ();
  done

let rec repl () =
  let l = read_line () in
  match List.map int_of_string (split l ' ') with
  | [] | [_] -> exit 1
  | h :: w :: _ ->
      if (h = 0) && (w = 0) then ()
      else begin
        print_rectangle h w;
        print_newline ();
        repl ()
      end

let () =
  try repl () with End_of_file -> ()

Measured memory_bytes: 2044
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
using namespace std;

int main() {
  int A, B, K;
  cin >> A >> B >> K;
  for (int i = 100; i >= 1; i--) {
	  if (A % i == 0 && B % i == 0) {
		  K--;
		}
	  if (K == 0) {
		  cout << i << endl;
		  break;
		}
	}
  return 0;
}


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

using namespace std;
int main(){
  while(true){
    int w, d;
    map<int, int> dict;
    int sum_block = 0;

    cin >> w >> d;

    if(w==0 && d==0) break;

    for(int i=0; i<w; ++i){
      int h;
      cin >> h;
      sum_block += h;
      
      if(dict.find(h)==dict.end()) dict[h] = 0;
      ++dict[h];
    }

    for(int i=0; i<d; ++i){
      int h;
      cin >> h;

      if(dict.find(h)==dict.end()){
	sum_block += h;
	continue;
      }
      if(dict[h]>0){
	--dict[h];
	continue;
      }
      sum_block += h;
    }
    cout << sum_block << endl;
  }
}

Measured memory_bytes: 1196
// stdin
macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

// input
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// Test
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r"RUDLUDR
" => r"Yes",

r"DULL
" => r"No",

r"UUUUUUUUUUUUUUU
" => r"Yes",

r"ULURU
" => r"No",

r"RDULULDURURLRDULRLR
" => r"Yes"
}

fn solve(src: &str) -> String {
    input! {
        source=src,
        s:String,
//        n:i32,
//        a:[char;n],
    };

    let s: String = s;

// 1.15.1はCEになる
//    let odd = s.chars().into_iter().step_by(2).collect::<Vec<char>>();
//    let even = s.chars().into_iter().skip(1).step_by(2).collect::<Vec<char>>();

    let mut even = vec![];
    let mut odd = vec![];
    for (i, char) in s.chars().into_iter().enumerate() {
        if (i + 1) % 2 == 0 {
            even.push(char);
        }else{
            odd.push(char);
        }
    }


    let ans = if odd.contains(&'L') || even.contains(&'R') {
        format!("{}", "No")
    } else {
        format!("{}", "Yes")
    };

    ans
}


fn main() {
    println!("{}", solve(&stdin!()));
}



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

int main(){
	int a, b;
	cin >> a >> b;
	if(a > b) {
		for(int i=0;i<a;i++) cout << b;
		cout << endl;
	} else {
		for(int i=0;i<b;i++) cout << a;
		cout << endl;
	}
}

Measured memory_bytes: 256
#include<stdio.h>
long long A,B,K;
int main(void){
  scanf("%ld %ld %ld",&A,&B,&K);

  if(A-K >=0){
	
	  printf("%ld %ld",(A-K),B);
  }else if((B+A-K)>0){
	  printf("0 %ld",B+A-K);
  }else{
	  printf("0 0");
  }
}

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

using namespace std;

int n, m, u, v, dp[100010], vis[100010], ret;
vector<int> adjlist[100010];

void dfs(int node) {
	vis[node] = 1;
	for(int i = 0; i < adjlist[node].size(); i++) {
		int next = adjlist[node][i];
		if(vis[next] == 0) {
			dfs(next);
		}
		dp[node] = max(dp[node], 1 + dp[next]);
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	memset(dp, 0, sizeof(dp));
	memset(vis, 0, sizeof(vis));
	cin >> n >> m;
	for(int i = 0; i < m; i++) {
		cin >> u >> v;
		adjlist[u]. push_back(v);
	}
	for(int i = 1; i <= n; i++) {
		if(vis[i] == 0) {
			dfs(i);
		}
	}
	for(int i = 1; i <= n; i++) {
		ret = max(ret, dp[i]);
	}
	cout << ret << endl;
}



Measured memory_bytes: 8576
use std::io;
//use std::collections::HashMap;
//use std::collections::BinaryHeap;
//use std::collections::HashSet;
//use std::mem; // mem::swap(&mut x,&mut y);
use std::cmp; // cmp::max,cmp::min

// Rust memo: https://hackmd.io/i0lQY1OKTDW1t66TECOmiw?both

#[allow(dead_code)]
fn read_line() -> String{
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
fn read_charvec() -> Vec<char>{
    read_line().chars().collect()
}

#[allow(dead_code)]
fn read_ints() -> Vec<i64>{
    let s = read_line();
    let split:Vec<&str> = s.split(" ").collect();
    split.iter().map(|&x| x.to_string().parse().unwrap()).collect()
}

#[allow(dead_code)]
fn read_int() -> i64{
    read_ints()[0]
}

#[allow(dead_code)]
fn reverse(s: &String) -> String{
    s.chars().rev().collect::<String>()
}

#[allow(dead_code)]
fn read_lines(n:i64) -> Vec<String>{
    let mut xs = Vec::new();

    for _i in 0..n{
        xs.push(read_line());
    }

    xs
}

#[allow(dead_code)]
fn read_ints2(n:i64) -> Vec<i64>{
    read_lines(n).iter().map(|x| x.parse().unwrap()).collect()
}

#[allow(dead_code)]
fn arange(start:i64,end:i64,step:i64) -> Vec<i64>{
    let mut ret = Vec::new();
    let mut i = start;

    while i < end{
        ret.push(i);
        i += step;
    }

    ret
}

#[allow(dead_code)]
const DXS : [i64; 4] = [0,0,1,-1];
#[allow(dead_code)]
const DYS : [i64; 4]  = [1,-1,0,0];
#[allow(dead_code)]
const INF : i64 = 999999999;
#[allow(dead_code)]
const N_PRIME : i64 = 1000000007;

////////////////////////////////////////////////

fn get_color(board:&Vec<Vec<bool>>) -> i64{
    let mut result = vec![vec![0;board[0].len()];board.len()];
    let mut ans = 0;

    for i in 0..board.len(){
        for j in 0..board[0].len(){
            let c = i*board[0].len() + j+1;
            let (b,w) = fill(i,j,&mut result,board,c as i64,board[i][j]);
            let pattern = b*w;
            ans += pattern;
        }
    }

    ans
}

fn fill(x:usize,y:usize,result:&mut Vec<Vec<i64>>,board:&Vec<Vec<bool>>,c:i64,wait:bool)->(i64,i64){
    let mut b = 0;
    let mut w = 0;

    if result[x][y] == 0{
        if board[x][y] != wait{
            return (0,0);
        }

        result[x][y] = c;

        for i in 0..4{
            let dx = DXS[i];
            let dy = DYS[i];
            let xx = x as i64 + dx;
            let yy = y as i64 + dy;

            if xx < 0 || xx >= board.len() as i64 || yy < 0 || yy >= board[0].len() as i64{
                continue;
            }
            let (bb,ww) = fill(xx as usize,yy as usize,result,board,c,!wait);

            b += bb;
            w += ww;
        }

        if board[x][y]{
            (b+1,w)
        }else{
            (b,w+1)
        }
    }else{
        (0,0)
    }
}

fn main(){
    let inputs = read_ints();
    let h = inputs[0] as usize;
    let mut board : Vec<Vec<bool>> = vec![];

    for _ in 0..h{
        board.push(
            read_line()
            .chars()
            .map(|x| x == '#')
            .collect()
        );
    }

    let colors = get_color(&board);
    println!("{:?}",colors);
}

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

ll calc(int b, int e) {
  ll cnt = e / b;
  return (b + e) * cnt / 2;
}

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  for (int i = 1; i <= n; i++) ans += calc(i, n / i * i);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <cstring>
#include <cstdlib>
#include <map>
#include <unordered_map>
#include <string>
#include <list>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstdio>
#include <iostream>
#include <set>
#include <unordered_set>
using namespace std;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)<0?(-(a)):(a))
#define CS while(cases())
#define I(n) int n = gi()
#define II(n) n = gi()
#define L(n) ll n = gli()
#define LL(n) n = gli()
#define F0(i, n) for (int i = 0; i < n; i++)
#define F1(i, n) for (int i = 1; i < n; i++)
#define Fi(n, a) for (int i = 0; i < n; i++) a[i] = gi()
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int, int> pii;

template<class T>
T gcd(T a, T b) {
    return (b == 0 ? a : gcd(b, a%b));
}

int gi() {
    int a;
    scanf("%d", &a);
    return a;
}

ll gli() {
    ll a;
    scanf("%lld", &a);
    return a;
}

int cases() {
    static int t = gi();
    return t--;
}

int a[200000];
int b[200000];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    I(n); I(m); L(k);
    a[0] = 0;
    b[0] = 0;
    ll s = 0;
    F0(i, n) a[i] = gi();
    F0(i, m) { b[i] = gi(); s += b[i]; }
    int h = m;
    while (h > 0 && s > k) {
        h--;
        s -= b[h];
    }
    int r = h;
    F0(i, n) {
        s += a[i];
        while (h > 0 && s > k) {
            h--;
            s -= b[h];
        }
        if (s > k)
            break;
        r = MAX(r, i+1+h);
    }
    printf("%d\n", r);

    return 0;
}


Measured memory_bytes: 5376
import sys
import numpy as np
import math
import collections
import copy
from collections import deque 
from functools import reduce
from itertools import product
from itertools import combinations

N = int(input())
An = list(map(int, input().split()))
Bn = []
Bn.append(0)
for i, A in enumerate(An):
    Bn.append(A+Bn[i])
Cn = collections.Counter(Bn)
ans = 0
for c in Cn.values():
    if c < 2:
        continue
    ans += c * (c-1) // 2
print(ans)





Measured memory_bytes: 61572
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	var s string
	fmt.Scan(&s)
	fmt.Println(s[0:k-1]+strings.ToLower(string(s[k-1]))+s[k:])
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 30;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

int x, y;

int main()
{
	cin >> x >> y;
	set<int> s1, s2;
	s1.insert(1);s1.insert(3);s1.insert(5);s1.insert(7);s1.insert(8);s1.insert(10);s1.insert(12);
	s2.insert(4);s2.insert(6);s2.insert(9);s2.insert(11);

	if (s1.find(x) != s1.end() && s1.find(y) != s1.end()) {
		cout << "Yes" << endl;
	}
	else if (s2.find(x) != s2.end() && s2.find(y) != s2.end()) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.util.function.*;

class Main {
    static In in = new In();
    static Out out = new Out();
    static long mod = 1000000007;
    static long inf = 0xfffffffffffffffL;

    void solve() {
        String s = in.next();
        String t = in.next();
        out.println(t + s);
    }

    public static void main(String[]$) {
        new Main().solve();
        out.flush();
    }
}

class In {
    private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 0x10000);
    private StringTokenizer tokenizer;

    String next() {
        try {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
        } catch (IOException ignored) {
        }
        return tokenizer.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    char[][] nextCharArray(int n, int m) {
        char[][] a = new char[n][m];
        for (int i = 0; i < n; i++) {
            a[i] = next().toCharArray();
        }
        return a;
    }

    int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextInt();
        }
        return a;
    }

    int[] nextIntArray(int n, IntUnaryOperator op) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsInt(nextInt());
        }
        return a;
    }

    long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = nextLong();
        }
        return a;
    }

    long[] nextLongArray(int n, LongUnaryOperator op) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = op.applyAsLong(nextLong());
        }
        return a;
    }
}

class Out {
    private static PrintWriter out = new PrintWriter(System.out);

    void println(Object... a) {
        StringJoiner joiner = new StringJoiner(" ");
        for (Object obj : a) {
            joiner.add(String.valueOf(obj));
        }
        out.println(joiner);
    }

    void flush() {
        out.flush();
    }
}


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

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    double a, b;
    while(cin>>a>>b)
    {
        printf("%.0lf\n", a+b);
    }
    return 0;
}

Measured memory_bytes: 1232
#include<stdio.h>

int main(void){

    int i,j,n,k,m;

    int p[1000];

    scanf("%d %d",&n,&k);

    for(i = 0; i < n; i++){
        scanf("%d",&p[i]);
    }
    for(i = 0; i < n - 1; i++){
        for(j = i + 1; j < n; j++){
            if(p[i] >= p[j]){
                m = p[i];
                p[i] = p[j];
                p[j] = m;
            }
        }
    }
    m = 0;
    for(i = 0; i < k; i++){
        m += p[i];
    }

    printf("%d\n",m);
    return 0;
}

Measured memory_bytes: 1732
n = int(input())

s = []
for _ in range(n):
    s.append(input())
s = s + s

def check(a):
    flag = True
    n = len(a)
    i, j_start = 0, 1
    while flag:
        if i == n - 1:
            break
        for j in range(j_start, n):
            if a[i][j] != a[j][i]:
                flag = False
        i += 1
        j_start += 1
    return flag

ans = 0
for i in range(n):
    if check(s[i:i+n]):
        ans += n
    else:
        pass
print(ans)

Measured memory_bytes: 3064
typedef long long ll;
#include<bits/stdc++.h>
using namespace std;
ll maxl(ll a, ll b){ return ((a<b)?b:a);}
ll minl(ll a, ll b){ return ((a>b)?b:a);}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    int arr[n];
    for (int i=0;i<n;i++)
        cin >> arr[i];
    int maxi = arr[0];
    ll ans = 0;
    for (int i=1;i<n;i++){
        if (arr[i]<maxi){
            ans += (maxi-arr[i]);
        } else {
            maxi = arr[i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4416
x1, y1, x2, y2 = map(int, input().split())

dx = x2 - x1
dy = y2 - y1

x3 = x2 - dy
y3 = y2 + dx

x4 = x3 - dx
y4 = y3 - dy

print(x3, y3, x4, y4)

Measured memory_bytes: 3060
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

S=get_nsp
N=S.size
if N==2
    if S.uniq.size !=N
        puts "1 2"
    else
        puts "-1 -1"
    end
else
    (N-3+1).times do|i|
        if S[i..i+2].uniq.size !=3
            puts "#{i+1} #{i+3}"
            exit
        end
    end
    puts "-1 -1"
end

Measured memory_bytes: 9468
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+5,M=1e6+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a) memset(a,0,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first 
#define se second
int main(){
	set<int>s;
	for(int i=0;i<3;i++){
		int x;
		scanf("%d",&x);
		s.insert(x);
	} 
	printf("%d\n",s.size());
	return 0;
}

Measured memory_bytes: 3784