akhauriyash/Code-Regression huggingface dataset:
#coding: utf-8
STDOUT.sync = true

sum = Array.new(51, 0)
a = b = c = d = 10

a.times { |a|
  b.times { |b|
    c.times { |c|
	  d.times { |d|
	    sum[a + b + c + d] += 1
      }
	}
  }
}

while num = gets do
  puts sum[num.to_i]
end

Measured memory_bytes: 8616
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
    int a, b, c, x, ans = 0;
    
    cin >> a >> b >> c >> x;

    for(int i = 0; i <= a; ++i){
        for(int j = 0; j <= b; ++j){
            for(int k = 0; k <= c; ++k){
                if((500 * i + 100 * j + 50 * k) == x) ans++;
            }
        }
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
const int MOD = 1E9 + 7;
const int INF = 1 << 29;

int main() {
  int N;
  cin >> N;
  char S[N];
  ll CountR = 0;
  ll CountG = 0;
  ll CountB = 0;
  rep(i, N) {
    cin >> S[i];
    if (S[i] == 'R') CountR++;
    if (S[i] == 'G') CountG++;
    if (S[i] == 'B') CountB++;
  };
  ll ans = CountR * CountG * CountB;
  rep(i, N) {
    rep(d, N) {
      int j = i + d;
      int k = j + d;
      if (k >= N) break;
      if (S[i] != S[j] && S[j] != S[k] && S[k] != S[i]) ans -= 1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3592
import sys
n = int(sys.stdin.readline())
p = [int(i) for i in sys.stdin.readline().split()]

if p == sorted(p):
    print('YES')
elif len(p) == 2:
    print('YES')
else:
    swap_index = []
    for i, v in enumerate(p[:-1]):
        if v > p[i + 1]:
            if len(swap_index) == 0:
                swap_index.append(i)
            else:
                swap_index.append(i + 1)
                break
    if len(swap_index) == 1:
        print('NO')
    else:
        p[swap_index[0]], p[swap_index[1]] = p[swap_index[1]], p[swap_index[0]]
        if p == sorted(p):
            print('YES')
        else:
            print('NO')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 1000000007;

int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	while (true) {
		c -= b;
		if (c <= 0) {
			cout << "Yes" << endl;
			break;
		}
		a -= d;
		if (a <= 0) {
			cout << "No" << endl;
			break;
		}
	}
}


Measured memory_bytes: 3620
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(a)			a.begin(), a.end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF				2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)	((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define	MAX_QWORD		((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI			3.14159265358979323846
typedef long long		ll;
typedef pair<ll, ll>	P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	int N;
	cin >> N;
	map<char, ll> mp;
	REP(i, N) {
		string a;
		cin >> a;
		mp[a[0]]++;
	}

	// 順列
	ll ans = 0;
	string march("MARCH");
	ans += (mp['M'] * mp['A'] * mp['R']);
	ans += (mp['M'] * mp['A'] * mp['C']);
	ans += (mp['M'] * mp['A'] * mp['H']);
	ans += (mp['M'] * mp['R'] * mp['C']);
	ans += (mp['M'] * mp['R'] * mp['H']);
	ans += (mp['M'] * mp['C'] * mp['H']);
	ans += (mp['A'] * mp['R'] * mp['C']);
	ans += (mp['A'] * mp['R'] * mp['H']);
	ans += (mp['A'] * mp['C'] * mp['H']);
	ans += (mp['R'] * mp['C'] * mp['H']);
	cout << ans << endl;
	return 0;
}



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

using namespace std;

int main()
{
	long long n, m;
	vector<long long> arr;
	vector<long long> diff;
	long long input;
	long long i;
	long long sum = 0;

	scanf("%lld %lld", &n, &m);

	for (i = 0; i < m; i++)
	{
		scanf("%lld", &input);
		
		arr.push_back(input);
	}

	if (n >= m)
	{
		printf("0\n");

		return 0;
	}

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

	for (i = 0; i < m - 1; i++)
	{
		diff.push_back(arr[i + 1] - arr[i]);
	}

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

	for (i = 0; i < m - n; i++)
	{
		sum += diff[i];
	}

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

	return 0;
}

Measured memory_bytes: 2548
V, E = map(int, input().split())
a = [0 for i in range(E)]
b = [0 for i in range(E)]
m = [[0 for i in range(V)] for i in range(V)]
for i in range(E):
    a[i], b[i]=map(int, input().split())
    m[a[i]-1][b[i]-1]+=1
    m[b[i]-1][a[i]-1]+=1
S=0
for n in range(E):
    m[a[n]-1][b[n]-1]-=1
    m[b[n]-1][a[n]-1]-=1
    U=[[] for i in range(V)]
    for i in range(V):
        for j in range(V):
            if m[i][j]!=0:
                U[i].append(j)
    P=[set() for i in range(E+1)]
    P[0].add(0)
    Q=set()
    R=[False for i in range(V)]
    for i in range(1,E+1):
        for u in P[i-1]:
            for v in U[u]:
                if not(R[v]):
                    R[v]=True
                    P[i].add(v)
                    Q.add(v)
        if len(P[i])==0:
            break
    if len(Q)!=V:
        S+=1
    m[a[n]-1][b[n]-1]+=1
    m[b[n]-1][a[n]-1]+=1
print(S)


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

int main(){
	int n;
	int m = 0;
	cin >> n;
	int a[n];
	for(int i = 0;i < n;i++){
		cin >> a[i];
	}
	
	while(1){
		int flag = 0;
		for(int i = 0;i < n-1;i++){
			if(a[i] > a[i+1]){
				flag = 1;
				int k;
				k = a[i];
				a[i] = a[i+1];
				a[i+1] = k;
				m++;
			}
		}
		if(flag == 0){
			break;
		}
	}
	
	for(int i = 0;i < n-1;i++){
		cout << a[i] << " ";
	}
	cout << a[n-1] << endl;
	cout << m << endl;
}



Measured memory_bytes: 3096
N = int(input())
ac = [list(map(int, input().split())) for _ in range(N)]
# 0 -> a
# 1 -> b
# 2 -> c

se = [[1, 2], [0, 2], [0, 1]]

#dpは(happiness, latest_activity) のタプルを保持する
dp = [[0 for _ in range(3)] for i in range(N + 1)]

for i in range(N):
  for j in range(3):
    dp[i + 1][j] = max(dp[i][se[j][0]] + ac[i][j], dp[i][se[j][1]] + ac[i][j])

a = max(dp[N][0], dp[N][1], dp[N][2])
print(a)

Measured memory_bytes: 74328
class BIT:
    '''
    0-indexed
    '''
    def __init__(self, N):
        self.size = N
        self.tree = [0] * (N + 1)
        self.depth = n.bit_length()

    def _bitsum(self, i):
        ret = 0
        while i:
            ret += self.tree[i]
            i ^= i & -i
        return ret

    def bitsum(self, l, r=None): # [l, r)
        if r is None:
            return self._bitsum(l)
        else:
            return self._bitsum(r) - self._bitsum(l)

    def bitadd(self, i, x):
        i += 1
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
        return

n = int(input())
m = n * (n + 1) // 4
a = list(map(int, input().split()))
d = dict()
_a = sorted(set(a + [0]))
for i, x in enumerate(_a):
  d[x] = i
a = [d[x] for x in a]


def check(X):
  b = [0] + [(y>=X)*2 - 1 for y in a]
  for i in range(n):
    b[i+1] += b[i]
  c = min(b)
  b = [x-c for x in b] 
  bit = BIT(max(b) + 2)
  ans = 0
  for x in b:
    ans += bit.bitsum(x + 1)
    bit.bitadd(x, 1)
  return ans >= m

t = [len(_a), 0]
while t[0] - t[1] > 1:
  mid = (t[0] + t[1]) // 2
  t[check(mid)] = mid
print(_a[t[1]])


Measured memory_bytes: 102564
#include <bits/stdc++.h>
#define sz(x) (int)((x).size())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define FOR(i, a, n, step) for (int (i) = (a); (i) < (int)(n); (i) += (step))
#define ROF(i, a, n, step) for (int (i) = (a); (i) >= (int)(n); (i) += (step))
#define FOREACH(it, v) for (auto (it) : (v))

using namespace std;

typedef unsigned long long ull;
typedef long long ll ;
typedef long double ld;
typedef pair <int, int> pii;

template <class T>
const bool is_impar(const T &x) {return (bool) (x & 1);}

int n, nrfin;
vector <int> v;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    v.resize(n + 5);
    FOR (i, 0, n, 1)
        cin >> v[i];
    FOR (i, 1, n, 1)
        if (v[i] == v[i - 1])
            v[i] = 0, nrfin++;
    cout << nrfin;
}

Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

int main(void) {
    string a, b, c;
    cin >> a;
    cin >> b;
    cin >> c;
    bool ans = (a.back() == b.front()) && (b.back() == c.front());
    cout << (ans ? "YES" : "NO") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include <unordered_map>
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
using namespace std;

typedef unsigned long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define MAPFOR(it,m) for( auto it = (m).begin(); it != (m).end() ; ++it )
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)


int main(void){
    int n;
    cin >> n;
    vll a(n);
    ll allx = 0;
    REP(i, n) {
        cin >> a[i];
        allx = allx ^ a[i];
    }
    REP(i, n-1) {
        ll x = allx ^ a[i];
        cout << x << " ";
    }
    ll x = (a[n-1] ^ allx);
    cout << x << endl;
    
    return 0;
}

Measured memory_bytes: 4800
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

const (
	initialBufSize = 64 * 1024
	maxBufSize     = 10000000
)

var (
	scanner = bufio.NewScanner(os.Stdin)
)

func main() {
	scanner.Split(bufio.ScanWords)
	n := scanInt()
	count := make(map[string]int, n)
	for i := 0; i < n; i++ {
		count[scanText()]++
	}

	var ans []string
	most := 0

	for k, v := range count {
		if v >= most {
			if v > most {
				ans = make([]string, 0, n)
			}
			ans = append(ans, k)
			most = v
		}
	}
	sort.Strings(ans)
	for _, v := range ans {
		fmt.Println(v)
	}
}

func scanInt() int {
	i, _ := strconv.Atoi(scanText())
	return i
}

func scanInts(size int) []int {
	ints := make([]int, size)
	for i := 0; i < size; i++ {
		ints[i] = scanInt()
	}
	return ints
}

func scanFloat64() float64 {
	f, _ := strconv.ParseFloat(scanText(), 64)
	return f
}

func scanFloat64s(size int) []float64 {
	f := make([]float64, size)
	for i := 0; i < size; i++ {
		f[i] = scanFloat64()
	}
	return f
}

func scanText() string {
	scanner.Scan()
	return scanner.Text()
}

func scanTexts(size int) []string {
	s := make([]string, size)
	for i := 0; i < size; i++ {
		s[i] = scanText()
	}
	return s
}

func abs(n int) int {
	return int(math.Abs(float64(n)))
}

func pow(x, y int) int {
	return int(math.Pow(float64(x), float64(y)))
}

func min(n []int) (min, idx int) {
	min = math.MaxInt64
	for i := 0; i < len(n); i++ {
		if n[i] < min {
			min = n[i]
			idx = i
		}
	}
	return
}

func max(n []int) (max, idx int) {
	max = math.MinInt64
	for i := 0; i < len(n); i++ {
		if n[i] > max {
			max = n[i]
			idx = i
		}
	}
	return
}


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

using namespace std;

int main()
{
	int n, x;
	cin >> n >> x;
	
	vector<int> m(n);
	for(int i = 0; i < n; i++)
	{
		cin >> m[i];
	}
	
	int ans = n;
	int sum = 0;
	for(int i = 0; i < n; i++)
	{
		sum += m[i];
	}
	
	ans += (x - sum) / *min_element(m.begin(), m.end());
	cout << ans << endl;
}

Measured memory_bytes: 256
from datetime import datetime
while 1:
    try:y,m,d=map(int,input().split())
    except:break
    dt = (datetime(y,m,d)-datetime(1868,9,8)).days
    if dt<0:print('pre-meiji')
    elif dt<16030:print('meiji',y-1867,m,d)
    elif dt<21291:print('taisho',y-1911,m,d)
    elif dt<43951:print('showa',y-1925,m,d)
    else:print('heisei',y-1988,m,d)

Measured memory_bytes: 7964
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <sstream>
#include <vector>

using namespace std;

typedef long long ll;
/****************************************/
ll gg[55][55];
void init()
{
    gg[0][0]=1;
    gg[1][0]=1;
    gg[1][1]=1;
    for(int i=2;i<51;i++){
        for(int j=1;j<i;j++){
            gg[i][j]=gg[i-1][j]+gg[i-1][j-1];
        }
        gg[i][0]=gg[i][i]=1;
    }
}
int main()
{
    init();
    int n,p,x;
    scanf("%d%d",&n,&p);
    int ji=0;ll ou=1;
    for(int i=0;i<n;i++){
        scanf("%d",&x);
        if(x%2)ji++;
        else ou*=2;
    }
    if(p){
        ll ans=0,he;
        for(int i=1;i<=ji;i+=2)
            ans+=gg[ji][i];
        //for(int i=0;i<=ou;i++)
           // he+=gg[ou][i];
        //printf("%d   %lld\n",ji,he);
        printf("%lld\n",ans*ou);
    }
    else {
        ll ans=0,he=0;
        for(int i=0;i<=ji;i+=2)
            ans+=gg[ji][i];
        //printf("%lld   ***\n",gg[3][2]);
        //for(int i=0;i<=ou;i++)
           // he+=gg[ou][i];
        printf("%lld\n",ans*ou);
    }
}


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

int main() {
  int n, num_query; cin >> n >> num_query;
  queue<int> que[num_query];
  
  for (int loop = 0; loop < num_query; loop++) {
    int command, a, b; scanf("%d %d", &command, &a);
    
    switch (command) {
      case 0:
        scanf("%d", &b);
        que[a].push(b);
        break;
        
      case 1:
        if (!que[a].empty()) printf("%d\n", que[a].front());
        break;
        
      case 2:
        if (!que[a].empty()) que[a].pop();
        break;
    }
  }
}


Measured memory_bytes: 138104
import sys


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


w, h, x, y, r = LI()

if x-r >= 0 and x + r <= w and y-r>=0 and y+r <=h:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 5604
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll h,w;
char a[200][200];

int main(){
	cin >> h >> w;
	REP(i,h) {
		cin >> a[i];
	}

	REP(i,w + 2) {
		cout << '#';
	}
	cout << endl;
	REP(i,h) {
		cout << '#' << a[i] << '#' << endl;
	}
	REP(i,w + 2) {
		cout << '#';
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
def resolve():
    N, D = [int(i) for i in input().split()]
    XXYY = [list(map(int, input().split())) for _ in range(N)]
    cnt = 0
    for x, y in XXYY:
        if x**2 + y**2 <= D**2:
            cnt += 1
    print(cnt)


resolve()


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

int main() {
  int n, a, b;
  
  cin >> n;
  cin >> a;
  cin >> b;
  
  if ( n * a < b ) {
    cout << n * a << endl;
  }else if ( n * a >= b){
        cout << b << endl;
  	} 
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#define rep(i,l,n) for(lint i=l;i<n;i++)
#define rer(i,l,n) for(lint i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main(){
	int n,m,f=-1;
	cin>>n;
	vector<string> u(n);
	string t;
	rep(i,0,n) cin>>u[i];
	cin>>m;
	sort(all(u));
	rep(i,0,m){
		cin>>t;
		if(binary_search(all(u),t)){
			cout<<(f==-1?"Opened by ":"Closed by ");
			cout<<t<<endl;
			f*=-1;
		}else{
			cout<<"Unknown "<<t<<endl;
		}
	}
}

Measured memory_bytes: 1224
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
constexpr ll INF = 1e18;

int main(void) {
    ll D;
    cin >> D;
    vector<ll> c(26);
    vector<vector<ll>> s(D, vector<ll>(26));
    for (int i = 0; i < 26; i++) {
        cin >> c[i];
    }
    for (int i = 0; i < D; i++) {
        for (int j = 0; j < 26; j++) {
            cin >> s[i][j];
        }
    }

    vector<ll> t(D);
    for (int i = 0; i < D; i++) {
        cin >> t[i];
        t[i]--;
    }

    ll v = 0;
    // vector<vector<ll>> last(D, vector<ll>(26));
    vector<ll> last(26);
    for (int day = 0; day < D; day++) {
        v += s[day][t[day]];
        last[t[day]] = day+1;
        for (int i = 0; i < 26; i++) {
            v -= c[i] * (day+1 - last[i]);
        }
        cout << v << endl;
    }

    return 0;
}



Measured memory_bytes: 3684
n,t = map(int,input().split())

ct = [[int(i) for i in input().split()] for _ in range(n)]

x=[]
for i in range(n):
  if ct[i][1] <= t:
    x.append(ct[i][0])
    
    
x.sort()

if len(x) != 0:
  print(x[0])
else:
  print("TLE")



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

long long mod = 1000000007;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> broken(1000000);
    vector<int> dp(n + 2);
	for (int i = 0; i < m; ++i) {
		int a;
		cin >> a;
		broken[a] = 1;
	}
	dp[0] = 1;
	for (int i = 0; i < n; i++) {
		if (broken[i + 1] == 0) {
			dp[i + 1] = dp[i + 1] + dp[i];
			dp[i + 1] = dp[i + 1] % mod;
		}
		if (broken[i + 2] == 0) {
			dp[i + 2] = dp[i + 2] + dp[i];
			dp[i + 2] = dp[i + 2] % mod;
		}
	}
	cout << dp[n] << endl;
}

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

using namespace std;

int main(){
	long long int n, d, ans = 0;
	cin >> n >> d;
	for (int i = 0; i < n; i++){
		long long int a, b;
		cin >> a >> b;
		if (a*a + b * b <= d * d) ans += 1;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3640
#include <stdio.h>
int main(void)
{
  int x,y,w,h,n;
  int limx,limy;
  int cx,cy;
  int i,j;
  int data;

  scanf("%d",&data);
  for(i=data;i>0;i--){
    
    int f=0;

    scanf("%d %d %d %d",&x,&y,&w,&h);
    scanf("%d",&n);
    limx=x+w;
    limy=y+h;

    for(j=0;j<n;j++){
      scanf("%d %d",&cx,&cy);
      if(x<=cx && cx<=limx && y<=cy && cy<=limy)
	f++;
    }

    printf("%d\n",f);
  }

  return 0;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acos(-1);

#define rep(i,n) for(int i=0; i<(n); ++i)
#define all(n) n.begin(),n.end()

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

#define DEBUG

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int n; cin >> n;
	vi b(n-1);
	rep(i, n-1) cin >> b[i];


	ll ans = 0;
	rep(i, n-2)
	{
		ans += min(b[i], b[i+1]);
	}
	ans += b.front();
	ans += b.back();

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,s,n) for(int i = s; i < n; i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using Graph = vector<vector<int>>;
const int INF = 1000000007;
int main(){
  ll x,k,d;
  cin >> x >> k >> d;
  x = abs(x);
  ll s = min(k,x / d);
  k -= s;
  x -= s * d;
  if(k % 2 == 0)cout << x << endl;
  else cout << d - x << endl;
  return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>

int isPrime(int n){
  int i;
  if(n<=1) return 0;
  if(!(n%2)) return (n==2)?1:0;
  for(i=3;i*i<=n;i+=2) if(!(n%i)) return 0;
  return 1;
}

int main(void){
  int n,i;
  int num[1000000];
  num[0]=0;
  for(i=1;i<1000000;i++) num[i]=num[i-1]+isPrime(i);
  while(scanf("%d",&n)!=EOF) printf("%d\n",num[n]);
  return 0;
}

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

int main(){
  int a;
  cin >> a;
  int s1 = (a - a % 100) / 100;
  int s3 = a % 10;
  int s2 = (a % 100 - s3) / 10;
  cout << s1 + s2 + s3 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	
	int a,b;
	
	scanf("%d %d",&a,&b);
	
	if(a<b){
		printf("a < b\n");
	}
	if(a>b){
		printf("a > b\n");
	}
	if(a==b){
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=0,b=0, c,k=0, i, j,l=1e9+7;
  string s, r, y;
  cin>>n>>a>>m;
  vector<ll>v,v1;
  ll ar[n],br[a];
  rep(i,0,n)  cin>>ar[i];
  rep(i,0,a) cin>>br[i];
  ll sum=0;
  i=0;
  while(sum<=m)
  {
    v. pb(sum);
    if(i==n) break;
    sum+=ar[i++];
  }
  sum=0;
  i=0;
  while(sum<=m)
  {
    v1. pb(sum);
    if(i==a) break;
    sum+=br[i++];
  }
  ll ans=0,booa=0,boob=v1.size()-1;
  while(1)
  {
    ll hit=booa+boob;
    if(hit>ans) ans=hit;
    booa++;
    if(booa==v. size()) break;
    while(v[booa]+v1[boob]>m) boob--;
  }
  cout<<ans<<endl;
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
   //cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
} 

Measured memory_bytes: 11064
#include <iostream>
#include <bits/stdc++.h>
const int Size = 200005;
long long Arr1[Size], Arr2[Size];
using namespace std;
int main()
{
    string S, T;
    cin >> S >>T;
    int c = 0;
    for (int i=0; i < S.length(); i++){
        if (S[i] != T[i]) c++;
    }
    cout <<c;
}


Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.precision(0);
#define forn(i,n) for(int i=0;i<n;i++)
#define for1(i,n) for(int i=1;i<n;i++)
const int mod=998244353;
typedef long long ll;
bool cmp(int a,int b){
	return a>b;
}
ll  a[105];
int main(){
	ll sum=0,sum2=0;
	ios::sync_with_stdio(false);
	/*int t;
	cin>>t;
	for(int i=0;i<t;i++){
		cin>>a[i];
		sum+=a[i];
	}
	sort(a,a+t,cmp);
	for(int i=0;i<t-1;i++){
		for(int j=i+1;j<t;j++){
			sum2+=a[i]*a[j]*(pow(2,j-i-1));
		}
	} 
	cout<<sum2<<endl;*/
	int d;
	cin>>d;
	if(d==25) cout<<"Christmas";
	else if(d==24) cout<<"Christmas Eve";
	else if(d==23) cout<<"Christmas Eve Eve";
	else if(d==22) cout<<"Christmas Eve Eve Eve";
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int N,ans = 0;
multiset<int> A;

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

	cin >> N;

	REP(i,N){
      	int x;
		cin >> x;
      	A.insert(x);
	}

	while(A.size() > 1){
		int x = *prev(A.end());
		A.erase(prev(A.end()));
		int d = 1;
		while(d <= x){
			d = d << 1;
		}
		if(A.find(d - x) != A.end()){
			ans++;
			A.erase(A.find(d - x));
		}
	}

	cout << ans << endl;

}


Measured memory_bytes: 9600
#include<stdio.h>
int main(){
  int N,X,m;
  int i;
  int S=0,R,A;
  scanf("%d%d",&N,&X);
  int W[101];
  for(i=0;i<N;i++){
    scanf("%d",&m);
    W[i]=m;
    S=S+m;
  }
  if(S!=X){
  int e,v;
        e=W[0];
  for(v=0;v<N-1;v++){
    if(W[v+1]<=e){
    e=W[v+1];
    }
  }
  R=X-S;
  A=R/e;
  printf("%d\n", A+N); 
  }else{
  printf("%d\n", N); 
  }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int X, Y;
  cin >> X >> Y;
  if(X == 1 && Y == 1) cout << 1000000 << endl;
  else if(X + Y == 3) cout << 500000 << endl;
  else if(X + Y == 4) cout << 400000 << endl;
  else if(X + Y == 5) cout << 300000 << endl;
  else if(X + Y == 6) cout << 200000 << endl;
  else if((X == 1 && Y > 3) || (Y == 1 && X > 3)) cout << 300000 << endl;
  else if((X == 2 && Y > 3) || (X > 3 && Y == 2)) cout << 200000 << endl;
  else if((X == 3 && Y > 3) || (X > 3 && Y == 3)) cout << 100000 << endl;
  else cout << 0 << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        string[] input = ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int m = int.Parse(input[1]);
//        string temp = ReadLine();
//        int a = int.Parse(ReadLine());
        if(n+m<10){
        WriteLine(n+m);
        }else{
            WriteLine("error");
        }
        
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

const string YES = "Yes";
const string NO = "No";

void solve(std::string S)
{
    for (int i = 0; i < S.size(); i++)
    {
        if (i % 2 == 0)
        {
            if (S[i] == 'R' || S[i] == 'U' || S[i] == 'D')
            {
            }
            else
            {
                cout << NO << endl;
                return;
            }
        }
        else
        {
            if (S[i] == 'L' || S[i] == 'U' || S[i] == 'D')
            {
            }
            else
            {
                cout << NO << endl;
                return;
            }
        }
    }
    cout << YES << endl;
}

int main()
{
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
hpi = input()
count = 1
k = list(map(int, input().split(" ")))
for c in range(int(hpi) - 1):
  jo = "yes"
  n = k[:c + 2]
  for co in range(len(n) - 1):
    if n[co] > k[c + 1]:
      jo = "no"
    else:
      pass
  if jo == "yes":
    count += 1
print(count)


Measured memory_bytes: 3060
N = int(input())
answer = [0]*N
M = int(N**(1/2))
for x in range(1,M):
    for y in range(1,M):
        for z in range(1,M):
            result = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if result<=N:
                answer[result-1] += 1
for i in range(N):
    print(answer[i])

Measured memory_bytes: 69712
from itertools import product

MOD = 10**9 + 7
N = int(input())
assert 3 <= N <= 100

char_to_idx = {"A": 0, "C": 1, "G": 2, "T": 3}
# chars = ("A", "C", "G", "T")

# dp[i][i1][i2][i3] = #valid strings of length i + 1 when s[i-3:] = c1c2c3
dp = [[[[0] * 4 for _ in range(4)] for _ in range(4)] for _ in range(N)]

# init
invalid_seqs = set(["AGC", "ACG", "GAC"])
for chars in product(char_to_idx.keys(), repeat=3):
    string = "".join(chars)
    if string not in invalid_seqs:
        i1, i2, i3 = [char_to_idx[char] for char in string]
        dp[2][i1][i2][i3] = 1

invalied_indices = set()
for chars in product(char_to_idx.keys(), repeat=4):
    string = "".join(chars)
    if string[:3] == "AGC" or string[1:] == "AGC":
        invalied_indices.add(tuple(char_to_idx[char] for char in string))
        continue
    for i in range(3):
        new_string = list(string)
        new_string[i], new_string[i + 1] = string[i + 1], string[i]
        new_string = "".join(new_string)
        if new_string[:3] == "AGC" or new_string[1:] == "AGC":
            invalied_indices.add(tuple(char_to_idx[char] for char in string))
            break
# print(len(invalied_indices))

for i in range(3, N):
    for i0 in range(4):
        for i1 in range(4):
            for i2 in range(4):
                for i3 in range(4):
                    if (i0, i1, i2, i3) not in invalied_indices:
                        dp[i][i1][i2][i3] += dp[i - 1][i0][i1][i2]
                        dp[i][i1][i2][i3] %= MOD

num_strings = 0
for i in range(4):
    for j in range(4):
        for k in range(4):
            num_strings += dp[-1][i][j][k]
            num_strings %= MOD
print(num_strings)



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

int main(){
    string s;
    cin >> s;
    int a = (int)(s.length());
    int cnt = 0;
    for(int i = 0; i < a/2; i++){
        if(s[i] != s[a -1 - i])cnt++;
    }
    cout << cnt;
    return 0;
}

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

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

int main(){
  int A, B, K;
  cin >> A >> B >> K;
  
  int g = gcd(max(A,B),min(A,B));
  int counter = 0;
  int ans;
  
  for(int i = g; i > 0; i--){
    if(g % i == 0){
      counter++;
      if(counter == K){
        ans = i;
        break;
      }
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
    string str;
    cin >> str;
    int n;
    n = str.size();
    char ed;
    ed = str[n-1];
    if( ed=='s'){
        cout << str + "es" << endl;
    }else{
        cout << str + "s" << endl;
    }
}



Measured memory_bytes: 3604
#include<cstdio>
using namespace std;
int n,a,b,k;
int solve(int a,int b){if(a%b==0)return a/b;int tp=(a%b)/(a/b+1)-1;if(tp<0)tp=0;a-=(a/b+1)*tp;return solve(a/b*(b-1)+a%b-1,b);}
int main(){scanf("%d",&n);while(n--)scanf("%d%d",&a,&b),k^=solve(a,b);printf("%s\n",k?"Takahashi":"Aoki");}

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

using namespace std;

int a,b;

int ans;

int main(){
    scanf("%d %d",&a,&b);

    for(int n=1;n<999;n++){
        long long int suma = n*(n+1)/2;
        long long int sumb = (n+1)*(n+2)/2;
        if(suma-a == sumb-b){
            ans = suma - a;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import math
class point:
    def __init__(self):
        self.x = 0.0
        self.y = 0.0

def koch(n,a,b):
    if n == 0 :
        return

    rad = 1.0471975511965976 
    s = point()
    t = point()
    u = point()
    tmp = point()

    s.x = (2 * a.x + b.x)/3.0
    s.y = (2 * a.y + b.y)/3.0

    t.x = (2 * b.x + a.x)/3.0
    t.y = (2 * b.y + a.y)/3.0

    tmp.x,tmp.y = s.x-t.x ,s.y-t.y
    u.x = (tmp.x * math.cos(rad) + tmp.y * math.sin(rad)) + t.x
    u.y = (-tmp.x * math.sin(rad) + tmp.y * math.cos(rad)) + t.y


    koch(n-1,a,s)
    print(s.x,s.y)

    koch(n-1,s,u)
    print(u.x,u.y)

    koch(n-1,u,t)
    print(t.x,t.y)

    koch(n-1,t,b)

    return

a = point()
b = point()
a.x,a.y = 0.0,0.0
b.x,b.y = 100.0,0.0
n = int(input())
print(a.x,a.y)
koch(n,a,b)
print(b.x,b.y)



    

Measured memory_bytes: 7992
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));


		char[] input = br.readLine().toCharArray();

		Arrays.sort(input);

		if(input[0] == input[1] && input[1] != input[2] && input[2] == input[3]){
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 24916
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

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

	auto over = 0;
	set<int> s;
	for (auto i = 0; i < N; ++i)
	{
		int a;
		cin >> a;
		auto temp = a / 400;
		if (temp >= 8)
		{
			++over;
		}
		else
		{
			s.insert(temp);
		}
	}

	cout << max(1, (int)s.size()) << " " << s.size() + over << endl;

	return 0;
}

Measured memory_bytes: 256
//O(N^2)解法
//2倍遅いけど, こっちの方がバグりにくい。
#include <iostream>
#include <queue>
#include <algorithm>
#include <vector>
#include <functional>
#include <tuple>
using namespace std;
typedef tuple<int, int, int> T;
typedef pair<int, int> P;

const int DEPTH = 18;
const int INF = 11451419;

class SegTree {
public:
	int data[1 << (DEPTH + 1)];
	SegTree() { for (int i = 0; i < (1 << (DEPTH + 1)); i++) data[i] = INF; }
	void update(int pos, int x) {
		pos += (1 << DEPTH) - 1;
		data[pos] = x;
		while (pos > 0) {
			pos = (pos - 1) / 2;
			data[pos] = min(data[pos * 2 + 1], data[pos * 2 + 2]);
		}
	}
	int getMin(int l, int r, int a = 0, int b = (1 << DEPTH), int id = 0) {
		if (a >= r || b <= l) return INF;
		if (l <= a && b <= r) return data[id];
		int u = getMin(l, r, a, a + (b - a) / 2, id * 2 + 1);
		int v = getMin(l, r, a + (b - a) / 2, b, id * 2 + 2);
		return min(u, v);
	}
};

int n;
int p[200000];
SegTree a[2];
int toPos[200001];
vector<P> ans;

//p[l]～p[r-1]を一つの数列(a[0], a[1], …)とみなすとき, 偶数番目の最小値を返す
int getEvenMin(int l, int r) {
	if (l >= r) return INF;
	return a[l % 2].getMin(l, r);
}

//p[l]～p[r-1]を一つの数列(a[0], a[1], …)とみなすとき, 奇数番目の最小値を返す
int getOddMin(int l, int r) {
	if (l + 1 >= r) return INF;
	return a[(l + 1) % 2].getMin(l, r);
}

int main() {
	int i;
	
	cin >> n;
	for (i = 0; i < n; i++) cin >> p[i];
	for (i = 0; i < n; i++) toPos[p[i]] = i;
	for (i = 0; i < n; i++) a[0].update(i, ((i % 2 == 0) ? p[i] : INF));
	for (i = 0; i < n; i++) a[1].update(i, ((i % 2 == 1) ? p[i] : INF));
	
	priority_queue<T, vector<T>, greater<T> > que;
	que.push(T(getEvenMin(0, n), 0, n));
	
	while (!que.empty()) {
		T t = que.top(); que.pop();
		if (get<1>(t) >= get<2>(t)) continue;
		
		int x = get<0>(t);
		int y = getOddMin(toPos[x], get<2>(t));
		ans.push_back(P(x, y));
		
		que.push(T(getEvenMin(get<1>(t), toPos[x]), get<1>(t), toPos[x]));
		que.push(T(getEvenMin(toPos[x] + 1, toPos[y]), toPos[x] + 1, toPos[y]));
		que.push(T(getEvenMin(toPos[y] + 1, get<2>(t)), toPos[y] + 1, get<2>(t)));
	}
	
	for (i = 0; i < ans.size(); i++) {
		cout << ans[i].first << " " << ans[i].second;
		if (i + 1 < ans.size()) cout << " ";
		else cout << endl;
	}
	return 0;
}

Measured memory_bytes: 11952
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

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

    int n;cin>>n;
    vector<pair<ll,ll>> v(n);
    ll sum=0;
    ll mini=LINF;
    rep(i,n){
        cin>>v[i].first>>v[i].second;
        sum+=v[i].first;
        if(v[i].second<v[i].first) chmin(mini,v[i].second);
    }
    if(mini==LINF){
        cout<<0<<endl;
    }else{
        cout<<sum-mini<<endl;
    }


    return 0;
}


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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repr(i,x,n) for(int i=(x);i<(n);i++)
#define sort(a) sort(a.begin(),a.end())
#define INT_MAX 2147483647

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

int main(){
    
    int n;
    cin >> n;
    vi a(n+1);
    a[0] = 0;
    repr(i,1,n+1)cin >> a[i];

    int ans_n = 0,temp_n;
    double temp_r;
    vi ans(n+1,0);

    for(int i=n;i>0;i--){
        temp_n = 0;
        temp_r = (double)n/i;
        for(int j=2;j<=temp_r;j++){
            if(ans[i*j] == 1)temp_n++;
        }
        if(temp_n%2 != a[i]){
            ans[i]=1;
            ans_n++;
        }
    }

    cout << ans_n << endl;
    repr(i,1,n+1){
        if(ans[i] == 1){
            cout << i << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 2432
#include <iostream>
using namespace std;
#define ll long long 
const ll mod=1000000007;
ll f(ll n,ll a)
{
    ll res=1;
 while(n>0)
    {
        if(n&1)
        {
            res=((res%mod)*(a%mod))%mod;
            n--;
        }
        else
        {
            a=((a%mod)*(a%mod))%mod;
            n=n/2;
        }
    }
    return res;
}
int main()
 {
    ll n;
    cin>>n;
    ll res1=f(n,10);
    ll res2=f(n,9);
    ll res3=f(n,8);
    ll res=((res1%mod)-(res2%mod)-(res2%mod)+(res3%mod))%mod;
    cout<<(res+mod)%mod;
    
}


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

int main() {
	int a, b; cin >> a >> b; a--; b--;
	cout << "100 100" << endl;

	for (int i = 0; i < 50; i++) {
		for (int j = 0; j < 100; j++) {
			if (a > 0 && i % 2 == 0 && j % 2 == 1) { cout << '.'; a--; }
			else cout << '#';
		}
		cout << endl;
	}

	for (int i = 0; i < 50; i++) {
		for (int j = 0; j < 100; j++) {
			if (b > 0 && i % 2 == 1 && j % 2 == 1) { cout << '#'; b--; }
			else cout << '.';
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int x, y;
	x = y = 1;

	while (x!=0||y!=0)
	{
		scanf("%d %d", &x, &y);

		if (x != 0 || y !=0)
		{
			if (x <= y)
			{
				printf("%d %d\n", x, y);
			}

			if(y<x)
			{
				printf("%d %d\n", y, x);
			}
		}

		else
		{

		}
	}

	return 0;
}


Measured memory_bytes: 2036
#include<bits/stdc++.h>
#include<vector>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define CEVCOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>
ll gcd(ll a, ll b){
    if(b == 0)	return a;
    return gcd(b , a % b);
}

int main(void){

    int N;		cin >> N;
    vector<ll> T(N);	VECCIN(T);
  	ll lcn = T[0], ans = T[0];
    for(int i = 1 ; i < N ; i++){
      lcn = gcd(ans , T[i]);
  	  ans *= T[i] / lcn;
      lcn = ans;
    }
  
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#define INF -9999999

using namespace std;

int main ()
{
	int d, n, a[205], b[205], c[205], t[205], dp[205][205], ans=0;
	memset(dp, 0, sizeof(dp));
	cin>>d>>n;
	for (int i=1; i<=d; i++) cin>>t[i];
	for (int i=1; i<=n; i++) cin>>a[i]>>b[i]>>c[i];
    for (int i=1; i<=n; i++) if (t[1]<a[i] || t[1]>b[i]) dp[1][i]=INF;
    for (int i=2; i<=d; i++)
    {
        for (int j=1; j<=n; j++)
        {
            if (t[i]<a[j] || t[i]>b[j]) dp[i][j]=INF;
            else
            {
                for (int k=1; k<=n; k++)
                {
                    dp[i][j]=max(dp[i][j], dp[i-1][k]+abs(c[j]-c[k]));
                }
            }
        }
    }
    for (int i=1; i<=n; i++) ans=max(ans, dp[d][i]);
    cout<<ans<<'\n';
}



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

using namespace std;

#define debug(x) '[' << #x << " is: " << x << "] "
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(10);
	cout << fixed;
	
	ll n,b,r;
	cin>>n>>b>>r;
	ll seg = b+r;
	ll times = n/seg;
	ll ans = times * b + min(b , n%seg);
	cout << ans << '\n';
}


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

int main() {
  int N;
  long K;
  std::cin >> N >> K;
  /*std::vector<int> a(N), b(N);
  for (long i=0; i<N; i++) {
    std::cin >> a.at(i) >> b.at(i);
  }*/
  map<int,long> m;
  for (int i=0; i<N; i++) {
    int ai, ki;
    cin >> ai >> ki;
    m[ai] += ki;
  }
  
  /*for (auto it=m.begin(); it!=m.end(); it++) {
    cerr << it->first << ' ' << it->second << endl;
  }*/
  
  long count = 0;  
  for (auto it=m.begin(); it!=m.end(); it++) {
    count += it->second;
    //cerr << it->first << endl;
    if (count>=K) {
      cout << it->first << endl;
      break;
    }
  }
  return 0;
}

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

int main(){
    long long n;
    cin >> n;
    long long a[n], b[n], c[n];
    for(int i=0;i<n;i++)cin >> a[i];
    for(int i=0;i<n;i++)cin >> b[i];
    for(int i=0;i<n;i++)cin >> c[i];

    sort(a, a+n);
    sort(b, b+n);
    sort(c, c+n);

    unsigned long long ans = 0;
    long long upPart = 0;
    long long downPart = 0;
    for(int i=0;i<n;i++){
        while(a[upPart]<b[i] && upPart<n)upPart++;
        while(c[downPart]<=b[i] && downPart<n)downPart++;
        ans += upPart * (n-downPart);
    }
    cout << ans << endl;
}


Measured memory_bytes: 2688
D = int(input())
C = list(map(int,input().split()))
S = [list(map(int,input().split())) for _ in range(D)]

# B
T = [int(input()) for _ in range(D)]

# 初期化
ans = 0 # 満足度
last = [-1]*26

# 満足度を計算
for d in range(D):
    # 開催するコンテストID
    contest_id = T[d]-1
    # 満足度をプラス
    ans += S[d][contest_id]
    # 最終開催日を更新
    last[contest_id] = d
    # 開催されなかったコンテストの処理
    for i in range(26):
        ans -= C[i]*(d - last[i])
    # 出力
    print(ans)


Measured memory_bytes: 9272
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll=long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
struct Edge {
    int to, cost;
    Edge(int to,int cost): to(to),cost(cost){}
};
using AdjList=vector<vector<Edge>>;
using Matrix=vector<vector<ll>>;
Matrix d;
void warshell_floyd(int n) {
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            for (int k = 0; k < n; ++k) {
                d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
            }
        }
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m,r;
    cin >> n>>m >>r;
    vector<int> R(r);
    d = Matrix(n, vector<ll>(n, LINF));
    for (int i = 0; i < r; ++i) {
        cin >> R[i];
        R[i]--;
    }
    int a, b;
    ll c;
    for (int i = 0; i < m; ++i) {
        cin >> a >> b >> c;
        --a;
        --b;
        d[a][b] = c;
        d[b][a] = c;
    }
    SORT(R);
    for (int i = 0; i < n; ++i) {
        d[i][i] = 0;
    }
    warshell_floyd(n);
    ll ans = INF;
    do {
        ll temp=0;
        for (int i = 1; i < r; ++i) {
            temp += d[R[i-1]][R[i]];
        }
        ans = min(ans, temp);
    } while (next_permutation(R.begin(), R.end()));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _20191024
{
    class Program
    {
        // int[] i = Console.ReadLine().Split().Select(int.Parse).ToArray(); 直接数値を配列へ
        // Math.Abs(); 絶対値を出せる
        static void Main(string[] args)
        {
            int[] i = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int n = i[0];
            int a = i[1];
            int b = i[2];

            if(n * a <= b)
            {
                Console.WriteLine(n * a);
            }
            else
            {
                Console.WriteLine(b);
            }

        }
    }
}


Measured memory_bytes: 11348
ab = input().split(' ')
#print(ab)
if int(ab[0])  % 3 == 0 or int(ab[1]) % 3 ==0   or (int(ab[1])+ int(ab[0])) % 3 == 0:
    ans  = 'Possible'

else:
    ans ='Impossible'
    
if (int(ab[0]) + int(ab[1])) <= 3:
    ans= 'Impossible'
print (ans) 

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

int main() {
    int N, ans = 0;
    cin >> N;
    for(int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        while(a % 2 == 0) {
            a /= 2;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256