akhauriyash/Code-Regression huggingface dataset:
import numpy as np
# import math
# import copy
# from collections import deque
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10000)
# from numba import njit,i8


def sieve(N,A,dp):
    for i in range(N):
        now = A[i]
        M = A[-1] // now
        for j in range(2,M+1):
            dp[now*j-1] = False
    return dp


def cnt(N,A,dp):
    skip = 0
    res = 0
    for i in range(N):
        now = A[i]
        if skip == now:
            continue
        if i != N - 1:
            if now == A[i+1]:
                skip = now
                continue
        if dp[now-1]:
            res += 1
    return res


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

    A = sorted(A)
    A = np.array(A)

    dp = np.array([True for i in range(A[-1])])
    # print(dp)
    dp = sieve(N,A,dp)
    # print(dp)

    res = cnt(N,A,dp)

    print(res)



main()


Measured memory_bytes: 51420
# 2019/06/16
# AtCoder Beginner Contest 130 - B

# Input
n, x = map(int,input().split())
l = list(map(int,input().split()))

cnt = 1
wd = 0

for i in range(n):
    wd += l[i]
    if wd > x:
        break
    cnt += 1

# Output
print(cnt)


Measured memory_bytes: 2940
for i in range(input()):
 	q,w=[0],[0]
 	flag=0
 	_L=map(int,raw_input().split())
 	q.append(_L[0])
 	for j in _L[1:]:
  		if q[-1] > w[-1]:
    		 if q[-1] < j: q.append(j)
    		 elif w[-1] < j: w.append(j)
    		 else: 
        		  flag=1
        		  break
  		if q[-1] < w[-1]:
    		 if w[-1] < j: w.append(j)
    		 elif q[-1] < j: q.append(j)
    		 else: 
        		  flag=1
        		  break
 	print "YES" if flag==0 else "NO"

Measured memory_bytes: 4248
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,f,e) for(int (i)=(f); (i)<(e); (i)++)
#define repr(i,e,f) for(int (i)=(e-1); (i)>=(f); (i)--)

const ll MOD = 1e9+7;
const int INF = (int)1e9+7;

// vector<tuple<long,long>> items; // (value, weight)
// auto item = items[i];
// long v = get<0>(item);
// long w = get<1>(item);
// long v, w;
//   for( int i = 0; i < N; i++ ){
//     cin >> v >> w;
//     items.push_back( make_tuple(v, w) ); // item : (value, weight)
//   }

deque<int> g[100001];
int dp[100001];

int rec(int i){
    if(dp[i]!=-1) return dp[i];
    int res = 0;
    for(auto j : g[i]) res = max(res, rec(j)+1);
    return dp[i] = res;
}

int main(){
    int N,M;
    cin >> N >> M;
    int x,y;

    rep(i,0,M){
        cin >> x >> y;
        g[x].push_back(y);
    }

    rep(i,1,N+1) dp[i] = -1;

    int ans = 0;
    rep(i,1,N+1) ans = max(ans, rec(i));
    cout << ans;
}


