akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
using namespace std;
int a,b;
int main() {
	scanf("%d %d",&a,&b);
	if (a==b)
		printf("Draw\n");
	else if (a==1)
		printf("Alice\n");
	else if (b==1)
		printf("Bob\n");
	else if (a>b)
		printf("Alice\n");
	else printf("Bob\n");
	return 0;
}

Measured memory_bytes: 128
use text_io::*;
use std::process::exit;
use im_rc::HashMap;
use std::cmp::min;

fn main() {
    let mut n:usize = read!();
    let mut a:usize = 1;
    let mut b:usize = 0;
    for _ in 0..100000000 {
        for i in 2..(n as f64).sqrt() as usize+1 {
            if n%i==0 {
                b+=1;
            }
        }
        if b==0 && n!=1 {
            println!("{}",n);
            exit(0);
        }
        n+=1;
        b=0;
    }
}

Measured memory_bytes: 2124
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <vector>
#include <bitset>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cassert>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std ;

#define rep(i, a, b) for (int (i)=(a);(i)<=(b);(i)++)
#define Rep(i, a, b) for (int (i)=(a)-1;(i)<(b);(i)++)
#define REP(i, a, b) for (int (i)=(a);(i)>=(b);(i)--)
#define reg(i, x) for (int (i)=head[x];(i);i=e[i].next)
#define clr(a) memset(a,0,sizeof(a))
#define Sort(a, len) sort(a + 1, a + len + 1)
#define Sort2(a, len, cmp) sort(a + 1, a + len + 1, cmp)
#define ass(a, sum) memset(a, sum, sizeof(a))

#define ull unsigned long long
#define ll long long
#define ls ((rt) << 1)
#define rs ((rt) << 1 | 1)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'
#define Pii pair<int, int>

const int N = 100010 ;
const int iinf = INT_MAX/2 ;
const ll linf = LLONG_MAX/2 ;
const int MOD = 1e9+7 ;

inline int read(){
    int X = 0,w = 0 ;
	char ch = 0;
    while(!isdigit(ch)) {w |= ch == '-';ch = getchar();}
    while(isdigit(ch)) X = (X<<3) + (X<<1) + (ch ^ 48),ch = getchar();
    return w ? -X : X;
}

void write(int x){
     if(x < 0) putchar('-'),x = -x;
     if(x > 9) write(x / 10);
     putchar(x%10 + '0');
}

void print(int x) {
	cout << x << endl ;
	exit(0) ;
}

void douout(double x){
	 printf("%lf\n", x + 0.0000000001) ;
}

Pii e[N] ;
int n, m, x,y, tot  ;
int main(){
	scanf("%d%d", &n, &m) ;
	for (int i = 1; i <= n; i++) {
		cin >> x >> y ;
		if (y > m) continue ;
		e[++tot] = (Pii) {x, y} ;
	}
	if (tot == 0) {
		cout << "TLE\n" ;
		return 0 ;
	}
	sort(e + 1, e + tot + 1) ;
	cout << e[1].fi << endl ;
}

/*
写代码时请注意：
	1.是否要开Long Long？数组边界处理好了么？
	2.特殊情况处理好了么？
	3.做一些总比不做好。
	4.最大值和最小值问题可不可以用二分答案？
	5.有没有贪心策略？否则能不能dp？
	6.实数精度有没有处理？
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll            long long
#define nl            "\n"
#define PB            push_back
#define fi            first
#define se            second
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define rep(i,n)      for(int i=0;i<n;i++)
#define repn(i,n)     for(int i=1;i<=n;i++)
#define rrep(i,n)     for(int i=n-1;i>=0;i--)
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
/*-----------------------------------------------------------------------------------------------*/
const int N = 1e5+10;
int n,t;
string s,ss;
int a[N];
int main()
{
    _SAD()
    int a,b;
    cin>>a>>b;
    if(b>=a)
    {
        cout<<"Yes"<<nl;
    }
    else
    {
        cout<<"No"<<nl;
    }
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> d(n);
  for(int i=0; i<n; i++){
    cin >> d[i];
  }
  sort(d.begin(),d.end());
  int ctr=1;
  for(int i=0; i<n-1; i++){
    if(d[i+1]==d[i]) continue;
    ctr++;
  }
  cout << ctr << endl;
  return 0;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int N;
    cin >> N;
    int P[N];
    for(int i = 0; i < N; i++) cin >> P[i];
    
    int min = inf, ans = 0;
    for(int i = 0; i < N; i++){
        if(min >= P[i]){
            min = P[i];
            ans++;
        }
    }
    
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false) ; cin.tie(NULL) ; cout.tie(NULL);
#define int long long
#define pi pair<int,int>
#define ff first
#define ss second
#define pb push_back
#define mod 1000000007
#define N 100000
vector<int > g[N+1];
int dp[N+1];

int solve(int r)
{

if(dp[r] != -1)
return dp[r];

int res = 0;
for(auto j : g[r])
{
     res = max(res , solve(j)+ 1);
}

return dp[r] = res;

}

int32_t main(){
    IOS;

int n,m;
cin>>n>>m;

for(int i=0;i<m;i++)
{
    int x,y;
    cin>>x>>y;
    g[x].pb(y);
}
memset(dp, -1 , sizeof(dp));
int res = 0;
for(int i=1;i<=n;i++)
{
    if(dp[i] == -1)
    {
        res = max(res , solve(i));
    }
}

cout<<res<<endl;
}


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

ll N;



