akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define INF 1e9
#define pb push_back
#define mp  make_pair
#define loop(a,n) for(long long i=a;i<n;i++)
#define vil vector<long long int>
#define vi vector<int>
#define sz(v) v.size()
#define setbits(x)          __builtin_popcountll(x)
#define ff first
#define ss second
using namespace std;

int nCrevenoroddfinder(int n,int r)
{
    int a=r;
    int b=n-r;
    for(int i=0;i<30;i++)
    {
        int x=1<<i;
        if((x&a)&&(x&b))
        {
            return 0;//even
        }
    }
    return 1;//odd
}

ll gcd(ll a, ll b) {
  if (a == 0)return b;
  return gcd(b % a, a);
}
bool isperfect(ll n) {
  ll y = sqrt(n);
  if (n % y == 0 && y * y == n)return true;
  return false;
}
bool comp(pair<int,int> a, pair<int,int> b) {
    if(a.first == b.first) return a.second>b.second;
  return a.first < b.first;
}
 ll powi(ll a, ll b) {
  ll ans = 1;
  while (b > 0) {
    if (b & 1)ans = (ans * a);
    b = b >> 1;
    a = (a * a);
  }
  return ans;
}
bool isprime(ll n) {
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0)return false;
  }
  return true;
}
bool prime[10000000];
void seive() {

  prime[1] = true;
  for (int i = 2; i * i < 10000000; i++) {

    if (prime[i])continue;
    for (int j = i * i; j < 10000000; j += i) {
      prime[j] = true;
    }

  }
}
ll nax=1e6+2;
int main()
{
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  ll n,k;
  cin>>n>>k;
  set<ll> s;
  pair<ll,ll> p[k+1];
  for(int i=0;i<k;i++){
        int l,r;cin>>l>>r;
        p[i].ff=l,p[i].ss=r;
  }
  ll mini=*(s.begin());
  ll maxi=*(--s.end());
  
  ll dp[n + 1]={},pp[k+2]={}; 
    int temp = 0; 
    dp[0] = 1; 
    for (int i = 1; i < n; i++) 
    { 
         // dp[i]+=dp[i-1];
        for(int j=0;j<k;j++){
              ll x=0;
              mini=p[j].ff,maxi=p[j].ss;
              //cout<<mini<<" "<<maxi<<endl;
              if(i-mini<0) continue;
              
              if(i-mini>=0) pp[j]+=(dp[i-mini]);//x+=dp[i-1]%998244353;
              //if(i-1>=0) 
              if(i-1-maxi>=0) pp[j]-=(dp[i-1-maxi]);
              pp[j]+=998244353;
                  pp[j]%=998244353;
              dp[i]+=pp[j];
              dp[i]%=998244353;
        }
      //  cout<<dp[i]<<" ";
    } 
    cout<<dp[n-1];
}



  


Measured memory_bytes: 5212
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
using namespace std;
string s;
int main()
{
	int rel=0;
	int temp=0;
	int flag=0;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		temp+=s[i]-'0';
		if(s[i]=='9')
			flag++;
	}
    if(s[0]=='1')
	{
		rel=9*(s.size()-1);
		if(s.size()==1) rel=s[0]-'0'; 
	}
	else
		rel=9*(s.size()-1)+s[0]-'0'-1;
	if(s[0]!='9'&&flag==s.size()-1) rel=temp;
	if(flag==s.size()) rel=temp;
	cout<<rel<<endl; 
	return 0;
}

Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
    N = parseInt(readline())
    a = Set()
    for i in 1:N
        s = readline()
        push!(a, s)
    end
    println(length(a))

end
main()





Measured memory_bytes: 179316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll N; cin >> N;
  ll a[N];
  for (ll i = 0; i < N; i++) {
    cin >> a[i];
  }
  ll res = 0;
  for (ll i = 0; i < N-1; i++) {
    ll n = a[i]/2;
    res += n;
    a[i] -= n*2;
    if (a[i] == 1 && a[i+1] > 0) {
      res++; a[i]--; a[i+1]--;
    }
  }
  res += (a[N-1]/2);
  cout << res << endl;
}

Measured memory_bytes: 1024
class PriorityQueue
  MIN = -(1 << 60)

  attr_reader :size

  def initialize(&block)
    @size = 0
    @heap = Array.new
    @get_key = block || :itself.to_proc
  end

  def empty?
    size == 0
  end

  def pop
    return nil if @size <= 0
    max = @heap[1]
    @heap[1] = @heap[@size]
    @size -= 1
    max_heapify(1)
    max
  end

  def push(x)
    @size += 1
    i = @size
    @heap[i] = x
    while i > 1 && (@get_key.call(@heap[i / 2]) <=> @get_key.call(@heap[i])) < 0
      t = @heap[i / 2]
      @heap[i / 2] = @heap[i]
      @heap[i] = t
      i = i / 2
    end
  end

  def top
    return nil if @size <= 0
    @heap[1]
  end

  def to_a
    return [] if @size == 0
    @heap[1..@size]
  end

  private

  def max_heapify(i)
    l = 2 * i
    r = 2 * i + 1
    largest =
      l <= @size && (@get_key.call(@heap[l]) <=> @get_key.call(@heap[i])) > 0 ? l : i
    largest = r \
      if r <= @size && (@get_key.call(@heap[r]) <=> @get_key.call(@heap[largest])) > 0
    unless largest == i
      t = @heap[i]
      @heap[i] = @heap[largest]
      @heap[largest] = t
      max_heapify(largest)
    end
  end
end

