akhauriyash/Code-Regression huggingface dataset:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n,m=mii()
s=[]
k=[]
for i in range(m):
    temp=limii()
    k0=temp[0]
    s0=temp[1:]
    s.append(s0)
    k.append(k0)

p=limii()
ans=0
#bit全探索
#print(p)
for i in product([0,1], repeat=n):
    #点灯している電球の数
    temp=0

    #全ての電球で探索
    for j in range(m):
        #対象の電球のonになっている個数
        cnt=0
        for x in s[j]:
            
            if i[x-1]==1:
                cnt+=1
            
        if cnt%2==p[j]:
            temp+=1
        #print(i,j,cnt)
    if temp==m:
        ans+=1
print(ans)



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

int main()
{
	int n;
	cin >> n;
	int a[n];
	int w[n-1];
	int sum = 0;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++){
		int b;
		cin >> b;
		sum += b;
	}
	for (int i = 0; i < n-1; i++) cin >> w[i];

	for (int i = 1; i < n; i++){
		if (a[i] == a[i-1]+1) sum += w[a[i-1]-1];
	}

	cout << sum << endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
int main() {
    string s;
    cin>>s;
    int n=s.size();
    vector<int>l(26);
    rep(i,n) l.at(s.at(i)-'a')++;
    string ans="yes";
    rep(i,26) if(l.at(i)>1) ans="no";
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a[250000];
long long ans=0;
int main()
{
   cin>>n;
   for(int i=0;i<n;i++)
   {
   	cin>>a[i];
   }
    for(int i=0;i<n-1;i++)
   {
   	if(a[i+1]<a[i])
   	   {
   	ans+=a[i]-a[i+1];
   	a[i+1]=a[i];
       }
   }
 /*  for(int i=0;i<n;i++)
   {
   	cout<<a[i]<<" ";
   }
   */
   cout<<ans;
   return 0;
}

Measured memory_bytes: 4376
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

long long yakusu(long long x,long long y,long long z)
{
    if (z == 1){
        return y-x+1;
    }
    if (x%z == 0 && y%z == 0){
        return y/z-x/z+1;
    }
    else if (x%z == 0 && y%z != 0){
        return y/z-x/z+1;;
    }
    else if (x%z != 0 && y%z == 0){
        return y/z-x/z;
    }
    else {
        return y/z-x/z;
    }
}

long long gcd(long long x,long long y){
    if (y%x == 0){
        return x;
    }
    else {
        return gcd(y%x,x);
    }
}

long long sakou(long long x,long long y)
{
    return (x*y)/gcd(x,y);
}


int main()
{
    long long a,b,c,d;
    cin >> a >> b >> c >> d;
    long long e;
    e = sakou(min(c,d),max(c,d));
    long long f = yakusu(a,b,c);
    long long g = yakusu(a,b,d);
    long long h = yakusu(a,b,e);
    
    printf("%lld\n",b-a+1-f-g+h);
}


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

void fnInput(vector<int> &a_rvoTarget, vector<int> &a_rvoSearch)
{
  int iTargetCnt;
  cin >> iTargetCnt;

  a_rvoTarget.resize(iTargetCnt);
  for (int i = 0; i < iTargetCnt; i++)
    cin >> a_rvoTarget[i];

  int iSearchCnt;
  cin >> iSearchCnt;

  a_rvoSearch.resize(iSearchCnt);
  for (int i = 0; i < iSearchCnt; i++)
    cin >> a_rvoSearch[i];
}

void fnBinarySearch(const vector<int> &a_cnrvoTarget, const vector<int> &a_cnrvoSearch, int &a_riFound)
{
  for (int i = 0; i < a_cnrvoSearch.size(); i++)
  {
    int jLow  = 0;
    int jHigh = a_cnrvoTarget.size();
    while (jLow != jHigh)
    {
      int jMid = (jLow + jHigh) / 2;
      if (a_cnrvoSearch[i] == a_cnrvoTarget[jMid])
      {
        a_riFound++;
        break;
      }
      else if (a_cnrvoSearch[i] < a_cnrvoTarget[jMid])
        jHigh = jMid;
      else
        jLow  = jMid + 1;
    }
  }
}

void fnResultOut(int a_iFound)
{
  cout << a_iFound << endl;
}

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

  vector<int> voTarget, voSearch;
  int iFound = 0;

  fnInput(voTarget, voSearch);
  fnBinarySearch(voTarget, voSearch, iFound);
  fnResultOut(iFound);

  return 0;
}

Measured memory_bytes: 1588
#include <bits/stdc++.h>
#define MOD 1000000007
//for(int i=0; i<n; ++i)
using namespace std;
#define all(c) c.begin(), c.end()

map<int, vector<int>> g;

void dfs(int i, int *v)
{
    v[i] = 1;
    vector<int> f = g[i];
    for (auto itr = f.begin(); itr != f.end(); ++itr)
    {
        if (v[*itr] == 0)
            dfs(*itr, v);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m, x, y, z, c = 0;

    cin >> n >> m;
    int v[n + 3];

    for (int i = 0; i <= n; ++i)
        v[i] = 0;

    for (int i = 0; i < m; ++i)
    {
        cin >> x >> y >> z;
        g[x].push_back(y);
        g[y].push_back(x);
    }

    for (int i = 1; i <= n; ++i)
        if (v[i] == 0)
        {
            ++c;
            dfs(i, v);
        }

    cout << c << endl;
    return 0;
}

Measured memory_bytes: 24064
x = int(input())

if 400 <= x and x <= 599:
    print(8)
elif 600 <= x and x <= 799:
    print(7)
elif 800 <= x and x <= 999:
    print(6)
elif 1000 <= x and x <= 1199:
    print(5)
elif 1200 <= x and x <= 1399:
    print(4)
elif 1400 <= x and x <= 1599:
    print(3)
elif 1600 <= x and x <= 1799:
    print(2)
elif 1800 <= x and x <= 1999:
    print(1)

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

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

}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}


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

  vector<int> x(5);
  rep(i, 5){
    cin >> x[i];
  }

  rep(i, 5){
    if(x[i]==0){
      cout << i +1 << endl;
    }
  }


  return 0;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define int long long
