akhauriyash/Code-Regression huggingface dataset:
/*
    Author: Mohammad faisal
    Problem:Linear Approximation.
    Date: 07/08/2019

*/
// #include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cstring>
#include<vector>
#include<algorithm>
#include<stack>
#include<map>
#include<set>
using namespace std;
// long long gcd(long long a,long long b)
// {
//   if(b)
//     return gcd(b,a%b);
//   else
//     return a;
// }
// Author: Mohammad Faisal
// #include<bits/stdc++.h>
// using namespace std;
// long long gcd(long long a,long long b)
// {
//   if(b)
//     return gcd(b,a%b);
//   else
//     return a;
// }
// int main()
// {
//   long long n;
//     cin >> n;
//     long long g = gcd(n,2);
//     cout<<(n*2)/g<<endl;
//     return 0;
// }
int main()
{
  long long n;
  cin >> n;
  long long* arr = new long long[n];
  for(int i=0;i<n;i++)
  {
    cin >> arr[i];
    arr[i]-=(i+1);
  }
  sort(arr,arr+n);
  long long sum =0;
  long long mid = arr[n/2];
  for(long long i=0;i<n;i++)
  {
    sum+=(max(arr[i],mid)-min(arr[i],mid));
  }
  cout<<sum<<endl;
  return 0;
}

// int main()
// {
//   int n;
//   cin >> n;
//   int * arr = new int[n];
//   int sum=0;
//   for(int i=0;i<n;i++)
//   {
//     cin >> arr[i];
//     sum+=arr[i];
//   }
//   int max = *max_element(arr,arr+n);
//   int res = (2*sum)/n;
//   if(res < max)
//   {
//     cout<<max<<endl;
//   }
//   else
//   {
//   cout<<((2*sum)/n)+1<<endl;
//   }
//   return 0;

// }

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define maxs(x,y) x = max(x, y)
#define mins(x,y) x = min(x, y)
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int N;
    cin >> N;
    
    vector<int> a(N);
    bool can = 0;
    REP(i, N) {
        cin >> a[i];
        if (a[i] == 1) can = 1;
    }
    
    if (!can) {
        cout << -1 << endl;
        return 0;
    } 

    int left = 1;
    int cnt = 0;
    for(int i = 0; i < N; i++) {
        if (a[i] == left) left++;
        else cnt++;
    }

    cout << cnt << endl;
    
    return 0;
}

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

long long pow1(long long a,long long b){
  long long ans=1;
  if(b==0){
    return 1;
  }
  else{
    for(long long i=0;i<b;i++){
      ans = a*ans;
      ans %= 1000000007;
    }
    return ans;
  }
}

