akhauriyash/Code-Regression huggingface dataset:
using Yorukatsu050.Questions;
using Yorukatsu050.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Yorukatsu050.Questions
{
    /// <summary>
    /// https://atcoder.jp/contests/abc133/tasks/abc133_d
    /// </summary>
    public class QuestionD : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var n = inputStream.ReadInt();
            var dams = inputStream.ReadIntArray();
            var rains = new int[dams.Length];

            for (int i = 0; i < dams.Length; i++)
            {
                rains[0] += (i % 2 == 0 ? 1 : -1) * dams[i];
            }

            for (int i = 1; i < rains.Length; i++)
            {
                rains[i] = 2 * dams[i - 1] - rains[i - 1];
            }

            yield return string.Join(" ", rains);
        }
    }
}


namespace Yorukatsu050
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionD();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace Yorukatsu050.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace Yorukatsu050.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 32092
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a < b) for(int i=0;i<b;i++) System.out.print(a);
        else for(int i=0;i<a;i++) System.out.print(b);
        System.out.println();
    }
}


Measured memory_bytes: 20692
from math import ceil
vals=list(map(int, input().split()))
cnt=0
vals.sort(reverse=True)
cnt += vals[0] - vals[1]
diffmaxmin = vals[0] - (vals[2] + cnt)
if diffmaxmin % 2 == 0:
    cnt += diffmaxmin/2
else:
    cnt += ceil(diffmaxmin/2) + 1

print(int(cnt))


Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        double l;
        double n,m;
        
        l = sc.nextInt();
        
        n = l / 3;
        
        m = l - n - n;
        
        System.out.println(n * n * m);
    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int dp[200000];
int w[200],v[200];

int main(){
	int n,W;scanf("%d%d",&n,&W);
	rep(i,n){
		scanf("%d%d",&w[i],&v[i]);
	}
	memset(dp,0x3f,sizeof(dp));
	dp[0]=0;
	rep(i,n){
		for(int j=100000;j>=0;j--){
			if(j>=v[i]){
				dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
			}
		}
	}
	int id=-1;
	rep(j,100001){
		if(dp[j]<=W)id=j;
	}
	cout<<id<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define mo 1000000007
#define ny 499122177
#define maxn 1000000000000000000LL
#define pi 3.1415926535898
#define eps 1e-9 
using namespace std;
long long read(){
    long long xx=0,flagg=1; 
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
long long n,i,j,x[105],y[105],max1,max2,min1,min2,sum[105],sum2[105];
long long top,nex[205],to[205],fir[105];
void lj(int u,int v){
	top++;
	nex[top]=fir[u];
	fir[u]=top;
	to[top]=v;
}
void ss(int u,int v,long long w){
	max1=max(max1,w);
	sum[v]=0;
	for(int top1=fir[v];top1;top1=nex[top1])
		if(to[top1]!=u){
			sum[v]++;
			ss(v,to[top1],w+1);
		}
	sum2[w]=max(sum2[w],sum[v]);
}
int main(){
//	freopen("number.in","r",stdin);
//	freopen("number.out","w",stdout);
	n=read();
	for(i=1;i<n;i++){
		x[i]=read();y[i]=read();
		lj(x[i],y[i]);
		lj(y[i],x[i]);
	}
	min1=n+1;
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			sum[j]=0;
			sum2[j]=0;
		}
		max1=0;
		ss(i,i,1);
		max2=1;
		for(j=1;j<=n;j++)
			max2=max2*max(1LL,sum2[j]);
		if(max1<min1||max1==min1&&max2<min2){
			min1=max1;
			min2=max2;
		}
	}
	for(i=1;i<n;i++){
		for(j=1;j<=n;j++){
			sum[j]=0;
			sum2[j]=0;
		}
		max1=0;
		ss(x[i],y[i],1);
		ss(y[i],x[i],1);
		max2=2;
		for(j=1;j<=n;j++)
			max2=max2*max(1LL,sum2[j]);
		if(max1<min1||max1==min1&&max2<min2){
			min1=max1;
			min2=max2;
		}
	}
	pus(min1,1);
	pus(min2,2);
  	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int w,a,b;
	cin>>w>>a>>b;
	if(a<b){
		if(b<=a+w)cout<<0<<endl;
		else cout<<b-a-w<<endl;
	}else{
		if(a<=b+w)cout<<0<<endl;
		else cout<<a-b-w<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())

i = 0
ac = 0
wa = 0
tle = 0
re = 0

for i in range(n):
    s = input()
    if s == "AC":
        ac += 1
    elif s == "TLE":
        tle += 1
    elif s == "WA":
        wa += 1
    else:
        re += 1
    i += 1

print("AC x %s" %(ac))
print("WA x %s" %(wa))
print("TLE x %s" %(tle))
print("RE x %s" %(re))


Measured memory_bytes: 9192
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long INF=1LL<<60;
//set<int>::iterator it;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int i,n,x,ans=0;
	cin>>n>>x;
	int m[n];
	for(i=0;i<n;i++)cin>>m[i];
	for(i=0;i<n;i++)x-=m[i];
	sort(m,m+n);
	ans+=x/m[0];
	ans+=n;
	cout<<ans<<endl;
	
	
	
	
	
	return 0;
}

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

