akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;
int main() {
    int i,j,n;
    int x=0;
    int y=0;
    int t=0;
    int flag=0;
    cin>>n;
    int txy[n][3];
    for(i=0; i<n; ++i){
        for(j=0;j<3; ++j){
            cin>>txy[i][j];
        }
    }
    for(i=0; i<n; ++i){
        if((abs(txy[i][1]-x)+abs(txy[i][2]-y))%2!=(txy[i][0]-t)%2){flag=1;break;}
        if((abs(txy[i][1]-x)+abs(txy[i][2]-y))<=txy[i][0]-t){
            x=txy[i][1];
            y=txy[i][2];
            t=txy[i][0];
        }
        else{flag=1;break;}

    }
    if(flag==1){cout<<"No";}
    else{cout<<"Yes";}
    return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define dbg(x) cout<<#x" = "<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, a[345678];
ll suml, sumr, b[123456], ans = -linf;
priority_queue<int, vi, greater<>> ql;
priority_queue<int> qr;

int main() {
	cin >> n;
	rep(i,n*3) cin >> a[i];
	
	// n <= k < 2nの範囲でkを動かし、qlに常に[0,k]の範囲で大きい方からn個の要素が入ってる状態を保つ
	// kを1ずつ右にずらし、その度にqlの最小値を取り出してa[k]を入れ直して差分をsumlに足し、sumをbにしまっておく しゃくとり的な
	// qrには[k,3n)の範囲で小さい方からn個の要素を入れて同様にsumrを求めていき、bから引く
	// これで(kより左n個の総和)-(kより右n個の総和)が全通り求められるので最大値を出力すればいい
	
	// 前半分
	rep(i,n) {
		suml += a[i];
		ql.push(a[i]);
	}
	b[0] = suml;
	reps(k,n,n*2) {
		// 今厳選してあるn個の最小値よりa[k]の方が更に小さいなら何もしなくていい
		if (ql.top()<a[k]) {
			suml -= ql.top(); ql.pop();
			suml += a[k];
			ql.push(a[k]);
		}
		b[k-n+1] = suml;
	}
	// 後ろ半分
	reps(i,n*2,n*3) {
		sumr += a[i];
		qr.push(a[i]);
	}
	b[n] -= sumr;
	for (int k = n*2-1; k >= n; --k) {
		if (qr.top()>a[k]) {
			sumr -= qr.top(); qr.pop();
			sumr += a[k];
			qr.push(a[k]);
		}
		b[k-n] -= sumr;
	}
	// 最大値探し
	rept(i,n) chmax(ans, b[i]);
	cout << ans << ln;
}

Measured memory_bytes: 3448
if __name__ == '__main__':
    s = input()
    t = input()

    if s == t:
        print('Yes')
        exit(0)

    for _ in range(len(s)):
        s = s[1:] + s[0]
        if s == t:
            print('Yes')
            exit(0)
    
    print('No')


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

int main()
{
	// ?????°??£?¨?
	int x;
	int y;

	while (1)
	{
		// ??\???
		cin >> x >> y;

		if (x == 0 && y == 0)
		{
			break;
		}

		if (x > y)
		{
			int temp = x;
			x = y;
			y = temp;
		}
		// ??????
		cout << x << " " << y << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
a,v=map(int,input().split())
b,w=map(int,input().split())
t=int(input())

ans='NO'
if v-w==0:
  if a==b:
    ans='YES'
elif abs(a-b)/(v-w)>=0 and abs(a-b)/(v-w)<=t:
  ans='YES'

print(ans)

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
 
#define fast { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define ll long long
 
#define vi vector<int>
#define vl vector<long>
#define vll vector<long long>
 
#define infi INT_MAX
#define infl LONG_MAX
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=(b-1);i>=a;i--)
#define F first
#define S second
#define G(a,b) get<a>(b)
#define MP make_pair
#define MT make_tuple


void func()
{ 
 ll n,a,b,ans;
 cin>>n>>a>>b;
 if(a>b) swap(a,b);
 if((b-a)%2==0) ans=(b-a)/2;
 else ans=min( a+( (b-a-1)/2) , (n-b+1)+( (b-a-1)/2) );
 cout<<ans<<endl;
} 
 
int main() 
{
    fast
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    
    ll q=1;
    //cin>>q;
    while(q)
    {
      func();
      q--;
    }
 
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <numeric>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007

using namespace std;

int main(void){
	int n,m;
	cin>>n>>m;
	vector<pair<pair<int,int>,int> > py(m);
	int ans[m][2];
	rep(i,m){
		cin>>py[i].first.first>>py[i].first.second;
		py[i].second=i;
	}
	sort(py.begin(),py.end());
	//rep(i,m)cout<<py[i].first.first<<","<<py[i].first.second<<","<<py[i].second<<endl;
	int pre=-1,cnt;
	rep(i,m){
		if(pre != py[i].first.first){
			pre=py[i].first.first;
			cnt=1;
		}
		ans[py[i].second][0]=pre;
		ans[py[i].second][1]=cnt;
		cnt++;
	}
	rep(i,m)printf("%06d%06d\n",ans[i][0],ans[i][1]);
	return 0;

}


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

vector<int> compress(string &S) {
    vector<int> A;
    int N = S.size();
    rep(i, 0, N) {
        int j = i;
        while(j < N && S[i] == S[j]) j++;
        A.push_back(j - i);
        i = j - 1;
    }
    return A;
}

int solve() {
    string S; cin >> S;
    vector<int> A = compress(S);
    int res = *max_element(A.begin(), A.end());
    int N = A.size();
    if(N > 2) {
        int sum = accumulate(A.begin(), A.end(), 0);
        int n = 0;
        rep(i, 0, N) {
            n += A[i];
            res = max(res, min(n, sum));
            sum -= A[i];
        }
    }
    return res;
}

int main() {
    cout << solve() << endl;
    return 0;
}


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

int main() {
  int N, M, x;
  cin >> N;
  map<int, int> D, T;
  for (int i = 0; i < N; i++) {
    cin >> x;
    ++D[x];
  }
  cin >> M;
  for (int i = 0; i < M; i++) {
    cin >> x;
    ++T[x];
  }

  bool cond = true;
  for (const auto &p : T) {
    if (D[p.first] < p.second) {
      cond = false;
      break;
    }
  }
  cout << (cond ? "YES" : "NO") << endl;
  return 0;
}


Measured memory_bytes: 18944
#include<cstdio>
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)


#ifdef __BORLANDC__
	typedef __int64 ll;
#else
	typedef long long ll;
#endif

const int N = 333;
const int S = N*N;
const int MOD = 1e9+7;
int n;
int s;
int t[N];

void add(int &a, int b){
	a = (a+b)%MOD;
}

void input(){
	cin>>n;
	rep(i,n)cin>>t[i];
	cin>>s;
}


int solve(){
	
	int count[S]={0};
	count[s] = 1;
	
	rep(i,n){
		rep(j,s+1){
			int next = j+t[i];
			if(next >= S)continue;
			
			add(count[j], -count[next]);
		}
	}
	
	int sum = 0;
	rep(i,s+1){
		int v = 1;
		rep(j,n){
			v = (int)((ll)v * i % MOD);
		}
		add(sum, (int)((ll)v * count[i] % MOD));
	}
	
	return (sum+MOD)%MOD;;
}


int main(){
	input();
	cout<<solve()<<endl;
}

Measured memory_bytes: 1600
#include <bits/stdc++.h>
#define ll long long int
#define forr(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
#define oo 100000000000000000
using namespace std;



void _sol(){
    int h,w,a,b,c,d; cin >> h >> w >> a >> b >> c >> d;
    vector<string> v(h+1);
    forr(i,h) cin >> v[i+1] , v[i+1] = '#' + v[i+1];
    int dp[h+2][w+2];
    forr(i,h+2) forr(j,w+2) dp[i][j] = INT_MAX/2;
    queue<pair<int,int>> q , border ; q.push({ a , b }) ;
    dp[a][b] = 0;
    int tot = 1;
    while(!q.empty()){
        pair<int,int> p = q.front(); q.pop();
        int x = p.first , y = p.second;
        // adj
        if( x-1>=1 && dp[x-1][y] > dp[x][y] && v[x-1][y]=='.' ) dp[x-1][y] = dp[x][y]  , q.push({x-1,y});
        if( x+1<=h && dp[x+1][y] > dp[x][y] && v[x+1][y]=='.' ) dp[x+1][y] = dp[x][y]  , q.push({x+1,y}) ;
        if( y-1>=1 && dp[x][y-1] > dp[x][y] && v[x][y-1]=='.' ) dp[x][y-1] = dp[x][y]  , q.push({x,y-1}) ;
        if( y+1<=w && dp[x][y+1] > dp[x][y] && v[x][y+1]=='.' ) dp[x][y+1] = dp[x][y]  , q.push({x,y+1}) ;

        // border
        if( x-1>=1 &&  v[x-1][y]=='#' )  border.push({x,y});
        else if( x+1<=h &&  v[x+1][y]=='#' )  border.push({x,y}) ;
        else if( y-1>=1 &&  v[x][y-1]=='#' )  border.push({x,y}) ;
        else if( y+1<=w &&  v[x][y+1]=='#' )  border.push({x,y}) ;

        if( q.empty()){
            while(!border.empty()){
                p = border.front(); border.pop();
                x = p.first , y = p.second;
                for(int i=max(x-2,1);i<=min(x+2,h);i++){
                    for(int j=max(y-2,1);j<=min(y+2,w);j++){
                        if( i>=1 && i<=h && j>=1 && j<=w && v[i][j]=='.' && dp[i][j] > dp[x][y]+1){
                            dp[i][j] = dp[x][y]+1;
                            q.push({i,j});
                        }
                    }
                }
            }
        }
    }
    if(dp[c][d] == INT_MAX/2) cout << -1;
    else cout << dp[c][d];

}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    _sol();
}


Measured memory_bytes: 8684
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Queue;

class Main {

    static class Process{
        String name;
        int time;

        Process(String n, int t){
            name = n;
            time = t;
        }
        void updateTime(int t){
            time -= t;
        }
    }


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

        int n = sc.nextInt();
        int quantum = sc.nextInt();

        Queue<Process> queue = new LinkedList<>();

        for (int i = 0; i < n; i++)
            queue.add(new Process(sc.next(), sc.nextInt()));

        int elapsed = 0;
        while (queue.size() > 0){
            Process p = queue.poll();
            if (p.time <= quantum){
                elapsed += p.time;
                System.out.println(p.name + " " + elapsed);
            }
            else{
                elapsed += quantum;
                p.updateTime(quantum);
                queue.offer(p);
            }
        }
    }
}