int main(){
	cin >> N;
	vector<int> A(N);
	vector<int> honest(N);
	vector<int> unkind(N);
	
	for ( int i = 0; i < N; i++ ){
		cin >> A[i];
		honest[i] |= ( 1 << i );
		for ( int j = 0; j < A[i]; j++ ){
			int x, y;
			cin >> x >> y;
			x--;
			if ( y )
				honest[i] |= ( 1 << x );
			else
				unkind[i] |= ( 1 << x );
		}
		//cout << i << " " << honest[i] << " " << unkind[i] << endl;
	}
	
	int max_honest = 0;
	for ( int must_honest = 1; must_honest < (1<<N); must_honest++ ){
		int honest_or = 0;
		int unkind_or = 0;
		int honest_num = 0;
		for ( int i = 0; i < N; i++ ){
			int c = 1 << i;
			if ( must_honest & c ){
				honest_num++;
				honest_or |= honest[i];
				unkind_or |= unkind[i];
			}
		}
		if ( (~must_honest & honest_or) == 0 && (must_honest & unkind_or) == 0 ){
			max_honest = max(max_honest, honest_num);
			//cout << must_honest << "  " << honest_or << " " << unkind_or << endl;
		}
	}
	
	
	
	cout << max_honest << endl;
	
	return 0;
}



Measured memory_bytes: 256
#include<cstdio>
int a[101],b,k;
int main(){
    scanf("%d",&b);
    for(int i=0;i<b;++i)scanf("%d",a+i);
    for(int i=0;i<b-1;++i)printf("%d ",a[i]);
    printf("%d\n",a[b-1]);
    for(int i=1;i<b;++i){
        k=a[i];
        int j;
        for(j=i-1;j>=0&&a[j]>k;--j){
            a[j+1]=a[j];
        }
        a[j+1]=k;
        for(int i=0;i<b-1;++i)printf("%d ",a[i]);
        printf("%d\n",a[b-1]);
    }
    return 0;
}


Measured memory_bytes: 2700
//Author - Rahil Malhotra
#include "bits/stdc++.h"
using namespace std;
 
template <typename T> void print(T t) { cout<<t<<endl; }
template<typename T, typename... Args> void print(T t, Args... args) { cout<<t<<" "; print(args...); }
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define int long long
#define double long double

int32_t main()
{
    IOS;
    // for(int i=1;i<=20;i++)
    // {
    //     int ans=0;
    //     for(int a=1;a<=20;a++)
    //         for(int b=1;b<=20;b++)
    //             for(int c=1;c<=20;c++)
    //                 if(a*b+c==i)
    //                     ans++;
    //     print(i,ans);
    // }
    int n;
    cin>>n;
    n--;
    int ans=0;
    for(int i=1;i<=n;i++)
        ans+=n/i;
    print(ans);
}   


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

#define LINE_BUF_SIZE 256

int main(){

    int A,N,R;

    scanf("%d %d", &N,&A);

    R = N % 500;

    if(R <= A){
        printf("Yes");
    }

    else{
        printf("No");
    }

    return 0;

}

Measured memory_bytes: 128
N = int(input())

ans = [0 for _ in range(10**4+1)]

for i in range(1, 101):
    for j in range(1, 101):
        for k in range(1, 101):
            val = i**2 + j**2 + k**2 + i*j + j*k + k*i
            if val <= 10**4:
                ans[val] += 1

for i in range(1, N+1):
    print(ans[i])


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

int D[100005], D2[100005], n;
vector<int> E[100005];

void DFS(int a, int pp, int d) {
  D[a] = d;
  for (int i = 0; i < E[a].size(); i++) {
    if (E[a][i] != pp) DFS(E[a][i], a, d + 1);
  }
}

int main() {
  int a,b;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    scanf("%d%d", &a, &b);
	E[a].push_back(b);
	E[b].push_back(a);
  }
  DFS(n, 0, 0);
  for (int i = 1; i <= n; i++) D2[i] = D[i];
  DFS(1, 0, 0);
  int r1 = 0, r2 = 0;
  for (int i = 1; i <= n; i++) {
    if (D[i] <= D2[i])r1++;
	else r2++;
  }
  if (r1 > r2)printf("Fennec\n");
  else printf("Snuke\n");
}


Measured memory_bytes: 12800
n,k,q=map(int,input().split())
p=[k-q]*n
a=[]

for i in range(q):
    a.append(int(input())-1)

for i in range(q):
    p[a[i]]+=1
    
for i in range(n):
    if p[i]>0:
        print("Yes")
    else:
        print("No")


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

const Long MX = 1e5 + 10;

Long cnt[MX];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout.precision(10);
	cout << fixed;

	Long n, x;
	cin >> n;
	Long sum = 0;
	for(Long i = 0; i < n; i++){
		cin >> x;
		cnt[x]++;
		sum += x;
	}
	
	Long q, y;
	cin >> q;
	for(Long i = 0; i < q; i++){
		cin >> x >> y;
		Long c1 = cnt[x];
		sum -= c1 * x;
		cnt[x] -= c1;
		cnt[y] += c1;
		sum += c1 * y;
		cout << sum << "\n";
	}
	return 0;
}


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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

int main()
{
  fastio;
  int n, m; cin >> n >> m;
  for (int i = 1; i <= m; i++){
    int x; cin >> x;
    n -= x;
  }
  cout << max(-1, n);
  return 0;
}

Measured memory_bytes: 3660
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
	int n;
	ll a[100000];
	int t;
	ll sum = 0;
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%lld",a+i);
	sort(a,a+n);
	sum = a[0];
	t = 0;
	for(int i=1;i<n;i++){
		if(2*sum<a[i]) t = i;
		sum += a[i];
	}
	printf("%d\n",n-t);
	return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll INF=1000000010;