ll solve() {
    ll X;
    cin >> X;
    if ( X >= 2100 ) return 1;
    ll N = 2100;
    vector<int> dp(N+1);
    dp[0] = 1;
    for ( int i = 0; i < 6; i++ ) {
        for ( int j = 0; j * (100+i) <= N; j++ ) {
            for ( int k = N; k >= 0; k-- ) {
                if (k-(j * (100+i)) >= 0)  {
                    dp[k] = max(dp[k], dp[k-(j * (100+i))]);
                }
            }
        }
    }
    ll ans = dp[X];
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n, m;
  cin >> n >> m;
  cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int[] alphabet = new int[26];       //配列alphabet

        //入力の繰り返し
        while (scan.hasNext()) {
            String s = scan.nextLine();

            //文字列の長さ分繰り返す
            for (int i=0; i<s.length(); i++) {
                char c = s.charAt(i);           //文字列を１文字ずつ

                //小文字、大文字によってインデックスを算出
                if ('a'<=c && c<='z') {
                    alphabet[c-97]++;
                }else if ('A'<=c && c<='Z') {
                    alphabet[c-65]++;
                }

            }
        }

        //alphabetの出力
        for (int i=0; i<26; i++) {
            System.out.println((char)(i+97)+" : "+alphabet[i]);     //intをcharにキャストしアルファベットに変換
        }

    }
}


Measured memory_bytes: 26296
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


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;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n,a;
  cin>>n>>a;
  vector<ll> v(a);
  rep(i,a) cin>>v[i];
  ll ans=Svec(v);
  if(ans>=n) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007

using namespace std;

long long N, A;


long long calpow(long long a, long long b){
	if(a == 0){
		return 0;
	}
	long long ret = 1;
	for(int i = 0; i < b; i++){
		if(ret > N/a){
			return N + 1;
		}
		ret *= a;
	}
	return ret;
}

//num: eat times
long long cal(int num){
	num++;
	long long s = -1;
	long long e = LONG_MAX/3;

	while(s+1 < e){
		long long m = (s+e)/2;
		if(N <= calpow(m, num)){
			e = m;
		}else{
			s = m;
		}
	}

	//e is ok
	//how many e - 1
	long long rep = 0;
	for(int i = num; i >= 0; i--){
		if(pow(e, num - i) * pow(e-1, i) >= N){
			rep = i;
			break;
		}
	}

	return rep * (e-1) + (num - rep) * e;

}


int main(){
	cin >> N >> A;
	long long ans = LONG_MAX/3;
	for(int i = 0; pow(2, i) <= N; i++){
		ans = min(ans, i*A + cal(i));
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
question_count = gets.to_i
question_levels = gets.split.map(&:to_i)

question_count_half = question_count/2
question_sorted_levels = question_levels.sort


if question_sorted_levels[question_count_half] == question_sorted_levels[question_count_half - 1]
  p 0
else
  p question_sorted_levels[question_count_half] - question_sorted_levels[question_count_half - 1]
end


Measured memory_bytes: 9712
import java.util.Scanner;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(a < b){
      System.out.println("a < b");
    }else if(a == b){
      System.out.println("a == b");
    }else {
      System.out.println("a > b");
    }
  }
}


Measured memory_bytes: 26408
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N=0;
    int M=0;
    int douro=0;
    cin >> N >> M;
    M = M*2;
    vector<int> toshi(N+1);
    for(int i=1;i<=M;i++){
        cin >> douro;
        toshi[douro]++;
    }
    for(int i=1;i<=N;i++){
        cout << toshi[i] << endl;
    }
}


Measured memory_bytes: 3636
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
template<class T> void 
debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int n;
int ar[100005];
int dp[100005][3];
int main(){
  cin>>n;
  lint res=0;
  REP(i,n){
    cin>>ar[i];
    if(ar[i]&1){
      res+=(ar[i]-1)/2;
      ar[i]=1;
    }
    else if(ar[i]==0) ;
    else {
      res+=ar[i]/2-1,
      ar[i]=2;
    }
  }
  memset(dp,-1,sizeof(dp));
  dp[0][ar[0]]=0;
  REP(i,n) REP(j,3) if(dp[i][j]!=-1){
    int val=dp[i][j];
    if(j==2) chmax(dp[i+1][ar[i+1]],val+1);
    if(j>0 && ar[i+1]>0) chmax(dp[i+1][ar[i+1]-1],val+1);
    chmax(dp[i+1][ar[i+1]],val);
  }
  lint ans=dp[n][0]+res;
  cout<<ans<<endl;
  return 0;
}





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