Measured memory_bytes: 70528
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    String s=sc.next();

    if (n%2==0) {
      String s1=s.substring(0,n/2);
      String s2=s.substring(n/2);
      if (s1.equals(s2)) {
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }else{
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VL = vector<LL>;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define FILL(a, b) memset(a, b, sizeof(a))

void dout() { cerr << endl; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

struct vec
{
    double x = 0, y = 0;
    vec() = default;
    vec(double X, double Y) : x(X), y(Y) {}
};

double dist(vec a, vec b)
{
    return hypot(a.x - b.x, a.y - b.y);
}


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    vec s, t;
    cin >> s.x >> s.y >> t.x >> t.y;
    int n;
    cin >> n;
    vector<vec> a(n);
    vector<double> r(n);
    FOR(i, 0, n)
    {
        cin >> a[i].x >> a[i].y >> r[i];
    }
    a.PB(s);
    a.PB(t);
    r.PB(0);
    r.PB(0);
    vector<vector<pair<int, double>>> g(SZ(a));
    FOR(i, 0, SZ(a))
    {
        FOR(j, i + 1, SZ(a))
        {
            double d = max(0.0, dist(a[i], a[j]) - r[i] - r[j]);
            g[i].EB(j, d);
            g[j].EB(i, d);
        }
    }
    vector<double> d(SZ(a), 1e18);
    d[SZ(g) - 2] = 0;
    set<pair<double, int>> q;
    q.emplace(0, SZ(g) - 2);
    while (SZ(q))
    {
        int u = q.begin()->S;
        q.erase(q.begin());
        for (auto p : g[u])
        {
            int v = p.F;
            double w = p.S;
            if (d[u] + w < d[v])
            {
                q.erase({d[v], v});
                d[v] = d[u] + w;
                q.emplace(d[v], v);
            }
        }
    }
    cout << fixed << setprecision(9) << d.back();
    return 0;
}

Measured memory_bytes: 16512
#include<iostream>
#include<vector>
#include<cstdio>
#include<iterator>
#include<string>
#include<queue>
#include<algorithm>
#include<string.h>
using namespace std;
#define MP make_pair
#define F first
#define S second
#define LL long long
#define INF	int(1e9)
typedef pair<int, int> P;
typedef pair<P, P> PP;
inline int in() {
	int temp;
	scanf("%ld", &temp);
	return temp;
}
LL n = in(), a = in(), b = in(), ans;
int main(){

	LL x1, x2;
	x1 = in();
	for (int i = 1; i < n; i++)
	{
		x2 = in();
		if ((x2 - x1) * a > b)
		{
			ans += b;
		}
		else
		{
			ans += (x2 - x1) * a;
		}
		x1 = x2;
	}
	cout << ans << endl;
}

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

using namespace std;

int mod(int a, int b){
  if(a>b)
    return a-b;
  return b-a;
}

long minimum(long a, long b)
{
  if(a<b)
    return a;
  return b;
}

int main(){
  int n,k;
  cin >> n >> k;
  int h[n];
  for(int i=0;i<n;i++)
    cin >> h[i];
  long dp[n];
  dp[n-1]=0;
  dp[n-2]=mod(h[n-1],h[n-2]);
  for(int i=n-3;i>=0;i--){
    //dp[i] = minimum(dp[i+1]+mod(h[i],h[i+1]), dp[i+2]+mod(h[i],h[i+2]));
    long ans = (long)dp[i+1]+mod(h[i],h[i+1]);
    for(int j=1;j<=k;j++){
        ans = minimum(ans, (long)dp[i+j]+mod(h[i],h[i+j]));
    }
    dp[i] = ans;
  }
  cout << dp[0] << endl;
  return 0;
}

Measured memory_bytes: 4768
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<cstring>
#include<climits>
#include<sstream>
#include<deque>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<bitset>

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

using namespace std;

typedef long long ll;

int main() {
  ll n;
  cin >> n;
  ll p = 1;
  REP(i,1,n+1) ( p = p * (ll)i ) %= 1000000007;
  cout << p << endl;
  return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    cout << max(0, C - (A - B)) << endl;
}


Measured memory_bytes: 888
# -*- coding: utf-8 -*-
from sys import stdin
import numpy as np
import heapq
# import sys
# sys.setrecursionlimit(10**4)

def _li(): return list(map(int, stdin.readline().split()))
def _li_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def _lf(): return list(map(float, stdin.readline().split()))
def _ls(): return stdin.readline().split()
def _i(): return int(stdin.readline())
def _f(): return float(stdin.readline())
def _s(): return stdin.readline()[:-1]


N, M = _li()

a_list = []
b_list = []
for _ in range(N):
    a, b = _li()
    a_list.append(a)
    b_list.append(b)

a_list = np.array(a_list)
b_list = np.array(b_list)
index = np.argsort(a_list)
a_list = a_list[index]
b_list = b_list[index]

ans = 0
cand = []
start = 0
for i in range(1, M+1):
    for j in range(start, N):
        if a_list[j] <= i:
            heapq.heappush(cand, -b_list[j])
            start = j+1
        else:
            break
    if len(cand) > 0:
        ans -= heapq.heappop(cand)
print(ans)


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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> dp(3);
    vector<int> oldp(3);
    for (int k =0; k<3; k++)
        cin >> oldp[k];
    for (int i=0; i<n-1 ; i++)
    {
        vector<int> v(3);
        for (int a=0; a<3; a++)
            cin >> v[a];
        for (int b=0; b<3; b++)
        {
            for (int c=0; c<3;c++)
            {
                if (b != c)
                    dp[b] = max(dp[b], v[b] + oldp[c]);
            }
        }
        oldp = dp;
    }
    if (n == 1)
        cout << max(oldp[0], max(oldp[1], oldp[2])) << "\n";
    else
        cout << max(dp[0], max(dp[1], dp[2])) << "\n";
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll a;
    string s;cin >>s;
    a=s[0]-'0';
    vector<ll>b(3);
    for (int i = 1; i <= 3; ++i) {
        b[i-1]=s[i]-'0';
//        cout <<b[i]<<endl;
    }
    ll now=a;
    for (int i = 0; i < (1 << 3); ++i) {
        now=a;
        for (int j = 0; j < 3; ++j) {
            if(i>>j&1){
              now+=b[j];
            }
            else  now-=b[j];
        }
//        cout <<now <<endl;
        if(now==7){
            cout <<a;
            for (int j = 0; j < 3; ++j) {
                if(i>>j&1){
                    cout <<'+';
                }
                else cout <<'-';
                cout <<b[j];
            }
            cout <<"=7"<<endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
# include <iostream>

using namespace std;

int main()
{
	string S, T;

	cin >> S;
	cin >> T;

	for (int i = 0; i < S.length(); i++)
	{
		if (S[i] != T[i])
			goto no;
	}

	cout << "Yes";
	goto end;

no:
	cout << "No";
end:

	return 0;
}

Measured memory_bytes: 3556
import sys
import numpy as np
MOD = 1000000007
def main():
    n, m = [int(x) for x in input().split()]
    pattern = [1]
    broken = -1
    brokencnt = 0
    if brokencnt < m:
        broken = int(input())
        brokencnt += 1
    for i in range(1, n + 1):
        if i == broken:
            pattern.append(0)
            if brokencnt < m:
                broken = int(input())
                brokencnt += 1
            continue
        if i == 1:
            pattern.append(pattern[i - 1])
        if i > 1:
            pattern.append((pattern[i - 1] + pattern[i - 2]) % MOD)
    print(pattern[n])
main()

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

//??????????????§
int a,b,c;

//???????§?????????????
int start;

//????????£?????????
int passage;

//?????????????????????????????????
bool can;

int main() {
	//??\???
	cin>>a>>b>>c;

	//?????????
	can=false;
	start=0;
	passage=0;

	do {
		//????????????????????????
		if(start<=c && c<=start+a){
			passage+=(c-start);
			can=true;
			break;
		}

		//??????????????????????¬???????????????????
		start+=(a+b);
		start%=60;

		passage +=(a+b);
	}while(start!=0);

	//??????
	if(can)cout<< passage <<endl;
	else   cout<<-1<<endl;

	return 0;
}

Measured memory_bytes: 3096
#include <cmath>
#include<iostream>
#include<vector>
#include <algorithm>
using namespace std;
# define maxi 100000
# define maxw 100000
# define maxn 1000

using ll=long long;
int main() {
  ll n,t[maxn],a[maxn];
  cin>>n;
  for (ll i(0);i<n;i++){
    cin>>t[i]>>a[i];
  }
  ll hyo1(1),hyo2(1);
  for (ll i(0);i<n;i++){
    ll sh1=(hyo1+(a[i]-1))/a[i],sh2=(hyo2+(t[i]-1))/t[i];
    ll d=max(sh1,sh2);
    hyo1=a[i]*d;hyo2=t[i]*d;
    // cout<<hyo1<<":"<<hyo2<<endl;
  }
  cout<<hyo1+hyo2;
}


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

//短縮
#define rep(i,n) for(int i=0;i<(n);++i)
//sort()用
#define all(v) v.begin(), v.end()

#define PB(N) push_back(N)

using namespace std;

using Graph = vector<vector<int>>;

int main(){
  int X,N;
  cin >> X >> N;
  set<int> p;
  rep(i,N) {
    int buffer;
    cin >> buffer;
    p.insert(buffer);
  }

long long flag;
  for(int i=1;;i++){
    if(i==1){
      if(!p.count(X)){
        flag=X;
        break;
      }
    }
    int buffer = X-i;
    int buffer2 = X+i;
    if(!p.count(buffer)){
      flag=buffer;
      break;
    }
    if(!p.count(buffer2)){
      flag=buffer2;
      break;
    }
  }

  if(N==0) cout << X;
  else cout << flag;

  return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int t,l;
    cin>>t>>l;

    int ar[t+1];
    double ar2[t+1];

    for(int i=1;i<=t;i++)
    {
        cin>>ar[i];
    }
    for(int i=1;i<=t;i++)
    {
        ar2[i]=((ar[i]*(ar[i]+1))/2.0)/ar[i];
    }
    double sm=0,mx=0;
    for(int i=1;i<=l;i++)
    {
        sm+=ar2[i];
    }
    mx=sm;
    for(int i=l+1;i<=t;i++)
    {
        sm+=ar2[i];
        sm-=ar2[i-l];
        mx=max(mx,sm);
    }

    cout<<setprecision(10)<<fixed;
    cout<<mx<<endl;


    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    int ans=-1;
    for(int i=1;i<=10000;i++){
        double c=0.08*i;
        double d=0.1*i;
        if((int)c==a && (int)d==b){
            ans=i;
            break;
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
n, a, b = map(int, input().split())
s = list(input())
line = a + b
rank = 1
bnum = 0
for student in s:
    if student == "a" or student== "b":
        if rank <= line:

            if student == "a":
                print("Yes")
                rank += 1
            else:
                bnum += 1
                if bnum <= b:
                    print("Yes")
                    rank += 1
                else:
                    print("No")
        else:
            print("No")
    else:
        # rank +=1
        print("No")

Measured memory_bytes: 9696
#include <iostream>
using namespace std;
int main(void){
    int n;
    cin >> n;
    string s;
    cin >> s;
    
    int r = 0;
    int w = 0;
    for(int i = 0;i < n;i++){
          if(s[i] == 'R')r++;
          else w++;
    }
    
    int moveRed = 0;
    int moveWhite = 0;
    for(int i = 0;i < r;i++){
          if(s[i] == 'W')moveRed++;
    }
    for(int i = n - 1;i > n - 1 - w;i--){
          if(s[i] == 'R')moveWhite++;
    }
    cout << min(moveWhite,moveRed) << endl;
}


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

int main(){
    ll n, k;
    cin >> k>>n;
    ll a[n + 5];
    ll ans=inf;
    rep(i, n)
    {
        cin >> a[i];
    }
    sort(a, a+n);
    ll l = 0;
    rep(i, n-1){
        l=max(l,a[i+1]-a[i]);
    }
    l = max(l, k-a[n-1]+a[0] );
    cout << k - l << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair <int, int> P;

int main() {
	string s;
	cin >> s;
	if (s[0] == s[1] && s[0] == s[2]) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# !/usr/bin/env python
# vim: set fileencoding=utf-8 :

"""
#
# Author:   Noname
# URL:      https://github.com/pettan0818
# License:  MIT License
# Created: 土  6/23 21:14:29 2018

# Usage
#
"""
import sys
def get_input():
    line = sys.stdin.readline()

    return line.rstrip()

def sum_digit(target: str):
    """
    >>> sum_digit("190")
    10
    >>> sum_digit("0")
    0
    """
    sumup = 0
    for digit in target:
        sumup = sumup + int(digit)

    return sumup

def check_sum(target, sumup):
    """
    >>> target = "999999999"
    >>> check_sum(target, sum_digit(target))
    Yes
    >>> target = "101"
    >>> check_sum(target, sum_digit(target))
    >>> target = "12"
    >>> check_sum(target, sum_digit(target))
    """

    target = int(target)

    try:
        if target % sumup == 0:
            print("Yes")
        else:
            print("No")
    except ZeroDivisionError:
        print("No")

if __name__ == '__main__':
    stdin = get_input()
    check_sum(stdin, sum_digit(stdin))

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main(int argc, char const* argv[])
{
	int a, b, c, ans = 0;
	cin >> a >> b >> c;
	for (int i=a; i<=b; i++) {
		if (c % i == 0) {
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1160
import math
N=int(input())
L=list(map(int,input().split()))

'''
ans=0
for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            if(L[i]!=L[j]):
                if(L[i]!=L[k]):
                    if(L[j]!=L[k]):
                        ans+=1
                        print('{},{},{}'.format(i,j,k))
            else:
                break
print(ans)
'''
count=0
ss=[]
S=[0]*N
for i in range(len(L)):
    if(not (L[i] in ss)):

        ss.append(L[i])
        if(S[ss.index(L[i])]==0):
            S[ss.index(L[i])]=1
    else:

        S[ss.index(L[i])]=S[ss.index(L[i])]+1

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

ans=0
for i in range(len(ss)-2):
    for j in range(i+1,len(ss)-1):
        for k in range(j+1,len(ss)):
            if(ss[i]+ss[j]>ss[k] and ss[j]+ss[k]>ss[i] and ss[k]+ss[i]>ss[j]):
                ans=ans+S[i]*S[j]*S[k]

print(ans)
'''
print(count)
print(combinations_count(count, 3))
'''


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

int h1, m1, h2, m2, k;

int main() {
	cin >> h1 >> m1 >> h2 >> m2 >> k;
	int t1 = 60 * h1 + m1;
	int t2 = 60 * h2 + m2;
	cout << t2 - t1 - k << '\n';
}

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

int main(){
	ll n; cin>>n;
	vector<ll> v(5);
	rep(i,5) cin>>v[i];
	sort(all(v));
	cout<<(n+v[0]-1)/v[0]+4<<endl;
}

Measured memory_bytes: 3540
#include "bits/stdc++.h"
#pragma comment (linker, "/STACK:526000000")
#define  _CRT_SECURE_NO_WARNINGS

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

int cnt[200000];
vector<pair<int, int>> vertexs[200000];
int ans[4000000];

pair<int, int> going[4000000];
void solve(){
	int n, m;
	cin >> n >> m;
	vector<pair<int, int>> bomb;
	vector<pair<int, int>> switches;
	REP(i, n) {
		int a, b;
		cin >> a >> b;
		bomb.push_back(mp(a, b));
	}
	sort(ALL(bomb));
	bomb.push_back(mp(2e9, 0));
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		switches.push_back(mp(0, 0));
		auto x = lower_bound(ALL(bomb), mp(a, -1));
		switches.back().first = x - bomb.begin();
		x = lower_bound(ALL(bomb), mp(b + 1, -1));
		switches.back().second = x - bomb.begin();
	}
	REP(i, switches.size()) {
		if (switches[i].first == switches[i].second) continue;
		vertexs[switches[i].first].push_back(mp(switches[i].second, i));
	}
	int now_itr = switches.size();
	for (int i = 0; i < n; ++i) {
		cnt[i] %= 2;
		if (cnt[i] != bomb[i].second) {
			//choose one!
			if (vertexs[i].size() == 0) {
				cout << -1 << endl;
				return;
			}
			cnt[i]++;
			cnt[vertexs[i][0].first]++;
			ans[vertexs[i][0].second]++;
		}
		sort(ALL(vertexs[i]));
		for (int q = 1; q < vertexs[i].size(); ++q) {
			if (vertexs[i][q - 1].first == vertexs[i][q].first) {
				continue;
			}
			going[now_itr] = mp(vertexs[i][q - 1].second, vertexs[i][q].second);
			vertexs[vertexs[i][q - 1].first].push_back(mp(vertexs[i][q].first, now_itr));
			now_itr++;
		}
		cnt[i + 1] += cnt[i];
	}
	for (int q = now_itr-1; q >= switches.size(); --q) {
		ans[q] %= 2;
		ans[going[q].first] += ans[q];
		ans[going[q].second] += ans[q];
	}
	vector<int> final_ans;
	REP(i, m) {
		if (ans[i] % 2 == 1) {
			final_ans.push_back(i);
		}
	}
	cout << final_ans.size() << endl;
	REP(i, final_ans.size()) {
		cout << final_ans[i] + 1 << " ";
	}
	cout << endl;
}
#undef int
int main() {
	init();
	solve();
}

Measured memory_bytes: 45168
#include <cstdlib>
#include <iostream>

int main()
{
    int N, X;
    std::cin >> N >> X;

    int* L = (int*)calloc(N, sizeof(int));

    int y_coord = 0;
    int bounce_num = 0;

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

    for (int i = 0; i < N; i++) {
        y_coord += L[i];
        if (y_coord > X) {
            break;
        }
        bounce_num++;
    }
    std::cout << bounce_num + 1 << std::endl;

    free(L);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define p push
#define ll long long
#define f first
#define s second
#define vi vector<int>
#define vll vector<long long>
#define all(vec) begin(vec), end(vec)
#define pii pair<int,int>
#define plli pair<ll,int>
#define pill pair<ill>
#define ft front()
#define bk back()
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
using namespace std;

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n; cin >> n; ll mod = (ll)1000000007;
    ll a = 1, b = 1, c = 1;
    for(ll i = 1; i <= n; i++){
        a = (a*10)%mod; b = (b*9)%mod; c = (c*8)%mod;
    }
    cout << ((a-b-b+c)%mod+mod)%mod << '\n';
    return 0;
}



Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include<queue>
#include <sstream>
#include <set>
typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
using namespace std;
int main(){
    double a,b;
    cin >> a>>b;

    cout << a/b <<endl;


}

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

// 0-indexed
struct dsu {
	int n; // number of connected components
	vector<int> par;
	vector<int> sz;

	dsu(int _n) : n(_n), par(n, -1), sz(n, 1) { }

	int getpar(int a) {
		return par[a] == -1 ? a : (par[a] = getpar(par[a]));
	}

	bool merge(int a, int b) {
		a = getpar(a);
		b = getpar(b);
		if (a == b) return false;
		n--;
		if (sz[a] < sz[b]) swap(a, b);
		par[b] = a;
		sz[a] += sz[b];
		return true;
	}
};

const int MAXN = 1.1e5;
const int MAXM = 1.1e5;
int N, M;
int P[MAXN];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		cin >> P[i]; P[i]--;
	}
	dsu conn(N);
	for (int e = 0; e < M; e++) {
		int x, y; cin >> x >> y; x--, y--;
		conn.merge(x, y);
	}

	int ans = 0;
	for (int i = 0; i < N; i++) {
		ans += (conn.getpar(i) == conn.getpar(P[i]));
	}
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 1408
import functools

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def inpm(line):
    return [inp() for _ in range(line)]


def inpfm(line):
    return [inpf() for _ in range(line)]


def inpsm(line):
    return [inps() for _ in range(line)]


def inlm(line):
    return [inl() for _ in range(line)]


def inlfm(line):
    return [inlf() for _ in range(line)]


def inlsm(line):
    return [inls() for _ in range(line)]


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper


x, a, b = inl()
print('A' if abs(x - a) < abs(x - b) else 'B')


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

int main(){
	int d,n,cnt=1;
	cin>>d>>n;
	for(int i=0; i<d; i++)cnt*=100;
	if(n!=100)cout<<cnt*n<<endl;
	else cout<<cnt*101<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn=10005;
long long adda,addb;
int n,a[maxn],b[maxn];
int main()
{
    scanf("%d",&n);
    for (int i=0;i<n;++i)
        scanf("%d",&a[i]);
    for (int i=0;i<n;++i)
        scanf("%d",&b[i]);
    for (int i=0;i<n;++i) {
        int now;
        if (b[i]>a[i])
            now=b[i]+(b[i]-a[i])%2;
        else
            now=a[i];
        adda+=1LL*max(0,(now-a[i])/2);
        addb+=1LL*max(0,now-b[i]);
    }
    if (adda<addb)
        puts("No");
    else puts("Yes");
    return 0;
}


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

int main(){
	int n, k;
	cin >> n >> k;
	vector<int> l(n);
	for(int i = 0; i < n; i++){
		cin >> l[i];
	}

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

	int ans=0;
	for(int i = 0; i < k; i++){
		ans += l[n - 1 - i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]

def count_coin(p):
	return A[p[0]][p[1]]

result = []
def move_coin(f, t):
	global result
	A[f[0]][f[1]] -= 1
	A[t[0]][t[1]] += 1
	result += ["{:d} {:d} {:d} {:d}".format(f[0] + 1, f[1] + 1, t[0] + 1, t[1] + 1)]

for y in range(H):
	for x in range(W):
		if 0 == count_coin((y, x)) % 2:
			continue
		if x == W - 1:
			if y == H - 1:
				#終端
				break
			else:
				#右端：下へ
				move_coin((y, x), (y + 1, x))
		else:
			#右へ
			move_coin((y, x), (y, x + 1))

print(len(result))
for line in result:
	print(line)


Measured memory_bytes: 16472
import sys
import heapq

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, K = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]

    def isOK(mid):
        cnt = 0
        for i in range(N):
            if A[i] > mid:
                cnt += -(-A[i] // mid) - 1
                if cnt > K:
                    return False
        return True

    ok = max(A)
    ng = 0

    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if isOK(mid):
            ok = mid
        else:
            ng = mid

    print(ok)


if __name__ == '__main__':
    main()


Measured memory_bytes: 91712
#include<bits/stdc++.h>
#define ll long long
#define MOD 1000000007
#define INF 0x7fffffff
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
typedef tree<int,null_type,std::less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
using namespace std;
/*
ordered_set X;
X.insert(1);
cout<<*X.find_by_order(1)<<endl; Kth largest element
cout<<X.order_of_key(-5)<<endl;  number of elemets less than K
*/
int const maxi = 200000;
int main(){
    //freopen(".txt", "w", stdout
    //IO;

    int n,w;
    scanf("%d%d",&n,&w);
    vector<ll> dp(maxi+1,INF);
    dp[0] = 0;
    for(int i = 0; i < n; i++){
        ll we,va;
        scanf("%lld%lld",&we,&va);
        //dp[va] = min(dp[va],we);
        //dp[va] = we;
        for(int x = maxi - va; x >= 0; x--){
            dp[x+va] = min(dp[x+va],dp[x] + we);

        }
    }
    ll answer = 0;
    for(int i = 0; i <= maxi; i++){

        if(dp[i] <= w)
            answer = i;
    }
    printf("%lld",answer);
    return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int K,T,x[2000];
int main(){
	scanf("%d%d",&K,&T);
	for (int i=1;i<=T;i++) scanf("%d",&x[i]);
	sort(x+1,x+T+1);
	int k1=x[T],k2=K-x[T];
	printf("%d\n",max(0,k1-k2-1));
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<set>

using namespace std;

int main(){
  set<int> st;

  int n;
  cin>>n;
  int temp;
  //cin>>temp;
  //st.insert(temp);
  // n--;
  while(n--){
    cin>>temp;
    if(st.find(temp)==st.end()){
        //cout<<"1"<<endl;
        st.insert(temp);
    }else{
         //cout<<"2"<<endl;
        st.erase(temp);
    }
  }
  cout<<st.size()<<endl;

}


Measured memory_bytes: 4864
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class ASTring {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            char[] x = in.next().toCharArray();
            int answer = 0;
            int count = 0;

            for (char c : x) {
                if (c == 'T')
                    count++;
                else
                    count--;
                answer = Math.max(answer, count);
            }
            answer *= 2;

            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

    }
}



Measured memory_bytes: 27220
# 再帰関数の最大再帰回数を変更
import sys
sys.setrecursionlimit(1000000)

# 再帰関数で作る木の個数を返す
def dfs(now, end, summary):
    # 終了条件
    if now == end:
        return summary
    # 1つ前の頂点時点で作ることのできる木の個数 *（１つ前の深さの頂点の数 ^ 現在の深さの頂点の数）で再帰関数
    else:
        return dfs(now + 1, end, summary * (deep[now - 1] ** deep[now]))

# 最後に割る数の定数
JOSU = 998244353

# 入力
N = int(input())
D = list(map(int, input().split()))

# 深さをメモするため、Dの最大値 + 1の数の配列を用意
# 例：深さの最大が2なら、0, 1, 2の3つが必要
deep = [0] * (max(D) + 1)

# 各深さの頂点の数を記録
for i in range(N):

    # 頂点1が深さ0以外なら制約違反
    if i == 0 and D[i] != 0:
        print(0)
        exit()
    # 頂点1以外が深さ0なら制約違反
    elif i > 0 and D[i] == 0:
        print(0)
        exit()

    deep[D[i]] += 1

# 再帰関数で計算
print(dfs(1, len(deep), 1) % JOSU)



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

using namespace std;

set<string> ans;

string s;
int x;
void rec(int i, string res, int k) {
  if(i == 9) {
    //  cout << res << endl;
    // cin >> x;
    ans.insert(res);
    return;
  }

  if(k < s.size()){
  rec(i + 1, res + s[k],k+1);
  rec(i + 1, res + "A",k);
  }
  else rec(i + 1, res + "A", k);
  
  return;
}

int main() {
  cin >> s;
  if(s.size() > 9) {
    cout << "NO" << endl;
    return 0;
  }
  rec(0,"",0);

  if(ans.count("AKIHABARA") > 0) cout << "YES" << endl;
  else cout << "NO" << endl;
  
}
  
  
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}

int main()
{
	int n,m,x;
	cin>>n>>m>>x;
	vec A(m);
	rep(i,0,m)cin>>A[i];
	cout<<min(lower_bound(all(A),x)-A.begin(),(int)A.size()-(lower_bound(all(A),x)-A.begin()))<<endl;
	return 0;
}



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

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<ll> v(n+1,0);
    for(int i=1;i<=n;i++) cin >> v[i];
    map<int,ll> m[n+1];
    m[0][0]=0;
    m[1][1]=v[1];
    for(int i=1;i<=n;i++)
    {
        for(int c=max(1,(i+1)/2-10);c<=(i+1)/2;c++)
        {
            if(m[i].find(c)==m[i].end()) m[i][c]=-(1ll<<60);
            for(int j=max(0,i-4);j<i-1;j++)
            {
                if(m[j].find(c-1)==m[j].end()) continue;
                m[i][c]=max(m[i][c],m[j][c-1]+v[i]);
            }
        }
    }
    ll res=-(1ll<<60);
    for(int i=1;i<=n;i++) if(m[i].find(n/2)!=m[i].end()) res=max(res,m[i][n/2]);
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 151568
#include<iostream>
using namespace std;
int main(){
	int z,ans;
	while(cin>>z,z){
		ans=0;
		for(int i=1;i*i*i<=z*z*z;i++)
		for(int j=1;i*i*i+j*j*j<=z*z*z;j++)
		if(ans<i*i*i+j*j*j)
		ans=i*i*i+j*j*j;
		cout<<z*z*z-ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 864
#include<stdio.h>
int main(){
  int n,i,sum=0;
  scanf("%d",&n);
  int a[n+2],b[n+2];
  for(i=1;i<=n;i++)
    scanf("%d",&a[i]);
  for(i=n;i>=1;i--){
    int j=2*i,count=0;
    while(j<=n){
      if(b[j]==1)
        count++;
      j+=i;
    }
    if(a[i]==count%2)
      b[i]=0;
    else{
      b[i]=1;
      sum++;
    }
  }
  printf("%d\n",sum);
  for(i=1;i<=n;i++)
    if(b[i]==1)
      printf("%d ",i);
  return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< string, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789


///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int a;

int main(){
    
    cin>>a;
    cout<<3*a*a<<endl;
    
    
    
    return 0;
}



Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ch=char;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
typedef vector<ch> vc;
typedef vector<vc> vvc;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
#define ROF(i,a,b) for(ll i=a;i>=b;i--)
#define per(i,a) ROF(i,a,0)
#define pb push_back
const ll MOD=1000000007;
const ll MOD2=998244353;
const ld PI=acos(-1);
const ll INF=1e18;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};
struct edge2{ll from,to,cost;};


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll n;
    cin >> n;
    ll a=0,w=0,t=0,r=0;
    rep(i,n){
        string s;
        cin >> s;
        if(s=="AC"){
            a++;
        }
        else if(s=="WA"){
            w++;
        }
        else if(s=="TLE"){
            t++;
        }
        else{
            r++;
        }
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << w << endl;
    cout << "TLE x " << t << endl;
    cout << "RE x " << r << endl;
}

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

int main() {
  int h,w,k;
  cin >> h >> w >> k;
  
  vector<char> a(h*w);
  for(int i=0; i<h*w; i++) cin >> a[i];
  
  vector<char> reset(h*w);
  for(int i=0; i<h*w; i++) reset[i] = a[i];
  
  int count = 0;
  int ans = 0;
  
  for(int bit=0; bit<(1<<h); bit++){
    
    for(int bitw=0; bitw<(1<<w); bitw++){
      
      for(int i=0; i<h; i++){
        if(bit & (1<<i)){
          for(int j=w*i; j<w*(i+1); j++) a[j] = 'R';
        }
      }
       
      for(int i=0; i<w; i++){
        if(bitw & (1<<i)){
          for(int j=i; j<=h*w; j+=w) a[j] = 'R';
        }
      }
      
      for(int i=0; i<h*w; i++){
        if(a[i] == '#') count++;
      }
      if(count == k) ans++;
      count = 0;
      
      for(int i=0; i<h*w; i++) a[i] = reset[i];
    }
      
  }
  
  cout << ans << endl;
  
	return 0;
}


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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,a=0,b=0,mi=1000000;
	string s;
	cin>>n>>s;;
	if(n==2){
		if(s.substr(0,1)=="W" && s.substr(1,1)=="E"){
			cout<<1<<endl;
		}else{
			cout<<0<<endl;
		}return 0;
	}
	vector<pair<ll,ll>>v(n);
	for(int i=0;i<n;i++){
		if(s[i]=='W'){
			a++;
		}else {
			b++;
		}
		v.at(i).first=a;
		v.at(i).second=b;
	}
	for(int i=0;i<n-1;i++){
		if(i==0){
			if(v.at(0).second==1){
				mi=b-1;
			}else if(v.at(0).second==0){
				mi=b;
			}
		}else{
			mi=min(v.at(i-1).first+b-v.at(i).second,mi);
		}
	}
	if(s.substr(n-1,1)=="W")a--;
	mi=min(a,mi);
	cout<<mi<<endl;
	return 0;
}


Measured memory_bytes: 5396
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

ll A, B, C, D, E, res;

ll gcd(ll x, ll y) {
	if (y) {
		return gcd(y, x%y);
	}
	else return x;
}

ll lcm(ll x, ll y) {
	return x*y / gcd(x, y);
}

int main() {
	cin >> A >> B >> C >> D;
	res = B - A + 1;
	res -= B / C + B / D;
	res += (A - 1) / C + (A - 1) / D;
	E = lcm(C, D);
	res += B / E;
	res -= (A - 1) / E;
	cout << res << endl;
}

Measured memory_bytes: 384
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
#define mst(a,b) memset((a),(b),sizeof(a))
#define rush() int T;scanf("%d",&T);while(T--)

typedef long long ll;
const int maxn = 200005;
const ll mod = 10;
const ll INF = 0x3f3f3f3f;
const double eps = 1e-9;

int n;
int ans=0;
ll a[maxn];

void dfs(int id,ll val)
{
    if(id==n)
    {
        ans+=!(val&1);
        return;
    }
    dfs(id+1,val*(a[id]-1));
    dfs(id+1,val*(a[id]));
    dfs(id+1,val*(a[id]+1));
    return;
}

int main()
{
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
    }
    dfs(0,1);
    printf("%lld\n",ans);
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;

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

  vector<int>oks(N+1,true);
  for(int i=0;i<M;++i){
    int a;cin>>a;
    oks[a]=false;
  }

  vector<long long int>dp(N+1);
  dp[0]=1;
  for(int now=0;now<N;++now){
    for(int next=now+1;next<=min(N,now+2);++next){
      if(oks[next]){
        dp[next]+=dp[now];
        dp[next]%=mod;
      }
    }
  }

  cout<<dp[N]<<endl;
  return 0;
}


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long answer =0;
		if(n ==1) {
			System.out.println(1);
			return;
		}
		long l0 =2;
		long l1 =1;
		for(int i =2;i <=n;i++) {
			answer = l0 + l1;
			l0 =l1;
			l1 = answer;
		}
		System.out.println(answer);

	}
}

Measured memory_bytes: 21716
H, W = map(int, input().split())
A = [input() for _ in range(H)]

y, x = 0, 0
c = 0
while True:
    c += 1
    if y == H - 1 and x == W - 1:
        break
    if y < H - 1 and A[y + 1][x] == '#':
        y += 1
    elif x < W - 1 and A[y][x + 1] == '#':
        x += 1
    else:
        break

if c == sum(a.count('#') for a in A):
    print('Possible')
else:
    print('Impossible')


Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        char c = in.nextLine().charAt(0);
        if (Character.isUpperCase(c)) {
            System.out.println('A');
        } else {
            System.out.println('a');
        }
    }
}


Measured memory_bytes: 35720
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
const int INF = 1e9;

typedef long long ll;

#define MAX_V 100010

struct edge {
    int to;
    int cost;
};


int V;
vector<edge> G[MAX_V];
int d[MAX_V];


void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;

        for (int i=0; i<G[v].size(); ++i) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}



int main(){
  int E,r;
  cin >> V;
  E = V-1;
  REP(i,E){
    int f,t,c;
    cin >> f >> t;
    f--;
    t--;
    c = 1;
    edge e = {t,c};
    G[f].pb(e);
    e.to = f;
    G[t].pb(e);
  }
  int dis[2][V];
  dijkstra(0);
  REP(i,V){
    dis[0][i] = d[i];
  }
  dijkstra(V-1);
  REP(i,V){
    dis[1][i] = d[i];
  }
  int black = 0,white = 0;
  REP(i,V){
    //cout << dis[0][i] << "      " << dis[1][i] << endl;
    if(dis[0][i] <= dis[1][i])
      black++;
    else
      white++;
  }
  if(black > white)
    cout << "Fennec" << endl;
  else
    cout << "Snuke" << endl;
  return 0;
}


Measured memory_bytes: 7568
import sys
input = sys.stdin.readline
from itertools import combinations

def readlines(n):
    for _ in range(n):
        k, *s = map(int, input().split())
        yield s

def on(s, p, comb):
    return len([s_ for s_ in s if s_ in comb]) % 2 == p

def main():
    n, m = map(int, input().split())
    switches = list(range(1, n+1))
    S = list(readlines(m))
    P = list(map(int, input().split()))
    for i in range(n+1):
        for comb in combinations(switches, i):
            if all(on(s, p, set(comb)) for s, p in zip(S, P)):
                yield 1

print(sum(main()))



Measured memory_bytes: 3188
using System;
using System.Linq;
using System.Collections.Generic;

namespace program
{
    class Program
    {
        static void Main()
        {
            string[] S = Input.ScanStrArray();
          Console.WriteLine(S[0]==S[1] ? "H" : "D");
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define RREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
#define YY cout << "Yes" << endl
#define NN cout << "No" << endl
const long long INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
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) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
int b[3][3];
int solve(){
  rep(i,3)rep(j,3)cin>>b[i][j];
  int n;
  cin >> n;
  rep(i,n){
    int tmp;
    cin>>tmp;
    rep(j,3)rep(k,3){
      if(b[j][k] == tmp)b[j][k] = 0;
    }
  }
  bool ans = false;
  rep(i,3){
    int cnt = 0;
    rep(j,3)if(!b[i][j])cnt++;
    if(cnt==3)ans = true;
  }
  rep(i,3){
    int cnt = 0;
    rep(j,3)if(!b[j][i])cnt++;
    if(cnt==3)ans = true;
  }
  if(b[0][0]+b[1][1]+b[2][2]==0)ans = true;
  if(b[0][2]+b[1][1]+b[2][0]==0)ans = true;
  if(ans)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0; 
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}

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

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

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


int main() {
  double a,b,x; cin >> a >> b >> x;

  double angle, pi=acos(-1);
  if(x > a*a*b/2) { angle = atan(2*b/a-2*x/(a*a*a))*180/pi;  }
  else { angle = atan(a*b*b/(2*x))*180/pi; }

  printf("%.10lf\n",angle);
  return 0;
}

Measured memory_bytes: 384