akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = INT64_MAX;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i=0;i<N;i++)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll a,b,c,d;

ll gcd(ll a,ll b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    
    return b ? gcd(b, a % b) : a;
}

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

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>a>>b>>c>>d;
    ll ans = 0;
    a--;
    ans += b/c - a/c;
    //if(a%c==0)ans++;
    ans += b/d -a/d;
    //if(a%d==0)ans++;
    ans -= b/lcm(c,d) -a/lcm(c,d);
    //if(a%lcm(c,d)==0)ans--;
    print(b-a-ans);
    return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#include<utility>
#define ll long long int
#define MOD 1000000007LL
using namespace std;
int main() {
    int n;
    cin>>n;
    ll a[114514]={};
    ll b[114514]={};
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    ll ans=0;
    for(int i=n-1;i>=0;i--){
        a[i]+=ans;
        if(a[i]%b[i]==0){
            continue;
        }else{
            ans+=b[i]-(a[i]%b[i]);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2048
#include <bits/stdc++.h>
 
#define f first
#define s second
#define pb push_back
#define mp make_pair
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
 
const int N = (int)2e5 + 123, inf = 1e9, mod = 1e9 + 7;
const ll INF = 1e18;
 
vector< int > g[N], a[2], b[3];
int n, m, c[N], ans[N];
void dfs(int v, int p){
	c[v] = c[p] ^ 1;
	a[c[v]].pb(v);
	for(auto to : g[v])
		if(to != p)
			dfs(to, v);
}            
int aa(int i){
	int x = a[i].back();
	a[i].pop_back();
	return x;
}
int bb(int i){
	int x = b[i].back();
	b[i].pop_back();
	return x;
}
void ff(int i, int j){
	while(a[i].size() && b[j].size())
		ans[aa(i)] = bb(j);
}
int main()
{
	scanf("%d", &n);
	m = n - 1;
	for(int i = 0; i < m; i++){
		int v, u;
		scanf("%d%d", &v, &u);
		g[v].pb(u);
		g[u].pb(v);
	}
	dfs(1, 1);
	for(int i = 1; i <= n; i++)
		b[i % 3].pb(i);
	if(a[0].size() > a[1].size()){
		ff(0, 1);
	}else{
		ff(1, 1);	
	}        
	if(a[0].size() > a[1].size()){
		ff(0, 2);
	}else{
		ff(1, 2);	
	}        
	ff(0, 0);
	ff(1, 0);
	assert(a[0].empty());
	assert(a[1].empty());
	for(int i = 1; i <= n; i++)
		printf("%d ", ans[i]);
}              


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

int main(){
  int N;
  cin >> N;
  double X;
  X = N * 100 / 108;
  for(int i = X-2; i<= X+1 ; i++){
    if(i * 108 /100 == N){
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" <<endl;
}

Measured memory_bytes: 256
function binary_sort(array,search_value){ 
  const array_len = array.length;
  
  var left_index = 0;
  var right_index = array_len - 1;
  var middle_index = 0;
  
  var count = 0; // 計算量
  var index = 0;

  // 最小値より小さい場合
  if (search_value <= array[0]) {
    index = 0;
    
  // 最大値の場合
  if (search_value == array[array_len-1]) {
    index = array_len - 1;
  }
    
  // 最大値より大きい場合
  } else if (search_value > array[array_len-1]) {
    index = array_len;

  // 最小値と最大値の間にある場合
  } else {
    while (left_index <= right_index) {
      count++;
      middle_index = Math.floor( (left_index + right_index) / 2 );

      // どんぴしゃの時
      if (search_value == array[middle_index]) {
        index = middle_index;
        break;

      // 真ん中より小さい場合 
      } else if (search_value < array[middle_index]) {
        right_index = middle_index;

      // 真ん中より大きい場合
      } else {
        left_index = middle_index;
      }

      // 最後にこれ以上探索する必要があるか確認
      if ( (right_index - left_index) <= 1) {
        index = right_index;
        break;
      }
      
    } // while
    
  } // else
  
  return index;
  
} // function

function Main(input){
  const input_text = input.split('\n');
  const N_Q = input_text[0].split(' ');
  const N = N_Q[0];
  const Q = N_Q[1];
  const S = input_text[1];
  var count = 0;
  var AC_Array = [];
  
  // Sに含まれるACのAのindex位置を配列化
  for (k = 0; k < N-1; k++) {
    if(S[k] === 'A' && S[k+1] === 'C'){
      AC_Array.push(k);
    }
  }
  
  for (i = 0; i < Q; i++) {
    var l_r = input_text[i+2].split(' ');
    var l_index = l_r[0] - 1; // start range
    var r_index = l_r[1] - 1; // end range
    var result = binary_sort(AC_Array,r_index) - binary_sort(AC_Array,l_index)
    console.log(result);
  }
}
 
Main(require("fs").readFileSync("/dev/stdin","utf-8"));

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

typedef long long ll;

int const N = 2e5 + 7;
int ar[N];
int main()
{
	int n;
	cin >> n;

	for (int i = 0; i < n; ++i)
		cin >> ar[i];
	sort(ar, ar+n, greater<int>());

	int ctr = n-1;
	ll res = 0;
	for (int i = 0; i < n; ++i)
	{
		if (ctr == 0)
			break;

		else if (ctr == 1 || i == 0)
			ctr--, res += ar[i];

		else
			ctr -= 2, res += 2 * ar[i];
	}
	cout << res << '\n';
	return 0;
}

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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;
const long long MOD = (long long)1e9 + 7;

int main(){
    int n, ans = 0;
    cin >> n;
    for(int i = 1; i <= n; i++){
        int sum = 0;
        ans = 0;
        for(int j = 1; j * j <= i; j++){
            for(int k = j; k * k <= i; k++){
                for(int l = k; l * l <= i; l++){
                    sum = j * j + k * k + l * l + j * k + k * l + l * j;
                    if(sum == i){
                        if(j == k && k == l){
                            ans += 1;
                        }else if(j == k || k == l){
                            ans += 3;
                        }else{
                            ans += 6;
                        }
                    }
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}



signed main() {

    int n, k;
    cin >> n >> k;
    vector<int> a(n);

    for(auto&&i:a) cin >> i;

    ll ans = 0;

    for(int i = 0; i < n; i++) {
        ll c = 0, x = 0, y;
        for(int j = i + 1; j < n; j++) 
            if(a[i] > a[j]) x++;
        y = x;
        for(int j = 0; j < i; j++)
            if(a[i] > a[j]) y++;

        ans = (ans + x * k % SMOD) % SMOD;
        ans = (ans + k * (k - 1) / 2 % SMOD * y % SMOD) % SMOD;
    }

    cout << ans << endl;

  
    return 0;
}



Measured memory_bytes: 256
#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>;
const int MAX = 1000;
const int INF = 1e9;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};
#define PI 3.14159265358979323846264338327950L
//setprecision(15)


map<string, int> memo;

int main() {
	int n; cin >> n;
	rep(i, n) {
		string s; cin >> s;
		memo[s] += 1;
	}
	int maxv = 0;
	for (auto it = memo.begin(); it != memo.end(); it++) {
		maxv = max(maxv, it->second);
	}
	for (auto it = memo.begin(); it != memo.end(); it++) {
		if (it->second == maxv) {
			cout << it->first << endl;
		}
	}
}

Measured memory_bytes: 19236
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,k;
    scanf("%d%d%d",&n,&m,&k);
    bool flag=false;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(k==i*m || k==j*n) {flag=true;break;}
            if(i*m+j*n-2*i*j==k) {flag=true;break;}
        }
    }
    if(flag) printf("Yes\n");
    else printf("No\n");
    return 0;
}


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

int main() {
  int h, w; cin >> h >> w;
  string s[60];
  int dh[] = {-1, -1, -1, 0, 0, 1, 1, 1};
  int dw[] = {-1, 0, 1, -1, 1, -1, 0, 1};

  for (int i = 0; i < h; i++) cin >> s[i];

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j] == '.') {
        int cnt = 0;
        for (int k = 0; k < 8; k++) {
          int y = i + dh[k];
          int x = j + dw[k];
          if (0 <= x && x <= w && 0 <= y && y <= h && s[y][x] == '#') cnt++;
        }
        s[i][j] = '0' + cnt;
      }
    }
  }
  for (int i = 0; i < h; i++) {
    cout << s[i] << endl;
  }
}

Measured memory_bytes: 256
function gets(str){
  this._s = str.split("\n");
  this._y = 0;
};
gets.prototype = {
  a: function(f){
    var s = this._s, y = this._y, r;
    if(typeof s[y] === "string")s[y] = s[y].split(" ").reverse();
    r = s[y].pop();
    if(!s[y].length)this._y++;
    return f?r:+r;
  },
  l: function(f){
    var s = this._s[this._y++].split(" ");
    return f?s:s.map(a=>+a);
  },
  m: function(n,f){
    var s = this._s, y = this._y, r = [], i = 0;
    if(f)for(;i < n; i++)r[i] = s[y+i].split(" ");
    else for(;i < n; i++)r[i] = s[y+i].split(" ").map(a=>+a);
    this._y += n;
    return r;
  },
};
var o=new gets(require("fs").readFileSync("/dev/stdin","utf8"));
var mod = 1e9 + 7;

console.log(main());
function main(){
  var n = o.a();
  var m = o.a();
  var p = o.m(m);
  var q = p.concat();
  p.sort((a,b)=>a[1]-b[1]);
  var a = Array(n+1).fill(1);
  var y = {};
  for(var i = 0; i < m; i++){
    y[p[i][1]] = a[p[i][0]]++;
  }
  var ans = [];
  for(i = 0; i < m; i++){
    ans[i] = ("000000"+q[i][0]).slice(-6);
    ans[i] += ("000000"+y[q[i][1]]).slice(-6);
  }
  return ans.join("\n");
}

Measured memory_bytes: 77952
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

int n, m;

typedef struct edge_ {
		int from, to, cost;
		edge_(int f, int t, int c): from(f), to(t), cost(c){};
} edge;
vector<edge> vec;

ll d[1001];

bool bellmanford(){
		bool updated;
		fill(d, d+n, linf);
		d[0] = 0;
		for(int i = 0; i <= n; i++){
				updated = false;
				for(auto itr = vec.begin(); itr != vec.end(); ++itr){
						int from = (*itr).from;
						int to = (*itr).to;
						int cost = (*itr).cost;
						if(d[from] != linf && d[from] + (ll)cost < d[to]){
								if(to == n - 1)updated = true;
								d[to] = d[from] + (ll)cost;
						}
				}
		}
		return !updated;
}

int main(int argc, char const* argv[])
{
	cin >> n >> m;
	for(int i = 0; i < m; i++){
			int a, b, c;
			cin >> a >> b >> c;
			a--; b--;
			vec.pb(edge(a, b, -c));
	}
	if(bellmanford())cout << -d[n - 1] << endl;
	else cout << "inf" << endl;
	return 0;
}


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

#define int long long
int A[2019],ans;

signed main(){
  string s;cin>>s;
  reverse(s.begin(),s.end());
  A[0]++;
  for(int i=0,t=1,pre=0;i<s.size();i++){
    int a=s[i]-'0';
    ans+=A[(pre+=a*t)%=2019]++;
    (t*=10)%=2019;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3728
#include <iostream>
#include <string>

using namespace std;

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

  int ans = 0;
  int p = 0;
  int g = 0;
  for (char c : s) {
    if (p == g) {
      ++g;
      if (c == 'p')
        --ans;
    } else if (p < g) {
      ++p;
      if (c == 'g')
        ++ans;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

int main() {
    int n;
    scanf("%d", &n);
    deque<int> ans;
    int sw = 0;
    for (int i = 0; i < n; i++) {
        int tmp;
        scanf("%d", &tmp);
        if (sw) ans.push_front(tmp);
        else ans.push_back(tmp);
        sw ^= 1;
    }
    if (sw) reverse(ans.begin(), ans.end());
    for (int i : ans) printf("%d ", i);
    puts("");
    return 0;
}


Measured memory_bytes: 2944
use v5.18;
use warnings;
sub read_line { chomp(my $s = <>); $s }
sub splited_read_line { split / /, read_line }

my $s = read_line;
my $t = read_line;

my @s_splited = split //, $s;
for (0 .. $#s_splited) {
  my $last = pop @s_splited;
  unshift @s_splited, $last;
  if ( join('', @s_splited) eq $t ) {
    say 'Yes';
    exit;
  }
}
say 'No';


Measured memory_bytes: 640
INF=100000000000


def floyd_warshall(dist):
    for k in range(n):
        for i in range(n):
            for j in range(n):
                dist[i][j] = min(dist[i][j], dist[i][k]+dist[k][j])

n,m = map(int,input().split())
dist=[[INF]*n for i in range(n)]
edges=[]

for i in range(m):
    ai,bi,ci=map(int,input().split())
    edges.append(tuple([ai-1,bi-1,ci]))
    dist[ai-1][bi-1]=ci
    dist[bi-1][ai-1]=ci

for i in range(n):
    dist[i][i] = 0

floyd_warshall(dist)

#print(dist)
ans = m
for edge in edges:
    ai,bi,ci=edge
    flag = 0
    for s in range(n):
        if dist[s][ai]+ci == dist[s][bi]:
            flag+=1

    if flag > 0:
        ans-=1

print(ans)

     

Measured memory_bytes: 3440
local DBG = false
function dbgpr(...)
    if DBG then
        io.write("[dbg]")
        print(...)
    end
end
function dbgpr_t(tbl)
    if DBG then
        dbgpr(tbl)
        io.write("[dbg]")
        for i,v in ipairs(tbl) do
            io.write(i)
            io.write(":")
            io.write(tostring(v))
            io.write(" ")
        end
        print("")
    end
end

function parse_problem()
    local tbl = {}
    local S = io.read("l"):gsub("[^%d]", "")
    dbgpr(S, string.len(S))
    --local S_split = {S:byte(1, S:len())}
    local cur_char = nil
    local cur_succ = nil
    for _,v in ipairs({S:byte(1, S:len())}) do
        if v ~= cur_char then
            if cur_succ ~= nil then
                table.insert(tbl, cur_succ)
            end
            cur_char = v
            cur_succ = 1
        else
            cur_succ = cur_succ + 1
        end
    end
    if cur_succ ~= nil then
        table.insert(tbl, cur_succ)
    end
    dbgpr_t(tbl)
    return tbl
end

function main()
    local tbl = parse_problem()
    local del_count = 0
    local start = 1
    while start <= (#tbl - 1) do
        local a, b = tbl[start], tbl[start + 1]
        if a == b then
            del_count = del_count + a
            -- remove a, b
            start = start + 2
        elseif a > b then
            local r = a - b
            del_count = del_count + b
            -- remove b, merge r into c
            start = start + 2
            if start <= #tbl then
                tbl[start] = tbl[start] + r
            end
        else
            -- b > a
            local r = b - a
            del_count = del_count + a
            -- remove a
            start = start + 1
            -- update b
            tbl[start] = r
        end
    end
    local ans = del_count * 2
    print(ans)
end

main()


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

int main() {
  int N, M;
  cin >> N >> M;
  set<int> to[2];
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    if (a == 0) {
      to[0].insert(b);
    }
    if (b == 0) {
      to[0].insert(a);
    }
    if (a == N - 1) {
      to[1].insert(b);
    }
    if (b == N - 1) {
      to[1].insert(a);
    }
  }
  for (int a : to[0]) {
    if (to[1].find(a) != to[1].end()) {
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
  return 0;
}

Measured memory_bytes: 9600
n = int(input())
xy = [[],[],[],[]]
s = {'L':0,'R':1,'U':2,'D':3}
for i in range(n):
  x,y,d = input().split()
  xy[s[d]] += [[int(x),int(y)]]
q = 10**9
xmax, xmin, ymax, ymin = [-q,-q,-q],[q,q,q],[-q,-q,-q],[q,q,q]
sx = [0,2,1,1]
sy = [1,1,2,0]
for i in range(4):
  if xy[i]:
    z = max(xy[i],key=lambda z:z[0])
    xmax[sx[i]] = max(xmax[sx[i]],z[0])
    z = min(xy[i],key=lambda z:z[0])
    xmin[sx[i]] = min(xmin[sx[i]],z[0])
    z = max(xy[i],key=lambda z:z[1])
    ymax[sy[i]] = max(ymax[sy[i]],z[1])
    z = min(xy[i],key=lambda z:z[1])
    ymin[sy[i]] = min(ymin[sy[i]],z[1])
t = set([0])
for z in [xmax,ymax]:
  if max(z)==z[1]:
    t.add(z[1]-z[2])
  elif max(z)==z[0]:
    if z[0]-z[1] < z[1]-z[2]:
      t.add(z[0]-z[1])
      t.add(z[1]-z[2])
    else:
      t.add((z[0]-z[2])/2)
for z in [xmin,ymin]:
  if min(z)==z[1]:
    t.add(z[0]-z[1])
  elif min(z)==z[2]:
    if z[1]-z[2] < z[0]-z[1]:
      t.add(z[1]-z[2])
      t.add(z[0]-z[1])
    else:
      t.add((z[0]-z[2])/2)
ans = 4*10**16
for u in t:
  if u >= 2*10**8:
    continue
  dx = max(xmax[0]-u,xmax[1],xmax[2]+u) - min(xmin[0]-u,xmin[1],xmin[2]+u)
  dy = max(ymax[0]-u,ymax[1],ymax[2]+u) - min(ymin[0]-u,ymin[1],ymin[2]+u)
  ans = min(ans,dx*dy)
print(ans)

Measured memory_bytes: 58200
#include<bits/stdc++.h>
/*	#include <boost/math/common_factor.hpp>  boost::math::lcm(10,20) ---> use it to find lcm. fill_n(&an[0][0],n*m,0); typedef long long ll;*/
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long 
#define PI pair<int , int >
#define mpr make_pair
#define ff first
#define ss second
#define endl "\n"
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define FO(i,a,b) for(int i = (int)a;i < (int)b;++i)
#define FE(i,a,b) for(int i = (int)a;i <= (int)b;++i)
const int MOD = 1e9+7;
const int MAXN = 1e5+3;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,-1,1};
#define print(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
bool cmp(PI p1,PI p2){
	if(p1.ff < p2.ff)return true;	// You should not be writing p1.ss <= p2.ss !!!
	else if(p1.ff == p2.ff){ if(p1.ss < p2.ss)return true; return false; }
	return false;
}

void solve(){
	int n,k;
	cin >> n >> k;
	int ans = 0;
	while(n>0){
		n /= k;
		ans++;
	}
	cout << ans << endl;
}
/* When you have to multiply many things , do it in different (multiple) lines, not in a single line .*/
int32_t main(){
	IO;
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	#endif // ONLINE_JUDGE
	// std::cout << std::setprecision(15); std::cout << std::fixed;
	int nT = 1;
	//cin >> nT;
	FE(i,1,nT)
		solve();
	return 0;
}


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

int n;
std::deque< long > deq;

int main() {
    std::cin >> n;
    for (int i=0; i<n; ++i) {
        long tmp;
        std::cin >> tmp;
        if (i%2) deq.push_back( tmp  );
        else     deq.push_front( tmp );
    }
    if (n%2 == 0) std::reverse(deq.begin(), deq.end());
    while (!deq.empty()) {
        long tmp = deq.front();
        deq.pop_front();
        std::cout << tmp;
        if (!deq.empty()) std::cout << ' ';
        else              std::cout << '\n';
    }
    return 0;
}

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

#define ld long double
#define MAXN 305

using namespace std;

int n;
ld dp[MAXN][MAXN][MAXN];

ld f(int i, int j, int k) {

    if(i + j + k == 0)
        return 0.0;
    if(dp[i][j][k] >= 0)
        return dp[i][j][k];
    
    dp[i][j][k] = (ld)n / (ld)(i + j + k);
    if(i)
        dp[i][j][k] += ((ld)i / (i + j + k)) * f(i - 1, j, k);
    if(j)
        dp[i][j][k] += ((ld)j / (i + j + k)) * f(i + 1, j - 1, k);
    if(k)
        dp[i][j][k] += ((ld)k / (i + j + k)) * f(i, j + 1, k - 1);
    return dp[i][j][k];
}

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> n;

    int br1 = 0, br2 = 0, br3 = 0;
    for(int i = 0; i < n; i++) {
        int a;
        cin >> a;

        if(a == 1)
            br1++;
        else if(a == 2)
            br2++;
        else
            br3++;
    }

    for(int i = 0; i < MAXN; i++)
        for(int j = 0; j < MAXN; j++)
            for(int k = 0; k < MAXN; k++)
                dp[i][j][k] = -1.0;
    cout << fixed << setprecision(10) << f(br1, br2, br3) << endl;
    return 0;
}


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

ans = 0
free = 0
tmp = a[0] // 400
for i in a:
    if i >= 3200:
        free += 1
    elif i >= 400 * tmp:
        tmp = i//400 + 1
        ans += 1
if ans > 0:
    print(ans, ans+free)
else:
    print(1, ans+free)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }

int main() {
  int n, m, q; cin>>n>>m>>q;
  vector<vector<int>> lr(n+1, vector<int>(n+1, 0));
  rep(i, m) {
    int l, r; cin>>l>>r;
    ++lr[l][r];
  }

  rep(i, n) rep(j, n) lr[i+1][j+1] += lr[i][j+1] + lr[i+1][j] - lr[i][j];
  rep(i, q) {
    int l, r; cin>>l>>r;
    print(lr[r][r] - lr[l-1][r] - lr[r][l-1] + lr[l-1][l-1]);
  }

  return 0;
}

Measured memory_bytes: 1920
package main

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

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func main() {
	a, p := nextInt(), nextInt()
	p += a * 3
	pie := p / 2
	fmt.Println(pie)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long N;
    cin >> N ;
    vector<long long> A(N);
    long long check = 0; 
    for(long long i = 0; i < N; i++){
        cin >> A.at(i);
        if(A.at(i) % 2 == 1){
            check++;
        }
    }
    if(check % 2 == 0){
        printf("YES");
    }
    else{
        printf("NO");
    }
    
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

int main() {
  int N, Q; cin >> N >> Q;
  string S; cin >> S;
  vector<int> cnt(N);
  REP(i, 1, N) {
    cnt[i] = cnt[i - 1] + (S[i - 1] == 'A' && S[i] == 'C');
  }
  rep(i, Q) {
    int l, r; cin >> l >> r;
    l--, r--;
    cout << cnt[r] - cnt[l] << endl;
  }
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>

using namespace std;

int main(){

    int n, m, x;
    cin >> n >> m >> x;

    vector<int> f(n+2);

    while( m-- ){
        int val;
        cin >> val;
        f[val]++;
    }

    for( int i = 1; i <= n + 1; i++){
        f[i] = f[i] + f[i - 1];
    }

    if( f[n + 1] - f[x] < f[x] ){
        cout << f[n + 1] - f[x];
    }else{
        cout << f[x];
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws java.io.IOException {
        Scanner scan = new Scanner(System.in);
        while (scan.hasNext()) {
            String[] tmp = scan.nextLine().split("\\B");
            int n = 10;
            int[] ns = new int[n];
            for (int i = 0; i < n; i++)
                ns[i] = Integer.parseInt(tmp[i]);
            while (n != 0) {
                n--;
                for (int i = 0; i < n; i++) {
                    ns[i] = (ns[i] + ns[i + 1]) % 10;
                }
            }
            System.out.println(ns[0]);
        }

    }
}

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

const int inf = 1e9;
const ll linf = 1e18;

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

    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    for (int i = 0; i < n - 2; i++) {
        if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#DP C
import sys
N = int(sys.stdin.readline())
L = [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
#print(L)

dp = [[0,0,0] for _ in range(N)]
dp[0] = L[0].copy()
for i in range(1, N):
    dp[i][0] = L[i][0] + max(dp[i-1][1], dp[i-1][2])
    dp[i][1] = L[i][1] + max(dp[i-1][0], dp[i-1][2])
    dp[i][2] = L[i][2] + max(dp[i-1][0], dp[i-1][1])
    #print(dp)
print(max(dp[-1]))

Measured memory_bytes: 47280
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <tuple>
template <typename T> constexpr T my_abs(const T &x) { return x < 0 ? -x : x; }
using ll = long long;
int deg[5];
int main()
{
	// freopen("yahoo2019-B.in", "r", stdin);
	for (int i = 0; i < 6; i++)
	{
		int x;
		scanf("%d", &x);
		deg[--x]++;
	}
	bool flg = true;
	for (int i = 0; i < 4; i++)
		flg &= deg[i] <= 2;
	puts(flg ? "YES" : "NO");
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int main ()
{
	int a, b;
	scanf("%d %d",&a,&b);
	if(a>b)
	{
		printf("a > b\n");
	}
	else if(a<b)
	{
		printf("a < b\n");
	}
	else if(a==b)
	{
		printf("a == b\n");
	}
	
	return 0;

} 



Measured memory_bytes: 2692
n = int(input())
h = list(map(int, input().split()))

ans = 0
count = 0
for i in range(1, n):
    prev = h[i-1]
    if h[i] <= prev:
        count += 1
    else:
        ans = max(ans, count)
        count = 0

ans = max(ans, count)
print(ans)


Measured memory_bytes: 14252
import sys
sys.setrecursionlimit(1000000)

n = int(input())
x = list(map(int, input().split()))
d = [x[i+1] - x[i] for i in range(n - 1)]

def pow(x, y):
    if y == 0:
        return 1
    ans = 1
    while y > 1:
        if y % 2 != 0:
            ans *= x
            ans %= 1000000007
        x *= x
        x %= 1000000007
        y //= 2
    return ans * x % 1000000007

def fact(m):
  return m * fact(m-1) % 1000000007 if m != 1 else 1
 
fact_n_1 = fact(n-1)

e = [None] * (n-1)
for i in range(n-1):
  if i == 0:
    e[i] = fact_n_1
  else:
    e[i] = (e[i - 1] + fact_n_1 * pow(i + 1, 1000000005)) % 1000000007

print(sum(e_i * d_i % 1000000007
          for i, (d_i, e_i) 
          in enumerate(zip(d, e))) % 1000000007 ) 

Measured memory_bytes: 91536
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M, sum=0, resultNum=0;
  cin >> N >> M;
  vector<int> vec(N,0);
  for(int i=0;i<N;i++){
    cin >> vec.at(i);
    sum += vec.at(i);
  }

  //sort(vec.begin(), vec.end());

  // for(int i=0;i<N;i++){
  //   if (vec.at(i) >= sum/(4*M))
  //   {
  //     resultNum++;
  //   }
  // }
  for(int i:vec){
    if(i*4*M >= sum){
      resultNum++;
    }
  }


  string answer;
  if(resultNum >= M){
    answer = "Yes";
  } else {
    answer = "No";
  }

  cout << answer << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <climits>
#include <cmath>

using namespace std;
using Pos = std::pair<int, int>;
//cout<<fixed<<std:cout<<fixed<<setprecision(2)<<Max<<endl;
constexpr int mod = 1e9 + 7;

int N,M;
vector<string> A,B;

bool check(int i,int j){
    for(int k=i;k<i+M;++k){
        for(int l=j;l<j+M;++l){
            if(k>=N || l>+N || A[k][l]!=B[k-i][l-j])return false;
        }
    }
    return true;
}

int main() {
    cin>>N>>M;
    A.resize(N);
    B.resize(M);
    for(auto& str:A)
        cin>>str;
    for(auto& str:B)
        cin>>str;

    bool ans=false;
    for(int i=0;i<N-M+1;++i){
        for(int j=0;j<N-M+1;++j){
            if(check(i,j)){
                ans=true;
                break;
            }
        }
    }

    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 256
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// find_by_order()  // order_of_key
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;


int main(){
    std::ios::sync_with_stdio(false); cin.tie(NULL);
    ll a;
    string b;
    cin>>a>>b;
    ll val;
    val=(b[0]-'0')*100+(b[2]-'0')*10 + b[3]-'0';
    //cout<<val<<endl;
    a*=val;
    a/=100;
    cout<<a<<endl;

    return 0;   
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    ll n, k, s;
    ll i;
    cin>>n>>k>>s;
    ll a[n+5];
    FOR0(i, k)
    {
        a[i] = s;
    }
    int fill = s-1;
    if( s == 1) fill = s+1;
    while( i < n)
    {
        a[i] = fill;
        i++;
    }
    FOR0(i, n) cout<<a[i]<<" ";
    cout<<endl;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 2176
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()


int main(void){
    ll c[3][3];

    /*
    c11 = c21 - a2 = c31 - a3
    c12 = c22 - a2 = c32 - a3
    c13 = c23 - a2 = c33 - a3
    */

    rep(i, 3) rep(j, 3) cin >> c[i][j];

    bool b1 = (c[1][0] - c[0][0] == c[1][1] - c[0][1] && c[1][0] - c[0][0] == c[1][2] - c[0][2]);
    bool b2 = (c[2][0] - c[0][0] == c[2][1] - c[0][1] && c[2][0] - c[0][0] == c[2][2] - c[0][2]);

    if (b1 && b2) cout << "Yes" << endl; 
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n;
	cin>>n;
	int s[n],sum=0;
	rep(i,n){
		cin>>s[i];
		sum+=s[i];
	}
	if(sum%10)cout<<sum<<endl;
	else{
		int num=0;
		rep(i,n){
			if((sum-s[i])%10)num=max(num,sum-s[i]);
		}
		cout<<num<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import bisect
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort()
C.sort()
res = 0
for i in B:
    res += bisect.bisect_left(A, i) * (N - bisect.bisect_right(C, i))
    
print(res)
    

Measured memory_bytes: 23232
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
	int N, T, S, M[3001]={};
	cin >> N >> T >> S;
	for(int n=0; n<N; n++){
		int mise_fun, mise_time;
		cin >> mise_fun >> mise_time;
		for(int t=T; t>=mise_time; t--)
			if(t<=S || t >= S  + mise_time) M[t] = max(M[t], M[t-mise_time] + mise_fun);
	}
	cout << *max_element(M+1, M+T+1) << endl;
	return 0;
}

Measured memory_bytes: 1216
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/04/04.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//  ABC162
//
//

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

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

template<class T> inline bool chmin(T& a, T b){ if(a>b){a=b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b){ if(a<b){a=b; return 1;} return 0;}

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;
//#define __DBG__

void solve(void){
  
  string S;
  
  cin >> S;
  
  bool flag=false;
  REP(i, S.size()){
    if(S[i]=='7'){flag=true; break;}
  }
  if(flag){
    cout << "Yes" <<endl;
    
  }
  else{
    cout << "No" << endl;
  }
  
  return;
   
}



#define TESTCASES 1

int main(int argc, const char * argv[]) {


    cin.tie(0);
    ios::sync_with_stdio(false);

    REP(i,TESTCASES){
      solve();
    }
 
    return 0;
}



Measured memory_bytes: 3656
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
   input! {
      r: usize, 
   } 

   println!("{}", 3*r*r);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define LL long long
#define INF 0x7FFFFFFF//or 0x3f3f3f3f ? -Wall
using namespace std;

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

/*============ Header Template ============*/

LL n, x;

int main() {
	read(n), read(x);
	LL ans = n;
	LL d = __gcd(x, n - x);
	ans += d + (x - d + n - x - d) * 2LL;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<bits/stdc++.h>
#include<vector>
#include<cmath>
using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    cout << max({a + b, a - b, a * b}) << endl;
}



Measured memory_bytes: 256
//package ABC172;
import java.util.*;
import java.lang.*;
import java.io.*;

class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		int k=sc.nextInt();
		int count=0;
		long sum=0;
		int a[]=new int[n];
		int b[]=new int[m];
		
		for(int i=0;i<n;i++)
		{
			a[i]=sc.nextInt();
		}
		
		for(int j=0;j<m;j++)
		{
			b[j]=sc.nextInt();
		}
		
		int i=0;
		int j=0;
		
		while(i<n && sum+a[i]<=k)
		{
			sum=sum+a[i];
			i++;
		}
		
		count=i; //number of elements inclued;
		
		
		while(j<m && i>=0)
		{
			sum=sum+b[j];
			j++; //added top of second;
			
			//our sume has incres;
			while(sum>k && i>0)
			{
				i--;
				sum=sum-a[i]; //we decrease the last element of stack;
			}
			if(sum<=k && i+j>count)
			{
				count=i+j;
			}
			
		}
		System.out.println(count);
		
		/*
		Stack<Integer> s1=new Stack<>();
		
		Stack<Integer> s2=new Stack<>();
		
		for(int i=0;i<n;i++)
		{
			s1.push(a[i]);
		}
		
		for(int j=0;j<m;j++)
		{
			s2.push(b[j]);
		}
		*/
		
		/*
		int dp[][]=new int[n+1][m+1];
		
		for(int j[]:dp)
		{
			Arrays.fill(j,-1);
		}
		*/
		/*
		HashSet<String> hs=new HashSet<>();
		HashMap<String,Integer> hm=new HashMap<>();
		
		
		System.out.println(solve(a,b,0,0,k,0,hm));*/
		
		
	}
	
	public static int solve(int a[],int b[],int i,int j,int k,long sum, HashMap<String,Integer> hm)
	{
		String ss=i+" "+j;
		if(hm.containsKey(ss))
		{
			return hm.get(ss);
		}
		if(sum>k)
		{
			return -1;
		}
		if(sum==k)
		{
			return 0;
		}
		if(i>=a.length && j>=b.length)
		{
			return 0;
		}
		int option1=0;
		int option2=0;
		if(i<a.length)
		{
			option1=1+solve(a,b,i+1,j,k,sum+a[i],hm);
		}
		if(j<b.length)
		{
			option2=1+solve(a,b,i,j+1,k,sum+b[j],hm);
		}
		
		hm.put(ss,Math.max(option1, option2));
		return hm.get(ss);
	}
	
	

}


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

int main() {
	int a, b;
	cin >> a >> b;
	int c;
	c = a * b;
	if (c % 2 == 0) {
		cout << "Even" << endl;
	}
	else {
		cout << "Odd" << endl;
	}
}

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

int main() {
  string s,t;
  cin>>s>>t;
  int ans=0;
  for(int i=0;i<s.size();i++){
    if(s[i]!=t[i]){
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3920
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    set<int>sugar,water;
    for(int i=0; i<=30; i++)
    {
        for(int j=0; j<=30; j++)
        {
            int cur=(100*i*a)+(100*j*b);
            if(cur<=f)
                water.insert(cur);
        }
    }
    for(int i=0; i<=3000; i++)
    {
        for(int j=0; j<=3000; j++)
        {
            int cur=(i*c)+(j*d);
            if(cur<=f)
                sugar.insert(cur);
        }
    }
    double per=-1e20;
    int mx_sugar=0,mx_mass=0;
    for(auto x:water)
    {
        for(auto y:sugar)
        {
            int sum=x+y;
            if(sum>f)
                continue;
            double cur=(100.0*(double)y)/(double)sum;
            if(cur>per && (x/100*e)>=y){
                per=cur;
                mx_sugar=y;
                mx_mass=sum;
            }
        }
    }
    cout<<mx_mass<<" "<<mx_sugar<<endl;


    return 0;
}


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

int main() {
  int N;
  string h;
  cin >> N;

  for (int i = 0; i < N; i++){
    cin >> h;
    if (h == "Y") {
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >>n;
  while(n!=0){
    int l =0;
    int p[n];
    int j[n];
    for(int i=0;i<n;i++){
      cin >> p[i];
      l+=p[i];
    }
    for(int i=1;i<n;i++){
      cin >> j[i];
    }
    j[0]=0;
    sort(j+1,j+n,greater<int>());
    unsigned ans[n];
    int jl=0;
    for(int i=0,t=n;t>0;i++,t--){
      jl+=j[i];
      ans[i]=t*(l+jl);
    }
    unsigned m=0;
    for(int i=0;i<n;i++){
      if(m<ans[i])m=ans[i];
    }
    cout <<m<<endl;
    cin >>n;
  }
  return 0;
}

Measured memory_bytes: 3924
#include <iostream>

using namespace std;

int main()
{
	int n[100], c = 0;

	while (true)
	{
		cin >> n[c];

		if (n[c] == 0) { goto Exit; }

		c++;
	}

Exit:;

	for (int i = 0; i < c; i++)
	{
		cout << n[i] / 5 + n[i] / 25 + n[i] / 125 + n[i] / 625 + n[i] / 3125 + n[i] / 15625 << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<math.h>
using namespace std;
typedef long long ll;

int main() {
	int N, K;
	cin >> N >> K;
	int* x = (int*)malloc(sizeof(int)*N);
	for (int i = 0;i < N;i++)cin >> x[i];
	int dist = 0;
	for (int i = 0;i < N;i++) {
		if (abs(x[i]) >= abs(K - x[i])) {
			dist += 2 * abs(K - x[i]);
		}
		else {
			dist += 2 * abs(x[i]);
		}
	}
	cout << dist << endl;
	return 0;
}

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

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int A, B;
	int result;
	cin >> A >> B;
	if (A >= 13) {
		result = B;
	} else if (A >= 6) {
		result = B/2;
	} else {
		result = 0;
	}
	cout << result << "\n";
	return 0;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define debug(...)   printf( __VA_ARGS__ )
//#define debug(...)   /****nothing****/
#define pb push_back
#define mp make_pair
#define LL long long
#define resett(arr,val,N) for(int ii=0;ii<(N);ii++) arr[ii]=val;
const int MX=1e6;
LL n,a,b,c,d,x,y,ar[MX];

int main()
{
    //freopen("d://i.txt","r",stdin);
    //freopen("d://o.txt","w",stdout);
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0) ;
    while(cin>>a>>b>>c>>d>>n)
    {
        b=min(2*a,b);
        c=min(2*b,c);
        d=min(2*c,d);
        cout<<(n/2*d+ n%2*c)<<endl;

    }

    return 0;
}




Measured memory_bytes: 256
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

const int magic=5000;

char s[2111][10111];
int n,k,l[2111];
bool dp[2111][10111];
vector<pii> pos,npos;
int main()
{
	get2(n,k);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",s[i]+1);
		l[i]=strlen(s[i]+1);
	}
	dp[n+1][0]=1;
	for(int i=n;i>=1;i--)
	{
		for(int j=0;j<=k;j++)
		{
			dp[i][j]=dp[i+1][j];
			if(j>=l[i])dp[i][j]|=dp[i+1][j-l[i]];
		}
	}
	for(int i=1;i<=n;i++)if(dp[i+1][k-l[i]])pos.pb(mp(i,1));
	for(int _=1;_<=k;_++)
	{
		npos.clear();
		char cur='z';for(int i=0;i<(int)pos.size();i++)cur=min(cur,s[pos[i].ff][pos[i].ss]);
		putchar(cur);
		
		int mn=n;
		for(int i=0;i<(int)pos.size();i++)
		{
			if(s[pos[i].ff][pos[i].ss]!=cur)continue;
			if(l[pos[i].ff]==pos[i].ss)
				mn=min(mn,pos[i].ff);
			else npos.pb(mp(pos[i].ff,pos[i].ss+1));
		}
		for(int i=mn+1;i<=n;i++)if(_+l[i]<=k&&dp[i+1][k-_-l[i]])npos.pb(mp(i,1));
		if((int)npos.size()>magic)
		{
			random_shuffle(npos.begin(),npos.end());
			npos.resize(magic);
		}
		
		pos.swap(npos);
	}
	return 0;
}


Measured memory_bytes: 41472