//#undef int
#define mk make_pair
#define pb push_back
#define pf push_front
typedef pair<int, int> pii;
const int mod = 1000000007;
const int INF = 1000000009;
const long long INFL = 1000000000000000018ll;

string s;
int a, b, c;
vector<int> v;

signed main()
{
    cin >> s;
    int N = s.size();
    for(int i = 0; i < N; i++){
        if(s[i] == 'a'){
            a++;
        }
        else if(s[i] == 'b'){
            b++;
        }
        else {
            c++;
        }
    }
    v.pb(a);
    v.pb(b);
    v.pb(c);
    sort(v.begin(), v.end());
    if(v[0] == v[1] && v[1] == v[2] || v[0] == v[1] && v[1] == v[2] - 1 || v[0] + 1 == v[1] && v[1] == v[2]){
        printf("YES\n");
    }
    else {
        printf("NO\n");
    }


    return 0;
}
/*


*/




Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
 
int main() {
	ll x,ma=-1,w;
	cin>>x;
	for(ll i=1;i<50;i++){
		for(ll j=2;j<50;j++){
			w=pow(i,j);
			if(w<=x){
				ma=max(ma,w);
			}
		}
	}
	cout<<ma<<endl;
	return 0;
}

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

using namespace std;
using ll = long long;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
    string s;
    cin >> s;
    stack<char> st;
    int ans=0;
    for (int i = 0; i < sz(s); i++) {
        if (!st.empty()&&s[i] != st.top()) {
            ans+=2;
            st.pop();
        } else {
            st.push(s[i]);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
class Card{
public:
  char m;
  int n;
};
int main(){
  int n,min,f=0;
  Card b[36],s[36];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>b[i].m>>b[i].n;
    s[i]=b[i];
  }
  for(int i=0;i<n-1;i++){
    for(int j=n-1;j>i;j--){
      if(b[j-1].n>b[j].n) swap(b[j-1],b[j]);
    }
  }
  for(int i=0;i<n;i++){
    min=i;
    for(int j=i;j<n;j++){
      if(s[j].n<s[min].n) min=j;
    }
    swap(s[i],s[min]);
  }
  for(int i=0;i<n-1;i++) cout<<b[i].m<<b[i].n<<" ";
  cout<<b[n-1].m<<b[n-1].n<<endl;
  cout<<"Stable"<<endl;
  for(int i=0;i<n-1;i++){
    if(b[i].m!=s[i].m) f=1;
    cout<<s[i].m<<s[i].n<<" ";
  }
  cout<<s[n-1].m<<s[n-1].n<<endl;
  if(f) cout<<"Not stable"<<endl;
  else cout<<"Stable"<<endl;
}

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


int main(void){
  
  long long int n;
  cin>>n;
  vector<long long int> v;
  for(long long int i=0;i<n;i++){
  	long long int t;
    cin>>t;
    
    v.push_back(t);
  }
  
 
  long long int sum=0;
  
  for(long long int i=1;i<n;i++){
  	if(v[i-1]>v[i]){
    	sum+=v[i-1]-v[i];
      	v[i]+=v[i-1]-v[i];
    }
  }
  
  cout<<sum<<endl;
    
}

Measured memory_bytes: 5224
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.Map;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskE solver = new TaskE();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskE {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			int n = in.nextInt();
			long k = in.nextLong();
			long[] a = new long[n];
			long[] s = new long[n + 1];

			for (int i = 0; i < n; i++) {
				a[i] = in.nextLong();
				s[i + 1] = s[i] + a[i] - k;

			}

			long[] sorted = s.clone();
			Arrays.sort(sorted);
			Map<Long, Integer> id = new HashMap<>();
			for (long x : sorted) {
				if (!id.containsKey(x)) {
					int sz = id.size();
					id.put(x, sz);
				}
			}

			int[] tree = new int[id.size()];
			long ans = 0;
			for (int i = 0; i < s.length; i++) {
				int j = id.get(s[i]);
				ans += sum(tree, j);
				add(tree, j);
			}
			out.println(ans);
		}

		private void add(int[] tree, int i) {
			while (i < tree.length) {
				++tree[i];
				i |= i + 1;
			}
		}

		private long sum(int[] tree, int r) {
			long res = 0;
			while (r >= 0) {
				res += tree[r];
				r = (r & (r + 1)) - 1;
			}
			return res;
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

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

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

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

	}
}