const ll MOD=1000000007;
const ll LINF=4000000000000000000;
const long double EPS=1e-9;
typedef pair<int,int> P;
int main(){
    int n;cin>>n;
    ll ans=0;
    int s=2;
    for(int i=0;i<n;i++){
        ll a;cin>>a;
        if(i==0){
            ans+=a-1;
        }else if(a==s){
            s++;
        }else{
            ans+=(a-1)/s;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define N 100005
#define M 10000007
#define O 1000000009
#define vll vector<long long>
#define vl vector<long>
#define dis(n) cout<<n<<endl
#define fo(i,N) for(int i=0; i<N; ++i)
#define fos(i,b,N) for(int i=b; i<N; ++i)
#define forr(i,N) for(i=N; i>=0; --i)

using namespace std;
int main()
{
    long n, w;
    cin >> n >> w;
    vl a(n), b(n);
    fo(i, n) cin >> a[i] >> b[i];

    long dp[n + 1][w + 1];

    fo(i, n + 1)
        fo(j, w + 1)
            dp[i][j] = 0;

    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= w; ++j) {
            dp[i][j] = dp[i - 1][j];

            if(j - a[i - 1] >= 0)
                dp[i][j] = max(dp[i][j], dp[i - 1][j - a[i - 1]]  + b[i - 1]);
        }
    }

    cout << dp[n][w];
    return 0;
}

Measured memory_bytes: 82328
program abc117b
  implicit none
  integer n
  integer,allocatable :: l(:)
  read *, n
  allocate(l(n))
  read *, l
  if (sum(l)-maxval(l)*2 > 0) then
     print *, 'Yes'
  else
     print *, 'No'
  end if
end program abc117b


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


int main(int argc, const char * argv[]) {
  vector<double> water;
  vector<double> sugar;
  double maxdensity = -1;
  double maxwater, maxsugar;
  double A, B, C, D, E, F;
  cin>>A>>B>>C>>D>>E>>F;
  for (double i = 0; i <= F/(100.0*A); i++) {
    for (double j = 0; j <= F/(100.0*B); j++) {
      if (100*A*i + 100*B*j <= F) {
        if (i != 0 || j != 0){
          water.push_back(100*A*i + 100*B*j);
        }
      }
    }
  }
  double sugar_solution_max = F/100.0*E;
  
  for (double i = 0; i <= sugar_solution_max/C; i++) {
    for (double j = 0; j <= sugar_solution_max/D; j++) {
      if (C*i + D*j <= sugar_solution_max) {
        sugar.push_back(C*i+D*j);
      }
    }
  }
  
  for (double i = 0; i < water.size(); i++) {
    for (double j = 0; j < sugar.size(); j++) {
      if (water[i]/100*E>=sugar[j] && water[i] + sugar[j] <= F) {
        double density = sugar[j] / water[i];
        if (maxdensity < density) {
          maxdensity = density;
          maxwater = water[i] + sugar[j];
          maxsugar = sugar[j];
        }
      }
    }
  }
  cout<<maxwater<<" "<<maxsugar;
  return 0;
}


Measured memory_bytes: 2420
#include<stdio.h>

int main(void){
	int H,W,a[100000],b,c=0,e=0;
	/*scanf("%d %d",&H,&W);
	a[b]=H;
	a[b+1]=W;*/
	for(b=0;;b++){
		scanf("%d %d",&H,&W);
		a[b]=H;
		a[b+1]=W;
		if(a[b]+a[b+1]==0){
			break;
		}
		b++;
	}
	/*printf("%d %d",a[4],a[5]);*/
	/*???????????????????????£?¢??????¨??????????????\?????????????????????????????\????????????????????????????????????*/
	for(b=0;a[b]+a[b+1]!=0;b++){
		/*printf("%d %d\n",a[b],a[b+1]);*/
		/*??????????????????????????£?¢??????¨2???????????\?????????????????????????????\????????????????????????????????????*/
		for(c=0;c<a[b];c++){
			for(e=0;e<a[b+1];e++){
				printf("#");
				if(c>=a[b]){
					printf("\n");
				}
			}
			printf("\n");
		}
		printf("\n");
		b++;
	}
		return 0;
}

Measured memory_bytes: 1804
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	char save = 0;
    	String ans = "Yes";
    	Set<String> old = new HashSet<>();
    	for (int i = 0; i < N; i++) {
    		String s = sc.next();
    		if (i != 0 && (s.charAt(0) != save || old.contains(s))) {
    			ans = "No";
    			break;
    		}
    		save = s.charAt(s.length()-1);
    		old.add(s);
    	}
    	System.out.println(ans);
    }
}

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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<vector<int>> a(2, vector<int>(n));
  rep(i, 2) rep(j, n) cin >> a[i][j];

  int maxValue = INT_MIN;
  int currentIndex = 0;
  rep(i, n) {
    int value = 0;
    currentIndex = 0;
    rep(j, n) {
      if (i == j) {
        // ここで移動
        value += a[currentIndex][j];
        currentIndex = 1;
      }
      value += a[currentIndex][j];
    }
    maxValue = max(value, maxValue);
  }
  cout << maxValue << endl;

  return 0;
}


Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():

    N = in_n()
    A = in_nl()

    ans = 0
    mod = 10**9 + 7
    sum_a = sum(A)
    for i in range(N):
        ans += A[i] * (sum_a - A[i])
        ans %= mod

    ans *= pow(2, mod - 2, mod)
    ans %= mod
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 92732
using System;
using System.Collections.Generic;

public class CSharp{
    public static void Main(){
        Kyopuro chokudai = new Kyopuro();
	    chokudai.AtCoder();
	}
}

public class Kyopuro{
    
    int p, n;
    string L;
    bool[] a;
    Mod mod;
    
    public void AtCoder(){
        p = 1000000007;
        L = Console.ReadLine();
        n = L.Length;
        a = new bool[n];
        for(int i=0; i<n; i++){
            if(L[i] == '1'){
                a[i] = true;
            }
        }
        
        mod = new Mod(1);
        Console.WriteLine(Solve(0));
    }
    
    public long Solve(int x){
        if(x == n - 1){
            if(a[x]) return 3;
            else return 1;
        }
        long y = 0;
        if(a[x]){
            y += mod.Pow(3, n-1-x);
            y %= p;
            y += Solve(x+1) * 2;
            y %= p;
        } else {
            y = Solve(x+1) % p;
        }
        return y;
    }
    
    public static void DebugWL(object x){ System.Diagnostics.Debug.WriteLine(x); }
}

// Mod(int n)
// int[] fac: factors (1-indexed)
// int n: the length of fac

