akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;

int main() {
	//cout << "" << endl; // prints
	int N, K;
	const long long int mod = 998244353;
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N >> K;
	long long int dp[N+1];
		dp[0] = 1;
		dp[1] = -1;
		dp[2] = 0;
	for(int a = 3; a <= N; a++){
		dp[a] = 0;
	}
	long long int LR[K+1][3];
	bool TF[N+1];
	for(int i = 0; i <= N; i++){
		TF[i] = false;
	}
	for(int i = 1; i <= K; i++){
		cin >> LR[i][1] >> LR[i][2];
		for(int j = LR[i][1]; j <= LR[i][2]; j++){
			TF[j] = true;
		}
	}

	for(int i = 0; i < N; i++){
		if(i > 0)dp[i] += dp[i - 1];
		dp[i] = dp[i] % mod;
		for(int j = 1; j <= K; j++){
			if(i + LR[j][1] < N){
				dp[i + LR[j][1] + 0] += dp[i];
				dp[i + LR[j][1] + 0] = dp[i + LR[j][1] + 0] % mod;
			}
			if(i + LR[j][2] + 1 < N){
				dp[i + LR[j][2] + 1] -= dp[i];
				dp[i + LR[j][2] + 1] = dp[i + LR[j][2] + 1] % mod;
			}
		}
	}
	dp[N-1] = dp[N-1] % mod;
	if(dp[N-1] < 0){
		dp[N-1] += mod;
	}
	cout << dp[N-1] << endl;
	return 0;
}


Measured memory_bytes: 5384
S = input()
T = input()

len_S = len(S)
len_T = len(T)
for i in range(len_S-len_T, -1, -1):
  if not all(s in ['?', t] for s, t in zip(S[i:i+len_T], T)):
    continue
  print((S[:i] + T + S[i+len_T:]).replace('?','a'))
  exit()
print("UNRESTORABLE")


Measured memory_bytes: 3060
# include <stdio.h>

int main (void){

  // int型の変数secにデータを格納する。
  int sec;
  scanf("%d",&sec);

  int hour, min;

  //時間を格納する
  hour = sec / (60*60) ;
  min = (sec - hour*60*60 ) / 60 ;
  sec = sec % 60;

  printf("%d:%d:%d\n",hour,min,sec);

  return(0);

}



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

d = {}

for _ in range(N):
  S = input()
  if S in d:
    d[S] += 1
  else:
    d[S] = 1

m = max(d.values())
      
#n = [int(x) for x in input().split()]

s = sorted(k for k in d if d[k] == m)

for i in s:
  print(i)

Measured memory_bytes: 32096
const line = require('fs').readFileSync('/dev/stdin', 'utf-8').split('\n');

const solve = (m, arr) => {
    if (arr.length === 0) return false;
    const hd = arr[0];
    const tl = arr.slice(1);
    if (m === hd) return true;
    else if (m < hd) return solve(m, tl);
    else return solve(m-hd, tl) || solve(m, tl);
}

const arr1 = line[1].split(' ').map(Number);
const arr2 = line[3].split(' ').map(Number);

arr2.map(x => solve(x, arr1))
    .map(x => x ? 'yes' : 'no')
    .forEach(x => console.log(x));



Measured memory_bytes: 24296
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <string.h>
#include <string>
#include <complex>