Measured memory_bytes: 62828
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <queue>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    int m = 0, d = 0;
    cin >> m >> d;
    int cnt = 0;
    for (int i=1; i<=d; i++) {
        int buf = (i/10) * (i%10);
        if (i/10 < 2 || i%10 < 2) {
            continue;
        }
        if (buf > 0 && buf <= m) {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


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

#define forn(i, a, b) for (int i = a; i <= b; ++i)

using namespace std;

const int N = (int)2e5 + 1;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef long double ld;

typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

string s;
int k;
int main (){
  cin >> s >> k;
  int ok = 0;
  forn (i, 0, k - 1){
    if (s[i] != '1'){
      ok = 1;
      break;
    }
  }
  if (!ok){
    return cout << 1 << "\n", 0;
  }
  forn (i, 0, k - 1){
    if (s[i] != '1'){
      return cout << s[i] << "\n", 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
		 static List<ArrayList<Integer>>  list = new ArrayList<ArrayList<Integer>>();
	    public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        int N = sc.nextInt();	
	        long[] m = new long[12];
	        m[0]=1;
	        int k=1;
	        for(int i=6;i<100005;i=i*6) {
	        	m[k]=i;
	        	k++;
	        }
	        for(int i=9;i<100005;i=i*9) {
	        	m[k]=i;
	        	k++;
	        }
	        Arrays.sort(m);
	        int[] ans = new int[100005];
	        ans[0]=0;
	        for(int i=1;i<100002;i++) {
	        	long min=100005;
	        	for(int j=0;j<12&&m[j]<=i;j++) {
	        		min = Math.min(min, ans[(int) (i-m[j])]+1);
	        	}
	        	ans[i]=(int) min;
	        }
	        
	        
	        System.out.println(ans[N]);
	        
	    }
	}

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

int main()
{
	int n;

	cin >> n;

	while (n != -1) {
		string s;

		if (n == 0)
			s = "0";

		while (n > 0) {
			s = to_string(n % 4) + s;
			n /= 4;
		}

		cout << s << endl;
		
		cin >> n;
	}

	return 0;
}



Measured memory_bytes: 3216
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string.h>
#include <string>
#include <vector>
#include <limits.h>
#include <stack>
#include <queue>
#include<cstdlib>
#define maxn 10000000
#define pi acos(-1)
using namespace std;
int a[10007];
int b[507];
int n,q,ans;
int linearSearch(int x)
{
	int i=0;
	a[n+1]=x;
	while(a[i]!=x)i++;
	if(i>=n+1)return false;
	return 1;
}
int main(){
	ans=0;
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	cin>>q;
	for(int i=1;i<=q;i++)cin>>b[i];
	for(int i=1;i<=q;i++)
	{
		ans+=linearSearch(b[i]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  string s;
  cin >> n;
  int i;
  for (i=0; i<n; i++) {
    cin >> s;
    if (s=="Y") {
      cout << "Four" << endl;
      break;
    }
    else if (i==n-1 && s!="Y") {
      cout << "Three" << endl;
    }
  }
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc= new Scanner(System.in);
		int N=sc.nextInt(),D=sc.nextInt(),X=sc.nextInt();
		int[] A = new int[N];
		for(int i=0;i<N;i++){
			A[i]=sc.nextInt();
		}
		int answer=X;
		for(int i=0;i<N;i++){
			answer=answer+(D-1)/A[i]+1;
		}
		System.out.println(answer);
	}
}


Measured memory_bytes: 21844
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 1000000007;

template<class _T> static void getint(_T& a) {
	std::cin >> a;
}
template<class _T> static void getint(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}

static void solve();

int main()
{
	solve();
	fflush(stdout);
	return 0;
}

static void solve()
{
	int N;
	getint(N);

	int bi = 1;
	int ai = 1;
	while (ai < N) {
		bi++;
		ai = ai + bi;
	}
	if (ai != N) {
		printf("No\n");
		return;
	}
	printf("Yes\n");
	std::vector<std::vector<int>> nums(bi + 1, std::vector<int>(bi, 0));
	printf("%d\n%d", bi + 1, bi);
	for (int i = 0; i < bi; i++) {
		printf(" %d", i + 1);
		nums[0][i] = i + 1;
	}
	putchar('\n');

	printf("%d", bi);
	for (int i = 0; i < bi; i++) {
		printf(" %d", i ? i + bi : 1);
		nums[1][i] = i + bi;
	}
	putchar('\n');

	int count = 2;
	int lastNum = bi * 2 - 1;
	while (count <= bi) {
		printf("%d", bi);

		int val = 0;
		for (int i = 0; i < bi; i++) {
			if (i < count) {
				int idx = count - 1;
				val = nums[i][idx];
			}
			else {
				lastNum++;
				val = lastNum;
			}
			nums[count][i] = val;
			printf(" %d", val);
		}

		putchar('\n');
		count++;
	}
}


Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(inti=a;i<=b;i++)

#define MOD 1000000007
typedef long long int ll;
typedef vector<int>vi;
typedef pair<int,int>pi;



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

int n ;
cin>>n;

while(n--)
    cout<<"ACL";
 return 0;
}


Measured memory_bytes: 3652
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {

	/** 入力文字列の数 */
	private static final int N = 3;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			System.out.println(IntStream.range(0, N).mapToObj(i -> scanner.next().substring(0, 1).toUpperCase())
					.collect(Collectors.joining()));
		}
	}
}


Measured memory_bytes: 36064
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    int count = 0;
    for(int i=1; i<=N; i++){
        if(0<=i && i<=9){
            count++;
        }else if(100<=i && i<=999){
            count++;
        }else if(10000<=i && i<=99999){
            count++;
        }
    }

    cout << count << endl;
    return 0;
}

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

int main() {
    char c;
    std::cin >> c;

    if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
        std::cout << "vowel\n";
    } else {
        std::cout << "consonant\n";
    }

    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int h = sc.nextInt();
    int m = sc.nextInt();
    
    double angH = 30*h;
    double angM = 5.5*m;
    double ang = Math.toRadians(Math.abs(angH - angM));
    double c = 0;
    c = Math.sqrt(a*a + b*b - 2*a*b*Math.cos(ang));
    System.out.print(c);
  }
}


