akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define sp ' '
#define endl '\n'
#define st first
#define nd second
#define sz(x) ((long long int)x.size())
#define pb push_back
#define pob pop_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define forn(YY, yy) for(long long int yy = 0; yy < YY; ++yy)
#define prn(XX) cout << XX << '\n'
#define prs(XX) cout << XX << ' '
#define TEST cout << "TEST\n";

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;

const long long int MOD = 1e9 + 7;
const long long int INF = 2e9 + 13;
const long long int mINF = -2e9 - 13;
const double PI = acos(-1.0);
const double EPS = 1e-9;

ll mx(ll x, ll y){ return (x>y?x:y); }
ll mn(ll x, ll y){ return (x<y?x:y); }

void max_self(ll &x, ll y){ x = mx(x, y); }
void min_self(ll &x, ll y){ x = mn(x, y); }
void add(ll &x, ll y){ x%=MOD; x += (y%MOD); x %= MOD; }
void mul(ll &x, ll y){ x%=MOD; x *= (y%MOD); x %= MOD; }

ll us(ll n, ll x, ll m){
    if(x == 0) return 1;
    ll a = us(n, x>>1, m);
    return (((a*a)%m)*(x&1?n:1))%m;
}

ll grid[3][3];
bool isbingo(void){
    if(grid[0][0] == -1 and grid[1][1] == -1 and grid[2][2] == -1) return true;
    if(grid[0][2] == -1 and grid[1][1] == -1 and grid[2][0] == -1) return true;
    
    if(grid[0][0] == -1 and grid[0][1] == -1 and grid[0][2] == -1) return true;
    if(grid[1][0] == -1 and grid[1][1] == -1 and grid[1][2] == -1) return true;
    if(grid[2][0] == -1 and grid[2][1] == -1 and grid[2][2] == -1) return true;

    if(grid[0][0] == -1 and grid[1][0] == -1 and grid[2][0] == -1) return true;
    if(grid[0][1] == -1 and grid[1][1] == -1 and grid[2][1] == -1) return true;
    if(grid[0][2] == -1 and grid[1][2] == -1 and grid[2][2] == -1) return true;
    return false;
}

void mark(ll n){
    for(ll i = 0; i < 3; ++i)
        for(ll j = 0; j < 3; ++j)
            if(grid[i][j] == n) grid[i][j] = -1;
    return;
}

int main(int argc, char **argv){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    //freopen(".gir", "r", stdin);
    //freopen(".cik", "w", stdout);
    
    forn(3, i) forn(3, j) cin >> grid[i][j];
    ll n; cin >> n;
    forn(n, i){ ll x; cin >> x; mark(x); }
    
    cout << (isbingo() ? "Yes\n" : "No\n");

    return 0;
}

//cikisir



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

using namespace std;

int main()
{
    int N;
    cin >> N;
    string S;
    cin >> S;
    if(N % 2) cout << "No";
    else{
        if(S.substr(0, N/2) == S.substr(N/2)) cout << "Yes";
        else cout << "No";
    }
    cout << endl;
}


Measured memory_bytes: 256
n = int(input())
p = list(map(int,input().split()))
count = 0
for i in range(1,n-1):
    M = max(p[i-1],p[i],p[i+1])
    m = min(p[i-1],p[i],p[i+1])
    if p[i] != M and p[i] != m:
        count += 1
print(count)

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

#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

typedef long long ll;

const char nl = '\n' ;
const ll MOD = 1e9 + 7;


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

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

   return 0;
}


Measured memory_bytes: 3612
H, W = map(int, input().split())
map = [list(input()) for _ in range(H)]
from collections import deque

que = deque()
seen = [[-1]*W for _ in range(H)]
max = 0



for i in range(H):
    for j in range(W):
        if map[i][j] == "#":
            que.append([i,j])
            seen[i][j] = 0

while que:
    #print(que)
    y, x = que.popleft()
    for dy, dx in ([0,1],[0,-1],[1,0],[-1,0]):
        ny = y + dy
        nx = x + dx
        if 0<=ny<H and 0<=nx<W and seen[ny][nx]==-1:
            seen[ny][nx] = seen[y][x] + 1
            que.append([ny,nx])
            if max < seen[ny][nx]:
                max = seen[ny][nx]

print(max)


Measured memory_bytes: 176476
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define MOD 1000000007
#define EPS 1e-10
#define MAX_N 100000
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n, m;
P x[300000];
int bit[300001];
int ans[100001];

int sum(int i){
	int s = 0;
	while(i <= m){
		s += bit[i];
		i += i&-i;
	}
	return s;
}

void add(int i, int y){
    if(i == 0) return;
	while(i > 0){
		bit[i] += y;
		i -= i&-i;
	}
}

int main(){
    cin >> n >> m;
    rep(i,n){
        int l, r; cin >> l >> r;
        x[i] = P(r-l+1,r);
    }
    sort(x,x+n);
    int it = 0;
    for(int i = 1; i <= m; i++){
        while(it < n && x[it].fi < i){
            add(x[it].sc,1);
            add(x[it].sc-x[it].fi,-1);
            it++;
        }
        ans[i] += n-it;
        for(int j = i; j <= m; j += i){
            ans[i] += sum(j);
        }
    }
    for(int i = 1; i <= m; i++) cout << ans[i] << endl;
}


Measured memory_bytes: 4096
#include<stdio.h>

int main(){
  int N;
  int C[22],V[22];
  scanf("%d",&N);
  int i;
  for(i=0;i<=N-1;i++)
    scanf("%d",&V[i]);
  for(i=0;i<=N-1;i++)
    scanf("%d",&C[i]);
  int SA[22];
  for(i=0;i<=N-1;i++)
    SA[i] = V[i] - C[i];
  int sum = 0;
  for(i=0;i<=N-1;i++)
    if(SA[i] > 0) sum += SA[i];
  printf("%d",sum);
}

