akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include<stdlib.h>
int compare(const void *x, const void *y);
int compare_char(const void* left, const void* right) {
    char *left_char = (char *)left;
    char *right_char = (char *)right;
 
    return strcmp( left_char, right_char );
}
int main()
{
    long int N;
    scanf("%ld", &N);
    char s[100000][11];
    long int i;
    long long int j, k=0,count=0;
    for (i = 1; i <= N; i++)
    {
        scanf("%s", &s[i]);
        qsort(s[i], strlen(s[i]), 1, compare);
       // printf("%s\n", s[i]);
    }
        qsort(s, N+1, sizeof (s[1]), compare_char);
  /*for (i = 1; i <= N; i++){
   printf("%s\n", s[i]);
  } */
      for(i=1;i<=N;i++){
        if(i!=N && strcmp(s[i],s[i+1])==0){
          k++;
        }
        else{
          count += k*(k+1)/2;
          k = 0;
        }
      }
    printf("%lld\n",count);
    return 0;
}
int compare(const void *x, const void *y)
{
const  char *a = (const char *)x;
const  char *b = (const char *)y;
return (int)*a - (int)*b;
}

Measured memory_bytes: 2300
/*
                    author         : TAPAN SAVANI 
                    codeforces     : savanitapan2001
                    codechef       : savanitapan17
*/

/*
------------------------------------------------------------------------

░██╗░░░░░░░██╗░█████╗░██████╗░██╗░░██╗  ██╗░░██╗░█████╗░██████╗░██████╗░
░██║░░██╗░░██║██╔══██╗██╔══██╗██║░██╔╝  ██║░░██║██╔══██╗██╔══██╗██╔══██╗
░╚██╗████╗██╔╝██║░░██║██████╔╝█████═╝░  ███████║███████║██████╔╝██║░░██║
░░████╔═████║░██║░░██║██╔══██╗██╔═██╗░  ██╔══██║██╔══██║██╔══██╗██║░░██║
░░╚██╔╝░╚██╔╝░╚█████╔╝██║░░██║██║░╚██╗  ██║░░██║██║░░██║██║░░██║██████╔╝
░░░╚═╝░░░╚═╝░░░╚════╝░╚═╝░░╚═╝╚═╝░░╚═╝  ╚═╝░░╚═╝╚═╝░░╚═╝╚═╝░░╚═╝╚═════╝░
 
------------------------------------------------------------------------
*/

#include <bits/stdc++.h>
using namespace std;

#define HAPPY_CODING              \
    ios_base::sync_with_stdio(0); \
    cin.tie(NULL);                \
    cout.tie(NULL);
#define pb push_back
#define mp make_pair
#define Debug(x) cout << #x " = " << (x) << endl
#define SORT(a) sort(a.begin(), a.end())
#define SORTR(a) sort(a.rbegin(), a.rend())
#define mod 1000000007
#define pi 3.141592653589793238
#define ll long long int
#define ull unsigned long long
#define be begin()
#define en end()
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define FORI(i, a, b) for (int i = a; i >= b; i--)

typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
typedef pair<ll, ll> PL;
typedef vector<PI> VPI;

int main()
{
    HAPPY_CODING;

    int n, k;
    cin >> n >> k;

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

    int dp[n];
    dp[0] = 0;
    FOR(i, 1, n)
    {
        int x = min(i, k);
        int y = i - x;
        dp[i] = INT_MAX;

        // while (x--)
        for (int j = i - 1; j >= y; j--)
        {
            dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
        }
    }

    cout << dp[n - 1] << "\n";

    return 0;
}


Measured memory_bytes: 4440
n=int(input())
hoge=list(map(int,input().split()))
d0,d2,d4=0,0,0
for i in range(n):
  if(hoge[i]%4==0):
    d4+=1
  elif(hoge[i]%2==0):
    d2+=1
  else:
    d0+=1
if(d2!=0):
  d0+=1  
if(d0-d4>1):
  print("No")
else:
  print("Yes")

Measured memory_bytes: 15020
use std::fmt::Debug;
use std::io;
use std::io::{Read, Stdin};
use std::str;
use std::str::FromStr;
use std::usize;
use std::cmp;
use std::collections::vec_deque::VecDeque;
use std::i64::MAX;

fn main() {
    let mut sc = Scanner::new();

    let a = sc.parse::<i32>();
    let b = sc.parse::<i32>();
    let c = sc.parse::<i32>();

    let sum = 100 * a + 10 * b + c;
    if sum % 4 == 0 {
        println!("YES");
    } else {
        println!("NO");
    }
}

struct Scanner {
    stdin: Stdin,
    buf: Vec<u8>,
}

impl Scanner {
    fn new() -> Scanner {
        Scanner {
            stdin: io::stdin(),
            buf: Vec::with_capacity(256),
        }
    }

    fn parse<T: FromStr>(&mut self) -> T
        where <T as FromStr>::Err: Debug
    {
        self.buf.clear();
        let mut it = self.stdin.lock().bytes();
        let mut c = it.next().unwrap().unwrap();
        while c == ' ' as u8 || c == '\n' as u8 {
            c = it.next().unwrap().unwrap();
        }
        while !(c == ' ' as u8 || c == '\n' as u8) {
            self.buf.push(c);
            c = it.next().unwrap().unwrap();
        }
        str::from_utf8(&self.buf).unwrap().parse::<T>().unwrap()
    }
}

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

using namespace std;
typedef long long ll;

ll N;