int main()
{
	long long n;
	cin>>n;

	int ans = 0;
  bool check=false;
  int a[n];

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

  sort(a,a+n);

  if(n%2==1){ //奇数個(中央0)
    for(long long i=0;i<=n/2;i++){
      if(a[0]!=0){
        break;
      }
      if(i>0){
        if(a[i*2-1]!=i*2||a[i*2-1]!=a[i*2])
          break;
      }
      if(i==n/2){
        check=true;
      }
    }
  }
  else{
    for(long long i=0;i<n/2-1;i++){
      if(a[i*2]!=i*2+1||a[i*2]!=a[i*2+1]){
         break;
      }
      if(i==n/2-2){
        check=true;
      }
    }
  }
   ans=0;

	cout << (check?pow1(2,n/2)%(pow1(10,9)+7):0) << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <string>
#include <cstring>
#include <cctype>
#include <climits>
#include <cmath>
#include <set>
#include <map>
#include <unordered_set>
#include <sstream>
#include <queue>
#include <stack>
using namespace std;
typedef long long LL;

int main(){
	string s,t,temp,temp1,temp2;
	cin>>s>>t;
	for(int i=0;i<s.length();i++){
		if(s[i]==t[0]){
			temp1=s.substr(0,i);
			temp2=s.substr(i);
			temp=temp2+temp1;
			if(temp==t){
				printf("Yes\n");
				return 0;
			} 
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N,ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

const double PI = 3.14159265358979323846;

int main() {
	double W, H, x, y; cin >> W >> H >> x >> y;

	double m = W / 2.0, n = H / 2.0;
	if (x == m && y == n) {
		cout << setprecision(10) << W * H / 2.0 << endl;
		cout << 1 << endl;
	}
	else {
		cout << setprecision(10) << W * H / 2.0 << endl;
		cout << 0 << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define inf 1000000000000000000
#define bpc(x) __builtin_popcountll(x)
#define autoit(x,it) for(auto it = x.begin(); it != x.end(); it++)
#define rep(n) for(ll i = 0; i < n; i++)
#define repi(i,n) for(ll i = 0; i < n; i++)

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

int main()
{
   FAST/**/
   
   ll a,b,n;
   cin>>a>>b>>n;
   
   ll ans = min(n,b-1);
   ans = (ans*a)/b;
   cout<<ans;
   
   
   return 0;        
}  
  
   

Measured memory_bytes: 3648
import sys

# input処理を高速化する
input = sys.stdin.readline

# 入力
S = input()
T = input()

def chmax(a, b):
    if a >= b:
        return a
    else:
        return b


def lcs(s, t):
    dp = [[0 for i in range(len(T)+1)] for j in range(len(S)+1)]
    for i in range(len(S)):
        for j in range(len(T)):
            if S[i] == T[j]:
                dp[i+1][j+1] = chmax(dp[i+1][j+1], dp[i][j] + 1)
            dp[i+1][j+1] = chmax(dp[i+1][j+1], dp[i+1][j])
            dp[i+1][j+1] = chmax(dp[i+1][j+1], dp[i][j+1])

    ans = ''
    i = len(S)
    j = len(T)
    while (i>0  and j>0):
        if dp[i][j] == dp[i-1][j]:
            i -= 1
        elif dp[i][j] == dp[i][j-1]:
            j -= 1
        else:
            ans += s[i-1] 
            i -= 1
            j -= 1
    
    print(ans[::-1])

        
lcs(S, T)



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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
#define str(n) to_string(n)
#define int(w) stoi(w)
#define len(l) l.size()
#define append(l,i) l.push_back(i)
int main() {
    long x;
    cin>>x;
    if (x%11==0){
        cout<<(x/11)*2<<endl;
    }
    else if (x%11<=6){
        cout<<(x/11)*2+1<<endl;
    }
    else{
        cout<<(x/11)*2+2;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
ll a, b, c;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin >> a >> b >> c;
    if (4 * a * b < (c - a - b) * (c - a - b) && (c - a - b) > 0)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }
    cin >> a;
}

Measured memory_bytes: 256
import sys
s = input()
lst1 = list(s[::2])
lst2 = list(s[1::2])
for i in lst1:
    if i ==  "R" or i== "U" or i== "D":
        a = "Yes"
    else:
         a = "No"
         print(a)
         sys.exit()
for j in lst2:
    if j ==  "L" or j== "U" or j== "D":
        a = "Yes"
    else:
        a = "No"
        print(a)
        sys.exit()
print(a)         


Measured memory_bytes: 3064
#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 - 1;i >= 0;i--)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define ll long long
#define INF 1e9
int main()
{
    int i = 15;
    int a[5];
    int sum = 0;

    REP(i, 5) cin >> a[i];
    REP(i, 5) sum += a[i]; 
    cout << 15 - sum << endl;

    return 0;
}

Measured memory_bytes: 3632
/*
Author : Harsh AKA Codula
*/
#include<iostream>

using namespace std;

#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
#define deb(x) cout<<"["<<#x<<"="<<x<<"]"<<"\n";
#define FOR(a,b) for(ll i=a;i<b;++i)
#define read(x) for(auto& i:x)cin>>i
#define pb push_back

class MAIN
{
	public:
		void run()
		{
			ll t=1;//cin>>t;
			while(t--)
			{
 				string s;
 				cin>>s;
 				if(s[s.size()-1]=='s')
 				{
 					s+="es";
 				}
 				else
 				{
 					s+="s";
 				}
 				cout<<s;
				cout<<"\n";
			}
		}	
};

int main()
{
	fast;
	MAIN solution;
	solution.run();
	return 0;
}

Measured memory_bytes: 3656
n = int(input())
np = n % 10
if (np - 2)*(np - 4)*(np - 5)*(np - 7)*(np - 9) == 0:
    print('hon')
elif np*(np-1)*(np-6)*(np-8) == 0:
    print('pon')
else:
    print('bon')        


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

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

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

    int cnt, cnt1;
    cnt1 = 0;

    for(int i=0; i < 31; i++) {
        cnt = 0;
       for(int j=0; j < N; j++){
         if(A[j]%2 == 0){
             cnt++;
         }
      }
      if(cnt == N){
          cnt1++;
          for(int k=0; k<N; k++){
                A[k] = A[k] / 2; 
          }
          cnt = 0;
      }
      else
      {
          break;
      }
      
    }

    cout << cnt1 << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main()
{
    int n,k;
    string s;
    cin>>n>>k>>s;
    switch (s[k-1])
    {
    case 'A':
        s[k-1]='a';
        break;
    
    case 'B':
        s[k-1]='b';
        break;

    case 'C':
        s[k-1]='c';
        break;
    default:
        break;
    }

    cout<<s<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin>>s;
  int a = (s[0]-'0')*100+(s[1]-'0')*10+s[2]-'0';
  int ans = 100000;
  ans = min(ans, abs(a-753));
  for(int i=3;i<s.length();++i) {
    a %= 100;
    a *= 10;
    a += s[i]-'0';
    ans = min(ans, abs(a-753));
  }
  cout<<ans;
  return 0;
}

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

class Main{
	public static void main(String args[]) {

		BufferedReader bfr=new BufferedReader(new InputStreamReader(System.in));
		String str="";
		int[] syugo;
		StringTokenizer stk;

		int mae_y_s,mae_y_e=0;
		syugo=new int[1001];

		for(int i=0; i<1001; i++) {
			syugo[i]=0;
		}

		try {
			str=bfr.readLine();
			if(str=="") {
				System.exit(0);
			}
			stk=new StringTokenizer(str," ");
			int yoyaku_s,yoyaku_e=0;
			yoyaku_s=Integer.parseInt(stk.nextToken());
			yoyaku_e=Integer.parseInt(stk.nextToken());

			str=bfr.readLine();
			int yoyaku=Integer.parseInt(str);

			for(int i=0; i<yoyaku; i++) {
				str=bfr.readLine();
				if(str=="") {
					System.exit(0);
				}
				stk=new StringTokenizer(str," ");
				mae_y_s=Integer.parseInt(stk.nextToken());
				mae_y_e=Integer.parseInt(stk.nextToken());

				for(int j=mae_y_s; j<=mae_y_e-1; j++) {
					syugo[j]=1;
				}
			}

			for(int a=yoyaku_s; a<=yoyaku_e-1; a++) {
				if(syugo[a]==0) {
					// nanimo sinai
				}
				else {
					System.out.println("1");
					System.exit(0);
				}
			}
			System.out.println("0");

		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
	}
}


Measured memory_bytes: 24392
#include <stdio.h>
 
int main(void) {
  int h1, m1, h2, m2, k,ans;
  if(scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k)==1);
  ans = (h2-h1)*60 + (m2-m1) -k; 
  printf("%d", ans);
  return 0;
}


Measured memory_bytes: 1728
from collections import Counter

n=int(input())
s=[ input() for i in range(n)]
dick=Counter(s)
dick=dick.most_common()
#print(dick)
#print(dick.values())
p=dick[0][1]

s=[]
for k,i in dick:
  if i==p:
    s.append(k)
  else:
    break
ss=sorted(s)
for i in ss:
  print(i)

Measured memory_bytes: 45040
#include<bits/stdc++.h>
using namespace std;
const long long maxn=2e5+5;
const long long inf=0x3f3f3f3f;
long long x[maxn],y[maxn],ans;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	long long n;
	double d;
	cin>>n>>d;
	for(long long i=1;i<=n;i++)
	{
		cin>>x[i]>>y[i];
		double b=sqrt(x[i]*x[i]*1.0+y[i]*y[i]*1.0);
		if(b<=d)
			ans++;
	}
	cout<<ans<<endl;
	return 0;
}




Measured memory_bytes: 6880
#include <iostream>
#include <cstdio>
#include <complex>
#include <cmath>
#include <utility>
#include <algorithm>
#include <vector>
#define MAX 1000000
using namespace std;

double width(int X[], int Y[], int n, double x)
{
	double Min = MAX, Max = -MAX;
	for (int i = 0; i < n; i++)
	{
		double x1 = X[i+1], y1 = Y[i+1], x2 = X[(i + 1) % n + 1], y2 = Y[(i + 1) % n + 1];
		if ((x1-x)*(x2-x)<=0 && x1!=x2)
		{
			double y = y1 + (y2 - y1) * (x - x1) / (x2 - x1);
			Max = max(Max, y);
			Min = min(Min, y);
		}
	}
	if(Max <= Min)
		return 0.0;
	else
        return Max-Min;
}

double volume(int m, int n, int x1[], int y1[], int x2[], int z2[])
{
    int min1=x1[1],max1=x1[1],min2=x2[1],max2=x2[1];
    for(int i=0;i<m;i++)
    {
        if(min1>x1[i+1])
            min1 = x1[i+1];
        if(max1<x1[i+1])
            max1 = x1[i+1];
    }
    for(int i=0;i<n;i++)
    {
        if(min2>x2[i+1])
            min2 = x2[i+1];
        if(max2<x2[i+1])
            max2 = x2[i+1];
    }
    vector<int> X;
    for(int i=0;i<m;i++)
        X.push_back(x1[i+1]);
    for(int i=0;i<n;i++)
        X.push_back(x2[i+1]);
    sort(X.begin(), X.end());
    double total = 0.0;
    for(int i=0;i+1<m+n;i++)
    {
        double a = X[i];
        double b = X[i+1];
        double mm = (a+b)/2.0;
        if(min1<=mm && mm<=max1 && min2<=mm && mm<=max2)
        {
            double va = width(x1, y1, m, a) * width(x2, z2, n, a);
            double vb = width(x1, y1, m, b) * width(x2, z2, n, b);
            double vm = width(x1, y1, m, mm) * width(x2, z2, n, mm);
            total +=  (b-a)/6 * (va+4*vm+vb);
        }
    }
    return total;
}

int main()
{
	int m, n;
	int x1[110], y1[110], x2[110], z2[110];
	cin >> m >> n;
	while(m && n)
    {
        for (int i = 1; i <= m; i++)
            cin >> x1[i] >> y1[i];
        for (int i = 1; i <= n; i++)
            cin >> x2[i] >> z2[i];
        double total = volume(m, n, x1, y1, x2, z2);
        //cout << total << endl;
        printf("%.10f\n",total);
        cin >> m >> n;
    }
	return 0;
}


Measured memory_bytes: 3260
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <set>
#include <queue>
#include <stack>
#include <utility>
#include <stdio.h>
#include <unistd.h>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)
#define itrep(itr, base) for (auto itr = base.begin(); itr != base.end(); itr++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl
#define PI 3.14159265359

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const int mod = 1000000007;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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

int main() {
  int a, b;
  cin >> a >> b;
  P(a * b);
  return 0;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, p;
    string s;
    cin >> n >> p >> s;
    if ((p == 2) || (p == 5)) {
        vector<vector<ll>> dp(n + 1, vector<ll>(p, 0));
        rep(i, n) {
            rep(j, p) {
                ll v = (j * 10 + (s[i] - '0')) % p;
                dp[i + 1][v] += dp[i][j];
            }
            dp[i + 1][(s[i] - '0') % p]++;
        }
        ll ans = 0;
        rep(i, n) ans += dp[i + 1][0];
        cout << ans << endl;
    }
    else {
        reverse(all(s));
        vector<ll> dp(n + 1, 0);
        ll sur = 1;
        rep(i, n) {
            dp[i + 1] = (dp[i] + (sur * (s[i] - '0'))) % p;
            sur = (sur * 10) % p;
        }
        vector<vector<ll>> idx(p);
        rep(i, n) idx[dp[i + 1]].push_back(i + 1);
        ll ans = 0;
        rep(i, n) {
            ans += sz(idx[dp[i]]) - (upper_bound(all(idx[dp[i]]), i) - idx[dp[i]].begin());
        }
        cout << ans << endl;
    }
    return 0;
}


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

int main(){
    int N, C;
    std::cin >> N >> C;
    std::vector< std::vector< int > > D(C, std::vector< int >(C));
    std::vector< std::vector< int > > color(N, std::vector< int >(N));
    for(int i=0; i<C; i++){
        for(int j=0; j<C; j++){
            std::cin >> D[i][j];
        }
    }
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            std::cin >> color[i][j];
            color[i][j]--;
        }
    }
    
    std::vector< std::vector< int > > color_cost(C, std::vector< int >(3, 0));
    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            for(int k=0; k<C; k++){
                color_cost[k][(i+j)%3] += D[color[i][j]][k];
            }
        }
    }
    
    int min = 1e9;
    for(int i=0; i<C; i++){
        for(int j=0; j<C; j++){
            if(i == j){
                continue;
            }
            for(int k=0; k<C; k++){
                if(i == k || j == k){
                    continue;
                }
                int cur = color_cost[i][0] + color_cost[j][1] + color_cost[k][2];
                if(min > cur){
                    min = cur;
                }
            }
        }
    }
    
    std::cout << min << std::endl;
    
    
    return 0;
    
}


Measured memory_bytes: 4580
/*
 _    _    _______   _    _
| |  / /  |  _____| | |  / /
| | / /   | |       | | / /
| |/ /    | |_____  | |/ /
| |\ \    |  _____| | |\ \
| | \ \   | |       | | \ \
| |  \ \  | |_____  | |  \ \
|_|   \_\ |_______| |_|   \_\

*/
/*#include <iostream>
#include <cstdio>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <cstring>
#include <string>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <assert.h>*/

#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define right(x) x << 1 | 1
#define left(x) x << 1
#define forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)
#define mkp make_pair
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define y1 kekekek

const ll ool = 1e18 + 9;
const int oo = 1e9 + 9, base = 1e9 + 7;
const ld eps = 1e-7;
const int N = 2e6 + 6;

int n, a[N];

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

    cin >> n;
    forn(i, 1, n) {
        cin >> a[i];
    }

    sort(a + 1, a + n + 1);

    if (a[n] - a[1] > 1) {
        cout << "No\n";
        return 0;
    }

    if (a[n] == a[1]) {
        if (n >= 2 * a[1] || n == a[1] + 1) cout << "Yes\n";
        else cout << "No\n";
        return 0;
    }

    int pos = -1;
    forn(i, 1, n - 1) {
        if (a[i] != a[i + 1]) {
            pos = i;
            break;
        }
    }

    if (pos > a[n] - 1 || n - pos < (a[n] - pos) * 2 || a[n] - pos + pos - 1 != a[1]) cout << "No\n";
    else cout << "Yes\n";

	return 0;
}



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