// int .Ncr(n,r): nCr
// int .Fac(n): n!%p
// int .Pow(n,m): n^m%p

public class Mod{
	const int p = 1000000007;
	int[] fac;

	public Mod(int n){
		fac = new int[n+1];
		fac[0] = 1;
		long tmp = 0;
		for (int i=1; i<=n; i++){
			tmp = fac[i-1];
			tmp *= i;
			tmp %= p;
			fac[i] = (int)tmp;
		}
	}

	public int Ncr(int n, int r){
		if(n<r) return 0;
		if(r==0|n==r) return 1;
		long a = fac[n];
		a = a * Pow(fac[n-r], p-2) % p;
		a = a * Pow(fac[r], p-2) % p;
		return (int)a;
	}

	public int Pow(int n, int m){
		if(m==0) return 1;
		if(m==1) return n;
		long a = 1;
		if(m%2 == 0){
			a = Pow(n,m/2);
			a = a * a % p;
		}else{
			a = Pow(n,m/2);
			a = a * a % p;
			a = a * n % p;
		}
		return (int)a;
	}
}

Measured memory_bytes: 16096
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, K: int):
    div = []
    for i in range(1,min(A,B)+1):
        if A % i == 0 and B % i == 0:
            div.append(i)
    print(div[len(div) - K])
    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(A, B, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
    long long int a, b, k, r;
    scanf("%lld%lld%lld", &a, &b, &k);

    if(a>=k)
        printf("%lld %lld\n", a-k, b);
    else if(a+b >= k)
    {
        r = k - a;
        b = b - r;
        printf("0 %lld\n", b);
    }

    else
    {
        printf("0 0\n");
    }
    return 0;
}


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

int main(void) {
  int A, B, C;
  cin >> A >> B >> C;
  if ((A == B && B != C) || (B == C && C != A) || (C == A && A != B)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long  n,k;
int main()
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int h = c/b +(c%b!=0);
  int h2 = a/d +(a%d!=0);
  if(h <= h2)cout<<"Yes";
  else cout<<"No";


}










Measured memory_bytes: 3636
n,q=map(int,input().split())
s=input()
d=[0]*n
#l=[int(i) for i in input().split()]
for i in range(1,n):
    if s[i-1]=="A" and s[i]=="C":
        d[i]+=d[i-1]+1
    else:
        d[i]=d[i-1]
#print(*d)
for i in range(q):
    l,r=map(int,input().split())
#    print(l,r,s[l-1:r],d[l-1],d[r-1])
    print(d[r-1]-d[l-1])


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

typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
const ll INF = 1001001001;
const ll MOD = 1e9 + 7;

int main(){
  ll a, b;
  cin >> a >> b;
  ll ans = 0;
  //cout << a % b <<endl;
  ans += abs((b+1) / 2 - a/2) % 2;
  for(int i = 1;i < 41; i++){
    ll m = pow(2, i);
    ll k = 2*m;
    ll p = (a-1) % k, q = b % k;
    if(p >= m) p = (p-m+1) % 2;
    else p = 0;
    if(q >= m) q = (q-m+1) % 2;
    else q = 0;
    if(abs(p-q) % 2) ans += m;
  }
  cout << ans <<endl;
}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

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

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

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

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

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

template <class T> T Sq(const T &t) { return t * t; }

const int mod = 1e9 + 7;

signed main() {
  string x, y;
  std::cin >> x >> y;
  if (x == y)
    std::cout << "=" << std::endl;
  else if (x < y)
    std::cout << "<" << std::endl;
  else
    std::cout << ">" << std::endl;
}


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

A=[]

for i in range(N):
    B = list(map(int, input().split()))
    A.append(B)

for i in range(N):
    if i==0:
        if A[i][0]<A[i][1]+A[i][2]:
            print('No')
            exit(0)
        elif A[i][0]%2!=(A[i][1]+A[i][2])%2:
            print('No')
            exit(0)
    else:
        if A[i][0]-A[i-1][0]<abs(A[i][1]+A[i][2]-(A[i-1][1]+A[i-1][2])):
            print('No')
            exit(0)
        elif (A[i][0]-A[i-1][0])%2!=abs(A[i][1]+A[i][2]-(A[i-1][1]+A[i-1][2]))%2:
            print('No')
            exit(0)
print('Yes')

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

#define f first
#define s second
#define pb push_back
#define all(c) c.begin(),c.end()

#define gi(x) scanf("%d", &x)
#define pi(x) printf("%d", x)
#define gl(x) scanf("%lld", &x)
#define pl(x) printf("%lld", x)
#define sp printf(" ")
#define nl printf("\n")

typedef long long int lld;
typedef long double ldb;



int f[30];

main(){
    lld ans = 1;
    string str;
    cin >> str;
    for(int i = 0; i < str.size(); ++i){
        ans += i - f[(int)(str[i] - 'a')];
        f[(int)(str[i] - 'a')]++;
    }
    cout << ans << endl;
}


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

#define MAXN (100010)

int n, a[MAXN];

bool solve(){
	int odd = 0, even = 0, sit;
	for(int i = 1; i <= n; ++ i){
		if(a[i] & 1){
			++ odd;
			sit = i;
		}
		else{
			++ even;
		}
	}
	
	if(even & 1) return true;
	if(odd >= 2) return false;
	
	if(a[sit] == 1) return false;
	-- a[sit];
	
	int gcd = std::__gcd(a[1], a[2]);
	for(int i = 3; i <= n; ++ i){
		gcd = std::__gcd(gcd, a[i]);
	}
	for(int i = 1; i <= n; ++ i){
		a[i] /= gcd;
	}
	
	return !solve();
}

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; ++ i){
		scanf("%d", a + i);
	}
	if(n == 1) return printf("Second\n"), 0;
	printf(solve() ? "First\n" : "Second\n");
	return 0;
}

Measured memory_bytes: 640
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
 
using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;
using ld = long double;
 
// ------------------------------------------------------------------------------------------------

ll p;
string s;
vector<string> phrases;