N, M = gets.split.map(&:to_i)
edges = M.times.map { gets.split.map(&:to_i) }
graph = Array.new(N) { [] }
edges.each.with_index do |(u, v, c), i|
  u -= 1
  v -= 1
  graph[u].push([v, c, i])
  graph[v].push([u, c, i])
end

def shortest_path(graph, s)
  # [[cost, path], ...]
  w_list = Array.new(graph.size, [1 << 60, []])
  w_list[s] = [0, []]
  queue = PriorityQueue.new
  queue.push([s, 0, []])
  while !queue.empty?
    u, w, path = queue.pop
    next if w > w_list[u][0]
    graph[u].each do |(v, c, m)|
      if w_list[v][0] > w_list[u][0] + c
        new_cost = w_list[u][0] + c
        new_path = path.dup
        new_path.push(m)
        w_list[v] = [new_cost, new_path]
        queue.push([v, new_cost, new_path])
      end
    end
  end
  w_list
end

require 'set'

set = Set.new
N.times do |u|
  path_list = shortest_path(graph, u)
  path_list.each do |_, path|
    set.merge(path)
  end
end
ans = M - set.size
puts ans

Measured memory_bytes: 4860
/*-- ILSH  --*/
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < ll >
#define vll vector < ll > 
#define dt cout<<"HERE\n";
#define pii pair < ll , ll >
#define pll pair < ll , ll >
#define vpi vector < pii >
#define vpl vector < pll >
#define fi first
#define se second 
#define sz size 
#define len length 
const ll inf=1e18+1e17;
const ll moda =29;
const ll modb =34483;
//const ll mod = 998244353;

ll modInverse(ll a,ll m){ll m0=m;ll y=0,x=1;if(m == 1)return 0;while(a> 1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=m0;return x;}  
/*ll powm(ll a,ll b){a=a%mod;ll res=1;while(b){if(b&1)res=(res*a)%mod;a=(a*a)%mod;b>>=1;}return (res%mod);}*/
const ll N =1e6+6;
int arr[N];
void solve(){
	int n;
	cin>>n;
	memset( arr,0,sizeof ( arr));
	bool va=0;
	int gc=0;
	for ( int i=0;i<n;i++){
		int xx;
		cin>>xx;
		if ( gc==0)
			gc=xx;
		else
			gc=__gcd( gc,xx);
		if ( arr[xx]&&xx!=1)
			va=1;
		arr[xx]=1;
	}
	for ( int i=2;i<N;i++){
		int cnt=0;
		for ( int j=i;j<N;j+=i)
			cnt+=arr[j];
		if ( cnt>=2)
			va=1;
	}
	if ( va){
		if ( gc<=1)
			cout<<"setwise coprime\n";
		else
			cout<<"not coprime\n";
	}
	else
		cout<<"pairwise coprime\n";

}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie( NULL);
	cout.tie(NULL);

	#ifndef ONLINE_JUDGE
		freopen ("INPUT.txt" , "r" , stdin);
		freopen ("OUTPUT.txt", "w" , stdout);
	#endif
	
	ll t=1;
	//cin>>t;
	for ( ll i=1;i<=t;i++){
		//cout<<"Case #"<<i<<": ";
    	solve();
    }
}

Measured memory_bytes: 7536
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
    cin >> first;
    IN(rest...);
    return;
}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

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

ll N, T;
vector<pair<ll,ll>>dish;
vvl memo;

ll dp(ll i, ll j)
{
    if (j >= T || i == N) return 0;
    if (memo[i][j] != -1) return memo[i][j];
    return memo[i][j] = max((dp(i + 1, j + dish[i].first) + dish[i].second), dp(i + 1, j));
}

int main()
{
    cin>>N>>T;

    rep(i, N){
        SS(ll,A,B);
        dish.push_back({A,B});
    }
    sort(all(dish));

    memo.resize(N, vl(T + 1, -1));
    p(dp(0,0));
}