#define inf 1e18
#define mod 1000000007

#define for0(i, n) for (ll i = 0; i < (ll)(n); ++i) // 0 based indexing
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i) // 1 based indexing
#define forc(i, l, r) for (ll i = (ll)(l); i <= (ll)(r); ++i) // closed interver from l to r r inclusive
#define forr0(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i) // reverse 0 based.
#define forr1(i, n) for (ll i = (ll)(n); i >= 1; --i) // reverse 1 based

#define tc ll T;cin >> T;while(T--)

#define ff first
#define ss second
#define pb push_back

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll h,w;
	cin >> h >> w;
	char grid[h][w];
	ll ans[h][w];
	for0(i,h){
		for0(j,w){
			ans[i][j] = 0;
			ans[0][0] = 1;
			cin >> grid[i][j]; 
			if(grid[i][j] == '.'){
				// ans[i][j]--;
				if(i > 0){
					ans[i][j] += ans[i-1][j];
					ans[i][j] %= mod;
				}
				if(j > 0){
					ans[i][j] += ans[i][j-1];
					ans[i][j] %= mod;
				}
				// if(ans[i][j] > 1){
				// 	ans[i][j]--;
				// }
			}
			else{
				ans[i][j] = 0;
			}
		}
	}
	// for0(i,h){
	// 	for0(j,w){
	// 		cout << ans[i][j]<<" " ;
	// 	}
	// 	cout << endl;
	// }
	cout << ans[h-1][w-1]%mod << endl;

	return 0;
}


Measured memory_bytes: 9088
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<map>
#include<stack>
#include<queue>
#include<vector>
#include<ctime>
//#include<Windows.h>
using namespace std;
#define ll long long int
#define LL ll
#define INF 0x3f3f3f3f
const int maxn = 1e5 + 10;
const int maxm = 1e2 + 10;
const double eps = 1e-8;
int sz = 0;
int n, m, p, q, T;
int a[maxn];
int fa[maxn];
int vis[maxn];
int head[maxn];
struct edge {
	int to, nx;
	int w;
}e[maxn];
void add(int u, int v) {
	e[++sz].to = v;
	e[sz].nx = head[u];
	head[u] = sz;
}
void addw(int u, int v, int w) {
	e[++sz].to = v;
	e[sz].w = w;
	e[sz].nx = head[u];
	head[u] = sz;
}
void init();
int _find(int x) {
	if (fa[x] == x) return x;
	else return _find(fa[x]);
}
int get_fri(int x, int y) {
	int xx = _find(x);
	int yy = _find(y);
	if (xx == yy) return 0;
	else fa[xx] = yy;
	return 1;
}

int main()
{
	LL ans = 0;
	cin >> n;
	ans = n * 180 - 360;
	cout << ans << endl;
	//system("pause");
	return 0;
}


//_CRT_SECURE_NO_WARNINGS
void init() {
	for (int i = 1; i < maxn; i++) {
		fa[i] = i;
	}
	memset(vis, 0, sizeof vis);
	memset(head, -1, sizeof head); sz = 0;
}

Measured memory_bytes: 256
/*
Author :: Shourov Chowdhury
............SUST_MATH14..........
*/
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <set>
#include <string>
#include <vector>

#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define II() ( { int a ; read(a) ; a; } )
#define LL() ( { Long a ; read(a) ; a; } )
#define DD() ({double a; scanf("%lf", &a); a;})
#define DB if(0) 
#define D(x) cout << #x " is " << x << endl
#define FI freopen ("input.txt", "r", stdin)
#define FO freopen ("output.txt", "w", stdout)

using namespace std;

typedef long long Long;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int, int> PII;
typedef vector<PII> VII;
typedef vector<string> VS;

template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }

//Fast Reader
template<class T>inline bool read(T &x){
    int c=getchar();int sgn=1;
    while(~c&&c<'0'||c>'9'){if(c=='-')sgn=-1;c=getchar();}
    for(x=0;~c&&'0'<=c&&c<='9';c=getchar())x=x*10+c-'0'; 
    x*=sgn; return ~c;
}

const int INF = 2000000009;
const int MX = 100005;
const double EPS = 1e-9;
const int MOD = 1000000007;

/**********************Code starts here*********************************/