Measured memory_bytes: 72784
import math
import fractions
import copy
import numpy as np
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def printrow(a):
    for i in a:
        print(i)
"""
#decomment when needed
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
"""
a = [i for i in input()]
n = ip()
minplace = [0]
minlet = a[0]
nextlet = 'z'
nextminplace = []
for i in range(1,len(a)):
    if a[i] < minlet:
        nextlet = minlet
        nextminplace = copy.copy(minplace)
        minlet = a[i]
        minplace.clear()
        minplace.append(i)
    elif a[i] == minlet:
        minplace.append(i)
    elif a[i] < nextlet:
        nextminplace.clear()
        nextlet = a[i]
        nextminplace.append(i)
    elif a[i] == nextlet:
        nextminplace.append(i)
wl = []
#print(minplace,nextminplace)
for start in minplace:
    word = [a[start]]
    wl.append(''.join(word))
    for i in range(start+1,start+5):
        if i >= len(a): break
        word.append(a[i])
        wl.append(''.join(word))
wl = list(set(wl))
#print(wl)
for start in nextminplace:
    word = [a[start]]
    wl.append(''.join(word))
    for i in range(start+1,start+5):
        if i >= len(a): break
        word.append(a[i])
        wl.append(''.join(word))
#print(wl)
wl = list(set(wl))
wl.sort()
print(wl[n-1])