int main(){
    cin >> N;
    ll sum = 0;
    for(int i=1;i<=N;i++){
        if(i%3!=0 && i%5!=0) sum += i;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin >> n >> m;
    int mx = 0;
    int mn = 100001;
    int l, r;
    for (int i=0;i<m;i++){
        cin >> l >> r;
        mx = max(mx,l);
        mn = min(mn,r);
    }
    cout << max(0,mn-mx+1) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
	int n;
	cin>>n;
	vector<int> d(n);
	FOR(i,0,n){
		cin>>d[i];
	}
	sort(d.begin(),d.end());
	if(d[n/2]-d[n/2-1]>0){
		cout<<d[n/2]-d[n/2-1];
	}else{
		cout<<0;
	}

	return 0;
}


Measured memory_bytes: 640
import sys
line = sys.stdin.readline()
while line :
	H,W = map(int,line.split())
	if H == 0 and W == 0:
		break;
	for i in range(0,H):
		for j in range(0,W):
			if (i+j)%2 == 0:
				sys.stdout.write("#")
			else:
				sys.stdout.write(".")
		print ""	
	print ""
	line = sys.stdin.readline()

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

#define int long long

#define inf (int)1000000007

#define rep(i, n) for(int i = 0; i < (n); i++)
#define trep(i, n) for(int i = 0; i <= (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define trrep(i, n) for(int i = (n); i >= 0; i--)

signed main() {
  int n;
  string s;
  cin >> n >> s;
  int x = 0;
  int ans = 0;
  rep(i, n) {
    if(s[i] == 'I') {
      x++;
    }
    else {
      x--;
    }
    ans = max(ans, x);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    
    ll n;
    cin>>n;

    ll counter=0;
    for(ll a=1;a<1000000;a++)
    {
        for(ll b=1;b<a;b++)
        {
            if(a*b<n and n-a*b>0)
                counter+=2;
            else
                break;
        }
        if(n-a*a>0)
            counter++;
    }
    cout<<counter<<endl;
    return 0;
}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  double n,m,d;cin>>n>>m>>d;
  if(n-d<=0)cout<<0<<endl;
  else if(d==0)
    printf("%.8lf\n",(double)(m-1)/n);
  else{
    printf("%.8lf\n",(double)2*(m-1)*(n-d)/(n*n));
  }
    
  return 0;
}


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

using namespace std;

typedef long long ll;
const ll mod = 1e9+7;

template<typename T> ostream& operator << (ostream& os, vector<T> v) {
  for (auto& i : v) os << i << " "; return os; 
}
template<typename T> istream& operator >> (istream& is, vector<T>& v) {
  for (auto& i : v) is >> i; return is;
}
template<typename K, typename V> ostream& operator << (ostream& os, unordered_map<K, V> m) {
  for (auto& i : m) os << i.first << ":" << i.second << endl; return os;
}
template<typename T> inline bool chmin(T& x, T y) {
  if (x > y) {
    x = y;
    return true;
  }
  return false;
}
template<typename T> inline bool chmax(T& x, T y) {
  if (x < y) {
    x = y;
    return true;
  }
  return false;
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> s(n), t(m);
  cin >> s >> t;

  vector<vector<ll>> dp(n+1, vector<ll>(m+1));
  dp[0][0] = 1;
  for (int i=0; i<=n; i++) {
    for (int j=0; j<=m; j++) {
      if (i>0) dp[i][j] += dp[i-1][j];
      if (j>0) dp[i][j] += dp[i][j-1];
      if (i>0 && j>0 && s[i-1] != t[j-1]) {
        dp[i][j] += mod - dp[i-1][j-1];
      }
      dp[i][j] %= mod;
    }
  }
  cout << dp[n][m] << endl;
  return 0;
}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

struct S{
    int s;
    int t;
    int x;
    bool operator()(S l, S r) const
    {
        return l.x > r.x;
    }
};

int main() {

    int N,Q;
    Scd2(N,Q);

    vector<S> a(N);

    Rep(i,N){
        Scd3( a[i].s, a[i].t, a[i].x );
        a[i].s -= a[i].x;
        a[i].t -= a[i].x;
    }

    sort( a.begin(), a.end(), []( S l, S r ){
            return l.s < r.s;
    });

    priority_queue<S, vector<S>, S > p;


    int d;
    int l = 0;
    Rep(i,Q){
        Scd(d);
        while( d >= a[l].s ){
            if( l >= N ) break;
            p.push( a[l++] );
        }
        while( !p.empty() ){
            if( d >= p.top().t )
                p.pop();
            else
                break;
        }
        if( p.empty() ) printf ("%d\n", -1 );
        else printf ("%d\n", p.top().x );
   }


    return 0;
}



Measured memory_bytes: 7028
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug: "<<x<<" "<<y<<endl;
using namespace std;
typedef long long ll;
const int maxn = 605;
const int mod = 1000000007;

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n;
  cin>>n;
  cout<<(n-1)/2<<endl;
  return 0;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    bool g[4][4];
    rep(i, 4) {
        rep(j, 4) { g[i][j] = false; }
    }
    rep(i, 3) {
        int a, b;
        cin >> a >> b;
        g[a - 1][b - 1] = true;
        g[b - 1][a - 1] = true;
    }
    int cnt1 = 0, cnt2 = 0;
    rep(i, 4) {
        int tmp = 0;
        rep(j, 4) { if (g[i][j]) {
                tmp++;
            }
        }
        if (tmp == 1) {
            cnt1++;
        } else if (tmp == 2 ){
            cnt2++;
        }
    }
    if (cnt1 == 2 && cnt2 == 2) {
        puts("YES");
    } else {
        puts("NO");
    }
    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;

const int N = 3;
int bingo[N][N];
int a[N][N];

signed main() {
  rep(i,N) rep(j,N) cin >> a[i][j];
  int n;
  cin >> n;
  rep(i,n) {
    int x; cin >> x;
    rep(j,N) {
      rep(k,N) {
        if(a[j][k] == x) bingo[j][k] = 1;
      }
    }
  }
  bool ok = false;
  rep(i,N) {
    if(bingo[i][0] && bingo[i][1] && bingo[i][2]) ok = true;
  }
  rep(i,N) {
    if(bingo[0][i] && bingo[1][i] && bingo[2][i]) ok = true;
  }
  if(bingo[0][0] && bingo[1][1] && bingo[2][2]) ok = true;
  if(bingo[2][0] && bingo[1][1] && bingo[0][2]) ok = true;

  if(ok) cout << "Yes" << '\n';
  else cout << "No" << '\n';
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

ll dp[100005][3];

void Main() {
    int N;
    cin >> N;
    vector<vector<int>> items;
    rep(i, N) {
        int a, b, c;
        cin >> a >> b >> c;
        items.push_back(vector<int>{a, b, c});
    }

    rep(i, N) {
        rep(j, 3) {
            rep(k, 3) {
                if (j == k) continue;
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + items[i][k]);
            }
        }
    }
    cout << max({dp[N][0], dp[N][1], dp[N][2]}) << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 8752
# coding: utf-8

def main():
    N = int(input())
    D = [int(d) for d in input().split()]
    
    hp = 0
    for n in range(N):
        for m in range(N):
            if n >= m:
                continue
            hp += D[n] * D[m]
    print(hp)

main()

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

signed main() {
	cin.tie(0);ios::sync_with_stdio(false);
	string s,t;cin>>s>>t;
	if(s==t.substr(0,s.size()))cout<<"Yes\n";
	else cout<<"No\n";
}


Measured memory_bytes: 3652
/**
 *      ABC 102 B
 *      author  : kyomukyomupurin
 *      created : 2018/08/21
**/
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}

#include <bits/stdc++.h>
using namespace std;

int main(){
    int N;
    cin >> N;
    string S = to_string(N);
    int sum = 0;
    for (int i = 0; i < S.size(); ++i) {
        sum += ctoi(S.at(i));
    }

    N % sum == 0 ? cout << "Yes" : cout << "No";
    
    return 0;
}


Measured memory_bytes: 256
program main
  implicit none
  integer(8) :: n, k, full, half
  read(*, *) n, k

  full = n / k
  if (mod(k, 2_8) == 0) then
    half = (n + k / 2) / k
  else
    half = 0
  end if

  write(*, "(i0)") full ** 3 + half ** 3
end program main


Measured memory_bytes: 256
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B, C, D);