Measured memory_bytes: 36016
def main():
    X, Y = (int(i) for i in input().split())
    if (X+Y) % 3 != 0:
        return print(0)
    m = (X + Y)//3 + 3
    fac = [0] * m
    finv = [0] * m
    inv = [0] * m
    MOD = 10**9 + 7

    def COMBinitialize(m):
        fac[0] = 1
        finv[0] = 1
        if m > 1:
            fac[1] = 1
            finv[1] = 1
            inv[1] = 1
            for i in range(2, m):
                fac[i] = fac[i-1] * i % MOD
                inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
                finv[i] = finv[i - 1] * inv[i] % MOD

    def COMB(n, k):
        if n < k:
            return 0
        if n < 0 or k < 0:
            return 0
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD

    COMBinitialize(m)
    n = (X+Y)//3
    k = X - n
    print(COMB(n, k))


if __name__ == '__main__':
    main()


Measured memory_bytes: 54384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define  all(x) (x).begin(),(x).end()
typedef long long ll;

int n;
vector<vector<pair<int, int>>> g;
const int INF = 1<<30;

void dijkstra(){
    vector<int> d(n), visited(n);
    priority_queue< pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>> > pq;
    rep(i,n) d[i] = INF;

    pq.push(make_pair(0,0));
    d[0] = 0;
    visited[0] = 1;

    while(!pq.empty()){
        pair<int, int> p = pq.top(); pq.pop();
        int u = p.second;

        visited[u] = 1;
        if (d[u] < p.first) continue;

        for(auto pp: g[u]){
            int v = pp.first;
            if (visited[v] == 1) continue;
            if (d[v] > d[u] + pp.second){
                d[v] = d[u] + pp.second;
                pq.push(make_pair(d[v], v));
            }
        }
    }
    rep(i,n){
        printf("%d %d\n", i, d[i]);
    }
}

int main(){
    cin >> n;
    g.resize(n);
    rep(i,n){
        int u, k;
        cin >> u >> k;
        rep(j, k){
            int to, cost;
            cin >> to >> cost;
            g[u].push_back(make_pair(to, cost));
        }
    }
    dijkstra();
}


Measured memory_bytes: 7976
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<map>
#include<queue>
#include<set>
#include<bitset>
#include<stdio.h>
#include<deque>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
 
int main()
{
   int a, b;
   cin >> a >> b;
   if(b % a == 0){
       cout << a+b << endl;
       return 0;
   }
   cout << b-a << endl;
}

Measured memory_bytes: 256
import itertools as it
def chk(s):
    if "7" in s and "5" in s and "3" in s:
        return True
    else:
        return False
N = int(input())
ans = 0
for i in range(3,len(str(N))+1):
    for p in it.product(["7","5","3"], repeat = i):
        string = ""
        for c in p:
            string += c
        num = int(string)
        if chk(string) and num <= N:
            ans += 1
print(ans)

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

using namespace std;

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

  int N, a, cnt, res = 0;
  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> a;
    cnt = 0;
    while (a > 0) {
      if (a%2 == 0) a /= 2;
      else break;
      ++cnt;
    }
    res += cnt;
  }
  cout << res << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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