int main(){
    ll n, a;
    while(1){
        cin >> n;
        if(n==0)break;
        ll sum = 0, ans = -LLINF, smin = 0;
        REP(i,n){
            cin >> a;
            sum += a;
            ans = max(ans, a);
            if(sum < smin){
                smin = sum;
            }
            else{
                ans = max(ans, sum-smin);
            }
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 2984
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef pair<int, int> P;
const int INF = 1 << 30;
struct edge {
	int to, cost;
};

edge es[800];
vector<edge> G[800];

int dp[800][2];

void dfs(int n, int prev) {
	int sum = 0;

	for(int i = 0; i < G[n].size(); i++) {
		int to = G[n][i].to;
		if(to == prev) continue;

		dfs(to, n);
		if(G[to].size() != 1) {
			sum += dp[to][1] + G[n][i].cost * 3;
		}
		else {
			sum += G[n][i].cost;
		}
	}

	int minc = sum;
	for(int i = 0; i < G[n].size(); i++) {
		int to = G[n][i].to;
		if(to == prev || G[to].size() == 1) continue;

		minc = min(minc, sum - dp[to][1] - G[n][i].cost + dp[to][0]);
	}

	dp[n][0] = minc;
	dp[n][1] = sum;
}


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

	int n;
	while(cin >> n, n) {
		for(int i = 0; i < n; i++) {
			G[i].clear();
		}

		for(int i = 0; i < n - 1; i++) {
			cin >> es[i].to;
			es[i].to--;
		}
		for(int i = 0; i < n - 1; i++) {
			cin >> es[i].cost;
		}
		for(int i = 0; i < n - 1; i++) {
			G[i + 1].push_back(es[i]);
			G[es[i].to].push_back(edge{ i + 1, es[i].cost });
		}

		int ans = INF;
		for(int i = 0; i < n; i++) {
			dfs(i, -1);
			ans = min(ans, dp[i][0]);
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 1396
N, X = map(int, input().split(" "))
i = 0
dough = []
count = N

while i < N:
    dough.append(int(input()))
    i += 1

# make at least one doughnut for each
excess = X - sum(dough)

while excess >= 0:
    excess -= min(dough)
    count += 1
print(count - 1)

Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main() {

	int cards[4][13];
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 13; j++) {
			cards[i][j] = 0;
		}
	}

	int n;
	cin >> n;
	for (int k = 0; k < n; k++) {
		int num;
		char m;
		cin >> m >> num;
		if (m == 'S') {
			cards[0][num-1] = 1;
		}
		if (m == 'H') {
			cards[1][num-1] = 1;
		}
		if (m == 'C') {
			cards[2][num-1] = 1;
		}
		if (m == 'D') {
			cards[3][num-1] = 1;
		}
	}

	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 13; j++) {
			if (cards[i][j] == 0) {
				if (i == 0) { cout << "S " << j+1 << endl; }
				if (i == 1) { cout << "H " << j+1 << endl; }
				if (i == 2) { cout << "C " << j+1 << endl; }
				if (i == 3) { cout << "D " << j+1 << endl; }
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3084
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new ABC124().SolveA(new ConsoleInput(Console.In, ' '));
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }

    public static class AtCoderLib
    {
        // ユークリッドの互除法 
        public static int Gcd(int a, int b)
        {
            if (a < b)
                // 引数を入替えて自分を呼び出す
                return Gcd(b, a);
            while (b != 0)
            {
                var remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }
    }
  class ABC124
    {
        public void SolveA(ConsoleInput cin)
        {
            var a = cin.ReadInt;
            var b = cin.ReadInt;
            if (a == b) WriteLine(a + b);
            else if (a > b) WriteLine(2 * a - 1);
            else WriteLine(2 * b - 1);
            ReadLine();
        }
    }
}


Measured memory_bytes: 11220
#include<stdio.h>

int main(){

      int kaisuu ;
      int N, X, T ;
      scanf("%d %d %d", &N, &X, &T) ;

      if ( N%X == 0 ) 
            kaisuu = N/X ;
      else
            kaisuu = N/X + 1 ;
      printf("%d", T * kaisuu ) ;
      
}

Measured memory_bytes: 1732
# coding: utf-8
# Your code here!

i = list(map(int, input().split()))

A_list = [1, 3, 5, 7, 8, 10, 12]
B_list = [4, 6, 9, 11]
C_list = [2]

if i[0] in A_list and i[1] in A_list:
    print("Yes")
elif i[0] in B_list and i[1] in B_list:
    print("Yes")
elif i[0] in C_list and i[1] in C_list:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <iostream>
#include<math.h>
#include<string>
#include<iomanip>
#include <limits>
#include<stdlib.h>
using namespace std;

int main()
{
string s; cin>>s;
for(int i=0;i<19;i++)
{
   if(s.at(i)==',') s.at(i)=' ';
}
cout<<s;
}


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

bool isSame(string a, string b) {
	for (int i = 0; i < a.size(); ++i) {
		if (a[i] != b[i] and a[i] != '?') {
			return false;
		}
	}
	return true;
}

string repl(string a, string b, int n) {
	for (int i = 0; i < b.size(); ++i) {
		a[n + i] = b[i];
	}
	return a;
}


signed main() {
	string s, t;
	cin >> s >> t;

	int N = s.size() - t.size() + 1;

	for (int i = N - 1; i >= 0; --i) {
		if (isSame(s.substr(i, t.size()), t)) {
			string ans = repl(s, t, i);
			replace(ans.begin(), ans.end(), '?', 'a');
			cout << ans << endl;
			return 0;
		}
	}
	cout << "UNRESTORABLE" << endl;
}

Measured memory_bytes: 256
import Data.Bits

main = do
  [a, b] <- map read.words <$> getLine :: IO [Int]
  print $ f a b
  
f :: Int -> Int -> Int
f a b = xor (f2 $ a - 1) (f2 b)
  
f2 :: Int -> Int
f2 n
  | m == 0 = n
  | m == 1 = 1
  | m == 2 = n + 1
  | m == 3 = 0
  where m = mod n 4

Measured memory_bytes: 508
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using vect=vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n;i>=0;i--)
#define Pool(i, m, n) for(ll i=n;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e
#define sum(v) accumulate(all(v), 0ll)
#define gcd(x,y) __gcd(x,y)
#define erase(s) s.erase(s.end()-1) //文字列sの末尾削除

ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
ll lcm(ll x,ll y){
  ll z=gcd(x,y);
  return x*y/z;
}
ll primejudge(ll n){
  if(n<2)return 0;
  else if(n==2)return 1;
  else if(n%2==0)return 0;
  double sqrtn=sqrt(n);
  Loop(i,3,sqrtn+1){
     if(n%i==0){
        return 0;
     }
     i++;
  }
  return 1;
}
int main() {
  cout << fixed << setprecision(30);
  ll n,a,b,c,d;
  cin5(n,a,b,c,d);
  string s;
  cin>>s;
  bool check=true;
  bool threecheck=false;
  ll count=0;
  ll dotcount=0;
  if(c<d){
    Loop(i,b-1,d){
      if(s[i]=='.')count=0;
      else count++;
      if(count>1)check=false;
    }
    Loop(i,a-1,c){
      if(s[i]=='.')count=0;
      else count++;
      if(count>1)check=false;
    }
    if(check)putout("Yes");
    else putout("No");
  }
  else{
       Loop(i,a-1,c){
      if(s[i]=='.')count=0;
      else count++;
      if(count>1)check=false;
      }
     Loop(i,b-2,d+1){
      if(s[i]=='#')dotcount=0;
      else dotcount++;
      if(dotcount>=3)threecheck=true;
      }
    if(check&&threecheck)putout("Yes");
    else putout("No");
  }
}


Measured memory_bytes: 640
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define ll long long
#define maxn 210
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static char buf[20],len; len=0;
	if(x<0)x=-x,putchar('-');
	for(;x;x/=10)buf[len++]=x%10+'0';
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]);
}
inline void writesp(ll x){write(x); putchar(' ');}
inline void writeln(ll x){write(x); putchar('\n');}
int a[maxn][maxn];
int n,m;
int check(int x,int y)
{
	int sum=0;
	for(int i=1;i<=m;i++)
		sum+=(a[x][i]-a[y][i])*(a[x][i]-a[y][i]);
	return fabs(sqrt(sum)-floor(sqrt(sum)))<1e-8;
}
int main()
{
	n=read(); m=read();
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			a[i][j]=read();
	int cnt=0;
	for(int i=1;i<n;i++)
		for(int j=i+1;j<=n;j++)
			cnt+=check(i,j);
	writeln(cnt);
	return 0;
}

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