Measured memory_bytes: 70912
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 200010
#define top 2000000000
#define ll long long
using namespace std;
int n, m, k, l1, l2, a[N], b[N], x, y, p1[N], p2[N], pos1[N], pos2[N], ans[N], now, x1, x2, L1, L2, R1, R2;
ll L, R, mid, sum;
int main(){
	scanf("%d%d%d", &n, &m, &k);
	l1=l2=0;
	for(int i=1; i<=n; i++){
		scanf("%d%d", &x, &y);
		if(y==1){a[++l1]=x; pos1[l1]=i;}
		else{b[++l2]=x; pos2[l2]=i;}
	}
	for(int i=1; i<=l1; i++)p1[i]=(a[i]+k)%m;
	for(int i=1; i<=l2; i++)p2[i]=(b[i]-k%m+m)%m;
	if(!l1||!l2){
		for(int i=1; i<=l1; i++)ans[pos1[i]]=p1[i];
		for(int i=1; i<=l2; i++)ans[pos2[i]]=p2[i];
		for(int i=1; i<=n; i++)printf("%d\n", ans[i]);
		return 0;
	}
	k<<=1;
	for(int i=1; i<=l1; i++)a[l1+i]=a[i]+m;
	for(int i=1; i<=l2; i++)b[l2+i]=b[i]+m;
	now=l2*2;
	for(int i=l1; i; i--){
		while(now>1&&b[now-1]>a[i])now--;
		x=k-(b[now]-a[i]); if(x<0){ans[pos1[i]]=p1[i]; continue;}
		L=0; R=top;
		while(L<R){
			mid=(L+R)>>1; if(L==R-1)mid++; sum=0;
			sum+=(ll)m*((mid+1)/(2*l1))+(ll)m*(mid/(2*l2));
			x1=((mid+1)/2)%l1; x2=(mid/2)%l2;
			L1=(i-x1+l1-1)%l1+1; R1=i;
			L2=(now-1)%l2+1; R2=(L2+x2-1)%l2+1;
			sum+=L1<=R1?a[R1]-a[L1]:m+a[R1]-a[L1];
			sum+=L2<=R2?b[R2]-b[L2]:m+b[R2]-b[L2];
			if(sum<=x)L=mid; else R=mid-1;
		}
		if(L&1)ans[pos1[i]]=p1[(i-((L+1)/2)%l1+l1-1)%l1+1];
		else ans[pos1[i]]=p2[((now-1)%l2+1+(L/2)%l2-1)%l2+1];
	}
	now=1;
	for(int i=1; i<=l2; i++){
		while(now<l1*2&&a[now+1]<b[l2+i])now++;
		x=k-(b[l2+i]-a[now]); if(x<0){ans[pos2[i]]=p2[i]; continue;}
		L=0; R=top;
		while(L<R){
			mid=(L+R)>>1; if(L==R-1)mid++; sum=0;
			sum+=(ll)m*(mid/(2*l1))+(ll)m*((mid+1)/(2*l2));
			x1=(mid/2)%l1; x2=((mid+1)/2)%l2;
			R1=(now-1)%l1+1; L1=(R1-x1+l1-1)%l1+1;
			L2=i; R2=(i+x2-1)%l2+1;
			sum+=L1<=R1?a[R1]-a[L1]:m+a[R1]-a[L1];
			sum+=L2<=R2?b[R2]-b[L2]:m+b[R2]-b[L2];
			if(sum<=x)L=mid; else R=mid-1;
		}
		if(L&1)ans[pos2[i]]=p2[(i+((L+1)/2)%l2-1)%l2+1];
		else ans[pos2[i]]=p1[((now-1)%l1+1-(L/2)%l1+l1-1)%l1+1];
	}
	for(int i=1; i<=n; i++)printf("%d\n", ans[i]);
	return 0;
}

Measured memory_bytes: 4608
// https://atcoder.jp/contests/abc106/tasks/abc106_c

#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
using namespace std;

typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOREACH(x, a) for (auto &(x) : (a))
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

// int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main() {
    string s;
    int k;
    vector<ll> x;
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> s >> k;
    x.resize(s.length());

    // 1以外の文字列を探す
    int ser = 0;
    while (s[ser] == '1') {
        ser++;
    }
    if (ser < k) {
        cout << s[ser] << endl;
    } else {
        cout << "1" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i) 
#define REP(i,n) FOR(i,0,n)
#define EACH(x,a) for(auto& (x):(a))
#define ALL(obj) (obj).begin(),(obj).end()
#define Yes(n) cout<<((n)?"Yes":"No")<<endl;
#define CO(x) cout<<(x)<<endl;
#define COSP(x) cout<<(x)<<" ";
#define DICIMAL(x) fixed<<setprecision(x)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
using namespace std;
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
const int INF=1e9;
const ll LINF=1e18;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

void print() {cout << endl;}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
    print(vec);
  }
}

int main(){
    INIT;

    int N, M, X, Y; cin>>N>>M>>X>>Y;
    vi x(N), y(M);
    REP(i,N) cin>>x[i]; REP(i,M) cin>>y[i];

    sort(ALL(x)); sort(ALL(y));

    int maxX = max(X, x[N-1]);
    int minY = min(Y, y[0]);


    if(maxX < minY) print("No War");
    else print("War");

    return 0;
}


Measured memory_bytes: 892
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  s = input().strip()
  sum = 0
  for i in range(2**(len(s)-1)):
    num = [s[0]]
    for j in range(1, len(s)):
      if i & (2**(j-1)) != 0:
        sum += int(''.join(num))
        num = [s[j]]
      else:
        num.append(s[j])
    sum += int(''.join(num))
  print(sum)

if __name__=='__main__':
  main()



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,a) for(int i=start[(a)];i;i=e[i].next)
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
inline int read()
{
	int sum=0,p=1;char ch=getchar();
	while(!(('0'<=ch && ch<='9') || ch=='-'))ch=getchar();
	if(ch=='-')p=-1,ch=getchar();
	while('0'<=ch && ch<='9')sum=sum*10+ch-48,ch=getchar();
	return sum*p;
}

const int mod=998244353;
const int maxn=320;

inline int power(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)ans=(ll)ans*a%mod;
		b>>=1;
		a=(ll)a*a%mod;
	}
	return ans;
}

int a[maxn][maxn],n,m;
bitset<320>b[maxn];
bitset<320>s[maxn];int vis[maxn];

inline void insert(bitset<320> x)
{
	DREP(i,m,1)if(x[i])
	{
		if(!vis[i]){ s[i]=x;vis[i]=1; break;}
		else x^=s[i];
	}
}

inline void init()
{
	n=read();m=read();
	REP(i,1,n)REP(j,1,m)a[i][j]=read();
	REP(j,1,m)
	{
		int s=0;
		REP(i,1,n)s+=a[i][j];
		//if(s&1)REP(i,1,n)a[i][j]^=1;
	}
	REP(i,1,n)REP(j,1,m)if(a[i][j])b[i].set(j);
	REP(i,1,n)
	{
		insert(b[i]);
	}
}