Measured memory_bytes: 14464
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )
typedef pair<int,int> P;
typedef long long ll;
const int INF = 100000000;
const double PI=3.14159265358979323846;

int main (){
    string S,T;
    cin >> S >> T;

    if (S+T.back()==T) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}





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

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

    ll n,m;
    cin >> n >> m;
    if (n == 1){
        if (m == 1){
            cout << 1 << endl;
        }
        else{
            cout << m-2 << endl;
        } 
    }
    else if (m == 1){
        cout << n-2 << endl;
    }
    else{
        cout << (n-2)*(m-2) << endl;
    }
}

Measured memory_bytes: 3488
//doaremon,squirtle is love
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define testcase ll t;cin>>t;while(t--)
#define input(x) ll x;cin>>x;
#define output(x) cout<<x<<endl;//to print (-1)
#define inputarray() ll n;cin>>n;ll arr[n];rep(0,n)cin>>arr[i];
#define deb(a) cout<<" :: "<<#a<<" = "<<a<<endl
#define deb2(a,b) cout<<" :: "<<#a<<" = "<<a<<" :: "<<#b<<" = "<<b<<endl
#define setbit(x)  __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define pll pair<long long int,long long int>
#define ub upper_bound // '>'
#define lb lower_bound // '>='
//erase,count,find,make_unique
#define len(arr) (sizeof(arr)/sizeof(arr[0]))
#define sz(x) ((long long)x.size())
#define make_unique(arr) arr.erase(unique(arr.begin(),arr.end()),arr.end()) //Makes a sorted array unique
#define rep(a,b) for(int i=a;i<b;i++)
#define updiv(a,b) (ceil)((a)*(1.0)/(b))
#define printarray(arr) cout<<"PRINT ARRAY"<<endl; rep(0,len(arr)) cout<<arr[i]<<" "; cout<<endl;
#define printvector(vect) cout<<"PRINT VECTOR"<<endl; for(auto x:vect) cout<<x<<" "; cout<<endl;
#define rev(x) reverse(all(x))
//LLONG_MAX, ULLONG_MAX INT_MAX
typedef long long int ll;
typedef unsigned long long int ull;
#define M 1000000007
using namespace std;
int main()
{
    fast
int n,m;
cin>>n>>m;
int arr[n]; int sum=0;
for(int i=0;i<n;i++)
{
    cin>>arr[i];
    sum+=arr[i];
} int temp=updiv(sum,4*m);
bool flag=0;int c=0;
for(int i=0;i<n;i++)
{
    if(arr[i]>=temp)
        c++;
    if(c==m)
        {
            flag=1;break;
        }
}
  if(flag==1)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}