int main() {
  int N;
  cin >> N;
  if (N < 1000)
    cout << "ABC" << endl;
  else
    cout << "ABD" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

typedef pair <int,int> pii;
typedef vector <pii> vpii;
typedef vector <int> vi;
typedef vector <vi> vvi;
typedef long long int lli;
typedef pair<lli,lli> plli;
typedef vector <plli> vplli;
typedef vector <lli> vlli;
typedef vector <vlli> vvlli;
typedef vector <string> vs;
typedef vector <bool> vb;

#define rep(i, n) for( i = 0; i < (n); ++i)
#define repA(i, a, n) for( i = a; i <= (n); ++i)
#define repD(i, a, n) for( i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sortr(x) sort(x.begin(),x.end(),greater <int> ())
#define mod 1000000007
#define ff first
#define ss second
#define fill(a,c)  memset(a, c, sizeof (a))
#define formap(i,v) for(auto &i: v)
#define dbg(x) cout << #x << " = " << x << '\n'
#define dbg2(x,y) cout<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;
#define dbgstl(v) cout<<#v<<" = \n"; { int c=0; formap(it,v) \
cout<<"    "<<#v<<"["<< ++c <<"] = "<<it<<endl;} cerr<<endl
#define dbgstlp(v) cout<<#v<<" = \n"; { int c=0; formap(it,v) \
cout<<"    "<<#v<<"["<< ++c <<"] = "<<it.first<<" , "<<it.second<<endl;} cerr<<endl
#define PI  3.14159265358979323846
#define pb push_back



int main() {
    cin.sync_with_stdio(0);cin.tie(0);
    cin.exceptions(cin.failbit);
    
    int x;
    cin>>x;
    cout<< 10-(x/200);
    
    
    
    
    
    
    
    
    
    
    
    
     
   
   
	return 0;
}


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

#define dbg(x) cerr << #x"=" << x << endl;
typedef long long LL;
const int MAX_N = 1e5+100;
bool has[MAX_N];
vector<int> G[MAX_N];

void dfs(int u){
    has[u] = true;
    for(int v : G[u]){
        if(!has[v]) dfs(v);
    }
}

int main(){
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    int n,m;
    cin >> n >> m;
    int u,v,c;
    for(int i = 0; i < m; ++i){
        cin >> u >> v >> c;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    memset(has, false, sizeof has);
    int ans = 0;
    for(int i = 1; i <= n; ++i){
        if(!has[i]){
            dfs(i);
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8960
#include <iostream>
typedef long long ll;
using namespace std;
int main(void){
    string s1,s2;
    cin >> s1 >> s2;
    ll ss1=s1.size(),ss2=s2.size();
    ll dp[++ss1][++ss2];
    int i,j;
    fill(dp[0],dp[0]+(ss1*ss2),10000);
    for(i=0;i<ss2;i++){
        dp[0][i]=i;
    }
    for(i=0;i<ss1;i++)dp[i][0]=i;
    for(i=1;i<ss1;i++){
        for(j=1;j<ss2;j++){
            if(s1[i-1]==s2[j-1])dp[i][j]=dp[i-1][j-1];
            else dp[i][j]=dp[i-1][j-1]+1;
            dp[i][j]=min(dp[i][j],min(dp[i-1][j],dp[i][j-1])+1);
        }
    }
    cout << dp[ss1-1][ss2-1] << endl;
    return 0;
}



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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;
typedef pair<int,int> ii;

void solve() {

}

int main() {
  string s;
  cin >> s;
  if( s == "ABC") puts("ARC");
  else puts("ABC");

  return 0;
}


Measured memory_bytes: 3624
/*
  KUNAL ANAND
  MNNIT ALLAHABAD
*/  

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<assert.h>
using namespace std;
using namespace __gnu_pbds;
#define debug1(x) cout << # x << " " << x << endl;
#define debug2(x,y) cout << #x << " " << x << " " << #y << " " << y << endl;
#define debug3(x,y,z) cout << #x << " " << x << " " << #y << " " << y << " " << #z << " " << z << endl;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
typedef long long int ll;
const ll INF=1e12;
const ll mod=998244353;

int main() {
    //code
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    ll t;
      ll i,j,k,a,b=LLONG_MAX,n,curr=1,l,r,val=0,prev=0,m,x1,x2,ans=0;
    char C;

    cin >> C;


    char ax=C+1;

    cout << ax << endl;
     
    return 0;
}

Measured memory_bytes: 256
//Robs Code

/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <iomanip>

/***********MACROS***************/
#define int long long int
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define pii pair<int,int>

using namespace std;

const int N = 1e5 + 1;
int n,m,i,j,k,l,x,y,z,cnt[3],sum[3];

/***********MAIN**************/
int foo(string s,char ch1,char ch2,char ch3){
	int ans = 0;
	vector<int> suf(n);
	if(s[n-1] == ch3){
		suf[n-1] = 1;
	}
	for(int i=n-2;i>=0;i--){
		if(s[i] == ch3){
			suf[i] = 1;
		}
		suf[i] += suf[i+1];
	}
	for(int i=0;i<n;i++){
		if(s[i] == ch1){
			for(int j=i+1;j<n;j++){
				if(s[j] == ch2){
					ans += suf[j];
					if((2*j - i) < n){
						if(s[2*j - i] == ch3) ans--;
					}
				}
			}
		}
	}
	return ans;
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n;
	string s;
	cin >> s;
	vector<char> ch;
	ch.push_back('B');
	ch.push_back('G');
	ch.push_back('R');
	int ans = 0;
	do{
		ans += foo(s,ch[0],ch[1],ch[2]);
	}while(next_permutation(all(ch)));
	cout<<ans;
}
//.........

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>PP;
const ll MOD = 1000000007;
ll T[100005]={0};
ll S[100005]={0};
ll modpow(ll a, ll mod) {
    ll res = 1;
    ll n=MOD-2;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main(){
  int n;cin >>n;
  for(int i=1;i<=n;i++){
    cin>>T[i];
  }
  for(int i=1;i<n;i++){
   T[i]=T[i+1]-T[i];
  }
  for(int i=1;i<=n;i++){
    S[i]=modpow(i,MOD);
  }
  //cout<<" "<<S[1]<<S[2]<<endl;
  for(int i=2;i<=n;i++){
    S[i]=(S[i-1]+S[i])%MOD;
  }
  ll ans=0;
  for(int i=1;i<n;i++){
    ans+=(T[i]*S[i])%MOD;
    ans%=MOD;
  }
  for(int i=1;i<n;i++){
    ans*=i;
    ans%=MOD;
  }
  cout<<ans<<endl;
}


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

using namespace std;

vector <int> v;

int main() {
	int n , k;
	ios::sync_with_stdio(0);
	cin >> n >> k;
	string s;
	cin >> s;
	int ans = 0;
	for(int i = 1 ; i < s.length() ; i++) {
		if(s[i] == s[i - 1])ans++;
	}
	ans = min(2 * k + ans , n -1); 
	cout << ans << "\n";
	return 0;
}


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

int main() {
	ll n,m,a[100010],dp[100010];
	cin>>n>>m;
	for(int i=0;i<100010;i++){
		a[i]=0;
	}
	for(int i=0;i<m;i++){
		int z;
		cin>>z;
		a[z]=1;
	}
	dp[0]=1;
	if(a[1]!=1){
		dp[1]=1;
	}
	for(int i=2;i<=n;i++){
		dp[i]=dp[i-1]+dp[i-2];
		dp[i]%=inf;
		if(a[i]==1){
			dp[i]=0;
		}
	}
	cout << dp[n];
}

Measured memory_bytes: 1792
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)
	begin, end := -1, -1
	for i, r := range s {
		if r == 'A' && begin == -1 {
			begin = i
		}
		if r == 'Z' {
			end = i
		}
	}
	fmt.Println(end - begin + 1)
}


Measured memory_bytes: 1920
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    String s=sc.next();
    String t=sc.next();
    int count=0;
    for (int i=0;i<3;i++) {
      if(s.charAt(i)==t.charAt(i)) count++;
    }
    System.out.println(count);
  }
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
using namespace std;
map<int,int> mp;
int main(){
	int n, x;
	cin >> n;
	for(int i = 1; i <= n; i ++) {
		cin >> x;
		mp[x] ++;
	}
	int ans = 0;
	map<int,int>::iterator it = mp.begin();
	for(; it!= mp.end(); it++) {
		if((*it).second % 2 == 1) ans ++;
	}
	printf("%d\n",ans);
	return 0;
}

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

    int main (){
        int n;
        cin >> n;
        vector<int> a(n);
        rep(i,n){
        cin >> a[i];
        }
        sort(a.begin(),a.end());

        double ans=(double)(a[0]+a[1])/2;

        for(int i=2;i<n;i++){
            ans=(double)(ans+a[i])/2;

        }

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

Measured memory_bytes: 3832
using System;
public class program
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Split(' ');
        //string[] line2 = Console.ReadLine().Split(' ');
        var count = int.Parse(line[0]);
        var height = int.Parse(line[1]);
        var sum = 0;

        string[] line2 = Console.ReadLine().Split();
        for(var i = 0; i < count; i++)
        {
            var a = int.Parse(line2[i]);
            if(a < height)
            {
                sum += 1;
            }
        }
        var answer = count - sum;
        Console.WriteLine(answer);
    }
}

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

using namespace std;
#define SUM_MAX 100000
#define N_MAX 105
#define W_MAX 1000000005

int dp[SUM_MAX+1][N_MAX];
bool v[SUM_MAX+1][N_MAX];

int solveDp(int r,int i,int* w,int* val,int n)
{
    if(r <= 0)
        return 0;
    if(i == n)
        return W_MAX;
    if(v[r][i])
        return dp[r][i];

    v[r][i] = 1;

    dp[r][i] = min(solveDp(r,i+1,w,val,n),w[i]+solveDp(r-val[i],i+1,w,val,n));

    return dp[r][i];
}

int maxW(int* w,int* val,int n,int c)
{
    for(int i=SUM_MAX;i >= 0;i--){
        if(solveDp(i,0,w,val,n)<= c){
            return i;
        }
    }

    return 0;
}


int main(){

    int w[N_MAX],val[N_MAX];

    int n,C;
    cin>>n>>C;

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

    cout<<maxW(w,val,n,C);

    return 0;
}

Measured memory_bytes: 51584
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
using namespace std;
typedef pair<int,int> P;//Pでpair<-,->を表す。
typedef long long LL; 

int main()
{ 
    int n,k;
    cin>>n>>k;
    int r,s,p;
    cin>>r>>s>>p;
    LL ans=0;
    int a[n];
    string t;
    cin>>t;
    for(int i=0;i<n;i++){
        if(t[i]=='r'){a[i]=p;}
        if(t[i]=='s'){a[i]=r;}
        if(t[i]=='p'){a[i]=s;}
    }
    for(int i=k;i<n;i++){
        if(t[i-k]==t[i]&&a[i-k]!=0){a[i]=0;}
    }
    //for(int i=0;i<n;i++){cout<<a[i]<<endl;}
    for(int i=0;i<n;i++){
        ans=ans+a[i];
    }
    cout<<ans<<endl;
    return 0;
}

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

#define ll long long
#define ld long double
#define ull unsigned long long
#define endl "\n"
#define MohamedMotaz ios::sync_with_stdio(0); cin.tie(0); ios_base::sync_with_stdio(0);
#define f(a, b, c) for(int a = b; a < c; a++)
using namespace std;
const ll mod = 1e9 + 7;



//ll fact[1000001]; ll inv[1000001];
//ll primes[100007];
//ll arr[1000007];
//ll modPower(ll b, ll p) {
//	if (p == 0)
//		return 1;
//
//	ll halfpow = modPower(b, p / 2);
//	ll toReturn = (halfpow * halfpow) % mod;
//	if (p % 2)
//		toReturn = (toReturn * b) % mod;
//
//	return toReturn;
//}
//
//ll fastPower(ll b, ll p) {
//	if (p == 0)
//		return 1;
//	ll ans = fastPower(b, p / 2);
//	ans = (ans * ans);
//	if (p % 2 != 0)
//		ans = (ans * b);
//	return ans;
//}
//ll GcdRecursive(ll a, ll b) {
//	if (b == 0) return a;
//	return GcdRecursive(b, a % b);
//}
//ll modLCM(ll a, ll b) {
//	ll val = GcdRecursive(a, b);
//	ll tmp = ((a % mod) * (b % mod)) % mod;
//	ll finalVal = ((tmp % mod) * (arr[val] % mod)) % mod;
//	return finalVal;
//
//}
//ll LCM(ll a, ll b) {
//	return (a * b) / GcdRecursive(a, b);
//}
//void move1step(ll& a, ll& b, ll q) { // a and b by reference
//	ll c = a - q * b;
//	a = b;
//	b = c;
//}
//ll GcdIterative(ll a, ll b) {
//	while (b) move1step(a, b, a / b);
//	return a;
//}
//
//void pre(ll n) {
//
//	fact[0] = 1;
//	inv[0] = 1;
//
//	for (ll i = 1; i <= n; i++) {
//		fact[i] = (i * fact[i - 1]) % mod;
//		inv[i] = modPower(fact[i], mod - 2);
//		arr[i] = modPower(i, mod - 2);
//	}
//}
//
//ll npr(ll n, ll r) {
//	return ((fact[n] * inv[n - r]) % mod);
//}
//
//ll ncr(ll n, ll r) {
//	return ((((fact[n] * inv[n - r]) % mod) * inv[r]) % mod);
//}
//
//void sieve(ll val) {
//	memset(primes, 1, sizeof primes);
//	primes[0] = primes[1] = false;
//	for (int i = 2; i <= val; i++) {
//		if (primes[i]) {
//			for (int j = i * i; j <= val; j += i) {
//				primes[j] = 0;
//			}
//		}
//	}
//
//}






int main()
{
    MohamedMotaz;
    ld l; cin >> l;

    cout << fixed << setprecision(10) << (ld) pow(l / 3.0 , 3);
}








Measured memory_bytes: 512
#include<cstdio>
#include<algorithm>
#define N 200000
using namespace std;

int v[N+1];
int poz[N+1];
int dp[N+1];
int verp[N+1];

bool meow(int a,int b){
    return (poz[a]<poz[b]);
}

int main(){
    int n,i,j;

    scanf ("%d",&n);

    for(i=1;i<=n;i++){
        scanf ("%d",&v[i]);
        poz[v[i]]=i;
    }

    dp[n]=0;
    for(i=n-1;i>0;i--){
        if (dp[i+1]==0){
            if (poz[i]<poz[i+1]) dp[i]=0;
            else {
                dp[i]=1;
                verp[i]=i+1;
            }
        }
        else {
            v[0]=i;
            v[1]=i+1;
            v[2]=verp[i+1];

            sort(v,v+3,meow);
            for(j=0;v[j]!=i;j++);

            if (v[(j+1)%3]==i+1){
                dp[i]=dp[i+1];
                verp[i]=verp[i+1];
            }
            else {
                dp[i]=dp[i+1]+1;
                verp[i]=i+1;
            }
        }
    }

    printf ("%d",dp[1]);
    return 0;
}


Measured memory_bytes: 3328
from itertools import *

H, W, K = map(int, input().split())
S = [list(map(int, input())) for i in range(H)]

cut_min = H+W-2

for r_cut in range(H):
  if cut_min <= r_cut:
    continue
  for r_pos in combinations(range(1, H), r_cut):
    r_pos = (None,)+r_pos+(None,)
    r_blocks = [slice(*r_pos[i:i+2]) for i in range(len(r_pos)-1)]
    
    cut = r_cut
    prev_sum = [0] * len(r_blocks)
    for col in zip(*S):
      curr_sum = [sum(col[b]) for b in r_blocks]
      if any(map(K.__lt__, curr_sum)):
        break
      next_sum = [x+y for x,y in zip(prev_sum, curr_sum)]
      if any(map(K.__lt__, next_sum)):
        cut += 1
        if cut_min <= cut:
          break
        prev_sum = curr_sum
      else:
        prev_sum = next_sum
    else:
      cut_min = cut
print(cut_min)


Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

bool second_compare(pair<int, int> x, pair<int, int> y){
    return x.second < y.second;
}

int main(){
    int n, m; cin >> n >> m;
    vector<pair<int, int>> a(m); for (int i = 0; i < m; i++) cin >> a[i].first >> a[i].second;

    sort(a.begin(), a.end());

    int ans = 0;
    int pos = 0;
    while (pos < m){
        pos += distance(a.begin() + pos, min_element(a.begin() + pos, a.end(), second_compare));
        ans++;
        int right_end = a[pos].second;
        while (pos < m && a[pos].first < right_end){
            pos++;
        }
    }

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

Measured memory_bytes: 1024
#include <iostream>

int main(){
    int H, N, A, tmp = 0;
    std::cin >> H >> N;
    for(auto i = 0; i < N; i++){
        std::cin >> A;
        tmp += A;
    }

    if(tmp < H){
        std::cout << "No" << std::endl;
    }
    else{
        std::cout << "Yes" << std::endl;
    }

    return 0;

}


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

int main (){

	string s,t;
	cin >> s >>t;
	int x = stoi(s+t);
	int i;
	
	for (i=1; i<=333; i++){
		if (i*i == x){
		   cout << "Yes" << endl;
		return 0;
			}
	}
	   cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize ("-O3")
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define int long long
#define double long double
#define pb push_back
int max(int a,int b){
    if(a>b)
        return a;
    return b;
}
void lcs(string s1,string s2,int n,int m){
    int dp[n+1][m+1];
    for(int i = 0;i <= n; i++){
        for(int j = 0;j <= m; j++){
            if(i==0||j==0)
                dp[i][j] = 0;
            else if(s1[i-1]==s2[j-1]){
                dp[i][j] = 1 + dp[i-1][j-1];
            }else{
                dp[i][j] = max(dp[i][j-1],dp[i-1][j]);
            }
        }
    }
    char len = dp[n][m];
    string s;
    int i = n, j = m;
    while(i > 0 && j > 0){
        if(s1[i-1]==s2[j-1]){
        //    cout << s1[i-1] << "+";
            s.push_back(s1[i-1]);
            i--,j--;
        }else if(dp[i-1][j]>dp[i][j-1])
            i--;
        else
            j--;
    }
    reverse(s.begin(),s.end());
    cout << s << "\n";
}
int32_t main()
{
    IOS;
    string s1,s2;
    cin >> s1;
    cin >> s2;
    int n = s1.length();
    int m = s2.length();
    lcs(s1,s2,n,m);
    return 0;
}

Measured memory_bytes: 74024
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <deque>

using namespace std;

typedef long long ll;

int N, P, A[51];
int main() {
	scanf("%d %d", &N, &P);
	int cntEven = 0, cntOdd = 0;
	for (int i = 1; i <= N; i++) {
		scanf("%d", &A[i]);
		if (A[i] % 2 == 0) {
			cntEven++;
		} else {
			cntOdd++;
		}
	}
	if (cntOdd == 0) {
		if (P == 1) {
			printf("%d\n", 0);
		} else {
			printf("%lld\n" , 1LL << cntEven);
		}
	} else {
		printf("%lld\n", (1LL << cntEven) * (1LL << (cntOdd - 1)));
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;

const int N = 2e5 + 10;
int l[N][2], r[N][2], a[N];
LL sum[N];
int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", a + i);
    for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i];
    for (int i = 1; i <= n; i++) {
        l[i][0] = min(l[i - 1][0], l[i - 1][1]) + (a[i] % 2 == 0);
        l[i][1] = l[i - 1][1] + (a[i] % 2 != 0);
        if (a[i] == 0) l[i][1] += 2;
        l[i][1] = min(1ll * l[i][1], sum[i]);
    }
    for (int i = n - 1; i >= 0; i--) {
        r[i][0] = min(r[i + 1][0], r[i + 1][1]) + (a[i + 1] % 2 == 0);
        r[i][1] = r[i + 1][1] + (a[i + 1] % 2 != 0);
        if (a[i + 1] == 0) r[i][1] += 2;
        r[i][1] = min(1ll * r[i][1], sum[n] - sum[i]);
    }
    int ans = 1e9;
    for (int i = 0; i <= n; i++) {
        ans = min(ans, min(l[i][0],l[i][1]) + min(r[i][0], r[i][1]));
    }
    printf("%d\n", ans);
    return 0;
}


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

int main(){
  int a,b;
  bool flg;
  cin >> a >> b;
  if(a%3==0){
    flg=true;
  }else if(b%3==0){
    flg=true;
  }else if((a+b)%3==0){
    flg=true;
  }else{
    flg=false;
  }
  if(flg){
    cout << "Possible" << endl;
  }else{
    cout << "Impossible" << endl;
  }
}
  

Measured memory_bytes: 256
/**
 * C - Shopping Street
 * https://atcoder.jp/contests/abc080/tasks/abc080_c
 **/
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<numeric>
#include<functional>
#include<sstream>
#include<iomanip>

using namespace std;

#define ll long long

int main() {
    int n; cin >> n;
    vector<vector<int>> f(n, vector<int>(10, 0));
    vector<vector<ll>> p(n, vector<ll>(10, 0));
    for(int i=0; i<n; ++i) {
        for(int j=0; j<10; ++j) cin >> f[i][j];
    }
    for(int i=0; i<n; ++i) {
        for(int j=0; j<11; ++j) cin >> p[i][j];
    }
    ll ans = -10000000000;
    // bit全探索を行う
    for(int bit=1; bit<(1<<10); ++bit) {
        vector<int> c(n, 0);
        for(int i=0; i<10; i++) {
            if(bit&(1<<i)) {
                for(int j=0; j<n; j++) {
                    if(f[j][9-i]==1) {
                        c[j] += 1;
                    }
                }
            }
        }
        ll cost = 0;
        for(int i=0; i<n; i++) {
            cost += p[i][c[i]];
        }
        ans = max(ans, cost);
    }
    cout << ans << endl;
    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
using str=string;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll a,ll b){
    ll v0=a,v1=b,v2=a%b;
    while(v2!=0){
        v0=v1;
        v1=v2;
        v2=v0%v1;
    }
    return v1;
}

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

int main(){
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    ll h[n],d[n-1];
    rep(i,n) cin >> h[i];
    rep(i,n-1){
        if(h[i]-h[i-1]>=1) h[i]--;
    }
    rep(i,n-1){
        if(h[i]>h[i+1]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#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,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define rn return
#define fi first
#define se second
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;


int main(){
    ll N; cin >> N;
    for(ll i = sqrt(N); i>0; i--){
        ll j = N/i;
        if(j*i == N){
            cout << (j+i-2);
            break;
        }
    }
    
    rn 0;
}

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

typedef pair<int, int> P;

P kyoutuu(P a, P b) {
  P p;
  p.first = max(a.first, b.first);
  p.second = min(a.second, b.second);

  return p;
}

int main() {
  int N, M;
  cin >> N >> M;
  vector<P> lr(M);
  for(int i=0;i<M;i++) {
    cin >> lr[i].first >> lr[i].second;
  }


  P p = lr[0];
  bool ok = true;

  for(int i=1;i<M;i++) {
    if(p.first > p.second) {
      ok = false;
      break;
    } else {
      p = kyoutuu(p, lr[i]);
    }
  }

  if(ok) {
    cout << p.second - p.first + 1 << endl;
  } else {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 #include <cstdio>
 #include <cstring>
 #include <algorithm>
 using namespace std;
    using namespace std;
     
    const int maxn=2e5+10;
    int a[maxn],sum[maxn];
     
    int main()
    {
        int n;
        cin >> n;
        for(int i=1;i<=n;i++)
            cin >> a[i];
        for(int i=1;i<=n;i++)
            sum[i]=sum[i-1]+(abs(a[i]-a[i-1]));
        sum[n+1]=sum[n]+abs(a[0]-a[n]);
        for(int i=1;i<=n;i++)
            cout << sum[i-1]+sum[n+1]-sum[i+1]+abs(a[i-1]-a[i+1]) << endl;
        return 0;
    }


Measured memory_bytes: 2048