int main()
{
    //std::ios_base::sync_with_stdio(false);

    int n = II(),x=II(),y=II();
    int mx = min(x,y);
    y = n-y+1;
    int mn = 0;
    if (y<=x) mn = x-y+1;
    printf("%d %d\n",mx,mn );

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<pair<int,int>> a(n),c(n);
  for(int i=0;i<n;i++){
    cin >> a[i].second >> a[i].first;
  }
  for(int i=0;i<n;i++){
    cin >> c[i].first >> c[i].second;
  }
  sort(a.begin(),a.end(),greater<pair<int,int>>());
  sort(c.begin(),c.end());
  int cnt=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(a[i].second<c[j].first&&a[i].first<c[j].second){
        cnt++;
        c[j]=make_pair(-1,-1);
        break;
      }
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
a = list(map(int, input().split()))
a_counter = Counter(a)

ans = 0

if N == 1 and a[0] != 1:
    print(1)
    exit()
elif N == 1 and a[0] == 1:
    print(0)
    exit()


for i in (a_counter.items()):
    key = (i[0])
    value = (i[1])

    if key == value:
        pass
    
    elif key < value:
        ans = ans + (value - key)
    else:
        ans = ans + (value) 

print(ans)

Measured memory_bytes: 22336
S = list(input())
N, = list(map(int,input().split()))

ans = 1
num_1 = 0

for i in range(len(S)):
    if  not S[i] == '1':
        ans = int(S[i])
        break
    else:
        num_1 += 1

if  len(S) == 1:
    ans = int(S[0])
if  num_1 >= N:
    ans = 1
        
print(ans)


Measured memory_bytes: 3060
n = int(input())
r_list = [0] * n
for i in range(1, n+1):
	t = i
	while True:
		if t % 2 != 0:
			break
		else:
			t = t // 2
			r_list[i-1] += 1
max_r = max(r_list)
r_list.reverse()
n_list = [i for i in range(1, n+1)]
n_list.reverse()
r = 0
for i, v in enumerate(r_list):
	if v == max_r:
		r = n_list[i]
print(r)
	  

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

int main(){
  int N,K,Q;
  cin>>N>>K>>Q;
  vector<int> A(Q),score(N,K);
  int zero=0;
  for(int i=0;i<Q;i++){
    cin>>A.at(i);
    A.at(i)--;
    score.at(A.at(i))++;
    zero++;
  }
  for(int i=0;i<N;i++){
    if(score.at(i)>zero){
      cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
  }
}


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

int main() {
    string S;
    cin >> S;
    int N = S.length();

    for (int i = 0; i < N; i++) {
        if (i + 1 < N && S.substr(i, 2) == "hi") {
            i++;
        } else {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
//-------------
//include
//-------------
#include <map>
#include <list>
#include <cmath>
#include <vector>
#include <string>
#include <cctype>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
//-------------
//typedef
//-------------
typedef  long long LL;
typedef  vector<int> VI;
typedef  vector<double> VD;
typedef  string STR;
typedef  pair<int, int> PII;
typedef  vector<int, int> VII;
typedef  map<string, int> MSI;
//-------------
//utillty
//-------------
#define ALL(a)  (a).begin(),(a).end()
#define MK make_pair
#define PB push_back
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define COUT(a) cout<<a<<endl
#define POW2(a) pow(a, 2.0)
//-------------
//repetition
//-------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//-------------
//debug
//-------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumpl(c) REP(i,SZ(c))cerr<<#c<<i<<"="<<(c[i])<<endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const int MOD = 1000000007;
int main()
{
	map<string, int> mp;
	mp["A"] = 1;
	mp["B"] = 2;
	mp["C"] = 3;
	mp["D"] = 4;
	mp["E"] = 5;
	mp["F"] = 6;
	string a, b;
	cin >> a >> b;
	if (mp[a]<mp[b])
	{
		COUT("<");
	}
	else if (mp[a]>mp[b])
	{
		COUT(">");
	}
	else
	{
		COUT("=");
	}
#ifdef _DEBUG
	while(1);
#endif // _DEBUG

	return 0;
}

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

int three(int a, int b, int c)
{
  int min, max;
  if (a > b && a > c) {
    max = a;
  } else if (b > c) {
    max = b;
  } else {
    max = c;
  }
  if (a < b && a < c) {
    min = a;
  } else if (b < c) {
    min = b;
  } else {
    min = c;
  }
  return max - min;
}

int main(void)
{
  int h, w;
  cin >> h >> w;

  int mini = w % 3 == 0 ? 0 : h;
  if (h % 3 == 0) {
    mini = 0;
  } else {
    mini = min(mini, w);
  }

  {
    int a = (w/3) * h;
    int b = (w - w/3) * ((h+1)/2);
    int c = (w - w/3) * (h/2);
    mini = min(mini, three(a, b, c));
  }
  {
    int a = ((w+1)/3) * h;
    int b = (w - (w+1)/3) * ((h+1)/2);
    int c = (w - (w+1)/3) * (h/2);
    mini = min(mini, three(a, b, c));
  }

  {
    int a = (h/3) * w;
    int b = (h - h/3) * ((w+1)/2);
    int c = (h - h/3) * (w/2);
    mini = min(mini, three(a, b, c));
  }
  {
    int a = ((h+1)/3) * w;
    int b = (h - (h+1)/3) * ((w+1)/2);
    int c = (h - (h+1)/3) * (w/2);
    mini = min(mini, three(a, b, c));
  }

  cout << mini << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <list>
#include <string>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <iomanip> // setprecisionを使用するのに必要 cout << fixed << setprecision(15) << p でpを小数点以下15桁表示
using namespace std;
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)
#define DIV0 1000000007
typedef long long ll;
#define fin(ans) cout << (ans) << '\n'
/*

*/
int main()
{
    int temp;
    REP(i,5){
        cin >> temp;
        if(temp){
            continue;
        }else{
            fin(i+1);
            return 0;
        }
    }
    fin("!!");
    return 0;
}

Measured memory_bytes: 3164
#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)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

    string s;
    cin >> s;
    int n = s.size();

    cout << s.substr(0, n-8) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll h, n;
    cin >> h >> n;
 
    vl a(n), b(n);
    rep(i, n) {
        cin >> a[i] >> b[i];
    }
 
    vvl dp(n+1, vl(h+1, INF));  // dp[i+1][j] : i番目の魔法まででjダメージ与えるときの魔力の総和の最小値
    dp[0][0] = 0;
    rep(i, n) {
        rep(j, h+1) {
            chmin(dp[i+1][j], dp[i][j]);
            chmin(dp[i+1][min(h, j + a[i])], dp[i+1][j] + b[i]);
        }
    }
 
    out(dp[n][h]);
    re0;
}

Measured memory_bytes: 78592
#include <cstdio>
#define loop_input(fmt,...) while(~scanf(fmt,__VA_ARGS__))

int main() {
    int a, i = 0;
    loop_input("%d", &a) {
        if (a == 0) break;
        printf("Case %d: %d\n", ++i, a);
    }
    return 0;
}


Measured memory_bytes: 2580
N, M = map(int, input().split())

def divisible(n):
	divisors = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			divisors.append(i)
			if i != n // i:
				divisors.append(n // i)
	return divisors

div = divisible(M)

div = [d for d in div if d <= M / N]

print(max(div))

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

void trace(int a[], int n){
    for(int i = 0; i < n; i++){
        cout << a[i];
        if (i != n - 1) cout << " ";
        else cout << endl;
    }
}

void swap(int *a, int *b){
    int temp = *a;
    *a = *b;
    *b = temp;
}

int selectionSort(int a[], int n){
    int c = 0;
    for(int i = 0; i < n - 1; i++){
        int minj = i;
        for(int j = i + 1; j < n; j++){
            if(a[minj] > a[j]) minj = j;
        }
        if(minj != i){
            swap(a[i], a[minj]);
            c++;
        }
    }

    return c;
}

int main(void){
    int n, a[100], c;

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

    c = selectionSort(a, n);
    trace(a, n);
    cout << c << endl;

    return 0;
}



Measured memory_bytes: 3108
// Problem : C - Marks
// Contest : AtCoder - M-SOLUTIONS Programming Contest 2020
// URL : https://atcoder.jp/contests/m-solutions2020/tasks/m_solutions2020_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*

WINNERS NEVER QUIT AND QUITTERS NEVER WIN!!

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<long,long> pl;
typedef pair<ll,ll> pll;
typedef vector<long> vl;
typedef vector<bool> vb;
typedef vector<ll> vll;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef vector<vll> vvll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef unordered_map<ll,ll> umll;

#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define REV(i,a,b) for(long long i=a;i>=b;i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define tc ll tests;cin>>tests;while(tests--)
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define coutv(v) for(auto it: (v))cout<<it<<" ";newl;
#define cout2d(v) for(auto it: (v)) {for(auto j:it) cout<<j<<" ";newl;}
#define cinv(v,n) vll (v)(n);FOR(i,0,(n)){cin>>v[i];}
#define cinvg(v,n) (v).resize(n);FOR(i,0,(n)){cin>>v[i];}
#define cin2d(v,n,m) vvll (v)(n,vll(m,0));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define cin2dg(v,n,m) (v).resize(n,vll(m));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define newl cout<<"\n"
#define mod 1000000007
#define INF LLONG_MAX/2

int main()
{
    io;
    ll n,k;
    cin>>n>>k;
    cinv(a,n)
    FOR(i,k,n)
    {
    	if(a[i]>a[i-k]){cout<<"Yes";newl;}
    	else{cout<<"No";newl;}
    }
    return 0;
}



Measured memory_bytes: 4776
# -*- coding: utf-8 -*-

n, k, q = map(int, input().split())

point = [k - q] * n

for _ in range(q):
    answer = int(input()) - 1
    point[answer] += 1

for j in point:
    if j > 0:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 6584
while True:
    h, w = [int(i) for i in input().split()]
    
    if h == 0 and w == 0:
        break
    
    pattern = "#." * 151
    
    for i in range(h):
        line = pattern[:w] if i % 2 == 0 else pattern[1:w+1]
        print(line)

    print("")


Measured memory_bytes: 5620
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll n;
    cin >> n;
    vector<pair<ll,ll> > a(n);
    map<pair<ll,ll>,ll> m;
    REP(i,n){
        cin>>a[i].first >> a[i].second;
    }
    
    REP(i,n){
        REP(j,n){
            if(i!=j)
                m[make_pair(a[i].first-a[j].first,a[i].second-a[j].second)]++;
        }
    }
    ll max_num = 0;
    for(auto itr = m.begin(); itr != m.end(); ++itr) {
        max_num = max(max_num,itr->second);
    }

    cout << n-max_num << endl;
    return 0;
}

Measured memory_bytes: 384
// includes, macros {{{
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <climits>
#include <cassert>
#include <functional>
#include <numeric>
#include <limits>
using namespace std;

#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)

#define rep(i, s, e)    for (int i = (s); i < (int)(e); i++)
//#define PB(e) push_back(e)
//#define MP(a, b) make_pair(a, b)

// for debug
#define kita            cout << "kita\n"
#define print2(i, n)    cout << (i) << ": " << (n) << endl
#define print3(i, j, n)     cout << "(" << (i) << ", " << (j) << ") : " << (n) << endl
#define print4(i, j, n, m)  cout << "(" << (i) << ", " << (j) << ") : " << (n) << ", " << (m) << endl
#define print_mat(mat, h, w) for(int i=0;i<(h);i++){for(int j=0;j<(w);j++){cout << mat[i][j] << " ";}cout << endl;}
 
typedef long long ll;
typedef unsigned long long ull; // }}}

int main(){
    ull n, x;
    cin >> n >> x;
    ull a, b, c;
    // pair<int, int> edge[3];
    // edge[0].first = edge[1].first = edge[2].first = 0;
    // edge[0].second = edge[1].second = edge[2].second = n;
    int status = 0;
    ull ans = n;
    a = n - x;
    b = x;
    while(1){
        if(status == 0){
            if(a%b == 0){
                ans += (a/b-1)*2*b + b;
                break;
            }
            ans += (a/b)*2*b;
            a -= (a/b)*b;
            status = 1;
        }else{
            if(b%a == 0){
                ans += (b/a-1)*2*a + a;
                break;
            }
            ans += (b/a)*2*a;
            b -= (b/a)*a;
            status = 0;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int nn = n;
		for (int i = 0; i < m; i++) {
			int a = sc.nextInt();
			nn = nn - a;
		}
		if (nn >= 0) {
			System.out.println(nn);
		} else {
			System.out.println("-1");
		}
		sc.close();
	}
}

Measured memory_bytes: 38984
n = int(input())
h = list(map(int, input().split()))

dp = [float('inf')]*n
dp[0] = 0
dp[1] = dp[0]+abs(h[0]-h[1])

for i in range(2, n):
  dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
  
print(dp[-1])

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

int A,B,C,K,i,newmax,maks;

int main(){
	cin>>A>>B>>C>>K;
	maks = max(max(A,B),C);
	newmax = 2 * maks;
	for (i = 1;i <= K - 1;i ++){
		newmax = 2 * newmax;
	}
	cout<< A + B + C + newmax - maks <<endl;
}


Measured memory_bytes: 256
s = input()

ok = True
if int(s[0:4]) > 2019:
    ok = False

if int(s[0:4]) == 2019 and int(s[5:7] + s[8:]) > 430:
    ok = False

if ok:
    print('Heisei')
else:
    print('TBD')

Measured memory_bytes: 3060
import math
N = math.factorial(int(input()))
ans = 1
M = 10**9+7
cnt = 1
for i in range(2,1001):
  while N%i == 0:
    cnt += 1
    N = N//i
  ans = ans*cnt
  i += 1
  cnt = 1
print(ans%M)


Measured memory_bytes: 3060
#include <stdio.h>
int main()
{
    int N,price[10];
    int i,MAX=0,MAXi,sum = 0;

    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d",&price[i]);
        if(price[i] > MAX){
            MAX = price[i];
            MAXi = i;
        }
    }

    for(i=0;i<N;i++){
        sum += price[i];
    }
    sum -= (price[MAXi] / 2);

    printf("%d",sum);
    return 0;
}

Measured memory_bytes: 128
import math


def sieve_of_eratosthenes(N):
    prime_list = []
    for i in range(0, N):
        if i * i > N:
            break
        prime_list.append(True)
    prime_list[0] = prime_list[1] = False
    prime = []
    n = len(prime_list)
    for i in range(2, n):
        if prime_list[i]:
            prime.append(i)
            for j in range(2 * i, n, i):
                prime_list[j] = False
    return prime


def cal_count(prime, N):
    for i in range(len(prime)):
        if N < prime[i]:
            break
        while N % prime[i] == 0:
            print('', prime[i], end='')
            N //= prime[i]
    if N != 1:
        print('', N, end='')
    print()


def main():
    N = int(input())
    prime = sieve_of_eratosthenes(N)
    prime.append(N)
    print(N,end='')
    print(':', end='')
    cal_count(prime, N)


if __name__ == '__main__':
    main()



Measured memory_bytes: 6016
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7
N = 10**4
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


N, K = map(int, input().split())
R = N-K

for i in range(1, K+1):    
    if i > R+1:
        print(0)
    else:
        ans = cmb(R+1, i, mod) * cmb(K-1, i-1, mod) % mod
        print(ans)

Measured memory_bytes: 4596
#include <bits/stdc++.h>
 
using namespace std;
 
#define BOOST        std::ios::sync_with_stdio(false);  cin.tie(NULL); cout.tie(NULL);
#define sp           <<" "<<
#define ll           long long
#define ld           long double
#define AZI(i,x)     for(auto i=x.begin();i!=x.end();i++)
#define AZ(x)        x.begin(),x.end()
#define P(x,y)       pair < x,y >
#define V(x)         vector < x >
#define fi           first
#define se           second
#define pb           push_back
#define mp           make_pair
#define PI           3.14159265358979323846264338327950288419716939937510

// find_by_order(int k) - returns k'th smallest element (0-indexed)
// order_of_key(int k) - returns number of elements strictly smaller than k.
// using namespace __gnu_pbds;
// #define ordered_set tree <int, null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update>

const ll mod=1e9+7,N=1e5+5,INF = 1e18;

ll power(ll a,ll b)
{
    a = a%mod;
    ll result = 1;

    while(b)
    {
        if(b&1)
            result = (result*a)%mod;
        b >>= 1, a = (a*a)%mod;
    }
    return result;
}


/*

1. Make sure you're taking all the inputs.
2. In case of nested loops, remember to use different variables.
3. If in doubt, do int -> ll
4. Don't fight the question, try solving the next one.

*/



//  Don't code anything above this //




int main() 
{ 
    BOOST

    ll a,b,c,d;
    cin>>a>>b>>c>>d;

    ll l1 = b/c - (a-1)/c;
    ll l2 = b/d - (a-1)/d;
    ll lcm = (c*d)/__gcd(c,d);
    ll l3 = b/lcm - (a-1)/lcm;
    // cout<<l1<<" "<<l2<<" "<<l3<<" chk1\n";
    l1 = (b-a + 1) - l1;
    l2 = (b-a + 1) - l2;
    l3 = (b-a + 1) - l3;

    cout<<(l1+l2-l3)<<"\n";
    return 0;    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<vector<int>> f(n);
    long t;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 10; j++){
            cin >> t;
            f[i].push_back(t);
        }
    }
    vector<vector<int>> p(n);
    for(int i = 0; i < n; i++){
        for(int j = 0; j <= 10; j++){
            cin >> t;
            p[i].push_back(t);
        }
    }
    
    long max = -10000000000;
    for(int i = 1; i < 1024; i++){
        vector<int> tag(10,0);
        int ii = 0;
        int tmp = i;
        while(tmp != 0){
            if(tmp%2==1){
                tag[ii] = 1;
            }
            ii++;
            tmp/=2;
        }
        long sum=0;
        for(int j = 0; j < n; j++){
            int count=0;
            for(int k = 0; k < 10; k++){
                if(f[j][k] == 1 && tag[k] == 1)
                    count++;
            }
            sum += p[j][count];
        }
        if(sum > max)
            max = sum;
    }
    cout<<max;
}

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

using ll = long long;
using ull = unsigned long long;
using namespace std;
constexpr int MAX = 1000000;
constexpr int inf = 1<<30;

int h,w,k;
int main(){
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    int n,k;
    cin>>n>>k;
    vector<int> v(n);
    for(auto & a : v) cin>>a;
    sort(v.begin(),v.end());
    int sum = 0;
    for(int i=0;i<k;++i){
        sum += v[i];
    }
    cout << sum << endl;
    return 0;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  ll n,d,x;
  cin >> n >> d >> x;
  vll a(n);
  REP(i, n)
    cin >> a[i];

  ll ans = 0;
  REP(i, n){
    ans += (d-1)/a[i] + 1;
  }

  ans += x;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#include <random>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1'000'000'007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  vector<ll> A(7);
  for(int i=0; i<7; i++){
    cin >> A[i];
  }
  ll ans = 0;
  ans += A[1];
  vector<int> id = {0,3,4};
  int cnt = 0;
  ll mn = inf;
  for(int i=0; i<3; i++){
    if(A[id[i]]%2) cnt++;
    chmin(mn,A[id[i]]);
  }
  if(cnt >= 2 && mn != 0){
    ans += 3;
    for(int i=0; i<3; i++){
      A[id[i]]--;
      ans += A[id[i]]/2*2;
    }
  }else{
    for(int i=0; i<3; i++){
      ans += A[id[i]]/2*2;
    }
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 3648
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] A = new int[M];
        for(int i = 0; i < M; i++){
            A[i] = sc.nextInt();
        }
        int a = N;
        for(int i = 0; i < M; i++){
            a = a - A[i];
        }
        if(a < 0){
            System.out.println(-1); 
        }else{
            System.out.println(a);
        }
    }
} 

Measured memory_bytes: 46472
//Jai Sai Ram 
// Please help me in every situation 
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl "\n"
ll P=1e9+7;
vector<ll> adj[100001];
ll a[400001],b[400001],segtree[4000001];
ll query(ll l,ll r,ll start,ll end,ll idx)
{
    if(start>end||start>r||end<l)
    return 0;
    if(start>=l&&end<=r)
    return segtree[idx];
    ll mid=(start+end)/2;
    ll x=query(l,r,start,mid,2*idx+1);
    ll y=query(l,r,mid+1,end,2*idx+2);
    return max(x,y);
}
void upd(ll idx, ll index, ll value,ll start,ll end)
{
    if(start>end||start>index||end<index)
    return;
    if(start==end&&start==index)
    {
        segtree[idx]=value;
        return;
    }
    if(start<end)
    {
        ll mid=(start+end)/2;
        upd(2*idx+1,index,value,start,mid);
        upd(2*idx+2,index,value,mid+1,end);
    }
    segtree[idx]=max(segtree[2*idx+1],segtree[2*idx+2]);
}
void solve()
{
    memset(segtree,0,sizeof(segtree));
    ll i,j,k,l,m,n,o,p,q,r,t,s;
    cin>>n>>k;
    ll ans=0;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        l=max(0LL,a[i]-k);
        r=a[i]+k;
        ll an=query(l,r,0,300000,1);
        ans=max(ans,an+1);
        upd(1,a[i],an+1,0,300000);
    }
    cout<<ans<<endl;
}
int main()
{
    ll t=1;
    ios_base::sync_with_stdio(false);
    cin.tie(0);

   //cin>>t;
   ll i=1;
    while(t--)
    {
      
        solve();
        i++;
    }
    return 0;
}