Measured memory_bytes: 256
#include <iostream>
#include <string>
using i64 = long long;

int main() {
    std::string s;
    std::cin >> s;

    const int ret = s == "RRR"
        ? 3
        : s == "RRS" || s == "SRR"
            ? 2
            : s != "SSS" ? 1 : 0;

    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#include <string>
#include <map> // pair
using namespace std;

int main(){
  string s,ans;
  cin>>s;
  ans.push_back(s.at(0));
  ans+=to_string(s.size()-2);
  ans+=s.at(s.size()-1);
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val bells = listOfInt().sorted()
    println(bells[0] + bells[1])
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt()= listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 37872
#include <bits/stdc++.h>
#include <variant>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int h,w,k;
  cin>>h>>w>>k;
  int x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;
  --x1;--y1;--x2;--y2;
  vector<string> tb(h);
  REP(i,h)cin>>tb[i];
  vector psh(h, vecint(w+1, 0));
  REP(i,h) {
    REP(j,w) {
      psh[i][j+1] = psh[i][j] + (tb[i][j] == '@');
    }
  }
  vector psv(h+1, vecint(w, 0));
  REP(i,h) {
    REP(j,w) {
      psv[i+1][j] = psv[i][j] + (tb[i][j] == '@');
    }
  }
  vecint vlen;
  int pw = 1;
  int rem = k;
  while (true) {
    if (pw <= rem) {
      vlen.push_back(pw);
      rem -= pw;
    } else {
      vlen.push_back(rem);
      break;
    }
    pw *= 2;
  }
  int m = size(vlen);
  using T = tuple<int,int,int,int>;
  deque<T> que;
  auto id = [&] (auto r, auto c, auto d, auto s) {
    return ((r * w + c) * 2 + d) * m + s;
  };
  que.emplace_back(x1, y1, 0, 0);
  int INF = 1000000000;
  vecint dist(h * w * 2 * m, INF);
  dist[id(x1, y1, 0, 0)] = 0;
  while (!que.empty()) {
    auto [r, c, od, s] = que.front();
    que.pop_front();
    int i = id(r, c, od, s);
    int j = id(r, c, od, (s+1)%m);
    if (s) {
      if (dist[j] > dist[i]) {
        dist[j] = dist[i];
        que.emplace_front(r, c, od, (s+1)%m);
      }
    } else {
      if (dist[j] > dist[i] + 1) {
        dist[j] = dist[i] + 1;
        que.emplace_back(r, c, od, (s+1)%m);
      }
      int j2 = id(r, c, 1-od, 0);
      if (dist[j2] > dist[i]) {
        dist[j2] = dist[i];
        que.emplace_front(r, c, 1-od, 0);
      }
    }
    int mv = vlen[s];
    REP(cs,2) {
      int cff = cs ? 1 : -1;
      int nr = (od == 0) ? r : (r + cff * mv);
      int nc = (od == 1) ? c : (c + cff * mv);
      if (nr < 0 || nr >= h || nc < 0 || nc >= w) continue;
      if (od == 0) {
        int mn = min(nc, c);
        int mx = max(nc, c);
        if (psh[r][mn] != psh[r][mx+1]) continue;
      } else {
        int mn = min(nr, r);
        int mx = max(nr, r);
        if (psv[mn][c] != psv[mx+1][c]) continue;
      }
      int cst = s ? 0 : 1;
      int j = id(nr, nc, od, (s+1)%m);
      if (dist[j] > dist[i] + cst) {
        dist[j] = dist[i] + cst;
        if (s) {
          que.emplace_front(nr, nc, od, (s+1)%m);
        } else {
          que.emplace_back(nr, nc, od, (s+1)%m);
        }
      }
    }
  }
  int i = id(x2,y2,0,0);
  if (dist[i] < INF) {
    cout<<dist[i]<<endl;
  }else {
    cout<<-1<<endl;
  }
  return 0;
}


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

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<setprecision(9)<<fixed;
	
	int n,m,k;
	cin>>n>>m>>k;
	int a[n+1],b[m+1];
	a[0]=0,b[0]=0;
	for(int i=0;i<n;i++)
		cin>>a[i+1];
	for(int i=0;i<m;i++)
		cin>>b[i+1];
	for(int i=1;i<=n;i++)
		a[i]+=a[i-1];
	for(int i=1;i<=m;i++)
		b[i]+=b[i-1];
	int i=0,j=m;
	int mx=0;
	while(i<=n && j>=0)
	{
		if(a[i]+b[j]<=k)
		{
			mx=max(mx,i+j);
			i++;
		}
		else
			j--;
	}
	cout<<mx<<endl;
	return 0;
}

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