Measured memory_bytes: 128
def stdinput():
    from sys import stdin
    return stdin.readline().strip()

def main():
    n, k = map(int, stdinput().split())
    W = list(map(int, [stdinput() for _ in range(n)]))

    l, r = max(W), 100000*10000

    # 二分探索で上限値を確認する
    while l != r:
        mid = (l + r) // 2
        if calc_tracks(W, mid) <= k:
            r = mid
        else:
            l = mid + 1

    print(l)
        
def calc_tracks(W, P):
    ret = 0
    current_w = 0
    for w in W:
        if current_w + w > P:
            ret += 1
            current_w = w
        else:
            current_w += w
    return ret + 1

if __name__ == '__main__':
    main()
    # import cProfile
    # cProfile.run('main()')


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

typedef long long ll;

int main(){
  ll N;
  cin >> N;
  ll rt = sqrt(N);
  ll ans = rt;
  for(ll i = rt; i <= N && i*i <= N; i++){
    if(i > ans){
      ans = i;
    }
  }
  cout << ans*ans << endl;
  
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int A1 = sc.nextInt();
		int A2 = sc.nextInt();
		int A3 = sc.nextInt();

		sc.close();

		if (A1 + A2 + A3 >= 22) {
			out.println("bust");
		} else {
			out.println("win");
		}

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


Measured memory_bytes: 24020
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
 
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
 
// C++
#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>
 
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define f(i, n) for(int i = 0; i < n; ++i)
#define pb push_back
#define eb emplace_back
#define m_p make_pair
#define T int t = 0; cin >> t; while(t--)
#define pr(a) for(int i = 0; i < (int)a.size(); ++i)cout << a[i] << " ";cout << endl;
#define b_e(a) a.begin(), a.end()
typedef long long ll;
typedef long double lld;
const ll mod = 1e15;
const ll mx = 1e3 + 1;
const ll inf = (1LL << 62LL);
const int sz = 256;
const int max_k = 20;
typedef long long ll;

void input(){
    IOS;
    ll n, k;
    cin >> n >> k;
    vector<ll>p(n), c(n);
    f(i, n)cin >> p[i], --p[i];
    f(i, n)cin >> c[i];
    ll ans = -inf;
    f(i, n){
        ll start = p[i];
        vector<ll>temp;
        temp.push_back(c[start]);
        while(i != start){
            start = p[start];
            temp.push_back(c[start]);
        }
        ll t = (int)temp.size();
        vector<ll>pre(t);
        pre[0] = temp[0];
        for(int i = 1; i < t; ++i)pre[i] += pre[i - 1] + temp[i];
        for(ll r : {0LL, 1LL, k / t, k / t - 1, k / t - 2, 2LL}){
            if(t * r > k || r < 0)continue;
            if(t * r == k){
                ans = max(ans, pre[t - 1] * r);
            }else{
                ll y = k - r * t;
                ll as = -inf;
                f(j, min(t, y))as = max(as, pre[j]);
                ans = max(ans, pre[t - 1] * r + as);
            }
        }
    }
    cout << ans << endl;
    
}

int main(){
    input();
    return 0;
} 
/*
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
*/


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

int main(){
    string s;
    cin >> s;
    char latest = s[0];
    int acc = 0;
    for (int i=1;i<s.size();i++){
        if (s[i] != latest){
            acc += 1;
        }
        latest = s[i];
    }
    cout << acc << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<cstdio> 
#include<cstring>
#include<cmath>
#include<map>
using namespace std;
long long n,i,a[20000],t;
int main() {
	scanf("%lld", &n);
	for (i = 1; i <= n; i++) scanf("%lld", &a[i]);
	sort(a + 1, a + 1 + n);
    t = 1;
	for (i = 1; i <= n; i++) {
		if (a[i] > t) {
			printf("%lld\n", t);
			return 0;
		}
		t = t + a[i];
	}
	printf("%lld\n", t);
	return 0;
}

Measured memory_bytes: 3340
import java.util.*;
public class Main {
    public static void main(String[] args) {
      Scanner scan = new Scanner(System.in);
      String name1 = scan.next();
        if(name1.equals("a")){
          System.out.println("vowel");
        }
        else if(name1.equals("i")){
          System.out.println("vowel");
        }
        else if(name1.equals("u")){
          System.out.println("vowel");
        }
        else if(name1.equals("e")){
          System.out.println("vowel");
        }
        else if(name1.equals("o")){
          System.out.println("vowel");
        }
        else {
          System.out.println("consonant");
        }
    }
}

Measured memory_bytes: 23252
#include <stdio.h>
#include<string.h>
 
int main()
{
    int n,i,T=0,H=0,f;
    char t[101],h[101];
    scanf("%d\n",&n);
    for(i=0;i<n;i++)
    {
        scanf("%s%s",t,h);
        f=strcmp(t,h);
        if(f==0){T+=1;H+=1;}
        else if(f>0)T+=3;
        else H+=3;
    }
    printf("%d %d\n",T,H);
    return 0;
}


Measured memory_bytes: 2036
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

struct union_find{
    VI par;

    void init(int n){
        par.resize(n);
        REP(i,n) par[i] = i;
    }

    int find(int x){
        if (par[x] == x) return x;
        else return par[x] = find(par[x]);
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }

    void merge(int x, int y){
        x = find(x);
        y = find(y);
        if (x == y) return;
        par[x] = y;
    }
};

bool solve(){
    ll n, m, q;
    cin >> n >> m >> q;
    VI u1, v1, u2, v2;
    REP(i,q){
        int u = in(), v = in(), c = in();
        if (c == 0){
            u1.push_back(u);
            v1.push_back(v);
        }else{
            u2.push_back(u);
            v2.push_back(v);
        }
    }
    union_find uf;
    uf.init(n);
    REP(i,u1.size()){
        uf.merge(u1[i], v1[i]);
    }
    REP(i,u2.size()){
        if (uf.same(u2[i], v2[i])){
            return false;
        }
    }
    ll c = 0;
    REP(i,n) if (uf.find(i) == i) c++;
    m -= n - c;
    if (u2.empty()){
        return m >= c - 1 && m <= c * (c - 1) / 2;
    }else{
        return m >= c && m <= c * (c - 1) / 2 && c > 2;
    }
}

int main() {
    cout << (solve() ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 1652
//let input = "7 4 2\n3";

function main(input){
  input = input.trim();
  let l1 = input.split("\n")[0];
  let l2 = input.split("\n")[1];
  let r = parseInt(l1.split(" ")[0]);
  let g = parseInt(l1.split(" ")[1]);
  let b = parseInt(l1.split(" ")[2]);
  let n = parseInt(l2);

  function hantei(){
    return(r<g && g<b);
  }
  
  function magic(){
    if(r>=g){
      g = g*2;
    }else if(g>=b){
      b = b*2
    }
  }
  
  for(i=0; i<n; i++){
    magic();
  }
  let answer = "";
  if(hantei()===true){
    answer = "Yes";
  }else{
    answer = "No";
  }
  console.log(answer);
}

//main(input);

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

Measured memory_bytes: 29504
#include<bits/stdc++.h>
#include <algorithm>
#include <cctype>
#include <iostream>
#include <string>
using namespace std;

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

const ll MOD = 1e9+7;

// Combinationの使い方
// vector<vector<ll>> v(N+1, vector<ll>(N+1, 0));
// comb(v);
void comb(vector<vector<ll>> &v){
    for(int i = 0; i < v.size(); i++){
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for(int k = 1; k < v.size(); k++){
        for(int j = 1; j < k; j++){
            v[k][j] = (v[k-1][j-1] + v[k-1][j]);
            //余りを求める問題は毎回計算ごとにやる
            // v[k][j] = (v[k-1][j-1] + v[k-1][j]) % MOD;
        }
    }
}

// Union Find
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

// 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)
//   }

// 1 << 3 : int "3" change to bit "100"
// rep(pattern, 1 << N) if (pattern & (1 << x)) cnt++

int main(){
    int a,b;
    cin >> a >> b;
    cout << (a+b+1)/2 << endl;
}

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

using namespace std;
using ll = long long;

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

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

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

  int dp[n];
  dp[0] = 0;
  for (int i = 1; i <= n; ++i) {
    int now = 1001001001;
    for (int j = 1; j <= k; ++j) {
      if (i - j < 0) break;
      now = min(now, dp[i - j] + abs(h[i] - h[i - j]));
    }
    dp[i] = now;
  }

  cout << dp[n - 1] << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
ll n,a[100010];
int main(){
//	freopen("input.txt","r",stdin);// <--Remove Before Submit
	cin >>n;
	for(ll x=0;x<n;x++){
		cin >> a[x];
	}
	sort(a,a+n);
	ll d=1,n1=0,n2=0;
	for(ll x=n-1;x>=1;x--){
		if(a[x] == a[x-1]){
			d++;
			n2 = n1;
			n1 = a[x];
			a[x] = 0;
			a[x-1]=0;
		}
		if(n1!=0&&n2!=0){
			cout << n1*n2 << endl;
			return 0;
		}
	}
	cout << 0 << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<queue>
#include<map>

using namespace std;
#define REP(i,m,n) for(long long i=m;i<n;++i)
#define INF 10000000000000000
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define all(v) v.begin(),v.end()

int main() {
	int ans;
	int a, t, b;
	cin >> a >> t >> b;
	ans = min(a*t, b);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second

using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a, b, h;
    cin >> a >> b >> h;
    cout << (a + b) * h / 2;
    
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())




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

	int n;
	cin >> n;

	int sq = sqrt(1 + 8 * n + 0.01);


	if (sq*sq == 1 + 8 * n && (1+sq)%2==0) {
		int k = (1 + sq) / 2;
		cout << "Yes" << endl;
		vector<vector<int>> ans(k);
		
		int m = 1;
		rep(i,k) {
			for (int j = i+1; j < k;j++) {
				ans[i].push_back(m);
				ans[j].push_back(m);

				m++;
			}
		}


		cout << k << endl;
		rep(i, k) {
			cout << k - 1;
			for (int a: ans[i]) {
				cout << ' ' << a;
			}
			cout << endl;
		}

	}
	else {
		cout << "No" << endl;
	}



	return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x).size()
#define S second
#define F first
#define all(x) (x).begin(), (x).end()


using namespace std;

const bool dbg_flg = 1;
#define debug(x) if (dbg_flg) cerr << #x << ' ' << x << '\n'
#define debug_pair(x) if (dbg_flg) cerr << #x << ' ' << x.F << ' ' << x.S << '\n'
 
const int inf = 1e9 + 7;
const int MAXN = 1e6 + 5;
const ll INF = 1e18;

int n, m;
vector<int> g[MAXN];
vector<int> q;
bool used[MAXN];
int dp[MAXN];

void dfs(int v, int p = 0) {
	used[v] = 1;
	
	for (auto to : g[v]) {
		if (!used[to]) {
			dfs(to, v);
		}
	}
	q.pb(v);
}

int main() {
	
	//~ freopen(".in", "r", stdin);
	//~ freopen(".out", "w", stdout);
	
	ios_base::sync_with_stdio(NULL);
	cin.tie(NULL);
	cout.tie(NULL);
	
	cin >> n >> m;
	
	for (int i = 1; i <= m; i++) {
		int a, b;
		cin >> a >> b;
		g[a].pb(b);
	}

	for (int i = 1; i <= n; i++) {
		if (!used[i]) {
			dfs(i);
		}
	}
	
	reverse(all(q));
	
	for (int x : q) {
		for (int y : g[x]) {
				dp[y] = max(dp[y], dp[x] + 1);
		}
	}
	
	int res = 0;
	for (int i = 1; i <= n; i++) {
		res = max(res, dp[i]);
	}
	
	cout << res;
	return 0;
}


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

int main(){
    int A, B;
    cin >> A >> B;
    if (A == 1){
        A = A + 13;
    }
    if (B == 1){
        B = B + 13;
    }
    if (A > B){
        cout << "Alice" << endl;
    }
    else if (B > A){
        cout << "Bob" << endl;
    }
    else{
        cout << "Draw" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
while True:
    n, x = map(int, input().split())
    if n == 0 and x == 0:
        break
    count = 0
    for i in range(1, n - 1):
        for k in range(i + 1, n):
            if k < x - (i + k) <= n:
                count += 1
    print(count)


Measured memory_bytes: 5592
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (sb-int:defconstant-eqx OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0))
    #'equal)
  #+swank (ql:quickload '(:cl-debug-print :fiveam) :silent t))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)
#-swank (disable-debugger) ; for CS Academy

;; BEGIN_INSERTED_CONTENTS
(declaim (ftype (function * (values fixnum &optional)) read-fixnum))
(defun read-fixnum (&optional (in *standard-input*))
  (declare #.OPT
           #-swank (sb-kernel:ansi-stream in))
  (macrolet ((%read-byte ()
               `(the (unsigned-byte 8)
                     #+swank (char-code (read-char in nil #\Nul))
                     #-swank (sb-impl::ansi-stream-read-byte in nil #.(char-code #\Nul) nil))))
    (let* ((result (loop (let ((byte (%read-byte)))
                           (when (<= 48 byte)
                             (return (- byte 48)))))))
      (declare ((integer 0 #.most-positive-fixnum) result))
      (loop
        (let* ((byte (%read-byte)))
          (if (<= 48 byte)
              (setq result (+ (- byte 48) (* 10 (the (integer 0 #.(floor most-positive-fixnum 10)) result))))
              (return result)))))))

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

;; Body

(define-modify-macro minf (new-value) min)

(defun main ()
  (declare #.OPT)
  (let* ((n (read))
         (k (read))
         (hs (make-array 100000 :element-type '(unsigned-byte 31)))
         (dp (make-array 100000 :element-type '(unsigned-byte 31) :initial-element #x7fffffff)))
    (declare ((unsigned-byte 31) n k))
    (setf (aref dp 0) 0)
    (dotimes (i n)
      (setf (aref hs i) (read-fixnum)))
    (dotimes (i n)
      (let ((h (aref hs i))
            (d (aref dp i)))
        (loop for dest from (+ i 1) to (min (+ i k) (- n 1))
              do (minf (aref dp dest) (+ d (abs (- h (aref hs dest))))))))
    (println (aref dp (- n 1)))))

#-swank (main)


Measured memory_bytes: 21988
while True:
  h, w = [int(i) for i in input().split()]
  if h == 0 and w == 0:
    break
  for i in range(h):
    for j in range(w):
      if i == 0 or i == h - 1:
        print('#', end='')
      elif j == 0 or j == w - 1:
        print('#', end='')
      else:
        print('.', end='')
    print()
  print()


Measured memory_bytes: 7012
#include <algorithm>
#include <cstdio>
#include <iostream>
using namespace std;
typedef long long LL;
static const int maxn = 200000 ;
int main()
{
	LL r [ maxn ] , n ;
	cin >> n;
	for ( int i = 0 ; i < n ; i ++ )
	{
		cin >> r [ i ] ;
	}
	LL maxv = -20000000000 ;
	LL minv = r [ 0 ] ;
	for ( int i = 1 ; i < n ; i ++ )
	{
		maxv = max ( maxv , r [ i ] - minv ) ;
		minv = min ( minv , r [ i ] ) ;
	}
	cout << maxv << endl ;
	return 0 ;
}


Measured memory_bytes: 4668
n = int(input())
a = list(map(int, input().split()))

ans, num, xor, cnt = 0, 0, 0, 0
for i in range(n):
    for j in range(cnt, n):
        if num + a[j] == xor ^ a[j]:
            num += a[j]
            xor ^= a[j]
        else:
            ans += j - i
            cnt = max(j, i + 1)
            break
    else:
        ans += n - i
        cnt = n
    num -= a[i]
    xor ^= a[i]
print(ans)


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

int main()
{
    size_t N, K;
    cin >> N >> K;

    vector<size_t> P(N);
    for (size_t &p : P)
    {
        cin >> p;
        p--;
    }

    vector<long long> C(N);
    for (long long &c : C)
    {
        cin >> c;
    }

    long long ans = LONG_LONG_MIN;
    for (size_t i = 0; i < N; i++)
    {
        vector<long long> visited(N, -1);
        vector<long long> score(N, 0);
        visited[i] = 0;
        long long tmp = LONG_LONG_MIN;
        bool warped = false;
        for (size_t j = 1, current = i; j <= K; j++)
        {
            size_t next = P[current];
            if (visited[next] != -1 && !warped)
            {
                long long diff = (score[current] + C[next]) - score[next];
                if (diff > 0)
                {
                    size_t freq = j - visited[next];
                    size_t period = (K - j) / freq;
                    if (period > 0)
                    {
                        period--;
                    }
                    score[next] += (period + 1) * diff;
                    j += period * freq;
                    visited[next] = j;
                    tmp = max(tmp, score[next]);
                    current = next;
                    warped = true;
                    continue;
                }
                else
                {
                    break;
                }
            }
            visited[next] = j;
            score[next] = score[current] + C[next];
            tmp = max(tmp, score[next]);
            current = next;
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3780
import java.util.*;
import java.io.*;
class Main{
  public static void main(String args[]){
    char s[] = stocs(readL());
    char t[] = stocs(readL());
    int max = t.length;
    for(int i=0;i<s.length-t.length+1;i++){
      int k = 0;
      for(int j=0;j<t.length;j++){
        if(s[i+j]!=t[j]){
          k++;
        }
      }
      if(k<max){max=k;}
    }
    pl(max+"");
  }

  public static void sortA(int n[]){
    Arrays.sort(n);
  }

  static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  public static void pr(String str){
    System.out.print(str);
  }
  public static void pl(String str){
    System.out.println(str);
  }
  public static String read(){
    try{
      return ctos((char)br.read());
    }catch(IOException e){
      e.printStackTrace();
      return "";
    }
  }
  public static char readC(){
    try{
      return (char)br.read();
    }catch(IOException e){
      e.printStackTrace();
      return (char)-1;
    }
  }
  public static String readL(){
    try{
      return br.readLine();
    }catch(IOException e){
      e.printStackTrace();
      return "";
    }
  }
  public static String readS(){
    StringBuilder sb = new StringBuilder();
    while(true){
      try{
        int k = br.read();
        if(k==-1||(char)k==' '||(char)k=='\n'){break;}
        sb.append((char)k);
      }catch(IOException e){
        e.printStackTrace();
      }
    }
    return sb.toString();
  }
  public static long readLong(){
    return stol(readS());
  }
  public static long stol(String s){
    return Long.parseLong(s);
  }
  public static int readI(){
    return stoi(readS());
  }
  public static String[] readSs(){
    return readL().split(" ");
  }
  public static int[] readIs(){
    return stoi(readSs());
  }
  public static int stoi(String s){
    return Integer.parseInt(s);
  }
  public static int[] stoi(String s[]){
    int a[]=new int[s.length];
    for(int i=0;i<s.length;i++){
      a[i]=stoi(s[i]);
    }
    return a;
  }
  public static String itos(int i){
    return String.valueOf(i);
  }
  public static String[] itos(int[] a){
    String s[]=new String[a.length];
    for(int i=0;i<a.length;i++){
      s[i]=itos(a[i]);
    }
    return s;
  }
  public static String ctos(char c){
    return String.valueOf(c);
  }
  public static String cstos(char[] c){
    return new String(c);
  }
  public static char stoc(String s){
    return s.charAt(0);
  }
  public static char[] stocs(String s){
    return s.toCharArray();
  }
  public static int[] Itoi(Integer a[]){
    int[]result=new int[a.length];
    for(int i=0;i<a.length;i++){
      result[i]=a[i];
    }
    return result;
  }
}


Measured memory_bytes: 36452
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<ll,ll> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

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

    vector<P> p(n);
    rep(i,n) {
        ll x, l;
        cin >> x >> l;
        p[i] = P(x+l,x-l);
    }
    sort(all(p));

    int ans = 0;
    ll t = -LINF;
    rep(i,n) {
        P r = p[i];
        if (t <= r.se) {
            ++ans;
            t = r.fi;
        }
    }
    cout << ans << endl;
    return 0;
}


















Measured memory_bytes: 1792
#include <algorithm>
#include <cstdio>

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

using namespace std;

int rint() {
  int n;
  scanf("%lld", &n);
  return n;
}

void wint(int n) {
  printf("%lld\n", n);
}

signed main() {
  int N = rint();
  int M = rint();
  // b_k := a_k / 2
  // a_k * (p + 0.5) = b_k * (2 * p + 1)
  // So semi-cm of b_k
  // - doesn't exist if LCM of (b_k) / b_k is even for any k
  // - is an odd multiple LCM of (b_k) otherwise
  int b[N];
  dotimes(i, N)
    b[i] = rint() / 2;
  int p = b[0];
  dotimes(i, N-1) {
    int q = b[i+1];
    p = p / __gcd(p, q) * q;
  }
  dotimes(i, N)
    if (p / b[i] % 2 == 0) {
      wint(0);
      return 0;
    }
  wint((M / p + 1) / 2);
  return 0;
}


Measured memory_bytes: 896
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N, K := nextInt(), nextInt()
	fmt.Println(K * int(math.Pow(float64(K-1), float64(N-1))))
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 640
import java.util.Scanner;
 
public class Main {
 
	public static final MyScanner in = new MyScanner();

	public static void main(String[] args) {

		char[] S = in.next().toCharArray();
		char[] T = in.next().toCharArray();

		for(int i=0;i<S.length;i++) {
			if(S[i] != T[i]) {
				System.out.println("No");
				return;
			}
		}

		System.out.println("Yes");


	}


	public static class MyScanner {
		Scanner sc = new Scanner(System.in);
		String next() { return sc.next();}
		int nextInt() { return Integer.valueOf(sc.next());}
		long nextLong() { return Long.valueOf(sc.next()); }
	}
}

Measured memory_bytes: 35732
import java.util.*;
import java.io.*;

public class Main {

  static int n;
  static int[] a;
  static final int MAX_LEN = 2000000;
  
  public static void main(String[] args) throws Exception {
    
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    Heap h = new Heap(MAX_LEN + 10);
    List<Integer> ans = new ArrayList<>();

    String[] in = br.readLine().split(" ");

    while(!in[0].equals("end")){
      if(in[0].equals("insert")){
        h.insert(Integer.parseInt(in[1]));
      }else if(in[0].equals("extract")){
        ans.add(h.extractMax());
      }
      in = br.readLine().split(" ");
    }

    br.close();

    for(int i = 0; i < ans.size(); i++){
      System.out.println(ans.get(i));
    }

  }
}

class Heap {

  static final int INITIAL_VAL = Integer.MIN_VALUE;
  int length;
  int[] ar;

  Heap(int n){
    this.length = 0;
    this.ar = new int[n];
    //Arrays.fill(ar, INITIAL_VAL);
  }

  Heap(int[] ori){
    this.length = ori.length;
    this.ar = ori.clone();
  }

  // MUST be tested
  // data in "ar" may be LOST
  //   when newSize < length
  public void resize(int newSize){
    int[] newAr = new int[newSize];
    for(int i = 0; i < Math.min(length, newSize); i++){
      newAr[i] = ar[i];
    }
    ar = newAr;
  }

  public void buildMaxHeap(){
    for(int i = length / 2; i >= 0; i--){
      maxHeapify(i);
    }
    return;
  }

  public void maxHeapify(int idx){
    int lIdx = 2 * idx + 1, rIdx = 2 * idx + 2;
    int largest = idx;

    if(lIdx < length && ar[lIdx] > ar[idx]){
      largest = lIdx;
    }
    if(rIdx < length && ar[rIdx] > ar[largest]){
      largest = rIdx;
    }

    if(largest != idx){
      int tmp = ar[idx];
      ar[idx] = ar[largest];
      ar[largest] = tmp;
      maxHeapify(largest);
    }
    return;
  }

  public void insert(int val){

    this.ar[length] = val;
    this.length++;

    int idx = length-1, parIdx = (idx-1)/2;

    while(idx > 0 && ar[idx] > ar[parIdx]){
      int tmp = ar[idx];
      ar[idx] = ar[parIdx];
      ar[parIdx] = tmp;
      idx = parIdx;
      parIdx = (parIdx-1)/2;
    }
    return;
  }

  public int extractMax(){

    if(length == 0) return INITIAL_VAL;
    int ret = this.ar[0];
    this.length--;
    this.ar[0] = this.ar[length];

    maxHeapify(0);

    return ret;
  }

  @Override
  public String toString() {
    StringBuilder ret = new StringBuilder("length = " + length + ",\n{ ");
    for(int i = 0; i < length; i++){
      if(i > 0) ret.append(", ");
      ret.append(ar[i]);
    }
    ret.append(" }");
    return ret.toString();
  }

}


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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 2e3, mod = 924844033;
int n, m, k, fac[nsz + 5], dp[2][nsz + 5][2], f[nsz + 5], ans;

void inline upd(int &a, int b) {
    (a += b) && (a >= mod) && (a -= mod);
    (a < 0) && (a += mod);
}

void inline init() {
    fac[0] = 1;
    cont (i, nsz) {
        fac[i] = (num) fac[i - 1] * i % mod;
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    init();
    cin >> n >> k;
    f[0] = 1;
    int o = 0, x = 1;
    cont (s, k) {
        int len = 0, t = s;
        for (; t <= n; t += k, ++len);
        memset(dp[o], 0, sizeof(dp[o]));
        dp[o][0][0] = 1;
        cont (i, len - 1) {
            circ (j, 0, i) {
                upd(dp[x][j][0], dp[o][j][0]);
                upd(dp[x][j + 1][1], dp[o][j][0]);
                upd(dp[x][j][0], dp[o][j][1]);
            }
            swap(o, x);
            memset(dp[x], 0, sizeof(dp[x]));
        }
        m += len;
        cont (_, 2)  for (int i = m; i >= 0; --i) {
            cont (j, len) {
                if (i - j < 0)  break;
                upd(f[i], (num) f[i - j] * (dp[o][j][0] + dp[o][j][1]) % mod);
            }
        }
    }
    circ (i, 0, n) {
        upd(ans, (num) (i & 1 ? -1 : 1) * fac[n - i] * f[i] % mod);
    }
    cout << ans << ln;
}

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

using namespace std;

int main(){
    
    int n,x,y;
    char c;
    cin >> n;
    x = 0;
    y = 0;
    while(n--){
        cin >> c;
        if('A' <= c && c <= 'M'){
            y++;
        } else if('N' <= c && c <= 'Z'){
            y--;
        } else if('a' <= c && c <= 'm'){
            x++;
        } else if('n' <= c && c <= 'z'){
            x--;
        }
    }
    
    cout << abs(x)+abs(y) << endl;
    if(abs(x)+abs(y) == 0) return 0;
    
    while(abs(x)+abs(y) != 0){
        if(y > 0){
            y--;
            cout << 'A';
        } else if(y < 0){
            y++;
            cout << 'N';
        } else if(x > 0){
            x--;
            cout << 'a';
        } else if(x < 0){
            x++;
            cout << 'n';
        }
    }
    
    cout << endl;
    
    return(0);
}


Measured memory_bytes: 3092
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<cassert>
#define PB push_back
#define MP make_pair
#define sz(v) (in((v).size()))
#define forn(i,n) for(in i=0;i<(n);++i)
#define forv(i,v) forn(i,sz(v))
#define fors(i,s) for(auto i=(s).begin();i!=(s).end();++i)
#define all(v) (v).begin(),(v).end()
using namespace std;
typedef int in;
typedef vector<in> VI;
typedef vector<VI> VVI;
struct bipm{
  in n,m;
  VVI a;
  VI pr,vs;
  void ini(in pn, in pm){
    n=pn;
    m=pm;
    a.clear();
    a.resize(n);
    pr.clear();
    pr.resize(m,-1);
  }
  void ad(in u, in v){
    a[u].PB(v);
  }
  bool mm(in u){
    if(vs[u])
      return 0;
    vs[u]=1;
    in tt;
    forv(i,a[u]){
      tt=a[u][i];
      if(pr[tt]==-1){
    pr[tt]=u;
    return 1;
      }
      if(mm(pr[tt])){
    pr[tt]=u;
    return 1;
      }
    }
    return 0;
  }
  in mmat(){
    vs.resize(n);
    in sm=0;
    forn(i,n){
      forn(j,n)
    vs[j]=0;
      sm+=mm(i);
    }
    return sm;
  }
};
bipm mat;
bool isp(in a){
  if(a<=2)
    return 0;
  for(in i=2;i*i<=a;++i){
    if(a%i==0)
      return 0;
  }
  return 1;
}
in ab(in a){
  return a<0?-a:a;
}
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  in n;
  cin>>n;
  VI x(n);
  forn(i,n)
    cin>>x[i];
  VI lft,rgt;
  in c;
  forv(i,x){
    if(i==0 || x[i-1]+1!=x[i]){
      c=x[i];
      if(c%2==0)
    lft.PB(c);
      else
    rgt.PB(c);
    }
    if(i==n-1 || x[i]+1!=x[i+1]){
      c=x[i]+1;
      if(c%2==0)
    lft.PB(c);
      else
    rgt.PB(c);
    }
  }
  in l=sz(lft);
  in r=sz(rgt);
  mat.ini(l,r);
  forv(i,lft){
    forv(j,rgt){
      if(isp(ab(rgt[j]-lft[i])))
    mat.ad(i,j);
    }
  }
  c=mat.mmat();
  in res=c;
  l-=c;
  r-=c;
  assert(l%2==r%2);
  if(l%2){
    res+=3;
    --l;
    --r;
  }
  res+=l+r;
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 256
w, h, n = gets.split.map(&:to_i)

x1 = 0
x2 = w
y1 = 0
y2 = h
n.times do
  x, y, a = gets.split.map(&:to_i)
  case a
  when 1
    x1 = [[x, x1].max, x2].min
  when 2
    x2 = [[x, x2].min, x1].max
  when 3
    y1 = [[y, y1].max, y2].min
  when 4
    y2 = [[y, y2].min, y1].max
  end
end
puts (x2 - x1) * (y2 - y1)



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

int main() {
  int n=0;
  cin>>n;
  ll seki=1;
  vector<ll> vec(n);
  
  rep(i,n){
    cin>>vec.at(i);
  }
  
  sort(vec.begin(),vec.end());
  
  rep(i,n){
    ll bseki=seki;
    seki*=vec.at(i);
    if(bseki==0){
      break;
    }
    if(seki>1000000000000000000){
      cout<<-1;
      return 0;
    }
    if(vec.at(i)>LLONG_MAX/bseki){
      cout<<-1;
      return 0;
    }
  }
  cout<<seki;
}

Measured memory_bytes: 4052
import sys
import collections
input = sys.stdin.readline
K = int(input())
 
queue = collections.deque()
 
for n in range(1, 10):
	queue.append(n)
 
n = 1
for k in range(K):
	n = queue.popleft()
	d = n % 10
	if d != 0:
		queue.append(n * 10 + d - 1)
	queue.append(n * 10 + d)
	if d != 9:
		queue.append(n * 10 + d + 1)
 
print(n)

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

using namespace std;

typedef long double ld;
typedef long long ll;

#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define f first
#define s second


const int MAXN = 1e6 + 5;
int n, res = 0;
vector<int> v;
vector<bool> vis(MAXN, 0);



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    map<int, int> m;
    for(int i = 0; i < n; ++i){
        int u;
        cin >> u;
        m[u]++;
    }
    for(auto i : m){
        if(i.s == 1) v.pb(i.f);
        else{
            if(!vis[i.f]){
                for(int j = i.f; j < MAXN; j += i.f){
                    vis[j] = true;
                }
            }
        }
    }
    sort(v.begin(), v.end());
    for(int i = 0; i < sz(v); ++i){
        if(!vis[v[i]]){
            res++;
            for(int j = v[i]; j < MAXN; j += v[i]){
                vis[j] = true;
            }
        }
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 13700
n = int(input())
a = [int(item) for item in input().split()]

ans = [0] * n
for i, item in enumerate(a[::-1]):
    number = n - i
    total = 0
    for i in range(1, n+1):
        if number * i > n:
            break
        total += ans[number * i - 1]
    if(total % 2 != a[number - 1]):
        ans[number - 1] = 1
ans_num = sum(ans)
print(ans_num)
if ans_num == 0:
    exit()
ret = []
for i, item in enumerate(ans):
    if item == 1:
        ret.append(i+1) 
if len(ans) > 0:
    print(" ".join([str(item) for item in ret]))

Measured memory_bytes: 19892
#include<iostream>
#include<string>
using namespace std;
int main(){
	string s;
	cin>>s;
	int n=s.size();
	int flag=1;
	for(int i=0;i<n;i++){
		if(s[i]!=s[n-i-1]){
			flag=0;
			break;
		}
	}
	for(int i=0;i<(n-1)/2;i++){
		if(s[i]!=s[(n-1)/2-i-1]){
			flag=0;
			break;
		}
	}
	for(int i=(n+3)/2;i<n;i++){
		if(s[i-1]!=s[n+(n+3)/2-i-1]){
			flag=0;
			break;
		}
	}
	if(flag)
		cout<<"Yes";
	else
		cout<<"No";
} 

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

int main(void){
	vector<pair<double,int> > v[3],vall;
	double time;
	int num;
	
	for(int i=0;i<24;i++){
		cin >> num >> time;
		if(i < 8){
			v[0].push_back(make_pair(time,num));
		}else if(i < 16){
			v[1].push_back(make_pair(time,num));
		}else{
			v[2].push_back(make_pair(time,num));
		}
	}
	sort(v[0].begin(),v[0].end());
	sort(v[1].begin(),v[1].end());
	sort(v[2].begin(),v[2].end());
	
	cout << v[0][0].second << " " << v[0][0].first << endl;
	cout << v[0][1].second << " " << v[0][1].first << endl;
	cout << v[1][0].second << " " << v[1][0].first << endl;
	cout << v[1][1].second << " " << v[1][1].first << endl;
	cout << v[2][0].second << " " << v[2][0].first << endl;
	cout << v[2][1].second << " " << v[2][1].first << endl;
	
	for(int i=2;i<8;i++){
		vall.push_back(v[0][i]);
		vall.push_back(v[1][i]);
		vall.push_back(v[2][i]);
	}
	
	sort(vall.begin(), vall.end());
	
	cout << vall[0].second << " " << vall[0].first << endl;
	cout << vall[1].second << " " << vall[1].first << endl;
}

Measured memory_bytes: 0
//hinagata.cpp
/*includes*/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <stdio.h>
#include <numeric>
#include <iomanip>
#include <limits>
/*namespace*/
using namespace std;
using ll= long long;
/*define macro*/
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPi(i,a,b) for(int i=(a);i<(b);i++)
#define REPRi(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end()

int main(){
    ll N;
    cin>>N;
    if(N%2!=0){
        cout<<N*2<<endl;
    }else{
        cout<<N<<endl;
    }
}

Measured memory_bytes: 256
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int main(){
  int N, K;
  cin >> N >> K;
  double ans = 0;
  rep(i, 1, N + 1){
    int num = i;
    double a = 1.0;
    while(num < K){
      num *= 2;
      a /= 2.0;
    }
    ans += a;
  }
  ans /= (double)N;
  printf("%.12f\n", ans);
  return 0;
}


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

using namespace std;

int main(){
    int N,M;
    cin>>N>>M;
    vector<int> in(N);

    for(auto &&x: in){
        cin>>x;
    }

    vector<int> SUM(N+1);
    SUM[0]=0;
    for(int i=0;i<N;i++){
        SUM[i+1]=(SUM[i]+in[i])%M;
    }

    long ans=0;
    map<int,int> mp;

    for(int i=0;i<SUM.size();i++){
        ans+=mp[SUM[i]];
        mp[SUM[i]]++;
    }

    cout<<ans<<endl;

}

Measured memory_bytes: 3968
#include <stdio.h>
int main (void)
{
  int x,a,b;
  int xx;
  
  scanf("%d",&x);
  scanf("%d",&a);
  scanf("%d",&b);
  
  xx=x-a;
  
  while(xx>=b){
  xx=xx-b;
  }
   
  printf("%d",xx);

  return 0;

}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SIZE = 1e5 * 2 + 10, INF = 1e9 + 10, MOD = 1e9 + 7;



int main()
{
    fastInp;

    ll n;
    cin >> n;

    ll sq = sqrt(n);
    vector<ll> ans(n);
    for (int i = 1; i <= sq; i++) {
        for (int j = 1; j <= sq; j++) {
            for (int k = 1; k <= sq; k++) {
                if ((i * i) + (j * j) + (k * k) + (i * j) + (j * k) + (k * i) <= n) ans[(i * i) + (j * j) + (k * k) + (i * j) + (j * k) + (k * i) - 1]++;
            }
        }
    }
    
    for (auto cur : ans) {
        cout << cur << "\n";
    }
    return 0;
}

Measured memory_bytes: 3600
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int main(void){
	ll l,r,i,j,ans=INFLL;
	cin >> l >> r;
	if(r-l>2018){
		ans = 0ll;
		cout << ans << endl;
		return 0;
	}
	for(i=l; i<r; ++i){
		for(j=i+1; j<=r; ++j){
			ans = min(ans,(i*j)%2019);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int unit=n%10;
  if(unit==2 || unit==4 || unit==5 || unit==7 || unit==9) cout<<"hon"<<endl;
  if(unit==0 || unit==1 || unit==6 || unit==8) cout<<"pon"<<endl;
  if(unit==3) cout<<"bon"<<endl;
  return 0;
}

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

int main()
{
    int n,ptr = 0;
    cin>>n;
    for(int i=1;i<10;i++){
        for(int j = 1;j<10;j++){
            if((i*j) == n){
                ptr = 1;
                break;
            }
            if(ptr == 1){
                break;
            }
        }
    }
    if(ptr == 1){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
 int n,l,all = 0;
 
 cin >> n >> l;
 vector<int> count(n,0);
 for(int i=1;i<=n;i++){
   all+=(l+i-1);
 }
 int ch = 0;
 int min_abs = 1000000; 
 for(int i=1;i<=n;i++){
  for(int j=1;j<=n;j++){
    if(j != i) count[i-1]+=(l+j-1);
  }
  if(min_abs > abs(all-count[i-1])){min_abs = abs(all-count[i-1]); ch = i-1;}   
 }
 cout <<count[ch]<< endl; 
}


Measured memory_bytes: 256