// ===

fn main() {
    let s: String = read();
    let k: usize = read();

    let n = s.len();
    let mut candidates = HashSet::new();
    for i in 0..n {
        for j in i+1..min(i+k+1, n+1) {
            candidates.insert(s[i..j].to_string());
        }
    }
    let mut candidates: Vec<String> = candidates.into_iter().collect();
    candidates.sort();

    println!("{}", candidates[k-1]);
}



Measured memory_bytes: 6396
#include<bits/stdc++.h>
using namespace std;
const int INF = 1001001001;
int main(){
  int H, N;
  cin >> H >> N;
  vector<pair<int, int>> spell(N);
  //monster health / minimum cosume
  int dp[H + 1];
  for(int i = 0; i < H + 1; ++i) dp[i] = INF;
  for(int i = 0, A, B; i < N; ++i){
    cin >> A >> B;
    spell[i] = make_pair(A, B);
  }
  dp[H] = 0;
  int hh;
  for(int h = H; h >= 0; --h){
    for(int i = 0; i < N; ++i){
      if(dp[h] == INF) continue;
      hh = max(0, h - spell[i].first);
      dp[hh] = min(dp[hh], dp[h] + spell[i].second);
    }
  }
  cout << dp[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i,a,b) for (ll i=a;i<=ll(b);i++)
using namespace std;
ll ctoi(const char c){if('0'<=c&&c<='9') return (c-'0');return -1;}
#define ALL(x) begin(x),end(x)
  
int main(){
  ll x;
  cin >> x;
  if(400<=x&&x<=599) cout << "8" << endl;
  if(600<=x&&x<=799) cout << "7" << endl;
  if(800<=x&&x<=999) cout << "6" << endl;
  if(1000<=x&&x<=1199) cout << "5" << endl;
  if(1200<=x&&x<=1399) cout << "4" << endl;
  if(1400<=x&&x<=1599) cout << "3" << endl;
  if(1600<=x&&x<=1799) cout << "2" << endl;
  if(1800<=x&&x<=1999) cout << "1" << endl;
} 

Measured memory_bytes: 3644
import numpy as np

n = int(input())
max_n = int(n ** 0.5)
memo = np.zeros((max_n, max_n, max_n))

ans = [0]*(n+1)

for x in range(1, max_n):
    for y in range(1, max_n):
        for z in range(1, max_n):
            s = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
            if s < n+1:
                ans[s] += 1


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


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

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;

std::vector<int> perm_inv(const std::vector<int> &p) {
  int len = p.size();
  std::vector<int> ans(len);
  for (int i = 0; i < len; ++i) {
    assert (0 <= p[i] && p[i] < len);
    ans[p[i]] = i;
  }
  return ans;
}


int main(void){
  int n;
  cin >> n;
  VI p(n);
  REP(i, 0, n) {
    cin >> p[i];
    p[i]--;
  }

  p = perm_inv(p);
  REP(i, 0, n) {
    p[i] += 9e8;
  }
  REP(i, 0, n) {
    cout << 30000 * i + 1 << (i == n - 1 ? "\n" : " ");
  }
  REP(i, 0, n) {
    cout << p[i] - 30000 * i << (i == n - 1 ? "\n" : " ");
  }
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,s,n) for(int i=(s);i<(n);i++)
using ll=long long;
using namespace std;
int main(void){
    ll N,W;
    cin>>N>>W;
    vector<ll> w(N+1,0);
    vector<ll> v(N+1,0);
    reps(i,1,N+1) cin>>w[i]>>v[i];
    vector<vector<ll>> dp(N+1,vector<ll>(W+1,0));
    reps(i,1,N+1){
        reps(j,1,W+1){
            dp[i][j]=max(dp[i-1][j],(j-w[i]>=0)?dp[i-1][j-w[i]]+v[i]:0);
        }
    }
    cout<<dp[N][W]<<endl;
}


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

const ll INF = 1e18L + 5; 
 
int main(){
    int n,W ; cin >> n >> W;
    vector<int> value(n), weight(n);
    
    for(int i = 0; i < n; i++) cin >> weight[i] >> value[i] ;
    //cout << knapsack1(n,W);
    int val_sum = 0;
    for(int x : value) val_sum += x;
    
    vector<ll> dp(val_sum+1,INF);
    dp[0] = 0;
    
    for(int i = 0; i < n; i++){
    //     for(int j = val_sum - value[i]; j >= 0; j--){
    //         dp[j+value[i]] = min( dp[j+value[i]], (dp[j]+weight[i]) );
    //     }
        
        for(int j = val_sum; j >= value[i]; j--){
            dp[j] = min( dp[j], (dp[j-value[i]]+weight[i]) );
        }
    }
    
    ll ans = 0;
    for(int i = 0; i <= val_sum; i++){
        if(dp[i] <=W) ans = max(ans,(ll)i);
    }
    
    cout << ans ;
    return 0;
}

Measured memory_bytes: 3992
h,w,k = map(int,input().split())

cake = []
for i in range(h):
    x = list(input())
    cake.append(x)

ans = [[0]*w for _ in range(h)]

c = 1
for i in range(h):
    if cake[i].count('#') == 1:
        for j in range(w):
            ans[i][j] += c
        c = min(c+1,k)
    elif '#' in cake[i]:
        ss = c
        s = cake[i].count('#')
        for j in range(w):
            if cake[i][j] =='.':
                ans[i][j] = c
            else:
                ans[i][j] = c
                c = min(c+1,ss+s-1)
        c = c+1

j = 0
while not '#' in cake[j]:
    j += 1

for l in range(j):
    ans[l] = ans[j]

for i in range(h):
    if min(ans[i]) == 0:
        ans[i] = ans[i-1]

for i in range(h):
    print(*(ans[i]))


Measured memory_bytes: 50652
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int x;
  cin>>x;
  REP(i,300)REP(j,300) {
    ll a = 1, b = 1;
    REP(k,5) {
      a *= i;
      b *= j;
    }
    if (a + b == x) {
      cout<<i<<" "<<-j<<endl;
      return 0;
    }
  }
  for (int i = 1; i*i <= x; ++i) {
    if ((x % i) == 0) {
      REP(j, 300) {
        ll a = i+j, b = j;
        ll s = a*a*a*a + a*a*a*b + a*a*b*b + a*b*b*b + b*b*b*b;
        if (i * s == x) {
          cout << a << " "<< b<<endl;
          return 0;
        }
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3644
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/




int main() {
int N;
cin>>N;
int A[N+1];
rep3(i,N){
  cin>>A[i];
}
int ans[N+1];
repr3(i,N){
  int sum=0;
  for(int j=2*i;j<=N;j+=i){
    sum+=ans[j];
  }
  ans[i]=(sum+2-A[i])%2;
}
vector<int> ans_list;
int count=0;
rep3(i,N){
  if(ans[i]==1){
    ans_list.push_back(i);
    count++;

  }
}
cout<<count<<endl;
rep(i,ans_list.size()){
  cout<<ans_list[i]<<endl;
}
return 0;
}

Measured memory_bytes: 5408
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <bitset>
#include <numeric>
#include <array>
#include <cstring>
#include <random>
#include <chrono>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {

  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  int h, w;

  cin >> h >> w;

  int sx, sy, fx, fy;

  cin >> sx >> sy >> fx >> fy;

  sx--; sy--; fx--; fy--;

  vector<string> m(h);

  for(int i = 0; i < h; i++) cin >> m[i];

  vector<vector<int> > cost(h, vector<int>(w, 1e9 + 42));

  cost[sx][sy] = 0;

  deque<pair<int, int> > dq;

  dq.push_front(mp(sx, sy));

  int movex[4] = {-1, 0, 0, 1}, movey[4] = {0, -1, 1, 0};

  int x, y;

  while(!dq.empty()) {
    tie(x, y) = dq.front();
    dq.pop_front();
    for(int mm = 0; mm < 4; mm++) {
      int cx = x + movex[mm], cy = y + movey[mm];
      if(cx >= 0 && cx < h && cy >= 0 && cy < w && m[cx][cy] == '.' && cost[cx][cy] > cost[x][y]) {
        cost[cx][cy] = cost[x][y];
        dq.push_front(mp(cx, cy));
      }
    }
    for(int xx = x - 2; xx <= x + 2; xx++)
      for(int yy = y - 2; yy <= y + 2; yy++) {
        if(xx >= 0 && xx < h && yy >= 0 && yy < w && m[xx][yy] == '.' && cost[xx][yy] > cost[x][y] + 1) {
          cost[xx][yy] = cost[x][y] + 1;
          dq.push_back(mp(xx, yy));
        }
      }
  }

  cout << (cost[fx][fy] >= 1e9 ? -1 : cost[fx][fy]);

  return 0;
}
/*

*/


Measured memory_bytes: 8712
#include<bits/stdc++.h>
// using namespace std;
typedef long long ll;
const int mod=1e9+9;
const int N=2e2+5;

ll x;
ll a[N<<1][2];
int main()
{
    // ios::sync_with_stdio(false);std::cin.tie(0);cout.tie(0);                           
    // freopen("a.in","r",stdin);
    // int T;scanf("%d",&T);while(T--){
    // while(~scanf("%d%d%d",&n,&p,&c)){
    int cnt=0;
    for(ll i=0;i<=150;i++)
    {
        a[cnt][0]=i;
        a[cnt][1]=i*i*i*i*i;
        cnt++;
    }
    for(ll i=-1;i>=-150;i--)
    {
        a[cnt][0]=i;
        a[cnt][1]=i*i*i*i*i;
        cnt++;
    }
    scanf("%lld",&x);
    for(int i=0;i<cnt;i++)
    {
        for(int j=0;j<cnt;j++)
        {
            if(a[j][1]-a[i][1]==x)
            {
                printf("%lld %lld\n",a[j][0],a[i][0]);
                return 0;
            }
        }
    }
    // }
    return 0;
}

Measured memory_bytes: 3764
#include <iostream>
#include <algorithm>
using namespace std;
 
int main() {
    long n;
    long a[10];
    long rep;
  
    cin >> n;
    for (int i = 0; i < 5; ++i) cin >> a[i];
    
    sort(a,a + 5);
    rep = ( (n + (a[0] - 1)) / a[0] ) + 4; 
      
    cout << rep << endl;     
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define mp make_pair
#define pb(x) push_back(x)
#define vi vector<int>
#define vs vector<string>
#define vll vector<long long>
#define vc vector<char>
#define vs vector<string>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define pcc pair<char, char>
#define pdd pair<double, double>
#define mll map<long long, long long>
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(), (v).end()
#define flsh fflush(stdout)
#define gcd __gcd
#define clr(x) memset(x, 0, sizeof(x))
#define mod 1000000007LL
#define mod2 998244353LL
#define INF 1000000000007
 

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> o_tree;


void solve()
{
   ll a,b;
   cin>>a>>b;
   ll g = gcd(a,b);

   set<ll > s;
   ll i;
//    cout<<g<<"\n";
   if(g==1)
   {
       cout<<"1\n";
       return;
   }
   s.insert(1);
   for(i=2;i*i<=g;i++)
   {
       if(g%i==0)
       {
           s.insert(i);
           while(g%i==0)
           {
               g/=i;
           }
       }
   }
   if(g>1)
   {
       s.insert(g);
   }
   ll si =s.size();
  
//    res++;
   cout<<si<<"\n";

}


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


if (fopen("input.txt","r" ))
  {
     freopen("input.txt", "r", stdin);
     freopen("output.txt", "w", stdout);
  }
cout<<setprecision(20);


ll t=1;


// cin>>t;


while(t--)
{
solve();
} 


return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val a = sc.nextInt()
    val b = sc.nextInt()
    val m = sc.nextInt()
    val aa = (1..a).map {
      sc.nextInt()
    }
    val bb = (1..b).map {
      sc.nextInt()
    }
    val xyc = (1..m).map {
      Triple(sc.nextInt(), sc.nextInt(), sc.nextInt())
    }

    println(hitachi2020b(aa, bb, xyc))
}

private fun hitachi2020b(aa: List<Int>, bb: List<Int>, xyc: List<Triple<Int, Int, Int>>): Int {
    val prices = mutableListOf<Int>()
    for (xyci in xyc) {
      val x = xyci.first
      val y = xyci.second
      val c = xyci.third
      val ap = aa.get(x - 1)
      val bp = bb.get(y - 1)
      val price = ap + bp - c
      prices.add(price)
    }
    val amin = aa.min()
    val bmin = bb.min()
    val ans = amin!! + bmin!!
    val minPrice = prices.min()!!
    if (ans > minPrice) {
      return minPrice
    }

    return ans
}

Measured memory_bytes: 122748
#include <bits/stdc++.h>
using namespace std;
int main(){
    int r;
    cin >> r;
    if (r < 1200) cout << "ABC" << endl;
    else if (1200 <= r && r < 2800) cout << "ARC" << endl;
    else cout << "AGC" << endl;
    return 0;
}


Measured memory_bytes: 256
def primeFactor(N):
    i = 2
    ret = {}
    n = N
    while i*i <= n:
        k = 0
        while n % i == 0:
            n //= i
            k += 1
        if k: ret[i] = k
        i += 1 + i%2
        if i == 101 and n >= 2**20:
            def findFactorRho(N):
                def gcd(a, b):
                    while b: a, b = b, a % b
                    return a
                def f(x, c):
                    return (x * x + c) % N
                for c in range(1, 99):
                    X, d, j = [2], 1, 0
                    while d == 1:
                        j += 1
                        X.append(f(X[-1], c))
                        X.append(f(X[-1], c))
                        d = gcd(abs(X[2*j]-X[j]), N)
                    if d != N:
                        if isPrimeMR(d):
                            return d
                        elif isPrimeMR(N//d): return N//d
            while n > 1:
                if isPrimeMR(n):
                    ret[n], n = 1, 1
                else:
                    j = findFactorRho(n)
                    k = 0
                    while n % j == 0:
                        n //= j
                        k += 1
                    ret[j] = k

    if n > 1: ret[n] = 1
    return ret

def isPrimeMR(n):
    if n == 2:
        return True
    if n == 1 or n & 1 == 0:
        return False
    d = (n - 1) >> 1
    while d & 1 == 0:
        d >>= 1
    
    L = [2, 7, 61] if n < 1<<32 else [2, 13, 23, 1662803] if n < 1<<40 else [2, 3, 5, 7, 11, 13, 17] if n < 1<<48 else [2, 3, 5, 7, 11, 13, 17, 19, 23, 29]
    for a in L:
        t = d
        y = pow(a, t, n)
        while t != n - 1 and y != 1 and y != n - 1:
            y = (y * y) % n
            t <<= 1

        if y != n - 1 and t & 1 == 0:
            return False
    return True


P = 10**9+7
D = {}
N = int(input())
A = [int(a) for a in input().split()]
t = 0
for a in A:
    t += pow(a, P-2, P)
    pf = primeFactor(a)
    for p in pf:
        if p in D:
            D[p] = max(D[p], pf[p])
        else:
            D[p] = pf[p]
s = 1
for f in D:
    s = (s * pow(f, D[f], P)) % P
print(s * t % P)

Measured memory_bytes: 46172
n,m = map(int,input().split())
k = [0 for _ in range(m)]
s = [[] for _ in range(m)]

for i in range(m):
    x = list(map(int,input().split()))
    k[i] = x[0]
    s[i] = x[1:]
p = list(map(int,input().split()))
t = 0
for i in range(2**n):
    for j in range(m):
        x = 0
        for y in s[j]:
            if(i & 2**(y-1)):x += 1
        if(x%2 != p[j]):break
    else:
        t += 1
print(t)

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    long X, Y;
    cin >> X >> Y;
    long counter = 0;
    for (long i = X; i <= Y;) {
        counter++;
        i *= 2;
    }
    cout << counter << endl;
    return 0;
}

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

#define MX_N 100000
#define LL long long

#define PII pair<int,int>
#define st first
#define nd second

int n;
LL M;
vector<int> graph[MX_N+5];

int parent[MX_N+5];
vector<int> tab[MX_N+5];
vector<LL> pref[MX_N+5], suf[MX_N+5];// veretex's v childs
int locat[MX_N+5];

LL dp1[MX_N+5], dp2[MX_N+5];

void dfs( int v, int p )
{
  dp1[v]=1;
  parent[v]=p;

  for( auto &u : graph[v] )
  {
    if( u==p ) continue;
    dfs(u,v);

    dp1[v]=( dp1[v]*(dp1[u]+1) )%M;
    tab[v].push_back(u);
    locat[u]=tab[v].size();
  }
}

void Count( )
{
  for( int i=1; i<=n; i++ )
  {
    int sz=tab[i].size();

    pref[i].push_back(1);
    for( int j=0; j<sz; j++ )
      pref[i].push_back( (pref[i][j]*( dp1[ tab[i][j] ]+1) )%M );

    suf[i].push_back(1);
    for( int j=sz-1; j>=0; j-- )
      suf[i].push_back( (suf[i][sz-1-j]*( dp1[ tab[i][j] ]+1 ) )%M );
  }
}

queue<PII> kol;
void bfs( int v, int p )
{
  kol.push( {v, p} );
  dp2[v]=1;

  while( !kol.empty() )
  {
    PII u=kol.front();
    kol.pop();

    int sz2=tab[u.st].size();
    for( auto &s : graph[u.st] )
    {
      if( s==u.nd ) continue;
      kol.push( {s,u.st} );

      dp2[s]=( ( ((dp2[u.st]*pref[u.st][ locat[s] -1 ])%M)*suf[u.st][ sz2-locat[s] ] )%M +1 )%M;
      //cout<<"dp2 "<<s<<" = "<<dp2[u.st]<<" * "<<pref[u.st][ locat[s] -1 ]<<" * "<<suf[u.st][sz2-locat[s] ]<<" \n";

    }
  }

}

int main( )
{
  cin>>n>>M;
  for( int i=1; i<n; i++ )
  {
    int a, b; cin>>a>>b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }

  dfs(1,0);

  // cout<<"dp1 :\n";
  // for( int i=1; i<=n; i++ )
  //   cout<<dp1[i]<<" ";
  //
  // cout<<"\n";

  Count( );

  // for( int i=1; i<=n; i++ )
  // {
  //   cout<<"locat : \n";
  //   for( int j=0; j<tab[i].size(); j++ )
  //     cout<<locat[ tab[i][j] ]<<" ";
  //
  //   cout<<"\n";
  //
  //   cout<<"pref dla "<<i<<" \n";
  //   for( int j=0; j<pref[i].size(); j++ )
  //     cout<<pref[i][j]<<" ";
  //
  //   cout<<"\n";
  //   cout<<"suf dla "<<i<<"\n";
  //   for( int j=0; j<suf[i].size(); j++ )
  //     cout<<suf[i][j]<<" ";
  //   cout<<"\n \n";
  // }

  bfs(1,0);

  // cout<<"dp2 :\n";
  // for( int i=1; i<=n; i++ )
  //   cout<<dp2[i]<<" ";
  //
  // cout<<"\n";

  for( int i=1; i<=n; i++ )
    cout<<( dp1[i]*dp2[i] )%M<<"\n";
}


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

int main() {
  int N;
  cin>>N;
  vector<int64_t> S(87);
  S.at(0)=2;
  S.at(1)=1;
  for(int i=2; i<87;i++){
    S.at(i)=S.at(i-1)+S.at(i-2);
  }
  cout<<S.at(N);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll n,m,q;
ll a[50],b[50],c[50],d[50];
ll maxi=0;
vector<ll>v;
void dfs(ll x,ll c1)
{
    if(c1==n)
    {
        ll s=0;
        for(ll i=0;i<q;i++)
        {
            if(v[b[i]-1]-v[a[i]-1]==c[i])
                s+=d[i];
        }
        maxi=max(maxi,s);
        return;
    }
    for(ll i=x;i<=m;i++)
    {
        v.push_back(i);
        dfs(i,c1+1);
        v.pop_back();
    }
}
int main()
{
    cin>>n>>m>>q;
    for(ll i=0;i<q;i++)
    {
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    dfs(1,0);
    cout<<maxi;
}

Measured memory_bytes: 3592
#include<stdio.h>
int main()
{
    int x,i,n;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        x=i;
        if(x%3==0){
            printf(" %d",i);
        }
        else if(x % 10 == 3) {
            printf(" %d",i);
        }
        else {
            while(x!=0){
                x /=10;
                if(x % 10 == 3){
                    printf(" %d",i);
                    break;
                  }
            }
        }
    }
    printf("\n");
    return 0;
}



Measured memory_bytes: 2084
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//gcdlcm, isPrime, eratos, divisor, modinv, bitSearch, bitList, dfs, bfs//
//dijkstra, UnionFind, COM, digitDP//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z;
ll MOD = 1000000007; ll INF = 9999999999999; ll ans = INF;
vl flag, color, D; vll path;
//***********//
int main() {
	cin >> N;
	for (i = 1; i <= 9; i++) {
		if (N <= i * 111) {
			cout << i * 111;
			exit(0);
		}
	}
}

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

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

int main() {
    ll a;
    long double b;
    cin >> a >> b;
    ll b1 = b;
    long double b2 = (b - b1) * 100;
    // cout << a * b2 << endl;


    ll ans = a * b1 + (a * b2) / 100;
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 3744
#pragma GCC optimize ("Ofast")
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
#define int long long int
#define pb push_back
#define fi first
#define se second
#define deb cerr << "Line no." << __LINE__
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
#define sz(x) (int)x.size()
const int mod = 1e9 + 7;
const int mod1 = 998244353;
typedef long double f80;
#ifndef LOCAL
#define endl '\n'
#endif

template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
	uniform_int_distribution<int> uid(l, r);
	return uid(rng);
}
int pwr(int a,int b){
	int ans = 1;
	while(b){
		if(b & 1) ans = (ans * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ans;
}
queue<int> q;
const int N = 1e5 + 5;
vector<int> g[N];
int dp[N];
bool vis[N];
int go(int u){
	if(vis[u]) return dp[u];
	dp[u] = 0;
	vis[u] = 1;
	for(int v : g[u]){
		dp[u] = max(dp[u], go(v) + 1);
	}
	return dp[u];
}
void solve(){
	int n, m;
	cin >> n >> m;
	fr(i, 1, m){
		int u, v;
		cin >> u >> v;
		g[u].pb(v);
	}
	int ans = 0;
	fr(i, 1, n){
		ans = max(ans, go(i));
	}
	cout << ans;
}
signed main(){
  	IO;
  	#ifdef LOCAL
		freopen("inp.txt","r", stdin);
		// freopen("out.txt", "w", stdout);
	#endif
 	clock_t clk = clock();
  	int t = 1;
  	// cin >> t;
  	fr(tt, 1, t){
    	solve();
  	}
  	cerr << endl << (double)(clock() - clk) / CLOCKS_PER_SEC;
  	return 0;
}

Measured memory_bytes: 7808
from collections import deque
import copy

swap = [[1, 4], [0, 2, 5], [1, 3, 6], [2, 7], [0, 5], [1, 4, 6], [2, 5, 7], [3, 6]]


def bfs():
    ia = list(range(8))
    count = {str(ia): 0}
    que = deque()
    que.append((ia, 0))
    while len(que) != 0:
        state, cnt = que.popleft()
        # pos:0?????????
        pos = state.index(0)
        swap_target = swap[pos]
        for i in swap_target:
            tmp_state = copy.copy(state)
            tmp_state[i], tmp_state[pos] = tmp_state[pos], tmp_state[i]
            if str(tmp_state) not in count:
                count[str(tmp_state)] = cnt + 1
                que.append((tmp_state, cnt + 1))
    return count


if __name__ == '__main__':
    count = bfs()
    while True:
        try:
            prob = list(map(int, input().split()))
            print(count[str(prob)])
        except:
            break

Measured memory_bytes: 10856
#include <bits/stdc++.h>
using namespace std;
using vec_int = vector<int>;
using P = pair<int,int>;
using T = tuple<int,int,int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846


int main(){

     double A, B, H, M; cin>>A>>B>>H>>M;

    double angle_A = 2*PI*(H+M/60.)/12;
    double angle_B = 2*PI*(M/60.);


    double distance = sqrt(pow((A*cos(angle_A)-B*cos(angle_B)),2)+pow((A*sin(angle_A)-B*sin(angle_B)),2));
//    cout << distance<<endl;
    printf("%.10lf\n",distance);



}

Measured memory_bytes: 4088
#include "bits/stdc++.h"
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
ll int MOD=998244353;
#define INF (ll)1e16
#define N 310000
 
using namespace std;
string alphabet("abcdefghijklmnopqrstuvwxyz");

main(){
    ll int a[N]={};
    ll int n;
    cin>>n;
    rep(i,n){
        cin>>a[i];
    }
    pair<ll,ll> b[N]={};
    ll int pos=0; b[pos].first=0;b[pos].second=0;
    ll int ans[N]={},ruiseki[N]={};
    rep(i,n){
        if(b[pos].first<a[i]){
            pos++;b[pos].first=a[i];b[pos].second=i+1;
        }
        pair<ll,ll> p={a[i],0};
        ll int t=lower_bound(b,b+pos,p)-b;
        ans[b[t].second]+=a[i]-b[t-1].first;
        ruiseki[1]++;ruiseki[t]--;
    }
    rep2(i,1,pos){
        ruiseki[i]+=ruiseki[i-1];
        ans[b[i].second]+=ruiseki[i]*(b[i].first-b[i-1].first);
    }
    rep2(i,1,n){
        cout<<ans[i]<<endl;
    }

}


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

int main() {
  int a,b;
  cin >> a >> b;
  int x = (a + b) % 2;
  
  if (x == 0) {
    cout << (a + b) / 2 << endl;
  }
  else {
    cout << (a + b) / 2 + 1 << endl;
  }
}


Measured memory_bytes: 256
t=int(input())
a=[int(i) for i in input().split()]
b=[int(i) for i in input().split()]
c=[int(i) for i in input().split()]
s=[]
for i in range(t):
    if i==0:
        s.append(b[a[i]-1])
    else:
        if a[i]-a[i-1]==1:
            su=b[a[i]-1]+c[a[i]-2]
            s.append(su)
        else:
            s.append(b[a[i]-1])
print(sum(s))
            



Measured memory_bytes: 3064
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define MAX 100000
#define INF 2140000000
#define MOD 1000000007

int main() {
	int n;
	cin >> n;
	vector<int> w(n);

	for (int i = 0; i < n; ++i) {
		cin >> w[i];
	}

	int ans = INF;

	for (int i = 0; i < n - 1; ++i) {
		int s1 = 0, s2 = 0;

		for (int j = 0; j <= i; ++j) {
			s1 += w[j];
		}

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

		ans = min(ans, abs(s2 - s1));
	}

	cout << ans << endl;

	return 0;
}

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

struct Point {
    int x, y, id;
};

struct KDTree {

    vector<Point>& points;

    KDTree(vector<Point>& points) : points(points) {
        build(0, points.size() - 1, 0);
    }

    void build(int left, int right, int depth) {
        if (left > right) return;

        int axis = depth % 2;
        if (axis == 0) sort(points.begin() + left, points.begin() + right + 1, [](const auto& p1, const auto& p2) { return p1.x < p2.x; });
        else sort(points.begin() + left, points.begin() + right + 1, [](const auto& p1, const auto& p2) { return p1.y < p2.y; });
        int mid = (left + right) / 2;
        build(left, mid - 1, depth + 1);
        build(mid + 1, right, depth + 1);
    }

    int check_position(Point& point, Point& start, Point& end, int axis) {
        if (axis == 0) {
            if (start.x <= point.x && point.x <= end.x) return 0;
            if (point.x < start.x) return -1;
            return 1;
        } else {
            if (start.y <= point.y && point.y <= end.y) return 0;
            if (point.y < start.y) return -1;
            return 1;
        }
    }

    vector<int> search(Point& start, Point& end) {
        Point s {min(start.x, end.x), min(start.y, end.y)};
        Point t {max(start.x, end.x), max(start.y, end.y)};
        vector<int> res;
        search_rec(s, t, res, 0, points.size() - 1, 0);
        return res;
    }

    void search_rec(Point& start, Point& end, vector<int>& res, int left, int right, int depth) {
        if (left > right) return;

        int axis = depth % 2;
        int mid = (left + right) / 2;
        bool contained = true;
        for (int i = 0; i < 2; i++) contained &= check_position(points[mid], start, end, i) == 0;
        if (contained) res.push_back(points[mid].id);
        if (left == right) return;
        int pos = check_position(points[mid], start, end, axis);
        if (pos != -1) search_rec(start, end, res, left, mid - 1, depth + 1);
        if (pos != 1) search_rec(start, end, res, mid + 1, right, depth + 1);
    }
};

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

    int n;
    cin >> n;
    vector<Point> points(n);
    for (int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        points[i] = {x, y, i};
    }
    KDTree kd_tree(points);
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int sx, tx, sy, ty;
        cin >> sx >> tx >> sy >> ty;
        Point s {sx, sy}, t {tx, ty};
        auto res = kd_tree.search(s, t);
        sort(res.begin(), res.end());
        for (int x : res) cout << x << '\n';
        cout << endl;
    }
}


Measured memory_bytes: 8452