akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;


int main() {
    string s;
    cin >> s;
    ll n = s.size();
    vl T(n+1);
    T[n] = 0;
    ll digit = 1;
    for(ll i = n-1; i >= 0; i--){
        T[i] = (T[i+1] + (s[i]-'0')*digit) % 2019;
        digit = digit*10 % 2019;
    }
    vl mod(2019, 0);
    rep(i, n+1){
        mod[T[i]]++;
    }
    ll ans = 0;
    rep(i, 2019){
        ll m = mod[i];
        ans += m*(m-1) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5144
n, k = map(int, input().split())

cnt = [0] * n
for i in range(k):
    d = int(input())
    a = [int(x) - 1 for x in input().split()]
    for j in a:
        cnt[j] += 1

ans = 0
for i in cnt:
    if i == 0:
        ans += 1
        
print(ans)

Measured memory_bytes: 9188
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

#define pb push_back
#define mk make_pair
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define sf(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pf(a) printf("%d\n",a);
#define pfl(a) printf("%lld\n",a);
#define TEST int test; cin >> test;while(test--)
#define ii pair<int,int>
#define iil pair<ll,ll>
#define loop(i,a,b) for(int i = a ; i < b ; i++)
#define INF 2147483647


int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const double pi = acos(-1.0);

map<ll,ll>mp;
void solve()
{
    int n, a, b, c;
    cin >> n >> a >> b >> c;
    char c1[n+10], c2[n+10];
    for(int i = 0 ; i < n ; i++)
    {
       cin >> c1[i] >> c2[i];
       //cout << c1[i] << " " << c2[i] << endl;
    }
    vector<char> v;

    for(int i = 0 ; i < n ; i++)
    {
      if((c1[i] == 'A' && c2[i] == 'B')  or (c1[i] == 'B' && c2[i] == 'A'))
      {
         if(a == 0 && b == 0) {cout << "No" << endl; return;}
         else if( a > b) a--,b++ , v.pb('B');
         else if( b > a ) b--,a++, v.pb('A');
         else{
           if(c1[i+1] == 'A' or c2[i+1] == 'A') b--,a++, v.pb('A');
           else  a--,b++ , v.pb('B');
         }
      }
      else if((c1[i] == 'A' && c2[i] == 'C')  or (c1[i] == 'C' && c2[i] == 'A'))
      {
         if(a == 0 && c == 0) {cout << "No" << endl; return;}
         else if( a > c) a--,c++ , v.pb('C');
         else if( c > a ) c--,a++, v.pb('A');
         else{
           if(c1[i+1] == 'A' or c2[i+1] == 'A') c--,a++, v.pb('A');
           else  a--,c++ , v.pb('C');
         }
      }
      else if((c1[i] == 'B' && c2[i] == 'C')  or (c1[i] == 'C' && c2[i] == 'B'))
      {
         if(b == 0 && c == 0) {cout << "No" << endl; return;}
         else if( b > c) b--,c++ , v.pb('C');
         else if( c > b ) c--,b++, v.pb('B');
         else{
           if(c1[i+1] == 'B' or c2[i+1] == 'B') c--,b++, v.pb('B');
           else b--,c++ , v.pb('C');
         }
      }
    }
    cout << "Yes" << endl;
    int sz = v.size();
    for(int i = 0 ; i < sz ; i++)
    {
      cout << v[i] << endl;
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //TEST
    solve();
    return 0;
}


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

int main(){
  int N, M;
  vector<int> L(100010), R(100010);

  cin >> N >> M;
  for(int i=0; i<M; i++) cin >> L[i] >> R[i];

  int left = 1; int right = N;
  for(int i=0; i<M; i++){
    left = max(left, L[i]);
    right = min(right, R[i]);
  }

  cout << max(0, right - left + 1) << endl;
}

Measured memory_bytes: 1024
/******************************************
* NICK : nikhilsinghh59 *
******************************************/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"

#define PB push_back
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
const int M = 1e9+7;

int main()
{   
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

    string s;
    cin >> s;

    if(s[3]==s[2] && s[4]==s[5])
    {
        cout << "Yes";
    }
    else cout << "No";
    return 0;
}


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

#define ll long long int
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(A) A.begin(), A.end()
#define SZ(A) (ll)A.size()
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <int, int> pii;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
const int inf = 1e9;
//const ll inf = 1e18;
const int N = 1e6;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s, t, u;
    int a, b;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    if (u == s) cout << (a - 1) << " " << b << "\n";
    else cout << a << " " << b - 1 << "\n";
 	return 0;
}


Measured memory_bytes: 256
/*hello! guys~*/
#include <bits/stdc++.h>
using namespace std;
long long a[200001],b[200001];
int reset()
{
	for(int i=0;i<200001;i++)
	{
		a[i]=0;b[i]=0;
	}
}
int main()
{
	long long n,c=0;
	cin>>n;
	set<long long> d;
	reset();
	for(long long i=0;i<n;i++)
	{
	scanf("%lld",&a[i]);
	b[a[i]]++;d.insert(a[i]);}
	set<long long>::iterator it;
	for(it = d.begin(); it != d.end(); it++)  
        {  
            c+=b[*it]* (b[*it]-1)/2;
        } 
    for(long long i=0;i<n;i++)
    {
    	long long m;
    	if(b[a[i]]>1)
		m=c-(b[a[i]]*(b[a[i]]-1)-(b[a[i]]-1)*(b[a[i]]-2))/2;
    	else m=c;
    	printf("%lld\n",m);
	}
	return 0;
	
}

Measured memory_bytes: 10624
using System;

namespace oasobi
{
    static class MainClass
    {
        public static void Main()
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int M = int.Parse(input[1]);

            int total = (N + M) * (N + M - 1) / 2;
            int odd = N * M;

            int ans = total - odd;

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<int> c(9);
  for(int i=0;i<9;i++){
    cin>>c[i];
  }
  if((3*(c[4]+c[5]-2*c[3])+3*(c[8]+c[6]-2*c[7])+3*(c[0]+c[1]-2*c[2]))==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int N,R=0,G=0,B=0,NG=0;string S;cin>>N>>S;
  for(int i=0;i<N;i++){
    if(S[i]=='R')R++;
    if(S[i]=='G')G++;
    if(S[i]=='B')B++;
  }
  for(int i=1;i<=N/2;i++)
    for(int j=0;j<N-2*i;j++)
      if(S[j]!=S[j+i]&&S[j+i]!=S[j+2*i]&&S[j+2*i]!=S[j])NG++;
  cout<<R*G*B-NG<<endl;
}

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

int main()
{
	int N,K,h;
	cin >> N >> K;
	int ans = 0;
	rep(i,N)
	{
		cin >> h;
		if (h >= K) ans++;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
c1 = list(map(int, input().split()))
c2 = list(map(int, input().split()))
c3 = list(map(int, input().split()))
total = 0
div = c1[0]+c2[1]+c3[2]
for (x,y,z) in zip(c1,c2,c3):
    total = total + x + y + z

print ('Yes' if total / 3 == div else 'No')

Measured memory_bytes: 3064
def solve(n, p_list):

    count = 0
    j = 2 * 10**5 +1
    for i in p_list:
        if j > i:
            count += 1
            j = i

    return count

if __name__ == "__main__":

    n = int(input())
    p_list = [int(i) for i in input().split()]
    ans = solve(n, p_list)
    print(ans)

Measured memory_bytes: 26012
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=2e5+5;
int a[N];
int s[N],top;
int l[N],r[N];
int n;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<=n;i++){
        while(top&&a[s[top]]>a[i])
            top--;
        if(top)
            l[i]=s[top]+1;
        else
            l[i]=1;
        s[++top]=i;
    }
    top=0;
    for(int i=n;i>=1;i--){
        while(top&&a[s[top]]>a[i])
            top--;
        if(top)
            r[i]=s[top]-1;
        else
            r[i]=n;
        s[++top]=i;
    }
    ll ans=0;
    for(int i=1;i<=n;i++)
        ans+=1ll*(i-l[i]+1)*(r[i]-i+1)*a[i];
    printf("%lld\n",ans);
}


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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
  }*/

int n, m;
vi es[100000];
int memo[100000];

int dfs(int v){
  if(memo[v] >= 0) return memo[v];

  int res = 0;
  for(int to : es[v]){
    chmax(res, dfs(to)+1);  
  }

  return memo[v] = res;
}

signed main(){
  memset(memo, -1, sizeof(memo));

  cin >> n >> m;
  rep(i, 0, m){
    int x, y;
    cin >> x >> y;
    es[x-1].emplace_back(y-1);
  }

  int ans = 0;
  rep(i, 0, n){
    chmax(ans, dfs(i));
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 8576
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
vector<int> v[200010];
int n,m,k;
long long vis[200010],d[200010];
void DFS(int x,int s){
	vis[x]+=s;
	for(int i=0;i<v[x].size();i++){
		if(vis[v[x][i]]%200010==0)DFS(v[x][i],s);
	}
}
void Solve(int r){
	for(int i=0;i<n;i++){
		v[i].clear();
		vis[i]*=200010;
	}
	for(int i=0;i<r;i++){
		int a,b;cin>>a>>b;a--,b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	for(int i=0;i<n;i++){
		if(vis[i]%200010==0){
			DFS(i,i+1);
		}
	}
}
int main(){
	cin>>n>>m>>k;
	for(int i=0;i<n;i++)vis[i]=0;
	Solve(m);
	Solve(k);
	for(int i=0;i<n;i++)d[i]=vis[i];
	sort(d,d+n);
	for(int i=0;i<n;i++){
		cout<<upper_bound(d,d+n,vis[i])-lower_bound(d,d+n,vis[i])<<endl;
	}
	return 0;
}


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

int main(){
  double n;
  cin >> n;
  cout << n*2*3.1415 << endl;
  return 0;
}


Measured memory_bytes: 3780
from collections import defaultdict
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N = int(input())
	S = input()
	D1 = defaultdict(int)
	D2 = defaultdict(int)
	for i in range(1 << N):
		R = ""
		B = ""
		for j in range(N):
			if ((i >> j) & 1) == 1:
				R += S[j]
			else:
				B += S[j]

		RB = R + "," + B
		D1[RB] += 1

	for i in range(1 << N):
		R = ""
		B = ""
		for j in range(N):
			if ((i >> j) & 1) == 1:
				R += S[-1 - j]
			else:
				B += S[-1 - j]

		RB = R + "," + B
		D2[RB] += 1

	ans = 0
	for i in D1:
		ans += D1[i] * D2[i]

	print(ans)


if __name__ == '__main__':
	main()

Measured memory_bytes: 90088
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	static int K,N;
	static int mod =1000000007;
	public static void main(String[] args) {
		int x1=sc.nextInt();
		int y1=sc.nextInt();
		int x2=sc.nextInt();
		int y2=sc.nextInt();
		
		int a=x2-x1;
		int b=y1-y2;
		
		int x3=x2+b;
		int y3=a+y2;
		
		int x4=x1+b;
		int y4=y1+a;
		
		System.out.println(x3+" "+y3+" "+x4+" "+y4);
		}

	
	//static ArrayList<Integer> cc = new ArrayList<>(10001);
	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 21844
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

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

    int N;
    cin >> N;
    int* A = new int[N];
    rep (i, N)
    {
        cin >> A[i];
    }

    int* B = new int[N];
    for (int i = N; i >= 1; --i)
    {
        B[i - 1] = A[i - 1];
        for (int j = i; j + i <= N; j += i)
        {
            B[i - 1] ^= B[j + i - 1];
        }
    }

    int count = 0;
    rep (i, N)
    {
        if (B[i])
        {
            ++count;
        }
    }

    cout << count << "\n";
    // cout << ret << "\n";
    if (count)
    {
        rep (i, N)
        {
            if (B[i])
            {
                cout << i + 1<< " ";
            }
        }
        cout << "\n";
    }

    return 0;
}



Measured memory_bytes: 2560
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <bitset>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#define PR pair
#define fi first
#define se second
#define mk make_pair
#define pb push_back
#define REP(i, x, y)   for(int i = (int)(x); i <= (int)(y); i++)
#define FOR(i, x, y)   for(int i = (int)(x); i <  (int)(y); i++)
#define PER(i ,x, y)  for(int i = (int)(x); i >= (int)(y); i--)
#define CH	         ch = getchar()
#define Exit(...)    printf(__VA_ARGS__), exit(0)
#define dln()        fprintf(stderr,"\n")
#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef double	  db;
typedef long long LL;
typedef vector<int> VI;
typedef vector<VI > VII;
typedef PR<int,int> PII;
typedef vector<PII> VPI;
const	int inf=2e9;
const	LL Inf=1e10;
const	int P=1e9+7;
const	int N=100005;

inline LL IN(){
	LL x = 0;
	int ch = 0, f = 0;
	for (CH; ch != -1 && (ch < 48 || ch > 57); CH) f = (ch == '-');
	for (; ch >= 48 && ch <= 57; CH) x = (x << 1) + (x << 3) + ch - '0';
	return f ? (-x) : x;
}
template<typename T> inline int chkmin(T &a, const T &b){if(b < a) return a = b, 1; return 0;}
template<typename T> inline int chkmax(T &a, const T &b){if(b > a) return a = b, 1; return 0;}

void renew(int &x, const int &y){
	x += y;
	if(x >= P) x -= P;
	if(x <  0) x += P;
}

int Pow(int x, int y, int p){
	int a = 1;
	for (; y; y >>= 1, x = (LL)x * x %p) if(y & 1) a=(LL)a * x%p;
	return a;
}

int perm[N], stat[N];
int c[N], n;
int a[5][N], vis[N];
int tre[N];

void Add(int x){
	for(; x <= n; x += x & (-x)) tre[x] ^= 1;
}

int Sum(int x){
	int res = 0;
	for(; x; x -= x & (-x)) res ^= tre[x];
	return res;
}

int main(){
	scanf("%d", &n);
	REP(i, 1, n) scanf("%d", &a[1][i]);
	REP(i, 1, n) scanf("%d", &a[2][i]);
	REP(i, 1, n) scanf("%d", &a[3][i]);
	REP(i, 1, n){
		int u = a[1][i], v = a[2][i], w = a[3][i];
		if(!((u + 2) / 3 == (v + 2) / 3 && (u + 2) / 3 == (w + 2) / 3)){
			puts("No");
			return 0;
		}
		if(!((u < v && v < w) || (u > v && v > w))){
			puts("No");
			return 0;
		}
		if(vis[(u + 2) / 3]){
			puts("No");
			return 0;
		}
		vis[(u + 2) / 3] = 1;
		perm[i] = (u + 2) / 3;
		stat[i] = (u > v && v > w);
	}
	REP(i, 1, n) if((i & 1) != (perm[i] & 1)){
		puts("No");
		exit(0);
	}
	REP(i, 1, n) c[i & 1] ^= stat[i];
	REP(i, 0, 1){
		int u = c[i];
		memset(tre, 0, sizeof tre);
		REP(j, 1, n) if((j ^ i) & 1){
			u ^= Sum(n) ^ Sum(perm[j]);
			Add(perm[j]);
		}
		if(u){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int main()
{
    long long x,y;
    scanf("%lld %lld",&x,&y);
    int ans=0;
    long long t=y/x;
    while(t)
    {
        ans++;
        t>>=1;
    }
    printf("%d\n",ans);
    return 0;
}


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

/* define*/
#define Yes(X) puts ( X ? "Yes" : "No")
#define YES(X) puts ( X ? "YES" : "NO")
#define FOR(i, a, b) for ( i = a, i < b ; i++)
#define REP(i, n) for ( i = 0; i < n ; i++)
#define DER(i, n) for ( i = 0; n ; i--)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = 1e9 + 7;

/* alias */
typedef long long ll;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}

//* main */
int i, j, k;

int main() {
	int n, m, p, f = 0;
	scanf("%d%d%d", &n, &m, &p);
	REP(i, n + 1)REP(j, m + 1) if (i * (m - j) + j * (n - i) == p) f = 1;
	Yes(f);
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;


int main(){
	int A,B,C,D,E;
	cin>>A>>B>>C>>D>>E;
	if(A <0){
		cout <<(0-A)*C+D+B*E<<endl;
	}else if(A == 0){
		cout << D+B*E<<endl;
	}else{
		cout << (B-A)*E<<endl;
	}
	

		return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define int long long
#define boost() ios_base :: sync_with_stdio(0); cin.tie(); cout.tie(); cout << fixed; cout << setprecision(15); srand(time(NULL))
#define all(x) x.begin(), x.end()
using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int n, h[100010];
int dp[100010][5];

signed main () {
  cin >> n;
  for (int i = 0; i < n; i++) cin >> h[i];
  dp[1][1] = abs (h[0] - h[1]);
  dp[1][2] = INT_MAX;
  dp[1][3] = dp[1][1];
  for (int i = 2; i < n; i++) {
    dp[i][1] = dp[i - 1][3] + abs (h[i - 1] - h[i]);
    dp[i][2] = dp[i - 2][3] + abs (h[i - 2] - h[i]);
    dp[i][3] = min (dp[i][1], dp[i][2]);
  }
  cout << dp[n - 1][3] << endl;
  return 0;
}


Measured memory_bytes: 4992
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import os
import math
import itertools
import numpy as np
from collections import OrderedDict, deque
from bisect import bisect_left, bisect_right, insort_left, insort_right
sys.setrecursionlimit(10000)


class EndLoop(Exception):
    pass


def debug_print(L):
    for col in L:
        print(col)


def debug_print_joined(L):
    for col in L:
        print("".join(col))


def transpose_matrix(L):
    transposed = list(map(list, zip(*L)))
    return transposed


def solve():
    N, M = list(map(int, input().split(" ")))
    graph = [[0] * N for _ in range(N)]
    for _ in range(M):
        a, b = list(map(int, input().split(" ")))
        graph[a - 1][b - 1], graph[b - 1][a - 1] = 1, 1

    visited = [False for _ in range(N)]
    cnt = 0
    def dfs(v, G):
        visited[v] = True
        for v2 in range(N):
            if G[v][v2] == 1 and visited[v2] != True:
                dfs(v2, G)

    check = [[False] * N for _ in range(N)]
    for i in range(N):
        for j in range(N):
            if check[i][j] == True:
                pass
            elif graph[i][j] == 1 and check[i][j] == False:
                graph[i][j], graph[j][i] = 0, 0
                dfs(0, graph)
                if visited.count(False) == 0:
                    pass
                else:
                    cnt += 1
                graph[i][j], graph[j][i] = 1, 1
                visited = [False for _ in range(N)]
                check[i][j], check[j][i] = True, True

    print(cnt)
    

solve()

Measured memory_bytes: 12088
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main {
    static Scanner sc = new Scanner();

    public static void main(final String[] args) throws IOException {
        int n = sc.nextInt();
        int[] x = new int[n];
        int[] y = new int[n];
        for(int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
        }
        double sum = 0;
        for(int i = 0; i < n; i++) {
            for(int j = i+1; j < n ; j++) {
                sum += Math.sqrt(Math.pow(x[j] - x[i], 2) + Math.pow(y[j] - y[i], 2));
            }
        }
        System.out.println(sum * 2 / n);
    }

    static class Scanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;
        String next() throws IOException {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                tokenizer = new StringTokenizer(reader.readLine());
            }
            return tokenizer.nextToken();
        }
        int nextInt() throws IOException {
            return Integer.parseInt(next());
        }
        long nextLong() throws IOException {
            return Long.parseLong(next());
        }
    }
}


Measured memory_bytes: 21204
n = int(input())
line = list(map(int,input().split()))
ans = 1
for i in range(n):
  if line[i] == 0:
    print(0)
    exit()
for i in range(n):
  ans *= line[i]
  if ans > 10**18:
    ans = -1
    break
print(ans)

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

int main()
{
    ll t,i,j,k,l,n,m;
    cin>>n;
    char S[n][n];
    for(i=0;i<n;++i){
        cin>>S[i];
    }
    ll ans=0;
    ll P[n][n];

    for(ll A=0;A<n;++A){
            bool ch=true;
            for(i=0;i<n&&ch;++i){
                for(j=0;j<n;++j){
                    if(S[(i+A)%n][j]!=S[(j+A)%n][i]){
                    ch=false;
                    break;
                    }
                }
            }
            if(ch){
                ans+=n;
            }
    }

    cout<<ans;

    return 0;
}


Measured memory_bytes: 384
/**
 *    author:  yoseph
 *    created: 27.07.2020 22:09:57      
**/
#include <bits/stdc++.h>
using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	vector<int> v(5);
	for (int i = 0; i < 5; ++i) {
		cin >> v[i];
		if (v[i] == 0) {
			cout << i + 1 << "\n";
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3496
#include <stdio.h>

int main(void) {

  int A,B,C,D;

  scanf("%d%d%d%d", &A, &B, &C, &D);

  int x;
  if( A < B)
    x = A;
  else
    x = B;

  int y;

  if( C < D)
    y = C;
  else
    y = D;
  
  printf("%d\n", x + y);
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pll = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, m, n) for(ll i = m; i > n; i--)
#define Rep(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define lmax(x, y) max<ll>(x, y)
#define lmin(x, y) min<ll>(x, y)
#define tmax(x, y, z) lmax((x), lmax((y), (z)))
#define tmin(x, y, z) lmin((x), lmin((y), (z)))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
const ll INF = 1LL << 60;
const ll MM = 1000000000; const ll MOD = MM + 7; const ll MMM=9223372036854775807;//2^63 -1
#define ADD(a,b) a = (a + ll(b)) % MOD
#define MUL(a,b) a = (a * ll(b)) % MOD
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){ fill( (T*)array, (T*)(array+N), val );}
// struct edge{ ll from, to, cost; };
// struct edge{ ll to, cost; };
// using Graph = vector<vector<ll>>;  // 重み無し
// using Graph = vector<edge>;  // 辺
// using Graph = vector<vector<edge>>;  // 重み付き
ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
ll ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);
// priority_queue<ll, vector<ll>, greater<ll>> pq;


int main(){
    string a, b, c; cin >> a >> b >> c;
    cout << 'A' << b[0] << 'C' << endl;
}


Measured memory_bytes: 3628
#include <iostream>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	bool b[10];
	for(int i=0;i<10;i++)	b[i]=true;
	for(int i=0;i<k;i++)
	{
		int x;
		cin>>x;
		b[x]=false;
	}
	for(;;)
	{
		bool p=true;
		int hn=n;
		while(hn/10!=0)
		{
			if(b[hn%10]==false)
			{
				p=false;
				break;
			}
			hn/=10;
		}
		if(p==true&&b[hn%10]==true)
		{
			break;
		}
		n++;
	}
	cout<<n<<endl;
	return 0;
}

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

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

long long read(void) {
	long long d;
	cin >> d;
	return d;
}
void println(void) {
	cout << endl;
}
template <typename T>void print(T t) {
	cout << t;
}
template <typename T>void println(T t) {
	print(t);
	println();
}

class Dice{
public:
	explicit Dice(std::vector<int> dice): Points_(dice) {
	}
	~Dice() {}
	int Top(void) const { return Points_[0]; }
	int South(void) const { return Points_[1]; }
	int East(void) const { return Points_[2]; }
	Dice& Roll(char c){
		switch (c)
		{
		case 'N': RollN(); break;
		case 'E': RollE(); break;
		case 'S': RollS(); break;
		case 'W': RollW(); break;
		case 'R': RollR(); break;
		case 'L': RollL(); break;
		default:
			break;
		}
		return *this;
	}
	Dice& Rolls(const string& rolls) {
		for(int i = 0; i < rolls.size(); ++i) {
			Roll(rolls[i]);
		}
		return *this;
	}
	int Search(int target) const {
		for (int i = 0; i < Points_.size(); ++i) {
			if (Points_[i] == target) {
				return i;
			}
		}
		return -1;
	}
	int SearchAndRoll(int target, std::vector<std::string> rolls) {
		int pos = Search(target);
		if (pos >= 0) {
			Rolls(rolls[pos]);
		}
		return pos;
	}
	int SearchAndRollTop(int target) {
		std::vector<std::string> rolls = {"", "N", "W", "E", "S", "NN"};
		return SearchAndRoll(target, rolls);
	}
	int SearchAndRollSouth(int target) {
		std::vector<std::string> rolls = {"", "", "R", "L", "RR", ""};
		return SearchAndRoll(target, rolls);
	}
private:
	std::vector<int> Points_;
	void RollN(void) {
		int temp = Points_[0];
		Points_[0] = Points_[1];
		Points_[1] = Points_[5];
		Points_[5] = Points_[4];
		Points_[4] = temp;
		return;
	}
	void RollE(void) {
		int temp = Points_[0];
		Points_[0] = Points_[3];
		Points_[3] = Points_[5];
		Points_[5] = Points_[2];
		Points_[2] = temp;
		return;
	}
	void RollS(void) {
		int temp = Points_[0];
		Points_[0] = Points_[4];
		Points_[4] = Points_[5];
		Points_[5] = Points_[1];
		Points_[1] = temp;
		return;
	}
	void RollW(void) {
		int temp = Points_[0];
		Points_[0] = Points_[2];
		Points_[2] = Points_[5];
		Points_[5] = Points_[3];
		Points_[3] = temp;
		return;
	}
	void RollR(void) {
		int temp = Points_[1];
		Points_[1] = Points_[2];
		Points_[2] = Points_[4];
		Points_[4] = Points_[3];
		Points_[3] = temp;
		return;
	}
	void RollL(void) {
		int temp = Points_[1];
		Points_[1] = Points_[3];
		Points_[3] = Points_[4];
		Points_[4] = Points_[2];
		Points_[2] = temp;
		return;
	}
};

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

	vector<int> points(6);
	REP(i, points.size()) {
		points[i] = read();
	}
	Dice dice(points);
	int questions = read();
	REP(i, questions) {
		dice.SearchAndRollTop(read());
		dice.SearchAndRollSouth(read());
		println(dice.East());
	}

	return 0;
}



Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    map<char,int>hexmp;

    hexmp['A'] = 10;
    hexmp['B'] = 11;
    hexmp['C'] = 12;
    hexmp['D'] = 13;
    hexmp['E'] = 14;
    hexmp['F'] = 15;
    char A,B;
    cin >> A >> B;

    if(hexmp[A] > hexmp[B])cout << ">" << endl;
    else if (hexmp[A] == hexmp[B])cout << "=" << endl;
    else cout << "<" << endl; 
}  

Measured memory_bytes: 256
#pragma GCC optimize (2)
#pragma G++ optimize (2)
#include<bits/stdc++.h>
#define INF 0x3f3f3f3f
#define mod 1000000007
#define MAX 305
using namespace std;
//char nc()
//{
//	static char buf[100000],*p1=buf,*p2=buf;
//	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
char nc(){return getchar();}
int read()
{
	int x=0,y=1;
	char c=nc();
	while(!isdigit(c))
	{
		if(c=='-')y=-1;
		c=nc();
	}
	while(isdigit(c))
	{
		x=(x<<1)+(x<<3)+(c^48);
		c=nc();
	}
	return x*y;
}
int n,a[MAX<<1],b[MAX<<1],cnt=0;
long long f[2][MAX][MAX];
long long mo(long long x)
{
	return x<mod?x:x-mod;
}
int main()
{
	n=read();
	for(int i=1;i<=n*2;i++)
		a[i]=read();
	for(int i=1;i<=n*2;i+=2)
		if(a[i]==-1&&a[i+1]==-1)
			cnt++;
		else if(a[i]==-1)
			b[a[i+1]]=1;
		else if(a[i+1]==-1)
			b[a[i]]=1;
		else
			b[a[i]]=b[a[i+1]]=2;
	int now=0,last=1,up1=0,up2=0;
	f[now][0][0]=1;
	for(int i=n*2;i;i--)
	{
		if(b[i]==2) continue;
		now^=1;last^=1;
		for(int j=0;j<=up1;j++)
			for(int k=0;k<=up2;k++)
				if(f[last][j][k])
				{
					if(b[i])
						f[now][j+1][k]=mo(f[now][j+1][k]+f[last][j][k]);
					else
					{
						f[now][j][k+1]=mo(f[now][j][k+1]+f[last][j][k]);
						if(j) f[now][j-1][k]=(f[now][j-1][k]+f[last][j][k]*j)%mod;
					}
					if(k) f[now][j][k-1]=mo(f[now][j][k-1]+f[last][j][k]);
					f[last][j][k]=0;
				}
		if(b[i]) up1=min(n,up1+1);
		else up2=min(n,up2+1);
	}
	long long ANS=f[now][0][0];
	for(int i=1;i<=cnt;i++)
		ANS=ANS*i%mod;
	printf("%lld",ANS);
	return 0;
}


Measured memory_bytes: 4956
import java.util.*;

public class Main{
  public static void main (String args[]){
    Scanner sc = new Scanner(System.in);
    int num = sc.nextInt();
    int[] order = new int[num];
    
    for (int i = 1; i < num+1; i++){
      order[sc.nextInt()-1] = i;
    }
    for (int i = 0; i < num; i++){
      System.out.print(order[i] + " ");
    }
  }
}

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

const int N=1e5 +3;
int a[N];
map<int, int> mp;

int main(){

    int n;
    scanf("%d", &n);
    for(int i=0; i<n; ++i){
        scanf("%d", a+i);
        ++mp[a[i]];
        --mp[a[i]];

        mp[a[i]] = !mp[a[i]];
    }

    int cnt=0;
    for(auto i:mp){
        if(i.second==1)
            ++cnt;
    }

    printf("%d", cnt);



    return 0;
}


Measured memory_bytes: 5376
import java.util.*;
import java.io.*;

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		long a[] = fs.nextLongArray(n);
		int cnt[] = new int[60];
		for(int i=0;i<n;i++) {
			for(int j=0;j<60;j++) {
				if((a[i]>>j&1)==1) {
					cnt[j]++;
				}
			}
		}
		long ans = 0;
		long k = 1;
		for(int i=0;i<60;i++) {
			long t = mul(cnt[i], (n - cnt[i]));
			t = mul(t, k);
			ans = plus(ans, t);
			k = mul(k,2);
		}
		System.out.println(ans);
	}

	//MOD culculations
	static long plus(long x, long y) {
		long res = (x + y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long sub(long x, long y) {
		long res = (x - y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long mul(long x, long y) {
		long res = (x * y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long div(long x, long y) {
		long res = x * pow(y, mod - 2) % mod;
		return res < 0 ? res + mod : res;
	}

	static long pow(long x, long y) {
		if (y < 0)
			return 0;
		if (y == 0)
			return 1;
		if (y % 2 == 1)
			return (x * pow(x, y - 1)) % mod;
		long root = pow(x, y / 2);
		return root * root % mod;
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

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

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

	public double nextDouble() {
		return Double.parseDouble(next());
	}

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

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


Measured memory_bytes: 81056
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  int n, q;
  string s;

  cin >> n >> q;
  cin >> s;

  vector<int> v(s.size(), 0);
  if (s[0] == 'A' && s[1] == 'C') {
    v[1] = 1;
  }
  for (int i = 2; i < s.size();) {
    if (s[i] == 'A' && s[i + 1] == 'C') {
      v[i] = v[i - 1];
      v[i + 1] = v[i] + 1;
      i += 2;
    } else {
      v[i] = v[i - 1];
      i++;
    }
  }

  for (int i = 0; i < q; ++i) {
    int l, r;
    cin >> l >> r;
    l--;
    r--;
    int ans = 0;
    if (r - l == 1) {
      ans = v[r] - v[l];
    } else {
      if (l == 0) {
        ans = v[r];
      } else {
        ans = v[r] - v[l];
      }
    }
    cout << ans << endl;
  }
  return 0;
}


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

int main(){
    int n,m;
    cin >> n >> m;
    priority_queue<ll> q;
    ll all=0;
    for(int i=0; i<n; i++){
        ll a;
        cin >> a;
        q.push(a);
        all += a;
    }
    ll discount = 0;
    for(int i=0; i<m; i++){
        ll use;
        use = q.top();
        q.pop();
        discount += (use+1)/2;
        q.push(use/2);
    }
    cout <<  all - discount << endl;
}


Measured memory_bytes: 4280
n, m, q = map(int, input().split())
points = [[0] * n for _ in range(n)]
for _ in range(m):
    li, ri = map(int, input().split())
    li -= 1
    ri -= 1
    points[li][ri] += 1

cumsum = [[0] * (n + 1) for _ in range(n + 1)]
for i in range(n):
    for j in range(n):
        cumsum[i + 1][j + 1] = cumsum[i][j + 1] + cumsum[i + 1][j] \
                             - cumsum[i][j] + points[i][j]

for _ in range(q):
    pi, qi = map(int, input().split())
    pi -= 1
    ans = cumsum[qi][qi] - cumsum[qi][pi] - cumsum[pi][qi] + cumsum[pi][pi]
    print(ans)


Measured memory_bytes: 15332
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;

unsigned long long lcm(unsigned long long a, unsigned long long b){
    if(a == 0 && b == 0)
        return 0;
    return a/__gcd(a, b) * b;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    unsigned long long a, b, c, d;
    cin >>a >>b >>c >>d;
    unsigned long long total = b - a + 1;
    unsigned long long lcmcd = lcm(c, d);
    cout <<total - ((b/c) - (a-1)/c) - ((b/d) - (a-1)/d) + ((b/lcmcd) - (a-1)/lcmcd);
    return 0;
}


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

int main(){
  int n; cin >> n;
  vector<pair<int, pair<int, int> > > A(n);
  for (int i=0; i<n; i++){
    cin >> A[i].first >> A[i].second.first >> A[i].second.second;
  }
  int cnt=0;
  for (int i=0; i<n; i++){
    if (A[i].first%2==0){
      if ((A[i].second.first+A[i].second.second)%2==0&&(A[i].second.first+A[i].second.second)<=A[i].first) cnt++;
    } else {
      if ((A[i].second.first+A[i].second.second)%2==1&&(A[i].second.first+A[i].second.second)<=A[i].first) cnt++;

    }
  }
  if(cnt == n){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

}

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

int n,k,c;
string s;
char pre;

int main(){
    cin>>s;
    n=s.size();
    pre=s[0];
    k=1;
    for(int i=1;i<n;i++){
        if(c){
            pre='2';
            c=0;
            k++;
        }
        else if(s[i]==pre){c=1;}
        else{
            pre=s[i];
            k++;
        }
    }
    cout<<k<<endl;
}

Measured memory_bytes: 640
import itertools as it
def main():
    n,m,k=map(int,input().split())
    Aa = list(map(int,input().split()))
    Bb = list(map(int, input().split()))
    a, b = [0],[0]
    for i in range(n):
        a.append(a[i] + Aa[i])
    for i in range(m):
        b.append(b[i] + Bb[i])
    M = m
    ans = 0
    for A in range(n+1):
        aa = a[A]
        Kaa = k-aa
        if Kaa < 0:
            break
        for B in range(M,-1,-1):
            if b[B] <= Kaa:
                ans = max(ans, A+B)
                M = B
                break
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 48768
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>

using namespace std;

int main () {
    int n;
    int data[300003];
    scanf("%d", &n);
    
    for (int i = 0; i < 3 * n; i++) {
        scanf("%d", data + i);
    }
    
    long long int sum = 0;
    sort (data, data + 3 * n);
    for (int i = n; i < 3 * n; i+=2) {
        sum += data[i];
    }
    printf("%lld", sum);
}


Measured memory_bytes: 1280
s=input()
N=len(s)
st=set(s)

ans=float("inf")
for str in st:
  a=s.split(str)
  max_len=0
  for part in a:
    leng=len(part)
    max_len=max(max_len,leng)
  #print(a,max_len)
  ans=min(ans,max_len)
  
print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;

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

	int N = sc.nextInt();
	int H[] = new int[N];
	for (int i = 0; i < N; i++)
	    H[i] = sc.nextInt();

	int max = H[N - 1];
	boolean bl = true;
	for (int i = N - 2; i >= 0; i--) {
	    if (H[i] == H[i + 1] + 1) {
		H[i]--;
	    }

	    if (H[i] <= max) {
		max = H[i];
	    } else {
		bl = false;
	    }
	}

	if (bl)
	    System.out.println("Yes");
	else
	    System.out.println("No");
	    
    }
}

Measured memory_bytes: 52636
class Node:
    def __init__(self,v):
        self.v= v
        self.left = None
        self.right = None

def inorder(n):
    if n != None:
        inorder(n.left)
        print n.v,
        inorder(n.right)

def preorder(n):
    if n != None:
        print n.v,
        preorder(n.left)
        preorder(n.right)

def postorder(n):
    if n != None:
        postorder(n.left)
        postorder(n.right)
        print n.v,

n = int(raw_input())
nodes = {}
root = -1
p = {}
for _ in range(n):
    nid,left,right = map(int,raw_input().split(' '))
    p[left] = nid
    p[right] = nid
    if not nid in nodes:
        nodes[nid] = Node(nid)
    if left != -1:
        if not left in nodes:
            nodes[left] = Node(left)
        nodes[nid].left = nodes[left]
    if right != -1:
        if not right in nodes:
            nodes[right] = Node(right)
        nodes[nid].right = nodes[right]

root = 0
while root in p:
    root = p[root]

tree = nodes[root]

print 'Preorder'
print '',
preorder(tree)
print
print 'Inorder'
print '',
inorder(tree)
print
print 'Postorder'
print '',
postorder(tree)
print

Measured memory_bytes: 6440
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

class Colon
{
    static void Main(string[] args)
    {

        var input = Console.ReadLine().Split(' ');

        int long_stick = int.Parse(input[0]);
        int short_stick = int.Parse(input[1]);
        var hour = int.Parse(input[2]);
        var minutes = int.Parse(input[3]);

        double ans_length ;

        var total_time = hour * 60.0 + minutes;

        var short_arg = (total_time * 0.5) % 360.0;
        
        var long_arg = minutes * 6.0;

        var total_arg = Math.Abs(short_arg -long_arg);

        if(total_arg >= 180.0)
        {
            total_arg = 360.0 - total_arg;
        }

        var ans_argR = total_arg * 3.14159265358979323846 / 180.0; 

        ans_length = Math.Sqrt(long_stick * long_stick + short_stick * short_stick - 2.0 * long_stick * short_stick * Math.Cos(ans_argR));




        Console.WriteLine( "{0:F20}", ans_length);
    }
}

Measured memory_bytes: 18768
#include <deque>
#include <iostream>
#include <cstdio>
#include <vector>
using namespace std;
const int V = 200010;
const int P = 1000000007;
int Max(int a, int b) {
	return a > b ? a : b;
}
char get() {
	static char buf[V], *p1 = buf, *p2 = buf;
	if (p1 == p2) {
		p2 = (p1 = buf) + fread(buf, 1, V, stdin);
		if (p1 == p2) return EOF;
	}
	return *p1++;
}
void Read(int &x) {
	x = 0; static char c;
	while (c > '9' || c < '0') c = get();
	while (c >= '0' && c <= '9') {
		x = x * 10 + c - '0';
		c = get();
	}
}
int N, F[V], pw[V], cnt[V], MxDep;
vector<int> G[V];
deque<int> f[V][3];
void Add(int &x, int y) {
	(x += y) %= P;
}
void Dfs(int u, int d) {
	int i, j;
	++cnt[d]; MxDep = Max(MxDep, d);
	int SZ = 0;
	for (auto v : G[u]) {
		Dfs(v, d + 1);
		if (f[u][0].size() < f[v][0].size())
			for (i = 0; i < 3; i++) swap(f[u][i], f[v][i]);
		int sz = f[v][0].size(); SZ = Max(SZ, sz);
		for (i = 0; i < sz; i++) {
			int tmp[3] = { 0, 0, 0 }, s = 0, t = 0;
			for (j = 0; j < 3; j++) Add(s, f[v][j][i]);
			for (j = 0; j < 3; j++) Add(t, f[u][j][i]);
			Add(tmp[0], 1LL * f[u][0][i] * f[v][0][i] % P);
			Add(tmp[1], 1LL * f[u][1][i] * f[v][0][i] % P);
			Add(tmp[1], 1LL * f[u][0][i] * f[v][1][i] % P);
			Add(tmp[2], 1LL * s * t % P);
			Add(tmp[2], P - tmp[0]);
			Add(tmp[2], P - tmp[1]);
			for (j = 0; j < 3; j++) f[u][j][i] = tmp[j];
		}
		for (i = 0; i < 3; i++) {
			deque<int> emp; f[v][i].swap(emp);
		}
	}
	f[u][0].push_front(1); f[u][1].push_front(1); f[u][2].push_front(0);
	for (i = 0; i <= SZ; i++) {
		Add(f[u][0][i], f[u][2][i]); f[u][2][i] = 0;
	}
}
int main() {
	int i, j;
	Read(N);
	for (pw[0] = 1, i = 1; i <= N; i++) pw[i] = (pw[i - 1] * 2LL) % P;
	for (i = 1; i <= N; i++) {
		Read(F[i]); G[F[i]].emplace_back(i);
	}
	Dfs(0, 0);
	int Ans = 0;
	for (i = 0; i <= MxDep; i++) {
		int v = f[0][1][i]; Add(Ans, 1LL * v * pw[N + 1 - cnt[i]] % P);
	}
	printf("%d\n", Ans);
	return 0;
}

Measured memory_bytes: 500608
a = input().split(" ")
b = list(map(int, a))
s = input()
ans = "Yes"
for i in range(0, len(s)):
    if i == b[0]:
        if s[i].isdigit():
            ans = "No"
    elif not (s[i].isdigit()):
        ans = "No"
print(ans)


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      if(a[i]>a[j]){
        int x=a[i];
        a[i]=a[j];
        a[j]=x;
      }
    }
  }
  int sum=0;
  for(int i=0;i<k;i++){
    sum+=a[i];
  }
  cout<<sum;
  return 0;
}

  

Measured memory_bytes: 3600
import java.util.*;

public class Main{
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        
        int[] h = new int[n];
        for(int i=0; i<n; i++){
            h[i] = Integer.parseInt(sc.next());
        }
        
        ArrayList<Integer>[] g = new ArrayList[n];
        for(int i=0; i<n; i++){
            g[i] = new ArrayList<>();
        }
        for(int i=0; i<m; i++){
            int a = Integer.parseInt(sc.next())-1;
            int b = Integer.parseInt(sc.next())-1;
            g[a].add(b);
            g[b].add(a);
        }
        
        int ans = 0;
        for(int i=0; i<n; i++){
            boolean yoi = true;
            for(int next : g[i]){
                if(h[i] <= h[next]){
                    yoi = false;
                }
            }
            if(yoi){
                ans++;
            }
        }
        
        System.out.println(ans);
        
    }
}


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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007;

int main(){
    
    int H,W;cin>>H>>W;
    vector<string> S(H);
    vector<vector<int>> T(H+2,vector<int>(W+2,1000000));
    queue<pair<int,int>> Q;
    vector<int> h={-1,0,0,1},w={0,-1,1,0};
    int cnt=0;
    for(int i=0;i<H;i++){
        cin>>S[i];
    }
    for(int i=0;i<H+2;i++){
        for(int j=0;j<W+2;j++){
            if(1<=i&&i<=H&&1<=j&&j<=W&&S[i-1][j-1]=='#'){
                T[i][j]=0;
                Q.push(make_pair(i,j));
            }else if(i==0||i==H+1||j==0||j==W+1) T[i][j]=0;
        }
    }
    while(H*W-cnt){
        int a=Q.front().first;
        int b=Q.front().second;
        Q.pop();
        for(int i=0;i<4;i++){
            if(T[a+h[i]][b+w[i]]==1000000){
                T[a+h[i]][b+w[i]]=T[a][b]+1;
                Q.push(make_pair(a+h[i],b+w[i]));
            }
        }
        cnt++;
    }
    int ans=0;
    for(int i=1;i<=H;i++){
        for(int j=1;j<=W;j++){
            ans=max(ans,T[i][j]);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 13456
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
using namespace std;
typedef long long LL;
const int INF = 999999999;

int main(){
    string l = "qazwsxedcrfvtgb";
    string s;
    cin >> s;
    while(s != "#"){
        int ans = 0;
        rep1(i, s.size()){
            if(l.find(s[i]) != string::npos && l.find(s[i-1]) == string::npos) ans++;
            if(l.find(s[i]) == string::npos && l.find(s[i-1]) != string::npos) ans++;
        }
        cout << ans << endl;
        cin >> s;
    }


}




Measured memory_bytes: 3212