Measured memory_bytes: 39588
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

ans = 0

b = [A[0]]

for i in range(1, N):
    b.append(b[-1]+A[i])

cnt = Counter(b)
cnt[0] += 1

for v in cnt.values():
    ans += v*(v-1)//2

print(ans)

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

int main() {
  int n,k,q;
  cin >> n >> k >> q;
  vector<int> a(q);
  vector<int> ans(n,k-q);
  rep(i,q){
    cin >> a[i];
  }
  rep(i,q){
    ans[a[i]-1]++;
  }
  rep(i,n){
    if(ans[i]>0){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <unordered_map>
#include <iostream>
#include <cstdio>
using namespace std;

long long gcd(long long c,long long d)
{
	if (c < d)
	{
		long long tmp = c;
		tmp = d;
		d = tmp;
	}
	if (d == 0)
	{
		return c;
	}
	else {
		return gcd(d, c % d);
	}
}

int main(void)
{
	long long a, b, c, d;

	cin >> a >> b >> c >> d;

	long long g = gcd(c, d);

	if (c < d)
	{
		long long tmp = c;
		tmp = d;
		d = tmp;
	}

	long long e = c/g*d;

	long long count = b - a + 1;

	if (b >= c)
	{
		if (a % c == 0)
		{
			count -= 1;
		}
		count -= b / c - a / c;
	}
	if (b >= d)
	{
		if (a % d == 0)
		{
			count -= 1;
		}
		count -= b / d - a / d;
	}
	if (b >= e)
	{
		if (a % e == 0)
		{
			count += 1;
		}
		count += b / e - a / e;
	}

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

	return 0;
}

Measured memory_bytes: 256