Measured memory_bytes: 384
// C.cpp
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 5050, mod = 1e9 + 7;

int n, A, B, bin[MAX_N], dp[MAX_N][MAX_N], f[MAX_N][MAX_N], pre[MAX_N];

int main()
{
    scanf("%d%d%d", &n, &A, &B);
    for (int i = bin[0] = 1; i <= n; i++)
        bin[i] = 2LL * bin[i - 1] % mod;
    if (A < B)
        swap(A, B);
    dp[0][0] = 1;
    for (int i = 0; i <= n; i++)
    {
        if (i != 0)
            pre[i] = (0LL + pre[i] + pre[i - 1]) % mod;
        dp[i][1] = (0LL + dp[i][1] + pre[i]) % mod;
        for (int j = 1; j <= A; j++)
        {
            dp[i][j] = (0LL + dp[i][j] + f[i][j]) % mod;
            f[i + 1][min(j + 1, A)] = (0LL + f[i + 1][min(j + 1, A)] + f[i][j]) % mod;
        }
        if (i == n)
            break;
        for (int j = 0; j <= A - 1; j++)
        {
            dp[i + 1][j + 1] = (0LL + dp[i + 1][j + 1] + dp[i][j]) % mod;
            pre[i + 2] = (0LL + pre[i + 2] + dp[i][j]) % mod;
            if (i + B + 1 <= n)
            {
                pre[i + B + 1] = (0LL + pre[i + B + 1] + mod - dp[i][j]) % mod;
                f[i + B + 1][min(j + B + 1, A)] = (0LL + f[i + B + 1][min(j + B + 1, A)] + dp[i][j]) % mod;
            }
            if (n - i >= B)
                dp[n][min(j + n - i, A)] = (0LL + dp[n][min(j + n - i, A)] + dp[i][j]) % mod;
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++)
        ans = (0LL + ans + 1LL * dp[i][A] * bin[n - i] % mod) % mod;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 201108
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
}

Measured memory_bytes: 3628
#if 0

#endif
#include <iostream>
#include <memory>
#include <vector>
#include <string>
#include <algorithm>
#include <assert.h>
#include <complex>
#include <queue>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define INF (1 << 30)
using namespace std;
using ll = long long;
int ec[4];
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b;
    while (cin >> a >> b) {
        ec[a - 1] += 1;
        ec[b - 1] += 1;
    }

    int o = 0;
    for (int i = 0; i < 4; ++i) {
        if (1 == ec[i] % 2) {
            ++o;
        }
    }
    if (0 == o || 2 == o) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
n = int(input())
XYH = [list(map(int, input().split())) for _ in range(n)]

for i in range(101):
    for j in range(101):
        temp = -1
        for x, y, h in XYH:
            if h == 0:
                continue
            temp = h + abs(x - i) + abs(y - j)
            break
        flag = 0
        for x, y, h in XYH:
            kouho = temp - (abs(x - i) + abs(y - j)) - h
            if kouho == 0:
                continue
            elif h == 0 and kouho < 0:
                continue
            else:
                flag = 1
                break
        if not flag:
            print(i, j, temp)
            exit()



Measured memory_bytes: 9184
//BadWaper gg
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#define inf 1e9
#define eps 1e-6
#define mp make_pair
#define N 200010
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
inline ll read()
{
	char ch=getchar();
	ll s=0,w=1;
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
	return s*w;
}
char s[N],t[N];
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	scanf("%s",s+1);scanf("%s",t+1);int len=strlen(s+1);
	int ans=0;
	for(register int i=1;i<=len;i++)if(s[i]!=t[i])ans++;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4068
[a, b] = map(int, input().split(" "))
s = input()

det = "Yes"

for i in range(len(s)):
    if i < a and (ord(s[i]) < ord('0') or ord(s[i]) > ord('9')):
        det = "No"
        break
    elif i == a and s[i] != '-':
        det = "No"
        break
    elif i > a and (ord(s[i]) < ord('0') or ord(s[i]) > ord('9')):
        det = "No"
        break

print(det)

Measured memory_bytes: 3064
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val a, b, x = sc.nextLong
  val result = calc(b, x) - calc(a - 1, x)
  println(result)

  def calc(v: Long, x: Long): Long = {
    if (v < 0) 0 else v / x + 1
  }
}


