akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lli  = long long;
using ulli = unsigned long long;

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

    lli D   = (lli)d * (lli)d;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        lli x, y;
        cin >> x >> y;
        if (x * x + y * y <= D) ++ans;
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 3612
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
dum = prime_factorize(int(input()))
dum_len = len(dum)

num = 0
ans = 0
cnt = 0
check = 0
for i in range(dum_len):
    if num == dum[i]:
        cnt += 1
        if cnt >= check:
            check += 1
            ans += 1
            cnt = 0
    else:
        num = dum[i]
        ans += 1
        cnt = 0
        check = 2
print(ans)

Measured memory_bytes: 9232
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll a,b,x,ct,p,q,r;
    string s,s1,s2;
    cin>>a>>b;
    if(a==1 && b==2 || a==2 && b==1) cout<<3<<endl;
    else if(a==1 && b==3 || a==3 && b==1) cout<<2<<endl;
    else if(a==3 && b==2 || a==2 && b==3) cout<<1<<endl;
}






Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{   
    int n;
    cin>>n;
    
    int i, arr[100];
    
    for(i=0;i<3;i++)
    {
        arr[i]=n%10;
        n=n/10;
    }
    
    int cnt=0;
    
    for(i=0;i<3;i++)
    {
        if(arr[i]==1)
        cnt++;
    }
    cout << cnt<<endl;
  
}

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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf

#define sf(n) scanf("%d",&n)
#define sff(n1,n2) scanf("%d %d",&n1,&n2)
#define sfff(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3)
#define sl(n) scanf("%lld",&n)
#define sll(n1,n2) scanf("%lld %lld",&n1,&n2)
#define slll(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3)

#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define sz(x) x.size()

#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))

#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >

#define endl "\n";
#define line puts("-------");
#define dbb(x) cout<<#x<<" : "<<x<<"\n";