inline void doing()
{
	int ss=0; REP(i,1,m)ss+=vis[i];
	int ans=(ll)(power(2,n)-power(2,n-ss)+mod)*power(2,m-1)%mod;
	printf("%d\n",ans);
}

int main()
{
	init();
	doing();
	return 0;
}



Measured memory_bytes: 640
import math

n, d = map(int, input().split())

lin = []
lin.append(list(map(int, input().split())))

count = 0

apd = lin.append

for i in range(1, n):
    apd(list(map(int, input().split())))

    for j in range(0, i):
        tmp = sum([(lin[i][k] - lin[j][k]) * (lin[i][k] - lin[j][k])
                   for k in range(d)])
        #print("{}, {}, {}".format(i, j, tmp))
        if(math.sqrt(tmp) % 1 == 0):
            count += 1
print(count)


Measured memory_bytes: 3064
#include <iostream>
#include <utility>
#include <queue>
using namespace std;

#define MAX_WIDTH  21
#define MAX_HEIGHT 21
#define INIT_X 10
#define INIT_Y 10

int main(){
    while(1){
        int N, M, tmp_x, tmp_y;
        int map[MAX_WIDTH][MAX_HEIGHT];
        pair<char,int> tmp_command;
        // initialization
        for(int i=0; i<MAX_WIDTH; i++){
            for(int j=0; j<MAX_HEIGHT; j++){
                map[i][j] = 0;
            }
        }
        
        // input
        cin >> N; if(!N){break;}
        for(int i=0; i<N; i++){
            cin >> tmp_x >> tmp_y;
            map[tmp_x][tmp_y] = 1;
        }
        cin >> M;
        pair<char,int> commands[M];
        for(int i=0; i<M; i++){
            cin >> tmp_command.first >> tmp_command.second;
            commands[i] = tmp_command;
        }
        
        // search
        pair<int, int> current_position(INIT_X, INIT_Y);
        map[current_position.first][current_position.second] = 0;
        for(int i=0; i<M; i++){
            char direction = commands[i].first;
            int  step      = commands[i].second;
            int delta_x=0, delta_y=0;

            switch(direction){
            case 'N': delta_x =  0, delta_y =  1; break; 
            case 'E': delta_x =  1, delta_y =  0; break;
            case 'S': delta_x =  0, delta_y = -1; break;
            case 'W': delta_x = -1, delta_y =  0; break;
            }
            
            for(int i=0; i<step; i++){
                current_position.first  += delta_x;
                current_position.second += delta_y;
                map[current_position.first][current_position.second] = 0;
            }
        }

        // result
        bool flag = true;
        for(int i=0; i<MAX_WIDTH; i++){
            for(int j=0; j<MAX_HEIGHT; j++){
                if( map[i][j] ){ flag = false; }
            }
        }
        if( flag ){ cout << "Yes\n"; }
        else{ cout << "No\n"; }
                
    }
    return 0;
}

Measured memory_bytes: 1120
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;

int main(){
    vector<int> v(3);
    cin>>v[0]>>v[1]>>v[2];
    sort(v.begin(),v.end());
    int ans=10*v[2]+v[1]+v[0];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  int S = 0;
  for(int i = 0; i < N ; i++){
    int l;
    cin >> l;
    if ( l - abs(l-K) < 0){
      S += 2*l;
    }
    else{
      S += 2*abs(l-K);
    }
   // cout << i+1 <<":"<< S << endl;
  }
  cout << S << endl;
}


Measured memory_bytes: 3520
#include <iostream>
using namespace std;
int main(){
  int n, a[50], b[50], c[50];
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  for(int i=0; i<n; i++){
    cin >> b[i];
  }
    for(int i=0; i<n-1; i++){
    cin >> c[i];
  }
  c[n-1] = 0;

  int ans=0;
  for(int i=0; i<n; i++){
    ans += b[i];
    if(a[i]+1 == a[i+1]){
      ans += c[a[i]-1];
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;

using ll = long long;
using ld = long double;
using lli = long long int;

#define PI 3.14159265358979323846264338327950L

int main(){
  int N, MAX_PURE;
  vector<int> pure_num;
  int size_pure_vec, div_cnt=0, z;
  bool loop_flag = true;
  int i, j, k;
  char alpha;

  cin >> alpha;

  if(alpha >= 'a' && alpha <= 'z'){
    cout << "a" << endl;
  } else if (alpha >= 'A' && alpha <= 'Z'){
    cout << "A" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
int main()
{
    int n;
    cin>>n;
    int a[26];
    memset(a,0,sizeof(a));
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++)
        a[s[i]-'a']++;
    long long ans=1;
    for(int i=0;i<26;i++)
        ans=ans*(a[i]+1)%mod;
    printf("%lld\n",(ans-1+mod)%mod);
}


Measured memory_bytes: 512
# ABC93, B - small and large integers
a, b, k = map(int, input().split(' '))


if k >= (b-a+1)/2:
    [print(x) for x in range(a, b+1)]
else:
    [print(x) for x in range(a, a+k)]
    [print(x) for x in range(b-k+1, b+1)]


Measured memory_bytes: 3060
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pi pair<int,int>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=1e5+10,size=1<<20;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
	char c=gc; x=0; int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c)) x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x/10) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); puts("");
}