using namespace std;
#define rep(i,n) for(int i = 0; i < n; ++i)
#define Rep(i,n) for(int i = 1; i <= n; ++i)
#define lowbit(x) ((x)&(-x))
//#pragma comment(linker,"/STACK:1024000000,1024000000")
#define eps 1e-2
#define sqr(x) ((x)*(x))
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef complex<double>cp;
template<class T>inline void rread(T&num){
    num=0;T f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
    num*=f;
}
const ll inf = 1e18;
const int maxn = 1e6 +10, mod = 1e9 + 7;
const double pi = acos(-1);
ll gcd (ll a, ll b)
{return ( a ? gcd(b%a, a) : b );}
void exgcd(ll a,ll b,ll &d,ll& x,ll& y)
{
    if(!b){d=a;x=1;y=0;}
    else {exgcd(b,a%b,d,y,x);y-=x*(a/b);}
}
cp power(cp a, int n)
{cp p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n)
{ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod)
{ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
//head
ll n,m,r;
ll bin[maxn];
int main()
{
    bin[0]=1;
    for(int i=1;i<=1e5;i++)
        bin[i]=bin[i-1]*i%mod;

    while(~scanf("%lld",&n))
    {

        printf("%lld\n",bin[n]);


    }
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {


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

        int n = s.nextInt();
        int k = s.nextInt();

        int[] num = new int[10];

        for (int i = 0;i < k; i++) {
            int a = s.nextInt();
            num[a]=1;
        }
        Integer op = n;
        while(!chechk(num,op)) {
            op++;
        }
        System.out.println(op);
    }

    private static boolean chechk(int[] num, Integer op) {
        while(op > 0) {
            if (num[op % 10] == 1) return false;
            op /= 10;
        }
        return true;
    }
  
}


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

int main(){
    int n,k;
    cin>>n>>k;
    vector<double> d;
    long double ans=0;
    for(int i=1;i<=n;i++){
        int a=0,b=i,c=1;
        while(b<k){
            b*=2;
            a++;
        }
        for(int k=0;k<a;k++)
        c*=2;
        d.push_back(n*c);
    }
    for(int i=0;i<d.size();i++){
        ans+=1/d[i];
    }
    cout<<setprecision(10)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1400
#include <stdio.h>

int main() {
  int r, c, i, j;
  int vec[200][200] = {};

  scanf("%d %d", &r, &c);
  for (i = 0; i < r; i++) {
    for (j = 0; j < c; j++) {
      scanf("%d", &vec[i][j]);
      vec[i][c] += vec[i][j];
      vec[r][j] += vec[i][j];
      vec[r][c] += vec[i][j];
    }
  }

  for (i = 0; i <= r; i++) {
    for (j = 0; j <= c; j++) {
      if(j) printf(" ");
      printf("%d",vec[i][j]);
    }
    printf("\n");
  }

  return 0;
}


Measured memory_bytes: 2100
#include<stdio.h>
int main(void){
	int a,b,price;
	scanf("%d%d",&a,&b);
	for(int i=0;i<10;i++){
		if((10*b+i)*8/100==a){
			price=10*b+i;
			break;
		}
		if(i==9){
			price=-1;
		}
	}
	printf("%d",price);





	return 0;
}


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

#ifdef DEBUG
#include "../include/debug.hpp"
#else
#define debug(...) 42
#define rdfile(...) 42
#endif

int S(int n) {
    int ret = 0;
    while (n > 0) {
        ret += n % 10;
        n /= 10;
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // rdfile("_input.txt");

    int N;
    cin >> N;
    cout << (N % S(N) == 0 ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>

using namespace std;

int main(){
	int sen[10000];
	int num[1024],s;
	for(int i=0;i<1024;i++)
		for(num[i]=0,s=i;s>0;s >>= 1)num[i]+=s&1;
	
  int r,c,cc;
  while(true){
		scanf("%d %d",&r,&c);
		if (!r&&!c)break;
		for(int i=0;i<c;i++)
			sen[i] = 0;
		
		for(int j=0;j<r;j++){
			for(int i=0;i<c;i++){
				scanf("%d",&cc);
				sen[i] <<= 1;
				sen[i] += cc;
			}
		}
		
		int n,sum = 0,smax = 0,k=1;
		k <<= r-1;
		for(int i=0;i<k;i++){
			sum = 0;
			for(int j=0;j<c;j++){
				s = sen[j]^i;
				//				for(n=0;s>0;s >>= 1)n+=s&1;
				sum += max(num[s],r-num[s]);
			}
			if (sum>smax)smax = sum;
		}
		printf("%d\n",smax);
  }
  return 0;
}

Measured memory_bytes: 924
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;

    cout << int(ceil(float(N) / 2)) << endl;
    
}


Measured memory_bytes: 256
#include<stdio.h>
int main() {
	int N;
	scanf("%d", &N);

	int a[200], b;
	int i, j;
	int count = 0;
	for (i = 1; i <= N; i++) {
		scanf("%d", &b);
		a[i] = b;
	}
	for (i = 2;i <= 2000000000; i = i * 2) {
		for (j = 1; j <= N; j++) {
			if (a[j] % i > 0) {
				count = count - j + 1;
				printf("%d", count);
				goto OUT;
			}
			else {
				count += 1;
			}
		}count = count - N + 1;
	}
OUT:
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    char s[10];
    cin>>s;
    int a,b,c,d;
    a=s[0]-'0';
    b=s[1]-'0';
    c=s[2]-'0';
    d=s[3]-'0';
    for(int i=43;i<=45;i+=2){
        for(int j=43;j<=45;j+=2){
            for(int k=43;k<=45;k+=2){
                int ans=a;
                if(i==43){
                    ans+=b;
                }
                else{
                    ans-=b;
                }
                if(j==43){
                    ans+=c;
                }
                else{
                    ans-=c;
                }
                if(k==43){
                    ans+=d;
                }
                else{
                    ans-=d;
                }
                if(ans==7){
                    cout<<a<<char(i)<<b<<char(j)<<c<<char(k)<<d<<"=7"<<endl;
                    return 0;
                }
            }
        }
    }
    //cout<<int('-');
    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	int max_bit = 21;

	ll n;
	cin >> n;

	int a[n];
	rep(i,n) cin >> a[i];

	ll ans = 0;

	int tmp = 0;
	int r = 0;
	
	rep(l,n){
		while(r<n && (tmp + a[r]) == (tmp ^ a[r])){
			tmp ^= a[r];
			r++;
		}
		ans += r-l;
		tmp ^= a[l];
	}

	cout << ans << endl;
}

Measured memory_bytes: 1024
H, W = [int(i) for i in input().split()]
A = [[s for s in input()] for j in range(H)]
p = 10 ** 9 + 7

DP = [[0] * W for i in range(H)]
DP[0][0] = 1

for h in range(H):
    for w in range(W):
        if h + 1 < H and A[h+1][w] == '.':
            DP[h+1][w] += DP[h][w]
            DP[h+1][w] %= p
        if w + 1 < W and A[h][w+1] == '.':
            DP[h][w+1] += DP[h][w]
            DP[h][w+1] %= p

print(DP[H-1][W-1])

Measured memory_bytes: 51388
N,*csfs=$<.read.split.map(&:to_i)

csfs = csfs.each_slice(3).to_a

0.upto(N-2) do |i|
    t = 0
    i.upto(N-2) do |j|
        c,s,f = csfs[j]
        # p [t,s]
        n = [t,s].max
        if n % f == 0
            t = n + c
        else
            t = n + f-(n%f) + c
        end
    end
    puts t
end

puts 0

Measured memory_bytes: 1788
#include<iostream>
#include<vector>
using namespace std;
int main(){
        cin.tie(0);
        ios::sync_with_stdio(false);
        int n;
        cin >> n;
        vector<int>a(n);
        double count=0;
        for(int i=0;i<n;i++){
                cin>>a[i];
                if(a[i]%4==0)count++;
                else if(a[i]%2==0)count+=0.5;
        }
        if(n/2<=count)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
        return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = INT_MAX;
const long long INFL = 1LL<<40;
const double PI = atan(1)*4;
//const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}


int main() {
    ll n,k;cin>>n>>k;

    ll c  =0;
    for(auto b=1LL; b<n+1;b++){
        
        ll p = n/b;
        ll r = n%b;
        
        c += p*max(0LL,b-k);
        c+= max(0LL,r-k+1);
        
    }
    
    if(k==0){
        c-=n;
    }
    
    cout<<c<<endl;
    
    return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define N 100005
int n,nw,ans=1;struct node {int l,r;}a[N];
int max(int x,int y) {return x>y?x:y;} 
bool cmp(node x,node y) {return x.r==y.r?x.l>y.l:x.r<y.r;}
int main()
{
	scanf("%d",&n);
	for(int i=1,x,y;i<=n;++i)
		scanf("%d %d",&x,&y),a[i].l=x-y,a[i].r=x+y;
	sort(a+1,a+n+1,cmp);nw=a[1].r;
	for(int i=2;i<=n;++i) if(a[i].l>=nw) nw=a[i].r,++ans;
	printf("%d\n",ans);return 0;
}

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

int main() {
    int n, d, x;
    cin >> n >> d >> x;

    int ans = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;

        for (int j = 0; j * a + 1 <= d; j++) {
            ans++;
        }
    }

    cout << ans + x << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;


int main(){
    ll N;
    cin >> N;
    vector<double> A(N,0);
    for(ll i=0;i<N;i++){
        cin>>A[i]
    ;}
    sort(A.begin(), A.end());
    ll ans=0;
    for(ll i=N-1;i>=1;i--){
        for(ll j=0;j<=40;j++){
            if(upper_bound(A.begin(), A.end()-(N-i), (1<<j)-A[i])!=lower_bound(A.begin(), A.end()-(N-i), (1<<j)-A[i]))
            {*lower_bound(A.begin(), A.end()-(N-i), (1<<j)-A[i])-=0.0000001;ans++;break;}
        }
    ;}
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
# Code for C - Poll
# Use input() to fetch data from STDIN
import collections

n = int(input())
s = [input() for x in range(n)]

c = collections.Counter(s)
maxC = max(c.values())
z = list(filter(lambda z: z[1] == maxC, c.most_common()))
for x in sorted([y[0] for y in z]):
    print(x)



Measured memory_bytes: 49332
#include <bits/stdc++.h>
#define MP make_first
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
const int N = 105;
int a, b, c;
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> a >> b >> c;
    ll d = a + b;
    ll ans;
    if(b >= c) {
        ans = b + c;
    } else {
        ans = 2ll * b;
        c -= b;
        if(a < c) {
            ans += a + 1;
        } else ans += c;
    }
    cout << ans;
    return 0;
}


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

int main(void)
{
	
	ll n,m,i,j,M=1000000007;
	cin>>n>>m;
	char path[n][m];
	
	for(i=0;i<n;i++)
	for(j=0;j<m;j++)
	{
		cin>>path[i][j];
	}
	
	ll dp[n][m];
	dp[0][0]=1;
	
	for(i=1;i<n;i++)
	{
		if(path[i][0]=='#')
		dp[i][0]=0;
		else dp[i][0]=dp[i-1][0];
	}
	
	for(j=1;j<m;j++)
	{
		if(path[0][j]=='#')
		dp[0][j]=0;
		else dp[0][j]=dp[0][j-1];
	}
	
	for(i=1;i<n;i++)
	{
		for(j=1;j<m;j++)
		{
			if(path[i][j]=='#')
			dp[i][j]=0;
		}
		
	}
	
	
	for(i=1;i<n;i++)
	for(j=1;j<m;j++)
	{
		if(path[i][j]=='.')
		dp[i][j]=((dp[i-1][j])%M+(dp[i][j-1])%M)%M;
		
	}
	
	cout<<dp[n-1][m-1];
}

Measured memory_bytes: 9088
def main():
    k = int(input())
    s = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    print(s[k-1])


if __name__ == '__main__':
    main()


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

int main()
{
    string s;
    cin >> s;
    int day = 0;
    if (s == "SUN")
    {
        day = 7;
    }
    else if (s == "MON")
    {
        day = 6;
    }
    else if (s == "TUE")
    {
        day = 5;
    }
    else if (s == "WED")
    {
        day = 4;
    }
    else if (s == "THU")
    {
        day = 3;
    }
    else if (s == "FRI")
    {
        day = 2;
    }
    else if (s == "SAT")
    {
        day = 1;
    }
    cout << day << endl;
}


Measured memory_bytes: 256
N=int(input())
if N%2==0:
  print(N*(N-2)//2)
  for i in range(1,N+1):
    for j in range(i+1,N+1):
      if i+j!=N+1:
      	print(i,j)
else:
  print(((N-1)*(N-3))//2+N-1)
  for i in range(1,N+1):
    for j in range(i+1,N+1):
      if i+j!=N:
        print(i,j)

Measured memory_bytes: 42736
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <memory>
#include <cstring>
#include <cassert>
#include <numeric>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define REP2(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(S) (S).begin(), (S).end()
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);

  int N, L;
  while (cin >> N >> L && N + L> 0){
    L *= 2;
    vector<int> d(N);
    vector<int> p(N);
    REP(i, N){
      char dir;
      cin >> dir >> p[i];
      d[i] = dir == 'R' ? 1 : -1;
      p[i] *= 2;
    }

    int time = 0;
    int last = 0;

    while (true){
      bool update = false;
      int  goal   = -1;
      
      REP(i, N) if (0 < p[i] && p[i] < L){
        p[i] += d[i];
        update = true;
        
        if ((p[i] == L && goal == -1) || p[i] == 0){
          goal = i + 1;
        }
      }
      
      if (!update){
        break;
      } else {
        last = goal;
        time++;

        REP(i, N) REP(j, i){
          if (p[i] == p[j] && 0 < p[i] && p[i] < L && p[i] % 2 == 0){
            assert(d[i] != d[j]);
            swap(d[i], d[j]);
          }
        }
      }
    }

    cout << time / 2 << " " << last << endl;
  }
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    vector<int> b(n);
    for (int i = 0; i < n; i++) cin >> b[i];
    vector<long long> x(2, 0);
    for (int i = 0; i < n; i++){
        if (a[i] > b[i]) x[1] += a[i] - b[i];
        if (b[i] > a[i]) {
            if ((b[i] - a[i]) % 2) x[0] += ((b[i] - a[i]) / 2) + 1, x[1]++;
            else x[0] += (b[i] - a[i]) / 2;
        }
    }
    if (x[0] >= x[1]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main() {
	int n, a, b; cin >> n >> a >> b;

	int maxAns, minAns;
	maxAns = (a>=b?b:a);
	minAns = (a + b > n ? a + b - n : 0);
	cout << maxAns << ' ' << minAns << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from heapq import heappop, heappush

N, M = map(int,input().split())
work_list = [[] for j in range(M+1)]
for i in range(N):
    temp = list(map(int,input().split()))
    if temp[0] > M:
        continue
    work_list[temp[0]].append(temp[1])

sum = 0
works = []

for i in work_list:
    for j in i:
        heappush(works, -1*j)
    if len(works) == 0:
        continue
    sum -= (heappop(works))

print(sum)


Measured memory_bytes: 62384
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>

using namespace std;

int main() {
	string s;

	cin >> s;

	int sz = s.size();
	for (int i = 0; i < sz-8; i++) {
		cout << s[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
from bisect import bisect_left
from collections import defaultdict
N = int(input())
points = list(tuple(map(int,input().split())) for _ in range(N))

xty = defaultdict(list)
ytx = defaultdict(list)
for x,y in points:
    xty[x].append(y)
    ytx[y].append(x)

area = 0
X = set()
Y = set()

for x,y in points:
    if x in X or y in Y:
        continue

    stack_x = [x]
    stack_y = [y]

    dx = set()
    dy = set()

    while stack_x or stack_y:

        while stack_x:
            x = stack_x.pop()
            if x not in dx:
                dx.add(x)
                for y in xty[x]:
                    if y not in dy:
                        stack_y.append(y)

        while stack_y:
            y = stack_y.pop()
            if y not in dy:
                dy.add(y)
                for x in ytx[y]:
                    if x not in dx:
                        stack_x.append(x)
    X |= dx
    Y |= dy
    area += len(dx)*len(dy)

print(area-len(points))

Measured memory_bytes: 43612
N,M = map(int, input().split())
if N <= 1 and M <= 1:
	answer = 0
elif N <= 1:
	answer = int(M*(M-1)/2)
elif M <= 1:
	answer = int(N*(N-1)/2)
else:
	answer = int(N*(N-1)/2)+int(M*(M-1)/2)

print(answer)

Measured memory_bytes: 3060
N=gets.to_i
def dfs(s)
	if s.to_i>N
		return 0
	end
	if s.count("7")>0&&s.count("5")>0&&s.count("3")>0
		ret=1
	else
		ret=0
	end
	"753".each_char{|c|
		ret+=dfs(s+c)
	}
	return ret
end
puts dfs("0")

Measured memory_bytes: 1788
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<vector>
std::vector<int> G[10000]={};
int match[10000]={};
bool used[10000]={};
void add_edge(int u,int v){
	G[u].push_back(v);
	G[v].push_back(u);
}
bool dfs(int v){
	used[v]=true;
	for(int i=0;i<G[v].size();i++){
		int u=G[v][i];
		int w=match[u];
		if(w<0 || !used[w] && dfs(w)){
			match[v]=u;
			match[u]=v;
			return true;
		}
	}
	return false;
}

int bipartite_matching(){
	int res=0;
	memset(match,-1,sizeof(match));
	for(int v=0;v<10000;v++){
		if(match[v]<0){
			memset(used,0,sizeof(used));
			if(dfs(v)){
				res++;
			}
		}
	}
	return res;
}
int main(){
	int n;
	scanf("%d",&n);
	int a[n]={};
	int b[n]={};
	int c[n]={};
	int d[n]={};
	for(int i=0;i<n;i++){
		scanf("%d %d",&a[i],&b[i]);
	}
	for(int i=0;i<n;i++){
		scanf("%d %d",&c[i],&d[i]);
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(a[i]<c[j]&&b[i]<d[j]){
				add_edge(i,n+j);
			}
		}
	}
	printf("%d\n",bipartite_matching());
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;


void array_show(int *a,int n){
	for(int i=0;i<n;i++)printf("%d%c",a[i],(i!=n-1?' ':'\n'));
}
void array_show(LL *a,int n){
	for(int i=0;i<n;i++)printf("%lld%c",a[i],(i!=n-1?' ':'\n'));
}

bool win[100005];

int main(){
	int n,m;
	int i,j,k;
	int a[105];
	cin>>n>>m;
	for(i=0;i<n;i++)cin>>a[i];
	for(i=a[0];i<=m;i++){
		for(j=0;j<n;j++){
			if(i<a[j])break;
			if(!win[i-a[j]]){
				win[i]=true;
				break;
			}
		}
	}
	if(win[m])cout<<"First"<<endl;
	else cout<<"Second"<<endl;
	return 0;
}


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

using namespace std;

int main()
{
	
	int n,a,b,c,d;
	string s;
	a=b=c=d=0;
	
	cin >> n;
	
	while(n--)
	{
		cin >> s;
		if(s=="AC") a++;
		else if(s=="WA") b++;
		else if(s=="TLE") c++;
		else d++;
	}
	cout << "AC x " << a << endl;
	cout << "WA x " << b << endl;
	cout << "TLE x " << c << endl;
	cout << "RE x " << d << endl;
	
	return 0;
}


Measured memory_bytes: 3628
a,b=map(int,input().split())
s=input()
if(s[0:a].isdigit() == True):
    if(s[a] == '-'):
        if(s[a+1:a+b+1].isdigit() == True):
            print('Yes')
            exit()
        else:
            print('No')
            exit()
    else:
        print('No')
        exit()
else:
    print('No')

Measured memory_bytes: 3060
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    u = [1] + [0] * K
    v = [1] + [0] * K
    s = 0
    for i in A:
        u, v = v, u
        s += i
        t = 0
        for k in range(i):
            t += u[k]
            v[k] = t
        for k in range(i, min(s, K) + 1):
            t += u[k]
            v[k] = t
            t -= u[k - i]
    print(v[K] % (10 ** 9 + 7))

main()


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

#define HAS_TEST_CASE 0  // Do you forget to complete this?

namespace rG
{
typedef long long ll;

const int N=5e5;

//int n,m,a[N+10];
char str[N+10];

ll x,k,d;

inline void main()
{
	scanf("%lld%lld%lld",&x,&k,&d);
	if(x<0)x=-x;
	ll t=x/d;
	if(t>k)printf("%lld\n",x-k*d);
	else if(t==k)printf("%lld\n",x-d*(x/d));
	else printf("%lld\n",(k-(x/d))%2==0?std::abs(x-d*(x/d)):std::abs(x-d*(x/d+1)));
}
}

int main()
{
#if !defined(ONLINE_JUDGE)&&HAS_TEST_CASE
	freopen("tmp.out","w",stdout);
#endif
	int T=1;
#if HAS_TEST_CASE
	scanf("%d",&T);
#endif
	while(T--)rG::main();
	return 0;
}


Measured memory_bytes: 3824
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

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

	ll N, A, B;
	ll result = 0;
	cin >> N >> A >> B;
	if (!A) {
		cout << "0\n";
		return 0;
	}
	ll status = N / (A + B);
	if (status) {
		result += (status * A);
		if (N % (A + B)) {
			if (N % (A + B) <= A)
				result += N % (A + B);
			else
				result += A;
		}
		cout << result << "\n";
		return 0;
	}
	else {
		if (N > A)
			result = A;
		else
			result = N;
		cout << result << "\n";
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)1e15
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
signed main()
{
	ios_base::sync_with_stdio(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{   
		int h,w,k;
		cin >> h >> w >> k;
		string s[h];
		rep(i,0,h) cin >> s[i];
		vector<vector<int>> a(h,vector<int>(w,0));
		rep(i,0,h){
			rep(j,0,w) if(s[i][j]=='1') a[i][j] = 1;
		}
		int ans = INF;
		for(int mask = 0; mask < (1<<(h-1)); mask++){
			map<int,int> cc;
			cc[1] = 1;
			for(int j=2; j<=h; j++){
				if(mask&(1<<(j-2))){
					cc[j] = cc[j-1]+1;
				}
				else cc[j] = cc[j-1];
				// trace(mask, cc[j]);
			}
			int tans = 0;
			map<int,int> cur;
			rep(j,1,w+1){
				rep(k,1,h+1){
					cur[cc[k]]+=a[k-1][j-1];
				}
				bool f = 0;
				for(auto j:cur){
					if(j.sc>k){
						f = 1;
						break;
					}
				}
				// for(auto j:cur) trace(j.fr, j.sc, f);
				// cout << endl;
				if(f){
					tans++;
					for(auto j:cur) cur[j.fr] = 0;
					rep(l,1,h+1){
						cur[cc[l]] += a[l-1][j-1];
					}
					// for(auto j:cur) trace(j.fr, j.sc, f);
					// cout << endl;
				}
				f = 0;
				for(auto j:cur){
					if(j.sc>k){
						f = 1;
						break;
					}
				}
				if(f) goto ou;
			}
			// trace(tans);
			ans = min(ans, tans+__builtin_popcount(mask));
			ou:;
		}
		cout << ans;
	}
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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 (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_N 100'000
#define MAX_M 100'000
i64 N, M;

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

  i64 l = 1;
  i64 r = N;
  i64 L, R;
  REP(i, M) {
    cin >> L >> R;
    chmax(l, L);
    chmin(r, R);
    if (r - l < 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  cout << r - l + 1 << endl;

  return 0;
}

Measured memory_bytes: 892
import sys
def main():
  input = sys.stdin.readline
  n, c = map(int, input().split())
  d = [0 for _ in range(c)]
  for i in range(c):
    d[i] = [int(x) for x in input().split()]
  grid = [0 for _ in range(n)]
  for i in range(n):
    grid[i] = [int(x) for x in input().split()]
  
  k1, k2, k3 = [0]*c, [0]*c, [0]*c
  for i in range(n):
    for j in range(n):
      if (i+j)%3 == 1:
        k1[grid[i][j]-1] += 1
      elif (i+j)%3 == 2:
        k2[grid[i][j]-1] += 1
      else:
        k3[grid[i][j]-1] += 1
  
  key1, key2, key3 = [], [], []
  for i in range(c):
    sub1, sub2, sub3 = 0, 0, 0
    for j in range(c):
      if i == j:
        continue
      sub1 += k1[j]*d[j][i]
      sub2 += k2[j]*d[j][i]
      sub3 += k3[j]*d[j][i]
    key1.append([sub1, i])
    key2.append([sub2, i])
    key3.append([sub3, i])
  key1.sort()
  key2.sort()
  key3.sort()
  key1 = key1[:3]
  key2 = key2[:3]
  key3 = key3[:3]
  ans = pow(10, 9)
  for i in range(3):
    for j in range(3):
      for k in range(3):
        if key1[i][1] != key2[j][1] and key2[j][1] != key3[k][1] and key1[i][1] != key3[k][1]:
          if ans > key1[i][0]+key2[j][0]+key3[k][0]:
            ans = key1[i][0]+key2[j][0]+key3[k][0]
  print(ans)
  
if __name__ == "__main__":
  main()

Measured memory_bytes: 5492
#include<iostream>
#include<math.h>

using namespace std;

int main(void){
	
	int R,G,B,N;
	int count=0;
	
	cin>>R>>G>>B>>N;
	
	for(int i=0;i<=N/R;i++){
		for(int j=0;j<=N/G;j++){
			if(ceil((double)((double)(N-i*R-j*G)/B))==floor((double)((double)(N-i*R-j*G)/B)) && (N-i*R-j*G)/B>=0){
				count++;
			}
		}
	}
	
	cout<<count;
	
	return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np
from numba import njit

input = sys.stdin.buffer.readline

N = int(input())
vws = [tuple(map(int, input().split())) for _ in range(N)]

n = min(2**11, N)
vws_arr = np.array(vws, np.int32)

dp = np.zeros((n, 10**5+1), np.int32)
for i in range(n):
    v, w = vws[i]
    dp[i] = dp[(i-1)//2]
    dp[i, w:] = np.maximum(dp[(i-1)//2, :-w]+v, dp[i, w:])


@njit("i4(i4[::1], i4[::1], i4, i4[::1])", cache = True)
def func(vs, ws, L, dp_):
    values = np.zeros(1 << len(vs), np.int32)
    weights = np.zeros(1 << len(vs), np.int32)
    for i in range(len(vs)):
        for bits in range(1 << len(vs)):
            if bits & (1 << i):
                values[bits] += vs[i]
                weights[bits] += ws[i]
    ret = 0
    for v, w in zip(values, weights):
        if w <= L:
            ret = max(dp_[L - w] + v, ret)
    return ret

Q = int(input())
for _ in range(Q):
    V, L = map(int, input().split())
    V -= 1
    if V < n:
        print(dp[V, L])
    else:
        Vs = []
        while V >= n:
            Vs.append(V)
            V = (V-1) // 2
        vs = vws_arr[Vs, 0]
        ws = vws_arr[Vs, 1]
        print(func(vs, ws, L, dp[V]))


Measured memory_bytes: 950328
#!/usr/bin/env python3
N, M = map(int, input().split())
L = sorted(list(map(int, input().split())) for _ in range(N))

ans = 0
cnt = 0
for A, B in L:
    if cnt + B > M:
        ans += A * (M - cnt) if cnt + B > M else B
        break
    ans += A * B
    cnt += B

print(ans)


Measured memory_bytes: 27756
#include <iostream>
#define r(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(void){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    a=a+b+c+d;
    
    cout<<a/60<<endl;
    cout<<a%60<<endl;
}



Measured memory_bytes: 3072
#include <bits/stdc++.h>
 
using namespace std;
 
const int MOD=1e9+7;
 
//const int MOD=998244353;
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    int n,h;
    cin>>h>>n;
    
    vector<pair<int,int>> vp(n);
    for(auto &p:vp){
        int x,y;
        cin>>x>>y;
        p={x,y};
    }
    
    
    
    vector<int> dists(h+1,MOD);
    
    
    dists[h]=0;
    for(int i=h-1; i>=0; i--){
        for(auto p:vp){
            int y=min(h, i+p.first);
            dists[i]=min(dists[i],dists[y]+p.second);
        }
    }
    
    
    priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> pq;
    pq.push({dists[h],h});
    while(!pq.empty()){
        auto cur=pq.top();
        pq.pop();
        int x=cur.second;
        
        for(auto& p:vp){
            int y=max(0,x-p.first);
            if(dists[y]>dists[x]+p.second){
                dists[y]=dists[x]+p.second;
                pq.push({dists[y],y});
            }
        }
    }
    cout<<dists[0];
    
    
    return 0;
}


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

int main(){
    long long a, b, k;
    cin >> a >> b >> k;

    set<long long> T;

    for(long long i = a; i < a + k and i <= b; i++){
        T.insert(i);
    }

    for(long long i = b; i > b - k and i >= a; i--){
        T.insert(i);
    }

    set<long long>::iterator it;

    for(it = T.begin(); it != T.end(); it++){
        printf("%lld\n", *it);
    }
    return 0;
}

Measured memory_bytes: 3696
#include <iostream>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <stack>
#include <cstdio>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pos;
const ll MOD = 1000000007, N = 100000, dx[4] = { -1,1,0,0 }, dy[4] = { 0,0,-1,1 };

ll mn(ll a, ll b) {
	if (a == -1)return b;
	if (b == -1)return a;
	return min(a, b);
}
ll gcd(ll v1, ll v2) {
	if (v1 == 0)return v2; if (v2 == 0)return v1; if (v2 > v1)return gcd(v2%v1, v1); return gcd(v1%v2, v2);
}

struct ab {
	ll a, b;
	bool operator<(const ab& right) const {
		return right.b*a - right.a*b < 0;
	}
};

ll n, l[N],ld;

int main() {
	cin >> n >> ld;
	for (int i = 0; i < n; i++)cin >> l[i];
	for (int i = 0; i < n - 1; i++){
		if (l[i] + l[i + 1] >= ld) {
			cout << "Possible" << endl;
			for (int j = 1; j <= i; j++) {
				cout << j << endl;
			}
			for (int j = n - 1; j >= i + 2;j--)cout << j << endl;
			cout << i+1 << endl;
			return 0;
		}
	}
	cout << "Impossible" << endl;
	return 0;
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
 
using namespace std;
 
//container util
//------------------------------------------
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
 
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).end()) i=(c).end(); i!=(c).begin(); --i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
 
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).begin(),(c).end(),greater<int>())
 
#define PB(a) push_back(a)
#define PF(a) pop_front(a)

#define MP(a,b) make_pair(a,b)
 
#define FS first
#define SE second
 
#define ALL(x) (x).begin(),(x).end()
#define MAX_EL(c) *max_element((c).begin(),(c).end())
#define MIN_EL(c) *min_element((c).begin(),(c).end())
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 
//grobal var
//------------------------------------------
const int MAX = 2*10e5+2;


int main(){
// magic spell------------------------------
  cin.tie(0);
  ios::sync_with_stdio(false);
//------------------------------------------
  int A,B;
  while(cin >> A >> B){
    LL ans=0LL;
    set<PII> s;
    if(A<=5) ans = 0;
    else if(A>=13) ans = B;
    else ans = B/2;
    cout << ans << endl;
    }
 
  return 0;
}

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

typedef long long ll;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define ANS(n) cout << (n) << endl

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(a);i>=(b);i--)

#define ALL(obj) (obj).begin(),(obj).end()

#define pii pair<int,int>

#define pb(a) push_back(a)
#define mp make_pair

int main()
{
	int n;
	cin >> n;
	vector<bool> v(101, false);
	FOR(i,0,n){
		int d;
		cin >> d;
		v[d] = true;
	}
	int ans = 0;
	FOR(i,0,101){
		if(v[i])ans++;
	}
	ANS(ans);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n=0;
	bool data[100000];
	int button[100000];
	cin>>n;
	for(int i=0;i<n;i++){
		data[i]=true;
		cin>>button[i];
	}
	int point=1;
	int count=0;
	for(;;){
		if(point==2){
			cout<<count<<endl;
			break;
		}
		if(data[point-1]){
			data[point-1]=false;
		}else{
			cout<<-1<<endl;
			break;
		}
		point=button[point-1];
		count++;
	}
	return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<iomanip>

using namespace std;

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

int n, k, t, u, v, l;
int d[10000];
int c[10000];
int s[10000];

int main(){
    cin >> n >> k >> t >> u >> v >> l;

    REP(i, l){
        c[i] = 0; 
        d[i] = 0;
    }
    REP(i, n){
        int di;
        cin >> di;
        d[di] = 1;
    }

    REP(i, l){
        int g = min(i+v*t, l);
        if(d[i]==1 && s[i]==1){
            if(c[i]+1<=k){
                for(int j=i; j<l; j++){
                    c[j] = c[j] + 1;
                }
            } else {
                for(int j=i; j<g; j++){
                    s[j] = 1;
                }
            }
        } else if(d[i]==1 && s[i]==0){
            for(int j=i; j<g; j++){
                s[j] = 1;
            }
        } else if(d[i]==0 && s[i]==1){
            continue;
        } else {
            if(c[i]>0){
                for(int j=i; j<g; j++){
                    s[j] = 1;
                }
                for(int j=i; j<l; j++){
                    c[j] = c[j] - 1;
                }
            }
        }
    }

    int normal = 0;
    int accel = 0;
    REP(i, l){
        if(s[i] == 0){
            normal += 1;
        } else {
            accel += 1;
        }
    }

    double output = (double)normal/u + (double)accel/v;
    cout << fixed << setprecision(7) << output << endl;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = INT_MAX / 2;

ll c1[3][3][4004];
ll c2[3][3][4004];
ll d[4004][4004];

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

  map<char, int> m;
  m.emplace('R', 0);
  m.emplace('G', 1);
  m.emplace('B', 2);

  // 1. c1[0][1][j] * c2[1][2][j] => N * N * 3^3
  // 2. d[100][len] => N * N
  // ans = 1 - 2
  rep(i, N) REP(j, i + 1, N) {
//    if (S[i] == S[j]) { continue; }
    c1[m[S[i]]][m[S[j]]][j]++;
  }
  rep(j, N) REP(k, j + 1, N) {
//    if (S[j] == S[k]) { continue; }
    c2[m[S[j]]][m[S[k]]][j]++;
  }
  rep(j, N) REP(len, 1, N) {
    auto i = j - len, k = j + len;
    if (i < 0) { continue; }
    if (k >= N) { continue; }
    if (S[i] == S[j] || S[i] == S[k] || S[j] == S[k]) { continue; }
    d[j][len]++;
  }
  ll ans = 0;
  rep(icol, 3) rep(jcol, 3) rep(kcol, 3) rep(j, N) {
    if (icol == jcol || icol == kcol || jcol == kcol) { continue; }
    ans += c1[icol][jcol][j] * c2[jcol][kcol][j];
  }
  rep(j, N) rep(len, N) {
    ans -= d[j][len];
  }
  cout << ans << endl;
}


Measured memory_bytes: 50996
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) {
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  int N; cin>>N;
  vector<int> A(N,0), B(N,0), C(N,0);
  REP(i,N) {
    cin>>A[i];
    A[i]--;
  };
  REP(i,N) cin>>B[i];
  REP(i,N-1) cin>>C[i];
  int ans = 0;
  REP(i,N) {
    ans	+= B[A[i]];
    if(i > 0 &&	A[i-1]+1 == A[i]) {
      ans += C[A[i-1]];
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
function Main(input) {
	input = parseInt(input, 10);
  // 入力
  if (input === 25) {
		console.log('Christmas');
	} else if (input === 24) {
		console.log('Christmas Eve');
	} else if (input === 23) {
		console.log('Christmas Eve Eve');
	} else if (input === 22) {
		console.log('Christmas Eve Eve Eve');
	}
}

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

Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
typedef long double LD;
LD Ef[605], Eb[605], Pf[605], Pb[605], E[605];
bool vis[605];
vector<int> g[605];
int n, m, a, b;
int main(){
    scanf("%d%d", &n, &m);
    for(int i=1;i<=m;i++){
        int a, b;
        scanf("%d%d", &a, &b);
        g[a].push_back(b);
    }   

    Pb[n] = 1;
    for(int i=n-1;i>=0;i--){
        for(int j=0;j<g[i].size();j++){
            int v = g[i][j];
            Ef[i] += (Ef[v]+1)/g[i].size();
            Pb[i] *= Pb[v]/g[i].size();
        }
    }

    for(int pos=n-1;pos>=1;pos--){
        memset(vis, 0, sizeof(vis));
        memset(E, 0, sizeof(E));
        vis[pos] = 1;
        E[pos] = 0;
        for(int i=pos-1;i>=0;i--){
            for(int j=0;j<g[i].size();j++){
                int v = g[i][j];
                if(!vis[v]) continue;
                E[i] += (E[i]+1)/g[i].size();
            }
        }
        Eb[pos] = E[1];
    }

    Pf[1] = 1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<g[i].size();j++){
            int v = g[i][j];
            Pf[v] += Pf[i]/g[i].size();
        }
    }

    LD ans = Ef[1];
    for(int i=1;i<=n;i++){
        if(g[i].size() <= 1) continue;
        LD res = Ef[1];
        vector<LD> best;
        for(int j=0;j<g[i].size();j++){
            int v = g[i][j];
            LD Ex = (Ef[v]+1)*Pf[i]/g[i].size() + Eb[i]*Pb[i]/g[i].size();
            res -= Ex;
            Ex = (Ef[v]+1)*Pf[i]/(g[i].size()-1) + Eb[i]*Pb[i]/(g[i].size()-1);
            best.push_back(Ex);
        }
        sort(best.begin(), best.end());
        for(int i=0;i<best.size()-1;i++) res += best[i];
        ans = min(ans, res);
    }
    printf("%.10Lf\n", ans);
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;cin>>s;
    int j['Z']={0};

    for(int i=0;i<s.length();i++){
        if(s[i]=='S') j['S']=1;
        if(s[i]=='E') j['E']=1;
        if(s[i]=='N') j['N']=1;
        if(s[i]=='W') j['W']=1;
    }
    if(j['S']^j['N']||j['E']^j['W']) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin >> n;
  vector<pair<long double, long double>> v(n);
  rep(i,n){
    long double x,y;cin >> x >> y;
    v[i] = mp(x,y);
  }
  vector<ll> p(n);
  rep(i,n){
    p[i] = i;
  }
  long double ans = 0.0;
  do{
    long double tmp = 0.0;
    rep(i,n-1){
      ll x1 = v[p[i]].first;
      ll x2 = v[p[i+1]].first;
      ll y1 = v[p[i]].second;
      ll y2 = v[p[i+1]].second;
      tmp += sqrt(pow(x1-x2,2) + pow(y1-y2,2));
    }
    ans += tmp;
  }while(next_permutation(all(p)));
  FOR(i,1,n+1){
    ans /= (long double)i;
  }
  printf("%.7Lf\n", ans);
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

public static class P
{
    public static void Main()
    {
        var n = long.Parse(Console.ReadLine());
        if (n == 0)
        {
            Console.WriteLine(0);
            return;
        }
        long gran = 1;
        long res = 1;
        while (gran <= n)
        {
            n -= gran;
            res++;
            gran *= 3;
            if (gran > n) break;
            n -= gran;
            res++;
        }
        while (n > 0)
        {
            res += n % 3;
            n /= 3;
        }
        Console.WriteLine(res - 1);
        //13931
    }
}



Measured memory_bytes: 18020