Measured memory_bytes: 25656
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=998244353 ;

/* SegTree<X>(n,fx,ex): モノイド(集合X, 二項演算fx, 単位元ex)についてサイズnで構築
    set(int i, X x), build(): i番目の要素をxにセット。まとめてセグ木を構築する。O(n)
    update(i,x): i 番目の要素を x に更新。O(log(n))
    query(a,b):  [a,b) 全てにfxを作用させた値を取得。O(log(n))
*/
template <typename X>
struct SegTree {
    using FX = function<X(X, X)>;
    int n;
    FX fx;
    const X ex;
    vector<X> dat;
    SegTree(int n_, FX fx_, X ex_) : n(), fx(fx_), ex(ex_), dat(n_ * 4, ex_) {
        int x = 1;
        while (n_ > x) {
            x *= 2;
        }
        n = x;
    }
 
    void set(int i, X x) { dat[i + n - 1] = x; }
    void build() {
        for (int k = n - 2; k >= 0; k--) dat[k] = fx(dat[2 * k + 1], dat[2 * k + 2]);
    }
 
    void update(int i, X x) {
        i += n - 1;
        dat[i] = x;
        while (i > 0) {
            i = (i - 1) / 2;  // parent
            dat[i] = fx(dat[i * 2 + 1], dat[i * 2 + 2]);
        }
    }
 