int main() {
    fast_io; cout_precision;
    phrases = {"maerd", "remaerd", "esare", "resare"};
    cin >> s;
    reverse(s.begin(), s.end());
    p = 0;
    while (p < (ll) s.length()) {
        ll found = 0;
        for (string &phrase : phrases) {
            if ((ll) s.find(phrase, p) == p) {
                p += phrase.length();
                found = 1;
                break;
            }
        }
        if (found == 0) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 512
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();

		long min = (long)A*(N-1)+B;
		long max = A+(N-1)*(long)B;
		System.out.println(Math.max(0, max-min+1));
		
		sc.close();
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = (a), i_len = (b); i < i_len; ++i)

int main()
{
    int A, B;
    cin >> A >> B;
    if(A >= 10 || B >= 10) cout << -1 << endl; 
    else cout << A*B << endl;
    return 0;
}

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

int main() {
    int N;
    cin >> N;
    string s;
    cin >> s;
    int right = 0, right_tmp = 0;
    int left = 0, left_tmp = 0;
    for (int i = 0, j = N - 1; i < N; i++, j--) {
        if (s[i] == ')') {
            if (right_tmp > 0) {
                right_tmp--;
            } else {
                right++;
            }
        }
        if (s[i] == '(') right_tmp++;
        if (s[j] == '(') {
            if (left_tmp > 0) {
                left_tmp--;
            } else {
                left++;
            }
        }
        if (s[j] == ')') left_tmp++;
    }
    cout << string(right, '(') << s << string(left, ')') << endl;
}

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

void solve(){
    int N;
    cin>>N;
    vector<int> v(N+1,0);
    for(int i=1;i<=N;i++){
        int a;
        cin>>a;
        v[a] = i;
    }
    for(auto i:v) if(i!=0)cout << i << " ";

}


int main(){
   solve();
}

Measured memory_bytes: 1152
//Ankit Verma
//Chandigarh University
//verma_ankit484( handle on cp sites)
//verma.ankit484@gmail.com

#include<bits/stdc++.h>
typedef long long ll;

using namespace std;

int main()
{
	#ifdef AV
	freopen("int.txt", "r", stdin);
	#endif
	ll n;
	cin>>n;
	vector<ll> vc(n);
	for(ll i=0; i<n; i++){
		cin>>vc[i];
	}
	vector<ll> dp(n, 0);
	dp[0]=0;
	dp[1]=abs(vc[0]-vc[1]);
	for(ll i=2; i<n; i++){
		dp[i]=min(abs(vc[i]-vc[i-1])+dp[i-1], abs(vc[i]- vc[i-2])+dp[i-2]);
	}
	cout<<dp[n-1]<<"\n";
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <map>
#include <queue>
using namespace std;

class Vertex {
public:
    int num;
    bool flag;                  // 以前訪れたかどうか
    vector<int> adj;            // 隣接リスト
};

int dist[101];
void bfs(map<int, Vertex>& graph, Vertex s) {
    queue<Vertex> que;

    dist[s.num] = 0;
    graph[s.num].flag = true;
    que.push(s);
    while (!que.empty()) {
        Vertex u = que.front(); que.pop();
        for (auto i = 0; i < u.adj.size(); i++) {
            Vertex v = graph[u.adj[i]];
            if (!v.flag) {
                graph[u.adj[i]].flag = true;
                dist[v.num] = dist[u.num]+1;
                que.push(v);
            }
        }
    }
}

int main(void) {
    int n;
    cin >> n;
    for (int i = 0; i < 101; i++) {
        dist[i] = -1;
    }

    map<int, Vertex> graph; // 頂点の番号->頂点
    for (int i = 0; i < n; i++) {
        Vertex v;
        int num, k;
        cin >> num >> k;
        v.flag = false;
        v.num = num;
        for (int j = 0; j < k; j++) {
            int tmp;
            cin >> tmp;
            v.adj.push_back(tmp);
        }
        graph[num] = v;
    }

    bfs(graph, graph[1]);
    for (int i = 1; i <= n; i++) {
        cout << i << " " << dist[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 1232
#include<algorithm>
#include<iostream>
#include<functional>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
  int n,count=0;
  int t[110000];
  int x[110000];
  int y[110000];
  t[0]=x[0]=y[0]=0;
  cin>>n;
  for(int i=1;i<n+1;i++){
    cin>>t[i]>>x[i]>>y[i];
    if(t[i]%2==1 and (x[i]+y[i])%2==0){
      count++;
      break;
    }
    if(t[i]%2==0 and (x[i]+y[i])%2==1){
      count++;
      break;
    }
    if(t[i]<(x[i]+y[i])){
      count++;
      break;
    }
    if(abs((x[i]+y[i])-(x[i-1]+y[i-1]))>(t[i]-t[i-1])){
        count++;
        break;
      }
    }
  if(count>0)
    cout<<"No"<<endl;
  else
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using Lint=long long;

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

    int N,K; cin>>N>>K;
    vector<int> a(N);
    for(int i=0;i<N;i++) cin>>a[i];

    auto check=[&](int P)
    {
        int cnt=1,cur=0;
        for(int i=0;i<N;i++){
            if(cur+a[i]<=P){
                cur+=a[i];
            }else{
                cnt++,cur=a[i];
            }
        }
        return cnt<=K;
    };

    int mx=*max_element(a.begin(),a.end());
    int ng=mx-1,ok=1e9;
    while(ok-ng>1){
        int mid=(ok+ng)/2;
        if(check(mid)) ok=mid;
        else ng=mid;
    }
    cout<<ok<<endl;
    return 0;
}


Measured memory_bytes: 3356
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
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; }

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

int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<ll> a(n+1);
  for(int i=1; i<=n; i++) cin >> a[i];
  int l[n+2],r[n+2];
    l[0]=r[n+1]=0;
    for(int i=1;i<=n;i++){
        l[i]=gcd(l[i-1],a[i]);
    }
    for(int i=n;i>=1;i--){
        r[i]=gcd(r[i+1],a[i]);
    }
    int ans=-1;
    for(int i=1;i<=n;i++){
        ans=max(ans,(int)gcd(l[i-1],r[i+1]));
    }
    cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>

int field[14][14];

int input();
void search(int x,int y);

int main()
{
	int x,y,islandnum;
	while(input(field)==0)
	{
		islandnum=0;
		for(y=1;y<=12;y++)
		{
			for(x=1;x<=12;x++)
			{
				if(field[x][y]==1)
				{
					search(x,y);
					islandnum++;
				}
			}
		}
		printf("%d\n",islandnum);
	}
	return 0;
}

int input()
{
	int x,y;
	char s[14];
	for(x=0;x<14;x++)
	{
		field[x][0]=0;
		field[x][13]=0;
	}
	for(y=1;y<=12;y++)
	{
		if(fgets(s,14,stdin)==NULL){return 1;}
		else if(strcmp(s,"\n")==0)
		{
			y--;
			continue;
		}
		field[0][y]=0;
		field[13][y]=0;
		for(x=1;x<=12;x++)
		{
			field[x][y]=(int)(s[x-1]-'0');
		}
	}
	return 0;
}

void search(int x,int y)
{
	field[x][y]=0;
	if(field[x-1][y]==1){search(x-1,y);}
	if(field[x+1][y]==1){search(x+1,y);}
	if(field[x][y-1]==1){search(x,y-1);}
	if(field[x][y+1]==1){search(x,y+1);}

}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define f first
#define s second
#define int long long
signed main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(b+1==d)c(0)
	else c(1)
}	

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long MOD = 1e9 + 7;
using namespace std;
typedef long long ll;

map<ll, int> mp;
int main() {
	string s;
	cin >> s;
	long long cnt = 0;
	for (int i = 0; i < s.size(); i++) {
		for (int j = i; j < s.size(); j++) {
			long long num = stoll(s.substr(i, j - i + 1));
			long long k = 1;
			if (i == 0) k *= 1;
			else k *= (1 << (i - 1));
			long long L = s.size() - j - 1;
			if (L == 0) k *= 1;
			else k *= (1 << (L - 1));
			cnt += num * k;
		}
	}
	cout << cnt << endl;
	return 0;
}

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

#define	pb	push_back

using namespace std;

int main(){
	for(int plen;cin>>plen,plen;){
		int cnum,w,cspace;
		cin>>cnum>>w>>cspace;
		cin.ignore();

		vector<string> mul;
		for(string s;getline(cin,s),s!="?";){
			int len=s.length();
			if(len==0)	mul.pb("");
			for(int i=0;i<len;i+=w){
				if(w<len-i)	mul.pb(s.substr(i,w));
				else		mul.pb(s.substr(i));
			}
		}
//for(int i=0;i<mul.size();i++)	cout<<mul[i]<<endl;
		int m=mul.size();
		int pages=(m+(plen*cnum-1))/(plen*cnum);	// ceiling
		for(int i=0;i<pages;i++){
			int offset=i*plen*cnum;
			vector<string> pg(plen);
			if(i==pages-1){	// last page
				for(int j=offset;j<m;j++){
					pg[j%plen]+=mul[j];
					int padding=w-mul[j].length();
					pg[j%plen]+=string(padding,'.');
				}
				for(int j=m;j<offset+plen*cnum;j++){
					pg[j%plen]+=string(w,'.');
				}
			}
			else{
				for(int j=offset;j<offset+plen*cnum;j++){
					pg[j%plen]+=mul[j];
					int padding=w-mul[j].length();
					pg[j%plen]+=string(padding,'.');
				}
			}

			for(int i=0;i<plen;i++){
				for(int j=0;j<cnum;j++){
					if(j>0)	cout<<string(cspace,'.');
					cout<<pg[i].substr(w*j,w);
				}
				cout<<endl;
			}
			cout<<'#'<<endl;
		}

		cout<<'?'<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#!/usr/bin/env python3
import math


def main():
    n, k = map(int, input().split())
    p = 0
    for i in range(1, n + 1):
        head_num = math.ceil(math.log(k / i, 2.0))
        head_num = max(head_num, 0)
        p += 1 / n * ((0.5) ** head_num)
    print(p)


if __name__ == '__main__':
    main()


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

int main() {
  string s;
  cin >> s;
  ll N;
  N = s.size();
  ll start, end;
  for (int i = 0; i < N; i++) {
    if (s[i] == 'A') {
      start = i;
      break;
    }
  }
  for (int i = 0; i < N; i++) {
    if (s[N-1-i] == 'Z') {
      end = N-1-i;
      break;
    }
  }
  cout << end-start+1 << endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <string>
using namespace std;
int main()
{
	int h[2], m[2], s[2], t, u, w, v = 7200;
	while (scanf("%d %d %d", &h[0], &m[0], &s[0]) && h[0] != -1 && m[0] != -1 && s[0] != -1)
	{
		t = h[0] * 3600 + m[0] * 60 + s[0];
		u = v - t;
		w = u * 3;
		h[1] = u / 3600;
		m[1] = (u % 3600) / 60;
		s[1] = (u % 3600) % 60;
		printf("%02d:%02d:%02d\n", h[1], m[1], s[1]);
		h[1] = w / 3600;
		m[1] = (w % 3600) / 60;
		s[1] = (w % 3600) % 60;
		printf("%02d:%02d:%02d\n", h[1], m[1], s[1]);
	}
}

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

const int N=200010;
int n,a[N];
bool f[N];

bool check(int x)
{
	for(int i=1;i<2*n;i++) f[i]=(a[i]>=x);
	for(int i=0;i<n;i++)
	{
		if(!f[n-i]&&!f[n-i-1]||!f[n+i]&&!f[n+i+1]) return false;
		if(f[n-i]&&f[n-i-1]||f[n+i]&&f[n+i+1]) return true;
	}
	return f[1];
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<2*n;i++) scanf("%d",a+i);
	int l=1,r=2*n-1,mid;
	while(l<r)
	{
		mid=(l+r)/2;
		if(check(mid)) l=mid+1;
		else r=mid-1;
	}
	printf("%d\n",check(l)?l:l-1);
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

    S[3] = '8';

    cout << S << endl;

    return 0;
}


Measured memory_bytes: 3080
#!/usr/bin/env python
# coding: utf-8

# In[13]:


S = input()


# In[14]:


odd_list = list(S[::2])
even_list = list(S[1::2])


# In[15]:


if "L" in odd_list:
    print("No")
elif "R" in even_list:
    print("No")
else:
    print("Yes")


# In[ ]:






Measured memory_bytes: 2940
#include<iostream>
#include<stdio.h>
#include<string>
#include <algorithm>
#include<cstring>
#include <math.h>
#include <iomanip>
using namespace std;


int insertionSort(int x,int y)
{
  int d;
  if(y==0)return x;
  d=x%y;
  int ans=insertionSort(y,d);
  return ans;
}
  

int main()
{
  int x,y;
 
  cin>>x>>y;
  int ans=insertionSort(x,y);
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3084
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define INF 2000000000
#define DESPACITO2 1000000000000000
#define DESPACITO 1000000000000000000
#define MOD 1000000007
#define ll long long
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define ii pair<int,int>
#define vii vector<ii>
#define si set<int>
#define msi map<string,int>
#define REP(i,a,b) for(int i=int(a);i<=int(b);i++)
#define TRvi(c,it) for(vi::iterator it=(c).begin();it!=(c).end();it++)
#define TRvii(c,it) for(vii::iterator it=(c).begin();it!=(c).end();it++)
#define TRmsi(c,it) for(msi::iterator it=(c).begin();it!=(c).end();it++)
 
 
using namespace std;


int main()
{
    IOS;
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
    int arr[3];
    cin >> arr[0] >> arr[1] >> arr[2];
    sort(arr,arr+3);
    cout << arr[2]-arr[0];
    
}

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

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

int main(){
    
    ll N;cin>>N;
    ll a1,b1,c1,a2,b2,c2;
    cin>>a1>>b1>>c1>>a2>>b2>>c2;
    if(a1>=a2&&b1>=b2&&c1>=c2){
        ll ans=N;
        for(ll i=0;i<=N/a2;i++){
            for(ll j=0;j<=(N-i*a2)/b2;j++){
                ll have=N;
                ll k=(N-i*a2-j*b2)/c2;
                have+=(i*(a1-a2)+j*(b1-b2)+k*(c1-c2));
                ans=max(ans,have);
            }
        }
        cout<<ans<<endl;
    }else if(a1<=a2&&b1<=b2&&c1<=c2){
        ll ans=N;
        for(ll i=0;i<=N/a1;i++){
            for(ll j=0;j<=(N-i*a1)/b1;j++){
                ll have=N;
                ll k=(N-i*a1-j*b1)/c1;
                have+=(i*(a2-a1)+j*(b2-b1)+k*(c2-c1));
                ans=max(ans,have);
            }
        }
        cout<<ans<<endl;
    }else if(a1>=a2&&b1<=b2&&c1<=c2){
        ll ans=N;
        for(ll i=0;i<=N/b1;i++){
            for(ll j=0;j<=(N-i*b1)/c1;j++){
                ll have=N+i*(b2-b1)+j*(c2-c1);
                ll k=have/a2;
                have+=k*(a1-a2);
                ans=max(ans,have);
            }
        }
        cout<<ans<<endl;
    }
    else if(a1<=a2&&b1>=b2&&c1<=c2){
        ll ans=N;
        for(ll i=0;i<=N/a1;i++){
            for(ll j=0;j<=(N-i*a1)/c1;j++){
                ll have=N+i*(a2-a1)+j*(c2-c1);
                ll k=have/b2;
                have+=k*(b1-b2);
                ans=max(ans,have);
            }
        }
        cout<<ans<<endl;
    }
    else if(a1<=a2&&b1<=b2&&c1>=c2){
        ll ans=N;
        for(ll i=0;i<=N/a1;i++){
            for(ll j=0;j<=(N-i*a1)/b1;j++){
                ll have=N+i*(a2-a1)+j*(b2-b1);
                ll k=have/c2;
                have+=k*(c1-c2);
                ans=max(ans,have);
            }
        }
        cout<<ans<<endl;
    }else if(a1>=a2&&b1>=b2&&c1<=c2){
        ll ans=N;
        ll don=N+(N/c1)*(c2-c1);
        for(ll i=0;i<=don/a2;i++){
            ll j=(don-i*a2)/b2;
            ll have=N+(N/c1)*(c2-c1);
            have+=i*(a1-a2)+j*(b1-b2);
            ans=max(ans,have);
            }
        cout<<ans<<endl;
    }else if(a1>=a2&&b1<=b2&&c1>=c2){
        ll ans=N;
        ll don=N+(N/b1)*(b2-b1);
        for(ll i=0;i<=don/a2;i++){
            ll j=(don-i*a2)/c2;
            ll have=N+(N/b1)*(b2-b1);
            have+=i*(a1-a2)+j*(c1-c2);
            ans=max(ans,have);
        }
        cout<<ans<<endl;
    }else if(a1<=a2&&b1>=b2&&c1>=c2){
        ll ans=N;
        ll don=N+(N/a1)*(a2-a1);
        for(ll i=0;i<=don/b2;i++){
            ll j=(don-i*b2)/c2;
            ll have=N+(N/a1)*(a2-a1);
            have+=i*(b1-b2)+j*(c1-c2);
            ans=max(ans,have);
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 256
($n,$q)=split / /,<>;
$s=<>;
chomp($q);
chomp($s);
@AC[0]=0;
for(my$i=1;$i<=$n;$i++){
    $judge = substr($s,$i-1,2) eq "AC";
    $j=$judge?1:0;
    $AC[$i]=$AC[$i-1]+$j;
}
# print @AC;
for(my$i=0;$i<$q;$i++){
    ($l,$r)=split / /,<>;
    # $t=substr($s,$l-1,$r-$l+1);
    # $c=(()=$t=~m/a/g);
    $k=$AC[$r-1]-$AC[$l-1];
    print"$k\n";
}

Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

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

long long modpow(long long x, long long n, long long m) {
	long long ans = 1;
	while (0 < n) {
		if (n % 2 == 0)x = x * x%m, n >>= 1;
		else ans = ans * x%m, n--;
	}
	return ans;
}

vector<long long> v = { 2,7,61 };

//ミラー-ラビン素数判定法
bool Miller_Rabin(long long n) {
	if (n < 2)return false;

	//(n-1)を(2^s*d)の形にする
	long long d = n - 1, s = 0;
	while (d % 2 == 0)
		d /= 2, s++;

	//aを2,7,61として調べる
	for (auto a : v) {
		if (a == n)return true;

		bool flag = false;
		long long r = modpow(a, d, n);

		if (r == 1 || r == n - 1)flag = true;
		for (int j = 0; j < s; j++) {
			r = modpow(r, 2, n);
			if (r == n - 1)flag = true;
		}
		if (!flag)return false;
	}
	return true;
}

int main() {
	VI p;
	for (int i = 2; i < 1000000; i++) {
		if (Miller_Rabin(i))p.pb(i);
	}
	int n;
	while (cin >> n) {
		decltype(p)::iterator it = lower_bound(all(p), n);
		size_t pos = distance(p.begin(), it);
		if (p[pos] == n)pos++;
		cout << pos << endl;
	}
}


Measured memory_bytes: 3356
#include<stdio.h>

#define pi 3.14159265358979323846

int main(){
	
    double a,luas,kll;
    scanf("%lf",&a);
    printf("%lf %lf\n",pi*a*a,2*pi*a);
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	return 0;
}


Measured memory_bytes: 2032
#include<bits/stdc++.h>
#include<math.h>
#define PI 3.1415926535
using namespace std;
int a, b, h, m;
int main() {
	cin >> a >> b >> h >> m;
	double angle = 30.0 * h - 11 * 0.5 * m;
	double ans = sqrt(a * a + b * b - 2 * a * b * cos((angle) * PI / 180.0));
	printf("%.10f\n", ans);
	return 0;
}

Measured memory_bytes: 4100
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int S = scanner.nextInt();
		int W = scanner.nextInt();
		if (S <= W) {
			System.out.println("unsafe");
		} else {
			System.out.println("safe");
		}
	}
}


Measured memory_bytes: 35764
#include "bits/stdc++.h"

using namespace std;

string join_vector(std::vector<int> data)
{
  ostringstream buf;
  auto delimiter = " ";
  for (auto i = data.begin(); i != data.end(); i++)
  {
    buf << *i;
    if (std::distance(i, data.end()) > 1)
    {
      buf << delimiter;
    }
  }

  return buf.str();
}

void print_vector(std::vector<int> data)
{
  cout << join_vector(data) << endl;
}

int main()
{
  int n;
  auto vec = std::vector<int>{};

  cin >> n;
  for (auto i = 0; i < n; i++)
  {
    int number;
    cin >> number;
    vec.push_back(number);
  }

  print_vector(vec);
  for (auto i = 1; i < n; i++)
  {
    auto v = vec.at(i);
    auto j = i - 1;
    for (; j >= 0 && vec.at(j) > v;)
    {
      vec[j + 1] = vec[j];
      j--;
    }

    vec[j + 1] = v;
    print_vector(vec);
  }

  return 0;
}



Measured memory_bytes: 3188
function Main(input) {
    input = input.trim().split("\n").map(function(x) { return x.split(" ")});
    var N = parseInt(input[0][0], 10);
    var M = parseInt(input[0][1], 10);
    var K = parseInt(input[0][2], 10);
    var C = 998244353;
    var C2 = 1e+5;
    v = nCr_amari(N - 1, K, C, C2).reverse();
    tmp = fastRuijoR(M - 1, N - K - 1, C, C2);
    var ans = 0;
    for  (var x of v){
        ans += kakeruR(tmp, x, C, C2);
        ans %= C;
        tmp = kakeruR(tmp, M - 1, C, C2);
    }
    ans = kakeruR(ans, M, C, C2);
    console.log(ans);
}

function kakeruR(a, b, C, C2){
    var tmpQ, tmpR, ans;
    tmpQ = (b / C2 | 0);
    tmpR = b - (tmpQ * C2);
    ans = (a * tmpQ % C) * C2 % C + (a * tmpR);
    ans %= C;
    return ans;
}

function nCr_amari(MAX, k, MOD, C2) { //return [maxC0, maxC1, ..., maxCk]
    // 前処理
    var v_ans = [ ];
    var fac, finv, inv;
    fac = [1,1];
    finv = [1,1];
    inv = [0,1];
    for (var i = 2; i <= MAX; i++){
        fac.push(fac[i - 1] * i % MOD);
        inv.push(MOD - kakeruR(inv[MOD%i], (MOD / i | 0), MOD, C2) % MOD);
        finv.push(kakeruR(finv[i - 1],inv[i] ,MOD, C2));
    }
    //二項係数計算
    for (var i = 0; i <= k; i++){
    v_ans.push(kakeruR(kakeruR(fac[MAX] , finv[MAX - i],MOD, C2), finv[i], MOD, C2));
    }
    return v_ans;
}


function fastRuijoR(a, b, C, C2){
    var ans = 1;
    var binary = b.toString(2);
    var l = binary.length;
    var tmp = a;
    for (var i = 0; i < l; i++){
        if (binary.substr((i + 1) * -1, 1) === '1') ans = kakeruR(ans, tmp, C, C2);
    tmp = kakeruR(tmp, tmp, C, C2);
    }
    return ans;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8")); 

Measured memory_bytes: 55240