int main() {
	int n,m; qr(n); qr(m);
	pr2((n*(n-1)+m*(m-1))>>1); 
	return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll h,w,n;

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

  cin>>h>>w>>n;
  ll mx=max(h,w);
  cout<<(n+mx-1)/mx<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long

vector<int>A;
vector<int>a, b, c, d;
int ans = 0;
int n, m, q;
void dfs(int i) {
  if(i == n) {
    int tmp = 0;
    rep(i, q) {
      if(A[b[i]-1] - A[a[i]-1] == c[i]) {tmp += d[i];}
    }
    ans = max(tmp, ans);
  }
  else if(i == 0) {
    for(int j = 1; j <= m; j++) {
      A[0] = j;
      dfs(1);
    }
  }
  else {
    for(int j = A[i-1]; j <= m; j++) {
      A[i] = j;
      dfs(i+1);
    }
  }
}

int main() {
  cin >> n >> m >> q;
  a = b = c = d = vector<int>(q);
  rep(i, q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
  }
  //return 0;
  A = vector<int>(n, 0);
  dfs(0);
  cout << ans << endl;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ff first
#define ss second
#define SZ(x) (long long)x.size()
#define endl '\n'
#define FAST                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define tc                                                                     \
  int tc;                                                                      \
  cin >> tc;                                                                   \
  while (tc--)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define REPO(i, b, a) for (int i = b - 1; i >= a; i--)
#define REPI(i, a, b) for (int i = a; i <= b; i++)
#define MOD 1000000007
bool comp(pair<int, int> v, int val) { return v.ff < val; }
inline int read() {
  int t = 0;
  char c;
  while ((c = getchar_unlocked()) != '\n' && c != ' ' && c != EOF) {
    t = t * 10 + c - 48;
  }
  return t;
}
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};
bool checkValidity(int a, int b, int c) {
  if (a + b <= c || a + c <= b || b + c <= a)
    return false;
  else
    return true;
}

int32_t main() {
  FAST;
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  freopen("output.txt", "w", stderr);
#endif
  string s;
  cin >> s;
  int ans = 0;
  for (auto ch : s) {
    ans += ch - '0';
  }
  if (ans % 9 == 0)
    cout << "Yes";
  else
    cout << "No";
  return 0;
}


Measured memory_bytes: 3784
#import<bits/stdc++.h>
using namespace std;
int h,i,j,k,m,n,s,w[100005];
main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>h>>n;
	for(;n--;)
	{
		cin>>k;
		s+=k;
	}
	if(s<h)cout<<"No";
	else cout<<"Yes";
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		if (n == 1) {
		    System.out.println("Hello World");
		} else {
		    int x = Integer.parseInt(sc.next());
		    int y = Integer.parseInt(sc.next());
		    System.out.println(x + y);
		}
    }
}

Measured memory_bytes: 23636
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

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

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

  int n;
  cin >> n;
  string s;
  cin >> s;

  ll count[26];
  fill(count, count + 26, 0);
  for(char c: s) count[c - 'a']++;

  ll sum = 1;
  for(int i = 0; i < 26; i++){
    sum = (sum * (count[i] + 1)) % MOD;
  }
  --sum;

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int INF=1e9+7107;
int n,a[100005],f[100005];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=0;i<=n;i++) f[i]=INF;
	f[1]=0;
	for(int i=2;i<=n;i++)
	{
		f[i]=min(f[i],f[i-1]+abs(a[i-1]-a[i]));
		f[i]=min(f[i],f[i-2]+abs(a[i-2]-a[i]));
	}
	printf("%d\n",f[n]);
	return 0;
}

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

using namespace std;

using i64 = long;

const i64 MOD = 1e9 + 7;
const i64 INF = 1e18 + 7;

signed main(){
    i64 n, m;
    cin >> n >> m;
    vector<i64> l(n), r(n);
    vector<i64> comp{0, 1, m - 1, m};
    for(i64 i = 0; i < n; ++i){
        cin >> l[i] >> r[i];
        // half open
        ++r[i];
        comp.emplace_back(l[i]);
        comp.emplace_back(l[i] + 1);
        comp.emplace_back(r[i] - 1);
        comp.emplace_back(r[i]);
    }
    sort(comp.begin(), comp.end());
    comp.erase(unique(comp.begin(), comp.end()), comp.end());
    vector<i64> l_comp(n), r_comp(n);
    i64 k = comp.size();
    vector<i64> rui(k + 1, 0);
    for(i64 i = 0; i < n; ++i){
        l_comp[i] = distance(comp.begin(), lower_bound(comp.begin(), comp.end(), l[i]));
        r_comp[i] = distance(comp.begin(), lower_bound(comp.begin(), comp.end(), r[i]));

        ++rui[l_comp[i]];
        --rui[r_comp[i]];
    }
    for(i64 i = 0; i < k; ++i)
        rui[i + 1] += rui[i];
    i64 cnt = *max_element(rui.begin(), rui.end());

    bool is_back = (cnt % 2 == 0);
    if(is_back){
        i64 idx = 0;
        for(i64 i = 0; i <= k; ++i)
            if(rui[i] == cnt){
                idx = i;
                break;
            }
        i64 dif = 0;
        for(i64 i = 0; i < n; ++i){
            if(l_comp[i] <= idx && idx < r_comp[i]){
                dif = max(dif, l_comp[i]);
            }
        }
        cout << (cnt * m) - comp[dif] << endl;
    }else{
        i64 idx = 0;
        for(i64 i = 0; i <= k; ++i)
            if(rui[i] == cnt){
                idx = i;
            }
        i64 dif = INF;
        for(i64 i = 0; i < n; ++i){
            if(l_comp[i] <= idx && idx < r_comp[i]){
                dif = min(dif, r_comp[i]);
            }
        }
        cout << ((cnt - 1) * m) + comp[dif - 1] << endl;
    }
}