    // the minimum element of [a,b)
    X query(int a, int b) { return query_sub(a, b, 0, 0, n); }
    X query_sub(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l) {
            return ex;
        } else if (a <= l && r <= b) {
            return dat[k];
        } else {
            X vl = query_sub(a, b, k * 2 + 1, l, (l + r) / 2);
            X vr = query_sub(a, b, k * 2 + 2, (l + r) / 2, r);
            return fx(vl, vr);
        }
    }
    /* debug */
    inline X operator[](int a) { return query(a, a + 1); }
    void print() {
        for (int i = 0; i < n; ++i) {
            cout << (*this)[i];
            if (i != n) cout << ",";
        }
        cout << endl;
    }
};


int main(){
  int n; cin >> n; pair<ll, ll>P[n]; ll aa[n];
  rep(i, n){
    ll a, b; cin >> a >> b; P[i] = {a, b};
    aa[i] = a;
  }
  sort(P, P+n); sort(aa, aa+n); int to[n];
  rep(i, n){
    to[i] = lower_bound(aa, aa+n, P[i].first+P[i].second) - aa;
  }
  using X = ll;
  auto fx = [](X x1, X x2) -> X{return max(x1, x2);};
  auto ex = 0;
  SegTree<X> seg(n, fx, ex);
  rep(i, n){
    seg.set(i, to[i]);
  }
  seg.build();
  for(int i=n-1; i>=0; i--){
    to[i] = seg.query(i, to[i]);
    seg.update(i, to[i]);
  }
  int ans = 0;
  int dp[n+1]; dp[n] = 1;
  for(int i=n-1; i>=0; i--){
    dp[i] = (dp[i+1] + dp[to[i]])%mod;
  }
  cout << dp[0]%mod << endl;
}


Measured memory_bytes: 12800
#include<iostream>
#include<cstdio>
#include<cstring>

const int N=101000;

char s[N];
int n;

bool t[N];
bool check(int L)
{
	for(int i=1;i<=n;i++)
		t[i]=s[i]-'0';
	for(int i=L+1;i<=n;i++)
		t[i]=t[L];
	for(int i=1;i<=(n-L);i++)
		t[i]=t[n-L+1];
	int a=1;
	while(a<n && t[a+1]==t[a])a++;
	if(a>=L)return 1;
	a=n;
	while(a>1 && t[a-1]==t[a])a--;
	if(n-a+1>=L)return 1;
	return 0;
}

int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	int u=n,d=1,mid;

	while(u>d)
	{
		mid=(u+d+1)>>1;
		if(check(mid))d=mid;
		else u=mid-1;
	}

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


Measured memory_bytes: 384
object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val a = sc.nextLong
    val b = sc.nextLong
    val n = sc.nextLong

    val x = math.min(b - 1, n)
    println(a * x / b)
  }
}



Measured memory_bytes: 55268
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

C = A.copy()
for i in range(N):
    if C[i] - B[i] > 0:
        C[i] -= B[i]
    else:
        C[i+1] = C[i+1] - (B[i] - C[i]) if C[i+1] - (B[i] - C[i]) > 0 else 0
        C[i] = 0
    # print(C)