void __print(int x) {cerr << x;} void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;} void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;} void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;} void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;} void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';} void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V> void __print(const pair<T, V> &x)
{cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T> void __print(const queue<T> &x)
{queue<T>temp=x;cerr<<"\n-----\n";while(!temp.empty())
{cerr << temp.front() << endl;temp.pop();}cerr<<"-----\n";}
template<typename T> void __print(const stack<T> &x)
{stack<T>temp=x;cerr<<"\n-----\n";while(!temp.empty())
{cerr << temp.top() << endl;temp.pop();}cerr<<"-----\n";}
template<typename T> void __print(const T &x)
{int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V> void _print(T t, V... v)
{__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
    #define db(x...) cerr << "[" << #x << "] = [", _print(x)
#endif

const int N = 100005;
const int MOD = 1000000007;
using ll = long long;

int main()
{
    #ifndef ONLINE_JUDGE
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt","w",stdout);
    #endif
    int a,b;
    cin>>a>>b;
    cout<<a*b;
}


Measured memory_bytes: 3664
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<map>
#include<ctime>

using namespace std;

template <typename T>

inline T read()
{
	T x=0,f=1;char c=getchar();
	while(!isdigit(c))
	{if(c=='-') f=-f;c=getchar();}
	while(isdigit(c))
	{x=(x<<3)+(x<<1)+(c-48);c=getchar();}
	return x*f;
}

#define lint long long int
#define ulint unsigned lint

const int inf=1e9+1e7;
const int MAXN=3e5+1e1;

int a[MAXN];
bool vis[MAXN];

int main(void)
{

	// freopen("testdata.in","r",stdin);
	// freopen("testdata.out","w",stdout);

	int n,m,ans=0;

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

	for(int i=1;i<=n;i++) a[i]=read<int>();

	for(int i=1;i<=m;i++)
	{
		int u=read<int>();
		int v=read<int>();
		if(a[u]<a[v]) vis[u]=true;
		if(a[u]>a[v]) vis[v]=true;
		if(a[u]==a[v]) vis[u]=vis[v]=true;
	}

	for(int i=1;i<=n;i++) if(!vis[i]) ++ans;

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

	return 0;

}


Measured memory_bytes: 4316
#include <iostream>

using namespace std;

int main() {
	
	int a, b;
	
	while (true) {
		cin >> a >> b;

		if (a == 0 || b == 0) break;
		int flag = 0;
		for (int i = 0; i < a; i++)	{		
			for (int j = 0; j < b; j++)	{
				if (flag == 0) {
					if (j % 2 == 0) cout << '#';
					else cout << '.';
				}
				else {
					if (j % 2 == 1) cout << '#';
					else cout << '.';
				}

			}
			flag = (flag + 1) % 2;
			cout << endl;
		}
		cout << endl;
	}

	return 0;
}


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

int n;
string s;
int r[10101], b[10101], g[10101];

int main()
{
    cin >> n >> s;
    for(int i = n - 1; i >= 0; i--)
    {
        if(s[i] == 'R') r[i]++;
        if(s[i] == 'B') b[i]++;
        if(s[i] == 'G') g[i]++;
        r[i - 1] = r[i];
        b[i - 1] = b[i];
        g[i - 1] = g[i];
    }

    ll sum = 0;
    for(int i = 0; i < n - 2; i++)
    {
        for(int j = i + 1; j < n - 1; j++)
        {
            if(s[i] == s[j]) continue;
            char x = 219 - s[i] - s[j];
            
            if(x == 'R')
            {
                sum += r[j + 1];
            }
            else if(x == 'B')
            {
                sum += b[j + 1];
            }
            else if(x == 'G')
            {
                sum += g[j + 1];
            }
            int k = j + j - i;
            if(k < n && s[k] == x)
            {
                sum--;
            }
        }
    }
    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 3684
#include <iostream>

int main(){
    using namespace std;
    int p,q,r;
    cin >> p >> q >> r;
    int ans = 0;
    if(p < q) ans += p;
    else ans += q;
    if(r < p || r < q) ans += r;
    else ans = p+q;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

ll N;
ll res = 0;

void dfs(ll n) {
	if (n > N) return;
	bool f3 = false, f5 = false, f7 = false;
	ll tmp = n;
	while (tmp) {
		if (tmp % 10 == 3) f3 = true;
		else if (tmp % 10 == 5) f5 = true;
		else if (tmp % 10 == 7) f7 = true;
		tmp /= 10;
	}
	if (f3&&f5&&f7) res++;
	dfs(10 * n + 3);
	dfs(10 * n + 5);
	dfs(10 * n + 7);
}

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

	cin >> N;
	dfs(0);
	cout << res << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int i, j, k;
    int n;
    int b, f, r, v;
    int p[4][3][10];
    for(i=0; i<4; i++){
        for(j=0; j<3; j++){
            for(k=0; k<10; k++){
                p[i][j][k] = 0;
            }
        }
    }
    scanf("%d", &n);
    for(i=0;i<n;i++){
        scanf("%d %d %d %d", &b, &f, &r, &v);
        p[b-1][f-1][r-1] += v;
    }
    
    for(i=0; i<4; i++){
        for(j=0; j<3; j++){
            for(k=0; k<10; k++){
                printf("% d", p[i][j][k]);
            }
            printf("\n");
        }
        if(!(i==3))printf("####################\n");
    }
    return 0;
}

Measured memory_bytes: 2756
let input = ''

process.stdin.resume()
process.stdin.setEncoding('utf8')
process.stdin.on('data', function(chunk) {
  input += chunk
})
process.stdin.on('end', function() {
  input = input.trim().split('\n')
  main()
})

function main() {
  let debt = 100000
  for (i=0; i< input[0]; i++) {
      debt = Math.ceil((debt + debt*0.05)/1000)*1000
  }
  console.log(debt)
}


Measured memory_bytes: 15280
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <cstdio>

using namespace std;

const long long INF = 100000000;
const long long MOD = 1000000007;

std::vector<bool> IsPrime;

void sieve(size_t max)
{
  if (max + 1 > IsPrime.size())
  {                                // resizeで要素数が減らないように
    IsPrime.resize(max + 1, true); // IsPrimeに必要な要素数を確保
  }
  IsPrime[0] = false; // 0は素数ではない
  IsPrime[1] = false; // 1は素数ではない

  for (size_t i = 2; i * i <= max; ++i)     // 0からsqrt(max)まで調べる
    if (IsPrime[i])                         // iが素数ならば
      for (size_t j = 2; i * j <= max; ++j) // (max以下の)iの倍数は
        IsPrime[i * j] = false;             // 素数ではない
}

class Pointer{
public:
  long long p;
  long long w;
};

int main()
{
  int H, W;
  cin >> H >> W;
  char map[H][W];

  for (int i = 0; i < H;i++){
    for (int j = 0; j < W; j++)
      cin >> map[i][j];
  }

  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      if (map[i][j] == '#')
      {
        cout << map[i][j];
        continue;
      }
      int ans = 0;
      for (int dx = -1; dx <= 1; dx++)
      {
        for (int dy = -1; dy <= 1; dy++)
        {
          if (0 <= i + dx && i + dx < H && 0 <= j + dy && j + dy < W)
          {
            if (map[i + dx][j + dy] == '#')
            {
              ans++;
            }
          }
        }
      }
      cout << ans;
    }
    cout << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <climits>
#include <cmath>
#include <unordered_map>

using namespace std;

typedef long long ll;

int main(void) {
  string S; cin >> S;

  int count1 = 0, count2 = 0;

  // 0101010101
  for (int i = 0; i < S.size(); i++) {
    if (i % 2 == 0) {
      if (S[i] != '1')
        count1++;
    } else {
      if (S[i] != '0')
        count1++;
    }
  }

  // 1010101010
  for (int i = 0; i < S.size(); i++) {
    if (i % 2 == 0) {
      if (S[i] != '0')
        count2++;
    } else {
      if (S[i] != '1')
        count2++;
    }
  }

  // cout << count1 << endl;
  // cout << count2 << endl;
  cout << min(count1, count2) << endl;
}


Measured memory_bytes: 512
#include <iostream>

#include <cmath>
#include <algorithm>

using namespace std;

int S[100100];
int s,q;

bool binarySearch(int A[], int key) {
    int left = 0;
    int right = s-1;
    int mid;

    while(left <= right) {
        mid = (left+right)/2;
        if(A[mid] > key) {
            right = mid - 1;
        } else if(A[mid] < key) {
            left = mid+1;
        } else {
            return true;
        }
    }
    return false;
}



int main(){

    cin>>s;
    for(int i = 0;i < s;i++) {
        cin>>S[i];
    }

    int count = 0;
    int temp;

    cin>>q;
    for(int i = 0;i < q;i++) {
        cin>>temp;
        if(binarySearch(S,temp)) {
            count++;
        }
    }




    cout<<count<<endl;






    return 0;
}

Measured memory_bytes: 3464
H,W=map(int,input().split())
S=['.']*(W+2)
i=0
while i<H:
    S+=['.']+list(input())+['.']
    i+=1
S+=['.']*(W+2)

j=W+3
while j<=(W+2)*(H+1)-2:
    count=0
    if S[j]!='#':
        if S[j-(W+3)]=='#':
            count+=1
        if S[j-(W+2)]=='#':
            count+=1
        if S[j-(W+1)]=='#':
            count+=1
        if S[j-1]=='#':
            count+=1
        if S[j+1]=='#':
            count+=1
        if S[j+(W+1)]=='#':
            count+=1
        if S[j+(W+2)]=='#':
            count+=1
        if S[j+(W+3)]=='#':
            count+=1
        S[j]=str(count)
    j+=1

k=1
while k<=H:
    print(''.join(S[k*(W+2)+1:k*(W+2)+1+W]))
    k+=1

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
//const int INF = 1 << 20;
const int INF = 1000000007; 
typedef long long ll;




int main(){
  int n;
  cin >> n;
  bool e = true;
  vector <int> t;
  vector <int> a;
  REP(i,n){
    int b;
    cin >> b;
    t.pb(b);
  }
  REP(i,n){
    int b;
    cin >> b;
    a.pb(b);
  }
  if(n == 1 && a[0] != t[0]){
    cout << 0 << endl;
    return 0;
  }
  bool f[n] = {0};
  f[0] = true;
  f[n-1] = true;
  for(int i = 1;i < n;i++){
    if(t[i]-t[i-1] > 0){
      f[i] = true;
      if(t[i] > a[i]){
	e = false;
      }
    }
  }
  for(int i = n-2;i >= 0;i--){
    if(a[i]-a[i+1] > 0){
      f[i] = true;
      if(t[i] < a[i]){
	e = false;
      }
      //cout << i << endl;
    }
  }
  ll res = 1;
  REP(i,n){
    if(!f[i]){
      res = res*min(t[i],a[i])%INF;
    }
  }
  if(!e)
    cout << 0 << endl;
  else
    cout << res << endl;
  return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
  
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}
  
int main()
{
  int a,b;
  cin >> a >> b;

  cout << max(a-b*2,0) << endl;
  return 0;
}


Measured memory_bytes: 256
A=[]
while True:
	#midterm exam score(50) : m
	#final  exam score(50)  : f
	#retest score(100)      : r
	m,f,r = [int(i) for i in input().split()]
	if m == f == r == -1:
		break
	elif m==-1 or f==-1:
		A.append('F')	
	elif m+f >= 80:
		A.append('A')
	elif 65<=m+f<80:
		A.append('B')
	elif (50<=m+f<65) or ((30<=m+f<50) and (50<=r)):
		A.append('C')
	elif (30<=m+f<50):
		A.append('D')
	else:
		A.append('F')

for i in range(len(A)):
	print(A[i])

Measured memory_bytes: 7684
#include <bits/stdc++.h>
#define int long long 
#define float long double 
#define el '\n'
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define vi vector<int>
#define vvi vector<vector<int>>

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__) << "] "
 
signed main(){
	int n ; 
	cin >> n ;
	vi slime(n);
	for(int& i : slime) cin >> i ;
	vvi dp(n,vi(n,1e18l));
	auto sum = [&](int l,int r){
		int res = 0;
		for(int i=l;i<=r;i++){
			res += slime[i];
		}
		return res;
	};
	for(int l=n-1;l>=0;l--){
		for(int r = l ; r< n;r++ ){
			if(l == r) dp[l][r] = 0;
			int s = sum(l,r);
			for(int i=l;i<r;i++){
				dp[l][r] = min(dp[l][r],dp[l][i]+dp[i+1][r]+s);
			}
		}
	}
	cout << dp[0][n-1] << endl ;
	return 0;
}


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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)



int main(void){

	int N; cin >> N;
	int odd = 0;
	int even = 0;
	REP(i,N){
		int A; cin >> A;
		if(A % 2 == 0) even++;
		else odd++;
	}

	even += odd / 2;
	odd = odd % 2;
	string ans;
	if(odd == 1 and even > 0) ans = "NO";
	else ans = "YES";

	cout << ans << endl;
	

	return 0;

}


Measured memory_bytes: 256
#include <iostream>
  #include <string>
  #include <vector>
  #include <algorithm>
  #include <deque>
  using namespace std;
  typedef long long ll;
  #define rep(i,n) for (int i=0;i < (int)(n);i++)

  
  int main(){
    double l;
    cin >> l;
    printf("%.10f\n",l*l*l/3/3/3);

    return 0;
  }


Measured memory_bytes: 256
import           System.IO
import           Control.Monad
import           Control.Applicative
import           Control.Monad.State
import           Data.List
import           Text.Printf

data Res = Res {
  x :: Double,
  y :: Double
}

instance Show Res where
  show r = (printf "%0.3f" $ x r) ++ " " ++ (printf "%0.3f" $ y r)

toRes :: [Int] -> Res
toRes (a : b : c : d : e : f : _) = Res x y
 where
  y = (fromIntegral (a * f - d * c) / fromIntegral (e * a - b * d))
  x = (fromIntegral c - (fromIntegral b) * y) / fromIntegral a

main = do
  l <- getLine
  let line = toRes $ map (read :: String -> Int) $ words l
  print line
  eof <- isEOF
  unless eof $ main



Measured memory_bytes: 4324
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vector<P> a(n),c(n);
  rep(i,n){
    cin>>a[i].se>>a[i].fi; 
  }
  rep(i,n) cin>>c[i].fi>>c[i].se;
  int ans=0;
  sort(begin(a),end(a),greater<P>());
  sort(begin(c),end(c));
  rep(i,n){
    rep(j,n){
      if(a[j].se<c[i].fi && a[j].fi<c[i].se && a[j].se>=0){
        ans++;
        a[j].se=-1;
        break;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std;
bool is_integer(double x)
{
  return floor(x) == ceil(x);
}
int main()
{
  string s;
  cin >> s;
  if (s[s.length() - 1] == 's')
  {
    cout << s << "es" << endl;
  }
  else
  {
    cout << s << "s" << endl;
  }
}


Measured memory_bytes: 3596
def codei
  return gets.split.map &:to_i
end
n = gets.to_i
t = codei; m = gets.to_i;
pa = [];
m.times do |i|
  pa[i] = codei
end
m.times do |i|
  ans = 0
  n.times do |j|
    if j == pa[i][0]-1
      ans += pa[i][1]
    else
      ans += t[j]
    end
  end
  puts ans
end


Measured memory_bytes: 1788
n=int(input())
a,b=[list(map(int,input().split())) for i in range(2)]
if sum(a) >sum(b):print("No")
elif sum(a)==sum(b):

    for x,c in zip(a,b):
        if x!=c:print("No");exit()
    print("Yes")
else:
    cnt=sum(b)-sum(a)
    v=cnt
    for x,y in zip(a,b):
        if x>=y:v-=(x-y)
        else:
            v-=(x+y)%2
            cnt-=(y-x+(x+y)%2)//2
    print("Yes") if cnt*2==v and cnt>=0 and v>=0 else print("No")

Measured memory_bytes: 4664
P=[99999,99999,380,550,760,850,1100,1230,1400,1610,1520,1950,1870,2070,2250,2244]
for i in range(16,51):
    P.append(min(P[i-2]+380,P[i-3]+550,P[i-5]+850,P[i-10]+1520,P[i-12]+1870,P[i-15]+2244))

while(1):
    q=int(raw_input())
    if q==0:
        break
    else:
        print P[q/100]

Measured memory_bytes: 4224
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int N,M;
int c[10] = {0,2,5,5,4,5,6,3,7,6};
bool can[10] = {};
int dp[10][10001];
int solve(int now, int nokori){
	if(nokori < 0) return -POWER9;
	if(now == 0){
		if(nokori > 0) return -POWER9;
		else return 0;
	}
	if(dp[now][nokori] != -1) return dp[now][nokori];
	if(!can[now]) return dp[now][nokori] = solve(now-1,nokori);
	return dp[now][nokori] = max(solve(now,nokori-c[now])+1,solve(now-1,nokori));
}
void show(int now, int nokori){
	if(now == 0) return;
	if(!can[now]){
		show(now-1,nokori);
		return;
	}
	if(solve(now,nokori-c[now])+1 >= solve(now-1,nokori)){
		cout << now;
		show(now,nokori-c[now]);
	}
	else{
		show(now-1,nokori);
	}
}
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << setprecision(9);

	cin >> N >> M;
	for(int i=0; i<M; i++){
		int tmp;
		cin >> tmp;
		can[tmp] = true;
	}
	for(int i=0; i<10; i++){
		for(int j=0; j<=N; j++){
			dp[i][j] = -1;
		}
	}
	solve(9,N);
	/*for(int i=0; i<10; i++){
		for(int j=0; j<=N; j++){
			if(dp[i][j] >= 0) cout << dp[i][j] << " ";
			else cout << "- ";
		}
		cout << endl;
	}*/
	show(9,N);
	cout << endl;

	return 0;
}


Measured memory_bytes: 896
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <deque>
#include <map>

using namespace std;

const int CMax = 100002;
const int CInf = 2000000001;
const long long CMod = 1000000007;

int n, a, b, t;

int gcd(int a, int b)
{
    if (b != 0) return gcd(b, a % b);
    else return a;
}

string baseConverter(int base, int num) {
    string tNum = "";
    while (num > 0) {
        tNum = (char)('0' + num%base) + tNum;
        num /= base;
    }
}

bool isPalindrom(string tS) {
    int sn = (int)tS.length();
    for (int i = 0; i < sn / 2; i++) {
        if (tS[i] != tS[sn - i - 1]) return false;
    }
    return true;
}

int dist(int i, int j) {
    return  (j < i ? n + j : j) - i;
}

int main()
{
    cin >> a >> b >> t;

    cout << (t / a) * b;

    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
  ll x; cin >> x;
  ll ans = 0;
  ll m = x / 11;
  ll n = x % 11;
  ans += 2*m;
  if(n >= 1) ans++;
  if(n >= 7) ans++;
  cout << ans << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    ll n,m,v,p;cin>>n>>m>>v>>p;
    vector<ll> a(n);
    rep(i,n)cin>>a[i];
    sort(a.rbegin(),a.rend());
    
    auto ok=[&](int i){
        if(i<p)return true;
        ll t= a[i]+m;
        ll f=0;
        for(int j=p-1;j<n;j++){
            if(i==j)continue;
            if(t<a[j])return false;
            f+=min(t-a[j],m);
        }
        return f>=m*(v-p);
    };
    int left=-1,right=n;
    while(right-left>1){
        int mid=(right+left)/2;
        if(ok(mid))left=mid;
        else right=mid;
    }
    cout<<right<<endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>
using namespace std;
struct point{double x,y;};
void koch(int n,point a,point b)
{
    if(n==0)return;
    point s,t,u;
    double th=M_PI*60.0/180.0;
    s.x=(2.0*a.x+1.0*b.x)/3.0;
    s.y=(2.0*a.y+1.0*b.y)/3.0;
    t.x=(1.0*a.x+2.0*b.x)/3.0;
    t.y=(1.0*a.y+2.0*b.y)/3.0;
    u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
        u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;
        koch(n-1,a,s);
        printf("%.8f %.8f\n",s.x,s.y);
        koch(n-1,s,u);
         printf("%.8f %.8f\n",u.x,u.y);
          koch(n-1,u,t);
         printf("%.8f %.8f\n",t.x,t.y);
         koch(n-1,t,b);
}
int main()
{
    point a,b;
    int n;
    scanf("%d",&n);
    a.x=0;
    a.y=0;
    b.x=100;
    b.y=0;
    printf("%.8f %.8f\n",a.x,a.y);
    koch(n,a,b);
    printf("%.8f %.8f",b.x,b.y);
    return 0;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
int main(){
  int X,Y;cin>>X>>Y;
  int ans;
  if(X%Y==0)ans=-1;
  else {
    for(int i=0;;i++){
      if(i*X%Y!=0){ans=i*X;break;}
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  long long int a,b,x,r,tmp;
  scanf("%lld%lld",&a,&b);
  x=a*b;
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  printf("%lld\n",x/b);
  return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007

int main() {
    int N;
    cin >> N;
    map<string, int> ma;
    rep(i, N) {
        string s;
        cin >> s;
        ma[s] += 1;
    }

    int cnt = 0;
    for (auto m : ma) {
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 19224
#include <iostream>
using namespace std;
string str;
int ans;
int main(void){
    // Your code here!
    cin >> str;
    for (int i = 0; i < str.length(); i++) {
        if (str[i] == 'p') ans++;
    }
    cout << str.length() / 2 - ans << endl;
}


Measured memory_bytes: 512
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int n, c, k;
vector<int> t;
bool a[100100];
int p, q, ans;

int main(){
	scanf("%d %d %d", &n, &c, &k);
	for(int i=0; i<n; ++i){
		int tmp;
		scanf("%d", &tmp);
		t.push_back(tmp);
	}
	std::sort(t.begin(), t.end());
	for(int i=0; i<n; ++i){
		if(c <= p || q < t[i]){
			++ans;
			q = t[i] + k;
			p = 0;
		}
		++p;
	}
	printf("%d\n", ans);
}

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

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int go[200001][26];
set<int> par[200001];

int main(){
    string s;
    cin >> s;
    int n = s.length();

    VI dp(n+1, 1e9), f(26);
    REP(c,26){
        while (f[c] < n && s[f[c]] != 'a' + c) f[c]++;
        dp[f[c]] = 1;
        par[f[c]].insert(-1);
        go[0][c] = f[c];
    }

    // REP(j,26) cout << f[j] << " ";
    // cout << endl;

    REP(i,n){
        int x = s[i] - 'a';
        f[x]++;
        while (f[x] < n && s[f[x]] != s[i]) f[x]++;
        REP(j,26){
            go[i+1][j] = f[j];
            if (dp[f[j]] == dp[i] + 1){
                par[f[j]].insert(i);
            }
            if (dp[f[j]] > dp[i] + 1){
                dp[f[j]] = dp[i] + 1;
                par[f[j]].clear();
                par[f[j]].insert(i);
            }
        }
    }

    VI dp2(n+1, 1e9);
    dp2[n] = dp[n];
    set<int> st(par[n]);
    FORR(i,dp[n],2){
        // cout << i << endl;
        set<int> stn;
        for (int x : st) {
            dp2[x] = i-1;
            for (int y : par[x]) stn.insert(y);
        }
        st.clear();
        for (int x : stn) st.insert(x);
    }

    // REP(i,n) cout << dp2[i] << " ";

    string ans;
    int x = -1;
    REP(i,dp[n]){
        REP(j,26){
            if (dp2[go[x+1][j]] == i+1){
                ans += (j + 'a');
                x = go[x+1][j];
                break;
            }
        }
        // cout << x << endl;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 158212
//
// Created by Hideaki Imamura on 2020-03-15.
//
# include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair <ll, ll> l_l;
typedef pair<int, int> i_i;

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

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

# define EPS (1e-7)
//# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

ll N, W;
ll w[110], v[110];

int main() {
    cin >> N >> W;
    for (int i = 0; i < N; ++i) cin >> w[i] >> v[i];

    vector<ll> dp(W + 1, 0);
    for (int i = 0; i < N; ++i) {
        for (int j = W; j >= 0; --j) {
            if (j - w[i] >= 0) chmax(dp[j], dp[j - w[i]] + v[i]);
        }
    }
    cout << dp[W] << endl;
    return 0;
}

Measured memory_bytes: 1024
/*
	Created by : imay_10
	" It won't be EASY, but I'll make it "
*/

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

typedef long long int ll;
const int mod = 1e9+7;
const ll inf = 1e18;
const double pi = 3.1415926535897932384626;

// Utility for fast exponentiation
ll mpow(ll a,ll b,ll m){
    ll res=1;
    //a%=m;
    while(b){
    	if(b%2) res=res*a%m;
		a=a*a%m;
		b/=2;
	}
	return res;
}

// Utility for modular inverse
ll inv(ll a,ll m){
	return mpow(a,m-2,m);
}

// Utility for GCD Calculation
ll gcd(ll a,ll b){
	if(b==0) return a;
	return gcd(b,a%b);
}

void solve(){
	//code
	int n,s=0;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i] , s+=a[i];
		
	sort(a,a+n);
	if(a[n-1]<s-a[n-1]) cout<<"Yes";
	else cout<<"No";
}

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


Measured memory_bytes: 3652
j;i;k;t;main(n){int c[501],f[500],s[500];
for(scanf("%d",&n);k<n-1;k++)scanf("%d%d%d",&c[k],&s[k],&f[k]);
for(;i<n-1;i++){t=0;for(j=i;j<n-1;j++)if(t>s[j])t=s[j]+c[j]+ceil((double)(t-s[j])/f[j])*f[j];else t=s[j]+c[j];
printf("%d\n",t);}printf("0");}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    ll a, b, c, k; std::cin >> a >> b >> c >> k;
    ll ans = a-b;
    if (k&1) ans *= -1;
    std::cout << ans << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define ip pair<ll,ll>
#define ff first
#define ss second
#define MAX 100005
const ll MOD = 1000000007;

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

	ll k;
	cin>>k;
	if(k%2 == 0 || k%5 == 0){
		cout<<"-1\n";
	}
	else{
		ll p = 7%k;
		int cnt = 1;
		while(p != 0){
			p = (p*10+7)%k;
			++cnt;
		}

		cout<<cnt<<"\n";
	}

}

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

int main(){
  string s;
  cin >> s;
  int n = s.length();
  int ans = INF;
  rep(i, n-1){
    if(s[i] != s[i+1]){
      int m = max(i+1,n-i-1);
      ans = min(m, ans);
    }
  }
  if(ans == INF) cout << n << endl;
  else cout << ans << endl;
  return 0;
}


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

int main(){
    int N;
    cin>>N;
    int64_t t=1,a=1;
    for(int i=0;i<N;i++){
        int64_t T,A;
        cin>>T>>A;
        if(abs((double)T/A-(double)t/a)<1e-8){
            //変化なし
            continue;
        }else if((double)T/A<(double)t/a){
            //Aが前進
            if(t%T!=0){
                t+=T-t%T;
            }
            a=A*(t/T);
        }else{
            //Tが前進
            if(a%A!=0){
                a+=A-a%A;
            }
            t=T*(a/A);
        }
        // cout<<a<<' '<<t<<endl;
    }
    cout<<a+t<<endl;
    return 0;
}

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll A, P;

    cin >> A >> P;

    cout << (A*3+P)/2 << endl;
}


Measured memory_bytes: 256
'use strict'
function main(input: string) {
    const [a, b] = input.split(' ').map(Number);
    const start = b - (a-1);
    const end = b + (a-1);
    let r = [];
    for (let i = start; i <= end; i++) {
        r.push(i);
    }
    console.log(r.join(' '));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
import java.util.*;
import java.math.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.next();
		int n = s.length();
		if(s.charAt(n - 1) == 's') {
			System.out.println(s + "es");
		}else {
			System.out.println(s + "s");
		}
	}
}

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

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

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

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

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

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

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

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

fn main() {
    input!(n: i64,a: [i64;n]);
    let result = solve(n,a);
    println!("{:?}",result);
}

fn solve(n: i64,a: Vec<i64>) -> i64 {
    a.iter().fold(0,|sum,cur| sum + cur - 1)
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout<<"The value of "<<#x<<" is "<<x<<endl;
typedef long long ll;
typedef unsigned long long ull;
int arr[100000];
int dp[100000];
const int INF=1e9+5;
int main()
{
    cin.sync_with_stdio(0); cin.tie(0); 
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
    cin>>arr[i];
    dp[0]=0;
    for(int i=1;i<n;i++)
    dp[i]=INF;
    for(int i=0;i<n;i++)
    for(auto j:{i+1,i+2}){
        if(j<n)
        dp[j]=min(dp[j],dp[i]+abs(arr[i]-arr[j]));
    }
    cout<<dp[n-1]<<endl;
}


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

int main(){
    int n;
    ll k;
    cin>>n>>k;
    vector<int> a(n);//要素数nのvector
    rep(i,n) cin>>a[i];

    vector<int> s;//訪れた頂点を格納==訪れる順番にソートのような感じ
    vector<int> ord(n+1,-1);//sの頂点の実際に訪れた順番を記載
    int c=1,l=0;
    int v=1;//最初の頂点は１
    while(ord[v]==-1){
        ord[v]=s.size();//頂点vを何番目に訪れたか 頂点1〜N+1の順に訪れた数字が並ぶイメージ
        s.push_back(v);//訪れた順番に格納
        v=a[v-1];//0-indexedなので、index v-1を参照
    }
    c=s.size()-ord[v];//周期を表す。s.size()が循環の一歩手前までの距離を表し、ord[v]は頂点vまでの長さを表すので、この式は周期となる
    l=ord[v];//例外部分の長さ

    if(k<l)cout<<s[k]<<endl;
    else{
        k-=l;
        k%=c;
        cout<<s[l+k]<<endl;

    }
    return 0;
}

Measured memory_bytes: 5888
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <float.h>
#include <math.h>

#define max(X, Y) ((X) > (Y) ? (X) : (Y))
#define min(X, Y) ((X) < (Y) ? (X) : (Y))

typedef long long ll;

int main()
{
	ll n, h, w;
	ll a, b;
	ll ans = 0;

	scanf("%lld %lld %lld", &n, &h, &w);
	for (ll i = 0; i < n; i++) {
		scanf("%lld %lld", &a, &b);

		if (a >= h && b >= w) {
			ans++;
		}
	}

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

	return 0;
}


Measured memory_bytes: 128
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define PI acos(-1)
typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;

int main(void) {
  /* 標準入力フラグ */
  int   scan;

  /* 数入力 */
  ll    answer;
  ll    n;
  answer = 0;
  scan = scanf("%lld", &n);

  /* プログラムを書く */
  if (n >= 30) {
    printf("Yes");
  } else {
    printf("No");
  }

  return (0);
}



Measured memory_bytes: 1696
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD (ll) (1e9+7)
int main()
{
    ll n,m,k;
    cin>>n>>m>>k;
    vector<ll>ar(n);
    vector<ll>br(m);
    for(int i=0;i<n;i++)
    {
         cin>>ar[i];
    }
    for(int i=0;i<m;i++)
    {
    	 cin>>br[i];
    }
    vector<ll>pref1(n+1);
    vector<ll>pref2(m+1);
    for(int i=0;i<n;i++)
    {
        pref1[i+1]=pref1[i]+ar[i];
    }
    for(int i=0;i<m;i++)
    {
       pref2[i+1]=pref2[i]+br[i];
    }
    ll ans = 0;
    ll vv;
    for(int i=0;i<n+1;i++)
    {
    	    ll calc = 0;
    	    if(pref1[i]<=k)
    	    {
    		ll left_over = k-pref1[i];
    		calc+=i;
    		calc+=(upper_bound(pref2.begin(),pref2.end(),left_over)-1)-pref2.begin();
    		ans = max(ans,calc);
    	    }
    	    else{
    	    	break;
    	    }
    }
    cout<<ans<<"\n";
}


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

using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf("%.12lf\n",mid);
// __builtin_popcount(int) count 1's in binary
// get decimal pert of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
int mod = 998244353;

long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}

/*string sentence = "And I feel fine...";
    istringstream iss(sentence);
*/  

double eps = .000000001;

int main ()
{
  prep();
  int num;
  string s;
  cin >> num >> s;
  if (num < 3200){
      cout << "red";
  }else{
      cout << s;
  }
  return 0; 
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
long long gcd(long long x, long long y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}
int main() {
	int Q;
	cin >> Q;
	for (int i = 0; i < Q; ++i) {
		long long A, B, C, D;
		cin >> A >> B >> C >> D;
		bool ans = true;
		if (A < B || B > D) ans = false;
		else {
			long long g = gcd(B, D);
			long long tar = -1;
			if (B % g > A % g) tar = B / g * g + A % g;
			else tar = (B / g - 1) * g + A % g;
			if (tar > C) ans = false;
		}
		cout << (ans ? "Yes" : "No") << endl;
	}
	return 0;
}

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

using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << 2 * min(b, c) + min(c - min(b, c), a) + b - min(b, c) + (c > b + a) << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
import numpy as np

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N = int(input())
    jobs = [tuple(map(int, input().split())) for _ in range(N)]
    jobs.sort(key=lambda x: x[1])
    jobs = deque(jobs)

    cur_time = 0
    while jobs:
        job = jobs.popleft()
        if job[1] < cur_time + job[0]:
            print("No")
            return 0
        else:
            cur_time += job[0]
    else:
        print("Yes")


if __name__ == '__main__':
    main()

Measured memory_bytes: 41068
import sys
sys.setrecursionlimit(10**8)
input = sys.stdin.readline

X, N = map(int,input().split())
P = list(map(int,input().split()))

ans = -1
nums = [True]*105
for p in P:
    nums[p] = False

MIN = 10**9
for i in range(105):
    if nums[i]:
        if MIN>abs(i-X):
            MIN = abs(i-X)
            ans = i

print(ans)


Measured memory_bytes: 9132
x, y, a, b, c = gets.split.map(&:to_i)

r = gets.split.map(&:to_i).sort()[-x..-1]
g = gets.split.map(&:to_i).sort()[-y..-1]
x = gets.split.map(&:to_i).sort()

sum = r.inject(:+) + g.inject(:+)
r.push(10000000000)
g.push(10000000000)

r_index = 0
g_index = 0

while true
    break if x.empty?
    if r[r_index] <= g[g_index] && r[r_index] <= x.last
        sum += x.pop - r[r_index]
        r_index += 1
    elsif g[g_index] <= r[r_index] && g[g_index] <= x.last
        sum += x.pop - g[g_index]
        g_index += 1
    else
        break
    end
end
puts sum


Measured memory_bytes: 25832
from itertools import permutations
n = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))

n_list = [x for x in range(1, n+1)]
# print(list(permutations(n_list, n)))
a = b = 0
for n, i in enumerate(permutations(n_list, n)):
  # print(n, i)
  if i == P:
    a = n
  if i == Q:
    b = n
    
print(abs(a-b))

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


int main() {
  string a,b;
  cin>>a>>b;
  int ans=0;
  REP(i,3)ans+=a[i]==b[i]; 
  cout << ans << endl;
}

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

int main(){
    int n, i, x, s = 0, t = 0;
    cin >> n;
    vector<int> v, a, b;
    for(i=0; i<n; i++){
        cin >> x;
        a.push_back(x);
        v.push_back(i+1);
    }
    for(i=0; i<n; i++){
        cin >> x;
        b.push_back(x);
    }
    i = 1;
    while(s == 0 || t == 0){
        if(a == v) s = i;
        if(b == v) t = i;
        i++;
        next_permutation(v.begin(), v.end());
    }
    cout << abs(s-t);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// 0 white, 1 black
int memo[100][100][100][100];
int row,col;
int color[100][100];
int dp(int i,int j,int wb,int bw,int c)
{
  if(i == row-1 && j == col-1)return max(wb,bw);
  if(memo[i][j][wb][bw]!=-1)return memo[i][j][wb][bw];
  int p1=20000,p2=20000;
  if(i+1 < row)
  {
    if(c != color[i+1][j])
    {
      if(c == 1 )p1 = dp(i+1,j,wb,bw+1,0);
      else p1 = dp(i+1,j,wb+1,bw,1);;
    }
    else p1=  dp(i+1,j,wb,bw,c);
  }
  if(j+1 < col)
  {
    if(c != color[i][j+1])
    {
      if(c == 1 )p2 = dp(i,j+1,wb,bw+1,0);
      else p2 = dp(i,j+1,wb+1,bw,1);;
    }
    else p2=  dp(i,j+1,wb,bw,c);
  }
  memo[i][j][wb][bw] = min(p1,p2);
  return memo[i][j][wb][bw];

}
int main()
{
  scanf("%d%d",&row,&col);
  string g;
  memset(memo,-1,sizeof memo);
  for(int w=0;w<row;w++)
  {
    cin >> g;
    for(int q=0;q<col;q++)
    {
      color[w][q] = (g[q] == '.') ? 0 : 1;
    }
  }
  int ans=0
  ;
  if(color[0][0] == 1 && color[row-1][col-1] == 1)
  {
    ans++;
    for(int w=0;w<row;w++)
    {
      for(int q=0;q<col;q++)
      {
        color[w][q] = (color[w][q] == 1) ? 0: 1;
      }
    }
  }
  ans += dp(0,0,0,0,color[0][0]);
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 390912
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;


int main(){
  string s; cin>>s;
  int k,n; cin>>k;
  n=s.size();


 vector<string> str(0);

//５個持ってくる
 REP(i,n){
    REP(j,5){
        if(n-1>=i+j)
        str.push_back(s.substr(i,j+1));
    }
 
   }
   sort(ALL(str));
   
   int count=1;
   int i=0;
   while (count<k){
       i++;
       if(str[i]!=str[i-1])count++;
       
   }
   cout<<str[i]<<endl;
 }

Measured memory_bytes: 1660
///
// File:  grl_4_b.cpp
// Author: ymiyamoto
//
// Created on Fri Oct 20 01:00:42 2017
//

#include <cstdint>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;
#define SIZE 10000

static vector<uint32_t> graph[SIZE];
static vector<uint32_t> connected_num(SIZE, 0);
static queue<uint32_t> q;
static vector<uint32_t> sorted;

int32_t main()
{
  uint32_t V, E;
  cin >> V >> E;

  for (uint32_t i = 0; i < E; i++) {
    uint32_t s, t;
    cin >> s >> t;
    graph[s].push_back(t);
    connected_num[t]++;
  }

  for (uint32_t i = 0; i < V; i++) {
    if (connected_num[i] == 0) {
      q.push(i);
    }
  }

  while (!q.empty()) {
    uint32_t index = q.front();
    q.pop();

    sorted.push_back(index);
    for (uint32_t i = 0; i < graph[index].size(); i++) {
      connected_num[graph[index][i]]--;
      if (connected_num[graph[index][i]] == 0) {
        q.push(graph[index][i]);
      }
    }
  }

  for (uint32_t i = 0; i < sorted.size(); i++) {
    if (i != 0) cout << " ";
    cout << sorted[i];
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 3900