Measured memory_bytes: 21700
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x)  cerr<<#x<<" = "<<(x)<<endl;

struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

signed main()
{
   int n; cin >> n;
   V<int> a(n);
   for (int i = 0; i < n; i++) {
      cin >> a[i];
   }

   int cnt = 1, flag = 0;
   for (int i = 0; i < n-1; i++) {
      if (a[i] < a[i+1]) {
         if (flag == 1) {
            cnt++;
            flag = 0;
         } else {
            flag = -1;
         }
      } else if (a[i] > a[i+1]) {
         if (flag == -1) {
            cnt++;
            flag = 0;
         } else {
            flag = 1;
         }
      }
   }
   cout << cnt << endl;

   return 0;
}

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

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _<< " _ " <<

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;
typedef complex<ld> cd;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() { FAST
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	string s, t;
	cin >> s  >> t;
	int best = 1000;
	M00(i, s.size() - t.size() + 1) {
		int cur = 0;
		M00(j, t.size()) {
			if(s[j+i] != t[j]) cur++;
		}
		best = min(cur, best);
	}
	cout << best << endl;
}


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

int main() {  
  int N;
  cin >> N;
  string S;
  cin>>S;
  int ans=N;
  vector<int> B(N);//０からi番目までに何回wが出てくるか
  int b=0;
  if(S.at(0)=='W'){
    B.at(0)=1;
    b=1;
  }
  else{
    B.at(0)=0;
  }
  
  for (int i = 1; i < N; i++) {
    if(S.at(i)=='W'){
      b++;
    }
     B.at(i)=b;
  }
  vector<int> C(N);//i番目からn−１番目までに何回eが出てくるか
  C.at(0)=N-B.at(N-1);
  for (int i =1; i < N; i++) {
    C.at(i)=N-i-B.at(N-1)+B.at(i-1);
  }
  ans=min(ans,C.at(0));
  ans=min(ans,B.at(N-1));
  for (int i =1; i < N-1; i++) {
    ans=min(ans,B.at(i-1)+C.at(i+1));
  }
    
  cout<<ans<<endl;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
int main(){
    int x, y;
    cin >> x >> y;
    if(y % 2){
	cout << "No" << endl;
    }
    else{
	if(2*x <= y && 4*x >= y) cout <<  "Yes" << endl;
	else cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<bitset>
#include<random>
#include<cstdint>
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
#define shosu setprecision(17)
  
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<char,P> Q;
ll longinf=(1ll<<60);
const ll inf=1ll<<29;
int main(){
      ll n;
      cin>>n;
      ll a[n];
      rep0(i,n)cin>>a[i];
    int mochi=0;
  rep0(i,n-1) if(a[i+1]<=a[i]) mochi=1;
  if(!mochi){
    cout<<1<<endl;
    return 0;
  }
      ll ng=1;
      ll ok=200002;
      map<ll,ll> counter;
      while(ok-ng>1){
            bool good=true;
            ll now=(ok+ng)/2;
            map<ll,ll> counter;
            rep0(i,n-1){
                  if(a[i+1]>a[i]) continue;
                  ll j=a[i+1];
                  while(1){
                        if(j<=-1){
                          good=false;
                          break;
                        }
                        if(counter[j]==(now-1)){
                              --j;
                        }
                        else if(counter[j]<now-1){
                          	counter[j]++;
                              counter.erase(counter.lower_bound(j+1),counter.end());
                              break;
                        }
                  }
                  //rep0(i,10) cout<<counter[i]<<" ";
                  //cout<<endl;
                  }
            if(counter[0]>0) good=false;
                  //cout<<endl;
            if(good) ok=now;
            else ng=now;
      }
      cout<<ok<<endl;
      return 0;
}


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

int f[3005][3005];

int main() {
	string s, t; cin >> s >> t;
	int n = s.size(), m = t.size();
	s = '$' + s; t = '$' + t;
	for (int i = 1; i <= n; i++)
	for (int j = 1; j <= m; j++) {
		if (s[i] == t[j]) f[i][j] = f[i - 1][j - 1] + 1;
		else f[i][j] = max(f[i - 1][j], f[i][j - 1]);
	}
	int i = n, j = m;
	string res;
	while (i && j) {
		if (s[i] == t[j]) {
			res += s[i];
			i--; j--;
		} else {
			if (f[i - 1][j] > f[i][j - 1]) i--;
			else j--;
		}
	}
	reverse(res.begin(), res.end());
	cout << res << '\n';
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
#define ll int64_t
#define ar array
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for (int i = 0; i < (n); ++i) 
using namespace std;


int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x, n;
    cin >> x >> n;
    set<int> s;
    for(int i=-111;i<=111;i++){
        s.insert(i);
    }
    forn(i,n){
        int el;cin>>el;
        s.erase(el);
    }
    int ans=1e9;
    int ans_dif=1e9;
    for(int el : s){
        if(abs(el-x)<ans_dif){
            ans_dif=abs(el-x);
            ans=el;
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 3628
package main
 
import (
    "bufio"
    "fmt"
    "os"
    "strconv"
)

func main(){
    
    s := nextString()
    t := nextString()
    
    n := len(s)
    m := len(t)
    
    dp := make([][]int, n+1)
    for i:=0;i<n+1;i++ {
        dp[i] = make([]int, m+1)
        for j:=0;j<m+1;j++ {
            dp[i][j] = 0
        }
    }
    
    for i:=0;i<n;i++ {
        for j:=0;j<m;j++ {
            if s[i]==t[j] {
                dp[i+1][j+1] = Max([]int{dp[i+1][j+1], dp[i][j] + 1})
            }
            dp[i+1][j+1] = Max([]int{dp[i+1][j+1], dp[i+1][j], dp[i][j+1]})
        }
    }
    
    ans := ""
    i:= n
    j:= m
    for i>0 && j>0 {
        if dp[i][j]==dp[i-1][j] {
            i--
        } else if dp[i][j]==dp[i][j-1] {
            j--
        } else {
            ans = string(s[i-1])+ans
            i--
            j--
        }
    }
    
    fmt.Println(ans)
}


/* templates */


func Max(a []int) int {
    r := a[0]
    for i := 0; i < len(a); i++ {
        if r < a[i] {
            r = a[i]
        }
    }
    return r
}
 
func Min(a []int) int {
    r := a[0]
    for i := 0; i < len(a); i++ {
        if r > a[i] {
            r = a[i]
        }
    }
    return r
}
 
func Sum(a []int) (r int) {
    for i := range a {
        r += a[i]
    }
    return r
}
 
func Abs(a int) int {
    if a < 0 {
        return -a
    }
    return a
}
 
type Pair struct {
    first, second int
}
 
type Pairs []Pair
 
func (p Pairs) Len() int {
    return len(p)
}
 
func (p Pairs) Swap(i, j int) {
    p[i], p[j] = p[j], p[i]
}
 
var nextReader func() string
 
func init() {
    nextReader = NewScanner()
}
 
func NewScanner() func() string {
    r := bufio.NewScanner(os.Stdin)
    r.Buffer(make([]byte, 1024), int(1e+11))
    r.Split(bufio.ScanWords)
    return func() string {
        r.Scan()
        return r.Text()
    }
}

func nextString() string {
    return nextReader()
}
 
func nextInt64() int64 {
    v, _ := strconv.ParseInt(nextReader(), 10, 64)
    return v
}
 
func nextInt() int {
    v, _ := strconv.Atoi(nextReader())
    return v
}
 
func nextInts(n int) []int {
    r := make([]int, n)
    for i := 0; i < n; i++ {
        r[i] = nextInt()
    }
    return r
}

func nextStrings(n int) []string {
    r := make([]string, n)
    for i := 0; i < n; i++ {
        r[i] = nextString()
    }
    return r
}

func nextFloat64() float64 {
    f, _ := strconv.ParseFloat(nextReader(), 64)
    return f
}


Measured memory_bytes: 80640
n, m, k = map(int, input().split())
A = tuple(map(int, input().split()))
B = tuple(map(int, input().split()))

from itertools import accumulate
AS = [0] + list(accumulate(A))
BS = [0] + list(accumulate(B))

from bisect import bisect
ans = 0
for i in range(n+1):
    if AS[i] > k:
        break
    # kb = bisect(BS, k - AS[i])-1
    # ans = max(ans, kb+i)
    ans = max(ans, bisect(BS, k - AS[i])-1+i)

print(ans)


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

struct rootedTree {
	struct node {
		int bro, chi, par;
	};

	vector<int> dep;
	vector<node> tree;

	rootedTree(int n) :
		dep(n),
		tree(n, { -1, -1, -1 })
	{}

	int getBrother(int a) {
		return tree[a].bro;
	}

	int getChild(int a) {
		return tree[a].chi;
	}

	int getDepth(int a) {
		return dep[a];
	}

	int getParent(int a) {
		return tree[a].par;
	}

	vector<int> getChildren(int a) {
		int b = tree[a].chi;
		vector<int> res;
		while (b != -1) {
			res.push_back(b);
			b = tree[b].bro;
		}
		return res;
	}

	void setBrother(int a, int newBro) {
		tree[a].bro = newBro;
	}

	void setChild(int a, int newChi) {
		tree[a].chi = newChi;
	}

	void setParent(int a, int newPar) {
		tree[a].par = newPar;
	}

	void updateDepth(int a, int b) {
		dep[a] = b;
		if (tree[a].bro != -1) updateDepth(tree[a].bro, b);
		if (tree[a].chi != -1) updateDepth(tree[a].chi, b + 1);
	}
};

int main() {
	int n, id, k, c, tmp1;
	cin >> n;
	rootedTree rt(n);
	for (int i = 0; i < n; ++i) {
		cin >> id >> k;
		for (int j = 0; j < k; ++j) {
			cin >> c;
			if (j) rt.setBrother(tmp1, c);
			else rt.setChild(id, c);
			tmp1 = c;
			rt.setParent(c, id);
		}
	}
	for (int i = 0; i < n; ++i) {
		if (rt.getParent(i) == -1) {
			tmp1 = i;
			break;
		}
	}
	rt.updateDepth(tmp1, 0);
	for (int i = 0; i < n; ++i) {
		vector<int> tmp2 = rt.getChildren(i);
		cout << "node " << i << ": parent = " << rt.getParent(i) << ", depth = " << rt.getDepth(i) << ", ";
		if (rt.getParent(i) == -1) cout << "root, [";
		else if (rt.getChild(i) == -1) cout << "leaf, [";
		else cout << "internal node, [";
		if (!tmp2.empty()) cout << tmp2[0];
		for (int j = 1; j < tmp2.size(); ++j) cout << ", " << tmp2[j];
		cout << "]" << endl;
	}
}


Measured memory_bytes: 6436
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = sc.nextInt();
    int W = sc.nextInt();
    int[] w = new int[N];
    int[] v = new int[N];

    for (int i = 0; i < N; i++) {
      w[i] = sc.nextInt();
      v[i] = sc.nextInt();
    }

    sc.close();

    long[][] dp = new long[N+1][W+1];

    for (int i = 0; i < N; i++) {
      for (int j = 0; j <= W; j++) {
        dp[i + 1][j] = Math.max(dp[i+1][j], dp[i][j]);
        if (j + w[i] <= W) {
          dp[i + 1][j + w[i]] = Math.max(dp[i + 1][j + w[i]], dp[i][j] + v[i]);
        }
      }
    }

    System.out.println(dp[N][W]);

  }

}

Measured memory_bytes: 124884
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;

    if((a>b)){
        a+=(a-1);
        cout<<a<<endl;
    }
    else if(b>a){
        b+=(b-1);
        cout<<b<<endl;
    }
    else
        cout<<a+b<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M,X;
    cin >> N >> M >> X;
    vec<int> C(N);
    vvec<int> A(N,vec<int>(M));
    for(int i=0;i<N;i++){
        cin >> C[i];
        for(int j=0;j<M;j++){
            cin >> A[i][j];
        }
    }
    int inf = 1e9;
    int ans = inf;
    for(int S=1;S<(1<<N);S++){
        vec<int> R(M);
        int val = 0;
        for(int i=0;i<N;i++) if(S>>i&1){
            val += C[i];
            for(int j=0;j<M;j++) R[j] += A[i][j];
        }
        if(all_of(R.begin(),R.end(),[&](int a){return a>=X;})) ans = min(ans,val);
    }
    cout << (ans!=inf? ans:-1) << "\n";
}

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

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

  int N; cin >> N;
  ll A,B; cin >> A >> B;
  
  ll ans = 0;
  ll before; cin >> before;
  rep(i, N - 1) {
    ll x; cin >> x;
    ll diff = x - before;
    if(diff * A > B) {
      ans += B;
    } else {
      ans += diff * A;
    }
    before = x;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        String input = scanner.nextLine();

        String[] text = input.split("");
        for(String t : text){
            if(t.matches("[a-z]")){
                System.out.print(t.toUpperCase());
            }else{
                System.out.print(t.toLowerCase());
            }
        }
        System.out.println();

        scanner.close();
    }
}



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

al = [list(input()) for _ in range(n)]
bl = [list(input()) for _ in range(m)]

def same(h,w):
    for hi in range(m):
        for wi in range(m):
            if al[h+hi][w+wi]!=bl[hi][wi]:
                return False
    return True


for hi in range(n-m+1):
    for wi in range(n-m+1):
        if same(hi,wi):
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, int> pli;
typedef pair<lint, lint> pll;
typedef complex<double> xy_t;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 200010;

template<typename T> struct SegTree_dual{
    using F=function<T(T, T)>;
    int sz=1;
    T et;
    F f, g;
    vector<T> node;

    SegTree_dual(int sz_, T et_, F f_, F g_): et(et_), f(f_), g(g_){
        while(sz<sz_) sz<<=1;
        node.resize(sz<<1, et);
    }

    void update(int l, int r, T x){
        for(l+=sz, r+=sz; l<r; l>>=1, r>>=1){
            if(l&1){
                node[l]=g(node[l], x);
                l++;
            }
            if(r&1){
                --r;
                node[r]=g(node[r], x);
            }
        }
    }

    T query(int i){
        i+=sz;
        T val=node[i];
        i>>=1;
        while(i){
            val=f(val, node[i]);
            i>>=1;
        }
        return val;
    }
};

int main(){
    int n, q;
    scanf("%d%d", &n, &q);
    auto f=[](pii a, pii b){return max(a, b);};
    auto g=[](pii a, pii b){return b;};
    SegTree_dual<pii> st(n, {-1, INT_MAX}, f, g);

    rep(time, q){
        int c;
        scanf("%d", &c);
        if(c==0){
            int s, t, x;
            scanf("%d%d%d", &s, &t, &x);
            st.update(s, t+1, {time, x});
        }
        else{
            int i;
            scanf("%d", &i);
            printf("%d\n", st.query(i).se);
        }
    }
}


Measured memory_bytes: 4928
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <cmath>
#include <limits>
#include <algorithm>

constexpr long long Mod = 1000000007;

int main()
{
  int N;
  std::cin >> N;
  std::vector<int> b(N);
  for (auto& val: b)
    std::cin >> val;

  std::vector<int> ans(N);
  for (int i = N; i > 0; --i)
  {
    int c = i;
    for (int j = N - 1; j >= 0; --j)
    {
      if (0 <= b[j])
      {
        if (b[j] == c)
        {
          ans[i - 1] = c;
          b[j] = -1;
          break;
        }
        else
          --c;
      }
    }
    if (c <= 0)
    {
      ans[0] = -1;
      break;
    }
  }

  if (0 <= ans.front())
  {
    for (auto& val: ans)
      std::cout << val << "\n";
    std::cout << std::flush;
  }
  else
  {
    std::cout << -1 << std::endl;
  }

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int n;
        cin >> n;
        int a[n];
        map<int, int> cnt;
        int sum = 0;
        for(int &it : a){
            cin >> it;
            cnt[it]++;
            sum += it;
        }
        int q;
        cin >> q;
        while(q--){
            int x, y;
            cin >> x >> y;
            sum -= x * cnt[x];
            sum += y * cnt[x];
            cnt[y] += cnt[x];
            cnt[x] = 0;
            cout << sum << '\n';
        }
    }
}

Measured memory_bytes: 41220