beaten_monster = sum(A) - sum(C)
print(beaten_monster)


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

using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;

int main() {
    int n,k;
    cin >> n >> k;
    VI h(n);
    rep(i,n) {
        cin >> h[i];
    }
    LL count = 0;
    rep(i,n) {
        if(h[i] >= k) count++;
    }
    cout << count << endl;
}

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

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            String[] line = sc.nextLine().split(" ");

            int n = Integer.valueOf(line[0]);
            int k = Integer.valueOf(line[1]);

            int aCnt = n - k;

            long result = 0;
            if (aCnt <= 0) {
                System.out.println(result);
                return;
            }

            long[] dList = new long[n];

            for(int i=0;i<n;i++){
                dList[i] = sc.nextInt();
            }
            Arrays.sort(dList);

            for (int i = 0; i < aCnt; i++) {
                result += dList[i];
            }

            System.out.println(result);
        }
    }
}

Measured memory_bytes: 71232
# AOJ 1519: Room of Time and Spirit
# Python3 2018.7.13 bal4u

# Weighted UNION-FIND library
class WeightedUnionSet:
	def __init__(self, nmax):
		self.ws = [0]*nmax
		self.par = [-1]*nmax
		self.power = [0]*nmax
	def find(self, x):
		if self.par[x] < 0: return x
		p = self.find(self.par[x])
		self.ws[x] += self.ws[self.par[x]]
		self.par[x] = p
		return p
	def weight(self, x):
		self.find(x)
		return self.ws[x]
	def connected(self, x, y): return self.find(x) == self.find(y)
	def unite(self, x, y, w):
		w += self.power[x]+self.weight(x)
		w -= self.power[y]+self.weight(y)
		x, y = self.find(x), self.find(y)
		if x == y: return 0
		if self.par[y] < self.par[x]: x, y, w = y, x, -w
		self.par[x] += self.par[y]
		self.par[y] = x
		self.ws[y] = w
		return 1
	def diff(self, x, y):
		if self.find(x) != self.find(y): return [0, None]
		return [1, self.ws[x]-self.ws[y]]
# Weighted UNION-FIND library

N, Q = map(int, input().split())
u = WeightedUnionSet(N+1)
for i in range(Q):
	q = input().split()
	if q[0] == "IN":
		a, b, c = int(q[1]), int(q[2]), int(q[3])
		u.power[a] += c
		u.power[b] += c
		u.unite(a, b, c)
	else:
		a, b = int(q[1]), int(q[2])
		if u.find(a) != u.find(b): print("WARNING")
		else: print((u.power[b]+u.ws[b])-(u.power[a]+u.ws[a]))


Measured memory_bytes: 12316
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
typedef long long ll;
typedef pair<ll,ll> PP;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false

signed main(void){
    int N,M,X;
    int C[15];
    int A[15][15];
    
    cin >> N >> M >> X;
    REP(i,N){
        cin >> C[i];
        REP(j,M){
            cin >> A[i][j];
        }
    }
    
    int Ans = INF;
    
    
    for(int j=0;j<(1<<N);j++){
        vector<int> R(M,0);
        int num=0;
        REP(i,N){
            if((j>>i)%2==1){
                num+=C[i];
                REP(k,M){
                    R[k]+=A[i][k];
                }
            }
        }
        
        bool ok = true;
        REP(i,M){
            if(R[i]<X)ok=false;
        }
        
        if(ok){
            Ans=min(Ans,num);
        }
    }
    
    if(Ans==INF){
        cout << -1 << endl;
    }else{
        cout << Ans << endl;
    }
    
    return 0;
}




Measured memory_bytes: 3640
s = str(input())
ans = 0

for i in range(2**(len(s)-1)):
    x = s[0]

    for j in range(len(s)-1):
        if (i>>j) & 1:
            x += '+'
        x += s[j+1]
        
    ans += sum(map(int,x.split('+')))
print(ans)

Measured memory_bytes: 3060