int main() {
	ios::sync_with_stdio(0), cin.tie(0);
	string s;
	cin >> s;
	int sum = 0;
	for (auto i : s) sum = (sum + (i - '0')) % 9;
	cout << (sum == 0 ? "Yes" : "No") << endl;
}

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

using namespace std;

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

  vector<int> X(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i];
  }

  int ans = 100 * 100 * 100;
  for (int p = 1; p <= 100; p++) {
    int cost = 0;
    for (auto x: X) {
      cost += (x - p) * (x - p);
    }
    ans = min(ans, cost);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <map>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define eps 1e-7
#define inf 0x3f3f3f3f
#define mod 1000000007ll
using namespace std;

int main() {
	speed;
	int a, b, c;
	cin >> a >> b >> c;
	cout << min(c, b / a);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<iomanip>
#include <math.h>
using namespace std;

int main(){
    long long int a,b,c,d,q,w,e,r;
    cin>>a>>b>>c>>d;
    q=a*c;
    w=a*d;
    e=b*c;
    r=b*d;
    if(q<w){
        q=w;
    }
    if(e<r){
        e=r;
    }
    if(q<e){
        q=e;
    }
    cout<<q<<endl;
    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a;
	cin>>a;
	if(a==2)
	cout<<"1";
	else if(a%2==1&&a!=2)
	cout<<((a-1)/2)*((a+1)/2);
	else
	cout<<(a/2)*(a/2); 
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
    string S, T;
    cin >> S >> T;
    bool ans = false;
    for (int i = 0; i < S.size(); ++i) {
        if (S == T) {
            ans = true;
            break;
        }
        S = S.back() + S.substr(0, S.size() - 1);
    }
    if (ans) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#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>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define int long long
#define endl "\n"
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define fr(a,b,c) for(int a=b; a<c; a++)
#define frr(a,b,c) for(int a=b;a>=c;a--)
#define pb push_back
#define pii pair<int,int>
#define R(a) ll a; cin >> a;
#define RS(a) string  a; cin >> a;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;

#define RA(a, n) ll a[(n) + 1] = {}; fr(i, 1, (n)+1) {cin >> a[i];}
#define RM(a, n, m) int a[n + 1][m + 1] = {}; fr(i, 1, n+1) {fr(j, 1, m+1) cin >> a[i][j];}
#define reset(X) memset(X, 0, sizeof(X))
using vi=vector<int>;
const int inf = 1e18;
const int mod=1e9+7;
unsigned int power(int x, unsigned int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}
bool isPrime(int n)
{   if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
    return true;
}
int modInverse(int n, int p)
{
    return power(n, p-2, p);
}
signed main()
{
    fastio;
    R(n);
    RA(a,n);
    int ans=0;
    sort(a+1,a+n+1);
    for(int i=1;i<=n;i++)
    {
        for(int j=i+1;j<=n;j++)
        {
            for(int k=j+1;k<=n;k++)
            {
                if(a[i]+a[j]>a[k]&&a[i]!=a[j]&&a[j]!=a[k])
                {
                   // cout<<i<<" "<<j<<" "<<k<<endl;
                    ans+=1;
                }
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3624
#include <iostream>

using namespace std;

int main() {
  long long n = 0;
  cin >> n;
  for (long long i=1; i<=3500; i++) {
    for (long long j=1; j<=3500; j++) {
      if (4*i*j-n*i-n*j == 0) continue;
      double k = n*i*j/(double)(4*i*j-n*i-n*j);
      if (k == (long long)k && k > 0) {
        cout << i << " " << j << " " << (long long)k << endl;
        return 0;
      }
    }
  }
}


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

int main(int argc, char *argv[]) {
  string s;
  cin >> s;

  char c = '\0';
  for (int i = 0; i < s.size(); ++i) {
    if (c == s[i]) {
      cout << "Bad" << endl;
      return 0;
    }
    c = s[i];
  }
  cout << "Good" << endl;
  
  return 0;
}

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

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi std::vector<int>
#define vvi std::vector<std::vector<int> >
#define vpi std::vector<pi >
#define pi std::pair<int,int>
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (int var = (from); var <= ((int)(to)); var++)
#define DOWNTO(var, from, to) for (int var = (from); var >= ((int)(to)); var--)
#define FOR(var, to)		  UPTO(var, 0, (to)-1)
#define DOWN(var, from)	   DOWNTO(var, (from)-1, 0)

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) std::cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) std::cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

static const int MOD = 1000000007;
static const int INF = ((1<<30)-1);
static const s64 LINF = ((1LL << 62)-1);

struct Comb {
	std::vector<std::vector<s64> > a;
	Comb(int n) { // O(n^2)
		a.resize(n+1);
		FOR(i,n+1) {
			a[i].resize(i+1, 1);
			UPTO(j,1,i-1) a[i][j] = a[i-1][j] + a[i-1][j];
		}
	}
	s64 ncr(int n, int r) {
		assert(n >= 0);
		assert(n <= (int)a.size());
		assert(r >= 0);
		assert(r <= n);
		return a[n][r];
	}
};

#define gc(c) (c)=getchar()
int ri() {
	int c,s=0,r=0;
	for(;;){gc(c);if(c=='-'){s=1;break;}if(c>='0'&&c<='9'){r=c-'0';break;}}
	for(;;){gc(c);if(c<'0'||c>'9')break;r*=10;r+=c-'0';}
	if(s)r=-r;
	return r;
}
s64 rs64() {
	s64 r = 0;
	int c,s = 0;
	for(;;){gc(c);if(c=='-'){s=1;break;}if(c>='0'&&c<='9'){r=c-'0';break;}}
	for(;;){gc(c);if(c<'0'||c>'9')break;r*=10;r+=c-'0';}
	if(s)r=-r;
	return r;
}

int int_less(const void *a, const void *b) {
	return (*(const int*)a - *(const int*)b);
}
int int_greater(const void *a, const void *b) {
	return (*(const int*)b - *(const int*)a);
}
std::string operator*(const std::string &s, int n){ std::string res; FOR(i,n) res += s; return res; }

template<class T> std::ostream& operator<<(std::ostream& os, std::vector<T> a) { for (auto i : a) os << i << " "; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, std::set<T> a) { for (auto i : a) os << i << " "; return os; }
template<class A, class B> std::ostream& operator<<(std::ostream&os, std::pair<A,B> a) { os << a.fi << "," << a.se; return os; }


int main() {
	int n = ri();
	std::cout << n - ri() + 1 << std::endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
inline int in(){int x;scanf("%lld",&x);return x;}
int32_t main()
{
	int n=in();int m=in();int k=in();
	vector<int> pa(n+1),pb(m+1);int x;
	for(int i=1;i<=n;i++)
	{
		x=in();pa[i]=pa[i-1]+x;
	}
	for(int i=1;i<=m;i++)
	{
		x=in();pb[i]=pb[i-1]+x;
	}
	
	int ans=0;
	for(int i=0;i<=n;i++)
	{
		int cur=pa[i];
		if((k-cur)<0)break;
		int it=upper_bound(pb.begin(),pb.end(),k-cur)-pb.begin();
		ans=max(ans,it+i-1);
	}
	cout<<ans;
	
}

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

int main(void){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int a[1<<n];
    for(int i=0; i<1<<n; i++){
    	cin>>a[i];
	}
	ll f[1<<n][2];
	for(int i = 0; i<(1<<n); ++i){
		f[i][0] = a[i];
		f[i][1] = 0;
	}
	for(int i = 0;i < n; ++i) for(int mask = 0; mask < (1<<n); ++mask){
		if(mask & (1<<i)){
			int indx = mask^(1<<i);
			ll tmp[] = {f[mask][0], f[mask][1], f[indx][0], f[indx][1]};
			sort(tmp, tmp+4);
			f[mask][0] = tmp[3];
			f[mask][1] = tmp[2];
			
			/*if(f[mask][0]<=f[indx][0]){
				f[mask][1] = f[mask][0];
				f[mask][0] = f[indx][0];
				if(f[mask][1]<f[indx][1]){
				f[mask][1] = f[indx][1];
			}
			}else if(f[mask][1]<f[indx][0]){
				f[mask][1] = f[indx][1];
			}*/
		}
	}
	ll vals[1<<n];
	for(int i=0; i<1<<n; i++){
		vals[i] = f[i][0]+f[i][1];
	}
	ll ans[1<<n], mx = 0;
	for(int i=1; i<1<<n; i++){
		ans[i] = max(mx, vals[i]);
		mx = ans[i];
		cout<<ans[i]<<'\n';
	}
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const double EPS = 1e-8;
const double PI = acos(-1);
const int N = 110;
int _w;

int dcmp( double x ) {
	if( fabs(x) < EPS ) return 0;
	return x < 0 ? -1 : 1;
}

struct Point {
	double x, y;
	Point() {}
	Point( double x, double y ):
		x(x), y(y) {}
	Point operator+( const Point &rhs ) const {
		return Point( x+rhs.x, y+rhs.y );
	}
	Point operator-( const Point &rhs ) const {
		return Point( x-rhs.x, y-rhs.y );
	}
	Point operator*( double rhs ) const {
		return Point( x*rhs, y*rhs );
	}
	Point operator/( double rhs ) const {
		return Point( x/rhs, y/rhs );
	}
	bool operator==( const Point &rhs ) const {
		return dcmp(x-rhs.x) == 0 && dcmp(y-rhs.y) == 0;
	}
	bool operator<( const Point &rhs ) const {
		if( dcmp(x-rhs.x) == 0 )
			return y < rhs.y;
		return x < rhs.x;
	}
};
typedef Point Vector;

double Cross( Vector v, Vector w ) {
	return v.x * w.y - v.y * w.x;
}
double Dot( Vector v, Vector w ) {
	return v.x * w.x + v.y * w.y;
}
double Length( Vector v ) {
	return sqrt(v.x * v.x + v.y * v.y);
}
double Angel( Vector v, Vector w ) {
	return acos(Dot(v, w) / Length(v) / Length(w));
}

int n, m;
Point P[N], Q[N], t[N];

void ConvexHull() {
	for( int i = 0; i < n; ++i )
		t[i] = P[i];
	sort(t, t+n), m = 0;
	for( int i = 0; i < n; ++i ) {
		while( m > 1 && Cross( Q[m-1]-Q[m-2], t[i]-Q[m-2] ) <= 0 ) --m;
		Q[m++] = t[i];
	}
	int k = m;
	for( int i = n-2; i >= 0; --i ) {
		while( m > k && Cross( Q[m-1]-Q[m-2], t[i]-Q[m-2] ) <= 0 ) --m;
		Q[m++] = t[i];
	}
	--m;
}

bool query0( Point P ) {
	for( int i = 0; i < m; ++i )
		if( P == Q[i] )
			return true;
	return false;
}
void solve0() {
	for( int i = 0; i < n; ++i )
		if( query0( P[i] ) )
			puts("0.5");
		else puts("0");
}

double query( Point P ) {
	for( int i = 0; i < m; ++i )
		if( P == Q[i] ) {
			Point A = Q[(i+1)%m];
			Point B = Q[(i-1+m)%m];
			double ang = PI - Angel(A-P, B-P);
			return ang/PI/2;
		}
	return 0;
}
void solve() {
	for( int i = 0; i < n; ++i )
		printf( "%.10lf\n", query( P[i] ) );
}

int main() {
	cin >> n;
	for( int i = 0; i < n; ++i )
		cin >> P[i].x >> P[i].y;
	ConvexHull();
	if( m == 2 ) solve0();
	else solve();
	return 0;
}


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

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

int main()
{
    long long N;
    cin >> N;
    for (long long h = 1; h <= 3500; h++) {
        for (long long n = 1; n <= 3500; n++) {
            if (4 * h * n - N * (h + n) > 0 && N * h * n > 4 * h * n - N * (h + n) && (N * h * n) % (4 * h * n - N * (h + n)) == 0) {
                long long w = (N * h * n) / (4 * h * n - N * (h + n));
                cout << h << " " << n << " " << w << endl;
                return 0;
            }
        }
    }

    return 0;
}

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

#define max(a,b) ((a>b)?(a):(b))
#define min(a,b) ((a<b)?(a):(b))

int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  for(int i=0;i<n;i++){
    cin >> p[i];
    p[i]--;
  }
  vector<int> a(n,0),b(n,0);
  for(int i=0;i<n;i++){
    if(p[i]<n-1){
      a[p[i]+1]+=n-i;
    }
    if(p[i]>0){
      b[p[i]-1]+=n-i;
    }
  }
  for(int i=1;i<n;i++){
    a[i]+=a[i-1];
    b[n-i-1]+=b[n-i];
  }
  for(int i=0;i<n;i++){
    a[i]++;
    cout << a[i] << " ";
  }
  cout << endl;
  for(int i=0;i<n;i++){
    b[i]++;
    cout << b[i] << " ";
  }
  cout << endl;
  return 0;
}


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

using namespace std;

#define all(x) (x).begin(), (x).end()

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;

void solve()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    string s;
    cin >> s;
    vector<ll> basis(64, -1);
    for (int i = n - 1; i >= 0; i--)
    {
        if (s[i] == '0')
        {
            ll x = a[i];
            for (int j = 60; j >= 0; j--)
            {
                if (x & (1ll << j))
                {
                    if (basis[j] == -1)
                    {
                        basis[j] = x;
                        break;
                    }
                    else
                    {
                        x ^= basis[j];
                    }
                }
            }
        }
        else
        {
            ll x = a[i];
            int t = 0;
            for (int j = 60; j >= 0; j--)
            {
                if (x & (1ll << j))
                {
                    if (basis[j] == -1)
                    {
                        t = 1;
                        break;
                    }
                    else
                    {
                        x ^= basis[j];
                    }
                }
            }
            if (t == 1)
            {
                cout << 1 << "\n";
                return;
            }
        }
    }
    cout << 0 << "\n";
}

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        solve();
    }
}

/*

*/


Measured memory_bytes: 3608
#include<iostream>
#include<cstdio>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<cassert>
#define pb push_back
#define F first
#define S second
#define INF (1<<26)
#define all(n) n.begin(),n.end()
#define insert(a,b,c,d) PP(P(a,b),P(c,d))
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
static const int dx[4] = {0,1,0,-1};
static const int dy[4] = {-1,0,1,0};
int w,h;
int imap[30][30];
int c[4],d[30][30][5];
typedef pair<int,int> P;
typedef pair<P,P> PP;

int get_dir(int x,int y){
  if(y == 0){
    return x;
  }
  else if(y == 1){
    return (x+1)%4;
  }
  else if(y == 2){
    return (x+2)%4;
  }
  else if(y == 3){
    return (x+3)%4;
  }
  else if(y == 4){
    return -1;
  }
 
  assert(true);
}

int get_c_index(int x,int y){
  if(x == y)return 0;
  if((x+1)%4 == y)return 1;
  if((x+2)%4 == y)return 2;
  if((x+3)%4 == y)return 3;
  assert(true);
}


int main(){

  while(true){
    scanf("%d %d",&w,&h);
    if(w+h == 0)break;
    rep(i,h)rep(j,w)rep(k,5)d[i][j][k] = INF;
    rep(i,h)rep(j,w)scanf("%d",&imap[i][j]);
 
    scanf("%d %d %d %d",&c[0],&c[1],&c[2],&c[3]);
   
    int men = INF;
    queue<PP> que;
    que.push(insert(0,0,1,0));
    d[0][0][4] = 0;

    while(!que.empty() ){
      PP pp = que.front(); que.pop();

    if(pp.F.F == w-1 && pp.F.S == h-1){
	men = min(men,pp.S.S);
	continue;
      }
      if(men <= pp.S.S)continue;
      
      int dir = get_dir(pp.S.F,imap[pp.F.S][pp.F.F]);
      //cout <<"---------- " << "pp = " << pp.F.F << "," << pp.F.S << endl;
      rep(i,4){
	int nx = pp.F.F+dx[i],ny = pp.F.S+dy[i];
	if(!(0<=nx && nx<w && 0<=ny && ny<h))continue;

	// cout << "nx = "<< nx << ", ny = " << ny <<", pp.S.S = " <<pp.S.S <<",pp.S.S+c["<<i<<"] = " << pp.S.S+c[i] << endl;
	if(dir == i){

	  if(d[ny][nx][i] > pp.S.S){
	    d[ny][nx][i] = pp.S.S;
	    que.push(insert(nx,ny,i,pp.S.S));
	  }
	}
	else{
	  int ind = get_c_index(pp.S.F,i); 
	
	  if(d[ny][nx][i] > pp.S.S+c[ind]){
	    d[ny][nx][i] = pp.S.S+c[ind];
	    que.push(insert(nx,ny,i,pp.S.S+c[ind]));
	  }
	}
      }

    }




    //  int mine = INF;
    //rep(i,4)mine = min(d[h-1][w-1][i],mine);
	cout << men << endl;

  }
  return 0;
}

Measured memory_bytes: 1384