akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
#define ll                  long long int
#define ull                 unsigned long long int
#define ld                  long double
#define fi                  first
#define se                  second
#define pb                  push_back
#define pbb                 pop_back
#define mp                  make_pair
#define pii     	        pair<int,int>
#define all(x)              x.begin(), x.end()
#define uniq(x)             x.erase(unique(x.begin(),x.end()),x.end())
#define mem(array, value)   memset(array, value, sizeof(array))
#define lcm(a,b)            (abs(a)/gcd(a,b))*abs(b)
#define PI      	        2*acos(0.0)
#define INF     	        1e9
#define EPS     	        1e-8
#define line                cout << "\n==========\n"
#define fastRead 	        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> orderedSet; 

const int N = 3000;
double p[N];
double dp[N][N];
bool visit[N][N];
int n;

double call(int idx, int cnt)
{
    if (idx >= n){
        return cnt > n/2 ? 1.0 : 0.0;
    }
    if (visit[idx][cnt]){
        return dp[idx][cnt];
    }
    visit[idx][cnt] = true;
    double res1 = 1.0;
    double res2 = 1.0;
    double res = 0.0;
    res1 *= call(idx+1, cnt+1) * p[idx];
    res2 *= call(idx+1, cnt) * (1 - p[idx]);
    res = res1 + res2;
    return dp[idx][cnt] = res;
}

int main ()
{
    #ifdef Lollipop
    //freopen ("input.txt", "r", stdin);
    //freopen ("output.txt", "w", stdout);
    #endif
    
    mem(visit, false);
    
    cin >> n;
    for (int i = 0; i<n; i++){
        cin >> p[i];
    }
    cout << setprecision(10) << call(0, 0) << endl;
    
    return 0;
}




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

int main(){
  int n,l;
  cin >> n >> l;
  int L = l;
  int R = l+n-1;
  int sum = n*(L+R)/2;
  int eat;
  if(L > 0) eat = L;
  else if(R < 0) eat = R;
  else eat = 0;
  cout << sum - eat << endl;	  
  return 0;
}

Measured memory_bytes: 256
fn main() {
    let n = read::<usize>();
    let d = read_vec::<i64>();

    let mut prepared = std::collections::HashMap::new();
    for num in d {
        *prepared.entry(num).or_insert(0) += 1;
    }

    let m = read::<usize>();
    let t = read_vec::<i64>();

    for tnum in t {
        if !prepared.contains_key(&tnum) {
            println!("NO");
            return;
        }
        if prepared[&tnum] == 0 {
            println!("NO");
            return;
        }
        *prepared.get_mut(&tnum).unwrap() -= 1;
    }
    println!("YES");
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 12356
#include <iostream>
#include <stdio.h>
#include<vector>
#include<climits>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<functional>
#include <numeric>
#include <map>
using namespace std;
using ll = long long;
ll gcd(ll m,ll n){
  if(n==0)return abs(m);
  return(gcd(n,m%n));
}
void putYN(bool b){
  if(b){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}
int main(){
  int y,m,d;
  scanf("%d/%d/%d",&y,&m,&d);
  if(m<=4){
    cout<<"Heisei"<<endl;
  }else{
    cout<<"TBD"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

#define ll long long int
#define str string
#define ALL(a)  (a).begin(),(a).end()
#define P pair<ll,ll>

using Graph = vector<vector<int>>;

const int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
ll INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Min = INFL, Max = -1;
ll a, b, c, n, sum, A[500010], B[500000], rui[500000], dp[5000];
str S, T, U; bool check = true;	vector<ll> v;



int main() {
	//Code Line
	cin >> a >> b >> c;
	for (int i = c; i <= b; ) {
		if (a <= i && i <= b)sum++;
		i += c;
	}
	cout << sum << endl;


	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const ll MOD = 1e9+7;
/*int dfs(vector<int> &T, vector<int> &C, int i, int sum, int g, int count){
   
}*/

int main(){
  /*
  int n, i, j;
  cin >> n;
  vector<int> A(n);
  rep(i, n) cin >> A[i];
  */
  int n, r;
  string s;
  cin >> s;
  if(s.at(2)==s.at(3)&&s.at(4)==s.at(5)) cout << "Yes" << endl;
  else cout << "No" << endl; 
}


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

using namespace std;

typedef struct{
	double x,y;
}mypear; 

int main(void){
	
	mypear xy[2],q,ans;
	
	while(scanf("%lf,%lf,%lf,%lf,%lf,%lf",
				&xy[0].x,&xy[0].y,&xy[1].x,&xy[1].y,&q.x,&q.y)!=EOF)
		{
		
		double a,b,m1,m2,n1,n2;
	
		a=xy[0].x-xy[1].x;
		b=xy[0].y-xy[1].y;
	
		if(a==0){
			ans.x=xy[1].x-(q.x-xy[1].x);
			ans.y=q.y;
		}
		else if(b==0){
			ans.x=q.x;
			ans.y=xy[1].y-(q.y-xy[1].y);
		}
		else{
			m1=b/a;
			n1=xy[0].y-m1*xy[0].x;
			
			m2=-1/m1;
			n2=q.y-m2*q.x;
			
			ans.x=(n1-n2)/(m2-m1);
			ans.y=m1*ans.x+n1;
			
			ans.x=ans.x*2-q.x;
			ans.y=ans.y*2-q.y;
		}
		printf("%0.6lf %0.6lf\n",ans.x,ans.y);
	}	
}

Measured memory_bytes: 1244
from itertools import product

n = int(input())

d = {}
for i in range(n):
  a = int(input())
  for _ in range(a):
    x, y = map(int, input().split())
    if i + 1 not in d:
      d[i + 1] = []
    d[i + 1].append((x, y))

ret = 0
for x in product((0, 1), repeat=n):
  tmp = [-1] * n
  ok = True
  for i in range(n):
    if x[i] == 1 and i + 1 in d:
      for y in d[i + 1]:
        if tmp[y[0] - 1] == -1:
          tmp[y[0] - 1] = y[1]
        elif tmp[y[0] - 1] != y[1]:
          ok = False
          break
    if not ok:
      break
  if ok and all(a == b or b == -1 for a, b in zip(x, tmp)):
    ret = max(ret, sum(x))

print(ret)

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

#define M_PI       3.14159265358979323846   // pi

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

#define rep(a,n) for(ll a = 0;a < n;a++)

static const ll INF = 1e15;
static const ll mod = 1e9+7;

template<typename T>
static inline void chmin(T& ref, const T  value) {
    if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T& ref, const T value) {
    if (ref < value) ref = value;
}

int main() {
    ll n, m, d;
    cin >> n >> m >> d;
    {
        ull b = n;
        if (d != 0) {
            b = d;
            b += max(0LL, 2 * (n - d - (d + 1 - 1) ));
            b += n - max(d, (n - d + 1 - 1));
        }
        b *= m - 1;
        double ans = (double)b / n / n;
        cout << fixed << setprecision(10);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3760
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <thread>
#include <chrono>
#include <queue>

using namespace std;

int main(void){
	string s;
	string ret;
	cin >> s;
	for(int i=0;i<s.length();i++){
		if(s.at(i)=='0'){
			ret += '0';
		}else if(s.at(i)=='1'){
			ret += '1';
		}else{
			if(!(ret.empty() == true)){
				ret.pop_back();
			}
		}
	}
	
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp(a,b) make_pair(a,b)
#define ff first
#define setp(a) setprecision(a)<<fixed
#define ss second
#define fori(v) for(ll i=0; i<v; i++)
#define forj(v) for(ll j=0; j<v; j++)
#define fork(v) for(ll k=0; k<v; k++)
#define forl(v) for(ll l=0; l<v; l++)
#define fort(v) for(ll t=0; t<v; t++)
#define forz(v) for(ll z=0; z<v; z++)	
#define forx(v) for(ll x=0; x<v; x++)
#define fory(v) for(ll y=0; y<v; y++)
#define ll long long
#define pb(a) push_back(a)
const ll INF = 0x3f3f3f3f;
const ll inf = pow(10,18);
ll modulo = pow(10,9)+7  ;
#define ld long double
#define MAX ((int)pow(10,5) + 10)


void deal(){
	ll n;
	cin>>n;
	map<ll,ll> ans;
	ans[0] = 0;
	vector<vector<ll> > arr(n, vector<ll>(2));
	forj(2)
		fori(n)
			cin>>arr[i][j];
	fori(n){
		ll ed, ai;
		ed = arr[i][0], ai = arr[i][1];
		auto it = ans.lower_bound(ed);
		--it;
		ans[ed] = (*it).ss + ai;
		it = ans.find(ed);
		auto it1 = it;
		++it1;
		while(it1!= ans.end() && (*it).ss >= (*it1).ss)
			ans.erase(it1), it1 = it, ++it1;
	}
	auto it = ans.end();
	--it;
	cout<<(*it).ss;
}
 
int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	deal();
}
 
/*
 
5 1
1 2 3 4 5


*/

Measured memory_bytes: 23680
import Control.Monad
import qualified Data.Vector as V
import qualified Data.List as L

check [] _ = []
check (x:xs) vector
    | V.elem x vector = x : check xs (V.cons x vector) 
    | otherwise       = check xs vector

main = do
    n <- readLn
    s <- replicateM n getLine
    print $ length $ V.uniq $ V.fromList $ L.sort s

Measured memory_bytes: 198504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){
    ll q,h,s,d;cin>>q>>h>>s>>d;
    ll n;cin>>n;
    ll k=min(q*4,min(h*2,s));
    if(k*2<=d){
        cout<<k*n<<endl;
    }else{
        cout<<(n/2)*d+(n%2)*k<<endl;
    }
    
    
    return 0;
}






Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

vector<vector<Int>> graph;
Int N, U;
vector<Int> distFrom0, distFromU;

void dfs(vector<Int>& res, Int now, Int parent, Int dist) {
    res[now] = dist;

    for(auto edge : graph[now]) {
        if (edge == parent) continue;
        dfs(res, edge, now, dist+1);
    }
}

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

    Int N; cin >> N;
    graph.assign(N, vector<Int>());
    distFrom0.assign(N, 0);
    distFromU.assign(N, 0);

    rep(i, 0, N-1) {
        Int A, B; cin >> A >> B;
        --A, --B;
        graph[A].emplace_back(B);
        graph[B].emplace_back(A);
    }

    dfs(distFrom0, 0, -1, 0);
    Int U = distance(distFrom0.begin(), max_element(distFrom0.begin(), distFrom0.end()));
    
    dfs(distFromU, U, -1, 0);
    Int diameter = *max_element(distFromU.begin(), distFromU.end());

    if (diameter % 3 == 1) cout << "Second" << endl;
    else cout << "First" << endl;
}

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



int main()
{
    ll n;
    cin>>n;ll l1[n+1];
    for(int i=1;i<=n;i++){
        cin>>l1[i];
    }
    if(n==1){cout<<l1[1];return 0;}
    ll x=(ll)((ll)(l1[2]/__gcd(l1[1],l1[2]))*l1[1]);
    //cout<<x<<endl;
    for(int i=3;i<=n;i++){
        x=(ll)((ll)(l1[i]/__gcd(x,l1[i]))*x);
    }
    cout<<x;

    return 0;
}


Measured memory_bytes: 256
fn main() {
    let _n: usize = read();
    let sn: Vec<i32> = read_vec();
    let _q: usize = read();
    let tq: Vec<i32> = read_vec();

    let mut ans = 0;
    for t in tq.iter() {
        if sn.binary_search(t).is_ok() {
            ans += 1;
        }
    }    

    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}



Measured memory_bytes: 5040
#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 n, m;
bool f[200000], g[200000];

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

	cin >> n >> m;
	rep(i,m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		if (a == 0) {
			f[b] = true;
		}
		else if (b == n - 1) {
			g[a] = true;
		}
	}
	bool ok = false;
	rep(i,n) {
		if (f[i] && g[i])ok = true;
	}
	cout << (ok ? "POSSIBLE" : "IMPOSSIBLE") << endl;

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
using std::string;

int main(){
  int n;
  int y,m,d;
  cin >> n;

  int summ,sumd;
  summ = 0;
  sumd = 0;
  for(int i = 1;i < 1000;i++){
    summ += 20*10;

    if(i % 3 != 0){
      summ -= 5;
    }
  }
  summ += 1;

  for(int i= 0 ;i < n;i++){
    sumd = 0;
    cin >> y >> m >> d;
    for(int j = 1;j < y;j++){
      sumd += 10*20;

      if(j%3 != 0){
        sumd -= 5;
      }
    }

    if(y % 3 == 0){
      for(int j = 1;j < m;j++){
        sumd += 20;
      }
    }else{
      for(int j = 1;j < m;j++){
        if(j % 2 == 0){
          sumd += 19;
        }else{
          sumd += 20;
        }
      }
    }

    sumd += d;
    cout << summ - sumd << endl;
  }
}

Measured memory_bytes: 3000
# -*- codinf: utf-8 -*-
import math
N = int(input())
# 素因数分解
n = N
i = 2
f = {} # keyが素因数、valueが素因数の数
while i * i <= n:
  count = 0
  while n % i == 0:
    count += 1
    f[i] = count
    n /= i
  i += 1
if 1 < n:
  f[n] = 1

if len(f) == 0:
  print(0)
  exit()

count = 0
for v in f.values():
  d = 1
  while v > 0:
    v -= d
    if v >= 0:
      count += 1
    d += 1
print(count)

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

int main(){
	
	int a,b;
	char op;
	while(cin>>a>>op>>b,op!='?'){
		cout<<(op=='+'?a+b:(op=='-'?a-b:(op=='*'?a*b:a/b)))<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 1160
N,M=map(int,input().split())
den=[0]*M
for i in range(M):
  s=list(map(int,input().split()))[1:]
  for j in range(len(s)):
    num=s[j]-1
    den[i]|=(1<<num)

P=list(map(int,input().split()))

ans=0
for i in range(2**N):
  # ループ一回が各スイッチの状況
  # これに対して、各電球の条件をチェックして、すべての電球が点くかをチェック
  ok=True
  for j in range(len(den)):
    # 電球の条件　例[01001]で1になっているものとスイッチの条件　例：[11001]を
    # 突き合わせて、両方とも1になっているものの数を数える。
    # ＝ANDした数で、いくつ1が立っているかを見る。
    res=i&den[j]
    cnt=0
    while res>0:
      if res&1:
        cnt+=1
      res>>=1
    if cnt%2!=P[j]:
      ok=False
      break
  if ok:
    ans+=1
      
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for(int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
#define pb push_back
typedef long long ll;
const ll INF = 1LL << 60;

vector<vector<ll>> g;
vector<int> visited;
vector<ll> path;

bool dfs(ll v, ll goal){
    visited[v] = 1;
    if(v == goal){return true;}
    for(auto nv : g[v]){
        if(!visited[nv]){
            if(dfs(nv, goal)){
                path.pb(nv);
                return true;
            };
        }
    }
    return false;
}

void dfs_n(ll v){
    visited[v] = 1;
    for(auto nv : g[v]){
        if(!visited[nv]){
            dfs_n(nv);
        }
    }
}

int main()
{
    ll n;
    cin >> n;
    g.resize(n);
    visited.resize(n);
    rep(i,n-1){
        ll a,b;
        cin >> a >> b;
        a--; b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    //path 0 - (n-1)
    dfs(0,n-1);
    reverse(path.begin(),path.end());
    vector<ll> path_;
    path_.pb(0);
    rep(i,path.size()){
        path_.pb(path[i]);
    }
    path = path_;
    //remove critical edge
    ll tmp_e = ceil(((double)path.size())/2);
    g[path[tmp_e]].erase(remove(g[path[tmp_e]].begin(), g[path[tmp_e]].end(), path[tmp_e-1]), g[path[tmp_e]].end());
    g[path[tmp_e-1]].erase(remove(g[path[tmp_e-1]].begin(), g[path[tmp_e-1]].end(), path[tmp_e]), g[path[tmp_e-1]].end());

    //num fennec
    visited.assign(n,0);
    dfs_n(0);
    ll visited_num = 0;
    rep(i,n){
        visited_num += visited[i];
    }
    if(visited_num > n-visited_num){
        cout << "Fennec";
    }else{
        cout << "Snuke";
    }
}

Measured memory_bytes: 14708
#include <iostream>

using namespace std;

int main(){
    string in;
    cin >> in ;
    int flag = -1;
    int cnt = 0;
    for ( int i = 0 ; i < in.length() ; i ++ ) {
        int temp = (in[i] == 'B') ? 1 : 0;
        if ( temp != flag ){
            cnt ++;
            flag = temp;
        }
    }
    cout << cnt - 1 << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int mod=1e9+7;
const int inf=0x3f3f3f3f;
char a[100005];
int main()
{
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    int c;
    for(int i=0; i<m; i++)
    {
        cin>>c;
        n-=c;
    }
    if(n<0)
        cout<<-1<<endl;
    else
        cout<<n;
}



Measured memory_bytes: 3644
#include<stdio.h>

#define INFTY 2000000000
typedef long long llong;

int L[200000/2+2], R[200000/2+2];


llong merge(int* A, int left, int mid, int right){
    llong cnt = 0;
    int n1 = mid - left;
    int n2 = right - mid;
    for(int i=0; i<n1; i++) L[i] = A[left + i];
    for(int i=0; i<n2; i++) R[i] = A[mid + i];
    L[n1] = R[n2] = INFTY;
    int i = 0;
    int j = 0;
    for(int k=left; k<right; k++){
        if(L[i] <= R[j]){
            A[k] = L[i];
            i++;
        }
        else {
            A[k] = R[j];
            j++;
            cnt += n1-i;
        }
    }
    return cnt;
}

llong mergeSort(int* A, int left, int right){
    int mid;
    llong v1, v2, v3;
    if(left + 1 < right){
        mid = (left + right)/2;
        v1 = mergeSort(A, left, mid);
        v2 = mergeSort(A, mid, right);
        v3 = merge(A, left, mid, right);
        return v1 + v2 + v3;
    }else return 0;
}

int main(){

    int n;
    scanf("%d", &n);
    int A[200000];
    for(int i=0; i<n; i++) scanf("%d", &A[i]);

    llong ans = mergeSort(A, 0, n);
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 4292
#include <iostream>
#include <vector>
#include <algorithm>
#define VEC_STR_ITER vector<string>::iterator
#define VEC_INT_ITER vector<int>::iterator

using namespace std;
void joinString(vector<string>& data, string& tar)
{
   VEC_STR_ITER endIter = data.end();
   for(VEC_STR_ITER iter = data.begin(); iter != endIter; ++iter)
   {
     tar += *iter;
   }
}
int main(){
  int N,L;
  cin >> N >> L;
  vector<string> res;
  for(int t=0;t<N;t++)
  {
    string s;
    cin >> s;
    res.push_back(s);
  }
  sort(res.begin(), res.end());
  string ans = "";
  joinString(res, ans);
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()?.toInt() ?: return
    val key = Math.pow(10.0, 9.0) + 7
    var power = 1.0
    for (i in 1..n) {
        power = (power * i) % key
    }
    print(power.toInt())
}

Measured memory_bytes: 33392
#include <cstdio>

int main()
{
	long long n,m; scanf("%lld%lld",&n,&m);
	if(n==1||m==1) printf("1");
	else if(n%2==0||m%2==0) printf("%lld",n*m/2);
	else printf("%lld",n*m/2+1);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;

typedef long double lld;

#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))

ll N, M;
ll A[100010];
ll B[100010], C[100010];
pair<ll, ll> itv[100010];

priority_queue<ll, vector<ll>, greater<ll> > que;

int main()
{
	cin >> N >> M;
	for (ll i = 0; i < N; i++)
	{
		cin >> A[i];
	}
	//デフォで昇順
	sort(A, A + N, greater<>());

	for (ll i = 0; i < M; i++)
	{
		cin >> B[i] >> C[i];
		//C[i]の大きさでソートしたいのでこうする
		itv[i].first = C[i];
		itv[i].second = B[i];
	}
	sort(itv, itv + M, greater<>());

//	for (int i = 0; i < M; i++)
	{
//		cout << itv[i].first << " " << itv[i].second << endl;
	}

	ll ans = 0;
	ll j = 0, k = 0;
	for (ll i = 0; i < N; i++)
	{
		//もうない
		if (k == M)
		{
			ans += A[j];
//			cout << "A[j] = " << A[j] << endl;
			j++;
			continue;
		}

		if (A[j] > itv[k].first)
		{
			ans += A[j];
//			cout << "A[j] = " << A[j] << endl;
			j++;
			
		}
		else
		{
			ans += itv[k].first;
//			cout << "itv[k].first = " << itv[k].first << endl;
			itv[k].second--;
			//もうなくなったらk++
			if (itv[k].second == 0)
			{
				k++;
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h> 
using namespace std;
int main()
{
	set <string> s;
	int n;
	string hhh;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> hhh;
		s.insert(hhh);
	}
	cout << s.size() << endl;
}

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

class Program
{
    int n;
    int[] v, c;
    void Run()
    {
        var sc = new Scanner();
        n = sc.NextInt();
        v = new int[n];
        for (int i = 0; i < n; i++) v[i] = sc.NextInt();
        c = new int[n];
        for (int i = 0; i < n; i++) c[i] = sc.NextInt();

        Console.WriteLine(Dfs(0, 0, 0));
    }

    int Dfs(int index, int x, int y)
    {
        if (index == n) return x - y;
        int max = 0;
        int res;
        res = Dfs(index + 1, x + v[index], y + c[index]);
        if (res > max) max = res;
        res = Dfs(index + 1, x, y);
        if (res > max) max = res;
        return max;
    }

    static void Main(string[] args)
    {
        new Program().Run();
    }
}

class UnionFindTree
{
    private int[] p;
    private int[] d;

    public UnionFindTree(int size)
    {
        p = new int[size];
        d = new int[size];
        for (int i = 0; i < size; i++) p[i] = i;
    }

    public int Find(int x)
    {
        if (p[x] == x) return x;
        return p[x] = Find(p[x]);
    }

    public void Unite(int x, int y)
    {
        int px = Find(x);
        int py = Find(y);
        if (px == py) return;

        if (d[px] < d[py])
        {
            p[px] = py;
        }
        else
        {
            p[py] = px;
            if (d[px] == d[py]) d[px]++;
        }
    }

    public bool Same(int x, int y)
    {
        return Find(x) == Find(y);
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }

    public long NextLong()
    {
        CheckNext();
        return long.Parse(buf[index++]);
    }

    public double NextDouble()
    {
        CheckNext();
        return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}


Measured memory_bytes: 11092
#include <stdio.h>
#include <stdlib.h>

#define MAX 2000001
#define VMAX 10000

int n;

void CountingSort(unsigned short *, unsigned short *, int);

int main(){
  unsigned short *A, *B;
  int i, k = 0;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for(i = 1; i <= n; i++){
    scanf("%d", &A[i]);

    if(k < A[i]) k = A[i];
  }

  CountingSort(A, B, k);


  for(i = 1; i <= n; i++){
    printf("%d", B[i]);

    if(i < n) printf(" ");
    else printf("\n");
  }
  
  return 0;
}


void CountingSort(unsigned short *A, unsigned short *B, int k){
  int i, j, l;
  int C[VMAX];

  for(i = 0; i <= k; i++){
    C[i] = 0;
  }

  for(j = 1; j <= n; j++){
    C[A[j]]++;
  }

  for(i = 1; i <= k; i++){
    C[i] = C[i] + C[i - 1];
  }

  for(j = n; j >= 1; j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
}



Measured memory_bytes: 9560
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
int timeV[1001];
int main(){
    int a, b, n; cin >> a >> b >> n;
    for(int i=0; i<n; ++i){
        int s, f; cin >> s >> f;
        for(int j=s; j<f; ++j) timeV[j]++;
    }
    bool ok=true;
    for(int i=a; i<b; i++){
        if(timeV[i]!=0) ok=false;
    }
    if(ok) cout << 0 << endl;
    else cout << 1 << endl;
    return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
#define all(v) v.begin(), v.end()
const int INF = 1 << 30;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }
//ミョ(-ω- ?)
int main() {
    int n;cin >> n;
    vector<ll> a(n,9);
    rep(i,n)cin >> a[i];
    ll res = 0;
    for(ll i = 0;i < n;i++){
        for(ll j = i+1;j < n;j++){
            for(ll k = j + 1;k < n;k++){
                ll p = max({a[i],a[j],a[k]});
                ll q = min({a[i],a[j],a[k]});
                ll r = a[i]+a[j]+a[k] - p - q;
                if(p == q || q == r || r == p)continue;
                if(p < q + r){
                    res++;
                }
            }
        }
    }
    cout << res << "\n";
    return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;
const int MOD = 1e9 + 7;

/*
    nCk : combination ,O(1)
*/
vector<long long> fact, fact_inv, inv;
void init_nCk(int SIZE)
{
    fact.resize(SIZE + 5);
    fact_inv.resize(SIZE + 5);
    inv.resize(SIZE + 5);
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < SIZE + 5; i++)
    {
        fact[i] = fact[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
    }
}
long long nCk(int n, int k)
{
    assert(!(n < k));
    assert(!(n < 0 || k < 0));
    return fact[n] * (fact_inv[k] * fact_inv[n - k] % MOD) % MOD;
}

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

    ll ans = 0;
    init_nCk(n);
    rep(i, n)
    {
        if (i > k)
            break;
        ans += (nCk(n, i) * nCk(n - 1, i)) % MOD;
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7868
#include <stdio.h>
#define N 100000
#define M 50000
int main(){
  int i,j,left,right,mid,n,length,count=0,A[N],B[M];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  scanf("%d",&length);
  for(j=0;j<length;j++){
    scanf("%d",&B[j]);
  }
  
  for(i=0;i<length;i++){
    left=0;
    right=n;
    while(left<right){
      mid=(right+left)/2;
      if(B[i]==A[mid]){
	count++;
	break;
      }
      if(B[i]>A[mid]){
	left=mid+1;
      }
      else if(B[i]<A[mid]){
	right=mid;
      }
    }
    
      
  }
  
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 1184
import std.stdio;
import std.range;
import std.array;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.container;
import std.typecons;
import std.random;
import std.csv;
import std.regex;
import std.math;
import core.time;
import std.ascii;
import std.digest.sha;
import std.outbuffer;

void main()
{
	auto _ = readln.chomp.split.map!(to!long);
	long n = _.front;
	long m = _.back;
	/+
	enum ofs = [
		[-1, -1], [0, -1], [1, -1],
		[-1, 0], [0, 0], [1, 0],
		[-1, 1], [0, 1], [1, 1]
	];
	bool[][] field = new bool[][](n, m);
	auto f = (int x, int y) {
		return x < 0 || m <= x
				|| y < 0 || n <= y;
	};
	foreach (i; 0..n) {
		foreach (j; 0..m) {
			foreach (d; ofs) {
				int nx = cast(int)j + d[0];
				int ny = cast(int)i + d[1];
				if (f(nx, ny)) {
					continue;
				}
				field[ny][nx] = !field[ny][nx];
			}
		}
	}
	foreach (i; 0..n) {
		foreach (j; 0..m) {
			if (field[i][j]) {
				"o".write;
			} else {
				"x".write;
			}
		}
		writeln;
	}
	+/
	if (n == 1 && m == 1) {
		1.writeln;
	} else if (min(n, m) == 1) {
		writeln(max(0, max(n, m) - 2));
	} else {
		writeln = n * m - 2 * n - 2 * m + 4;
	}
}


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


void solve(std::string s){
    ll n = s.length();
    for(ll i=0; i< n; i++){
        if(i%2==0) cout << s.at(i);
    }
    cout << endl;
}

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


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

using namespace std;

string s[10];
bool u[10][10];

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

    for (int i = 0; i < n; i++)
        cin >> s[i];

    int i = 0, j = 0;
    while (1){
        u[i][j] = 1;
        if (i > 0 && !u[i - 1][j] && s[i - 1][j] == '#'){
            cout << "Impossible\n";
            return 0;
        }
        if (j > 0 && !u[i][j - 1] && s[i][j - 1] == '#'){
            cout << "Impossible\n";
            return 0;
        }

        int cnt = 0;
        if (i < n && !u[i + 1][j] && s[i + 1][j] == '#')
            cnt++;
        if (j < m && !u[i][j + 1] && s[i][j + 1] == '#')
            cnt++;
        if (cnt == 0)
            break;
        if (cnt > 1){
            cout << "Impossible\n";
            return 0;
        }
        if (i < n && !u[i + 1][j] && s[i + 1][j] == '#'){
            i++;
            continue;
        }

        j++;
        continue;
    }

    for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
    if (s[i][j] == '#' && !u[i][j]){
        cout << "Impossible\n";
    }

    cout << "Possible\n";
    return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define Check system("pause")
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)

int a[200005],b[200005];

int main()
{
	ios::sync_with_stdio(false);
	int n,k,w,t;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	while(k--)
	{
		for(int i=1;i<=n;i++)
		{
			b[max(1,i-a[i])]+=1;
			b[min(n+1,i+a[i]+1)]-=1;
		}
		w=t=0;
		for(int i=1;i<=n;i++)
		{
			w+=b[i];
			a[i]=w;
			b[i]=0;
			if(a[i]!=n)
			t=1;
		}
		if(!t) break;
	}
	for(int i=1;i<=n;i++)
	cout<<a[i]<<' ';
	return 0;
}




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

#define null               ""
#define endl               '\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, fr, to)    for (int i = fr; 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;

int n, cnt, mn = 1e9;
num ans;

int inline read() {
    int f = 1, res = 0;
    char c = getchar();
    for (; !isdigit(c); f = c == 45 ? -1 : 1, c = getchar());
    for (; isdigit(c); res *= 10, res += c ^ 48, c = getchar());
    return f * res;
}

int main() {
    ios_base::sync_with_stdio(0);
    n = read();
    cont (i, n) {
        int cur = read();
        ans += abs(cur);
        mn = min(mn, abs(cur));
        cnt += cur < 0;
    }
    ans -= mn * (cnt & 1) * 2;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
  string  a,b;
  cin >> a>> b;
  if(a=="H"){
    if(b=="H") cout <<"H"<<endl;
    else cout <<"D"<<endl;
  }
  else{
    if(b=="H") cout <<"D"<<endl;
    else cout <<"H"<<endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ld long double
#define mx 200005
#define fr first
#define se second
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

int dp[3005][3005];
int N,m;
vector < pair<int,int> > v;
int func(int n, int times)
{
    if(times<=0) return 0;
    if(n>=N) return 0;
    if(dp[n][times]!=-1) return  dp[n][times];
    int ans1=0,ans2=0;
    ans1 += func(n+1,times-v[n].fr)+v[n].se;
    ans2 += func(n+1,times);

    return dp[n][times] = max(ans1,ans2);

}

bool cmp(pair <int,int> &p1, pair<int,int> &p2)
{
    if(p1.fr<p2.fr) return 1;
    if(p1.fr == p2.fr){
        if(p1.se > p2.se) return 1;
    }
    return 0;
}

int main()
{
   fast;
   memset(dp,-1,sizeof dp);
   cin >> N >> m;
   for(int i=0; i<N; i++){
      int k1,k2;
      cin >> k1 >> k2;
      v.pb({k1,k2});
   }
   sort(v.begin(),v.end(),cmp);
//   puts("");
//   for(int i=0; i<N; i++) cout << v[i].fr << " " << v[i].se << "\n";
   cout << func(0,m) << "\n";

   return 0;
}


Measured memory_bytes: 35712
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    vector<int> c1(n, 0), c2(n, 0);
    rep(i, n - 1)
    {
        if (i % 2 == 0)
            c1[i]++, c1[i + 1]--, c2[i]--, c2[i + 1]++;
        else
            c1[i]--, c1[i + 1]++, c2[i]++, c2[i + 1]--;
    }
    sort(all(c1));
    sort(all(c2));
    int res1 = 0, res2 = 0;
    rep(i, n)
    {
        res1 += a[i] * c1[i];
        res2 += a[i] * c2[i];
    }
    cout << max(res1, res2) << endl;
}

Measured memory_bytes: 2560
from collections import deque
def sol():
    n=int(input())
    d=[-1]*n
    l=deque([])
    for i in range(n-1):
        u,v,w=map(int,input().split())
        u,v=min(u,v),max(u,v)
        l.append((u-1,v-1,w))
    f=0
    while len(l):
        x=l.popleft()
        if f:
            if x[2]%2 and d[x[0]]==0:
                d[x[1]]=1
            elif x[2]%2 and d[x[0]]==1:
                d[x[1]]=0
            elif x[2]%2==0 and d[x[0]]==1:
                d[x[1]]=1
            elif x[2]%2==0 and d[x[0]]==0:
                d[x[1]]=0
            elif x[2]%2 and d[x[1]]==0:
                d[x[0]]=1
            elif x[2]%2 and d[x[1]]==1:
                d[x[0]]=0
            elif x[2]%2==0 and d[x[1]]==1:
                d[x[0]]=1
            elif x[2]%2==0 and d[x[1]]==0:
                d[x[0]]=0
            else:
                l.append(x)
        else:
            f=1
            if x[2]%2:
                d[x[0]]=0
                d[x[1]]=1
            else:
                d[x[0]]=0
                d[x[1]]=0
    for i in d:
        print(i)

if __name__=="__main__":
    sol()


Measured memory_bytes: 149080
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
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;
}
//今見てる頂点、親の頂点が欲しい
void dfs(vector<vector<ll>>& adj,vector<ll>& cnt,ll now,ll par,ll add){
    cnt[now] += add;
    for(auto next:adj[now]){
        if (next == par) continue;
        else
            dfs(adj, cnt, next, now,cnt[now]);
    }
}
int main(){
ll n,q;
cin >> n >> q;
vector<vector<ll>> adj(n);
for (ll i = 0; i < n - 1; i++){
    ll a, b;
    cin >> a >> b;
    a--;
    b--;
    adj[a].push_back(b);
    adj[b].push_back(a);
}
vector<ll> cnt(n, 0);
for (ll i = 0; i < q;i++){
    ll p, x;
    cin >> p >> x;
    p--;
    cnt[p] += x;
}
dfs(adj, cnt, 0, -1, 0);
for (ll i = 0; i < n-1; i++) {
    cout << cnt[i] << " ";
}
cout << cnt[n - 1] << endl;
}

Measured memory_bytes: 30464
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;



#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)
#define MP(a,b) make_pair(a,b)

ll debugFlag = false;
template<typename T> void debug(T&);
template<typename T> void debug(T&, bool);
template<typename T> void debug(vector<T>&);
template<typename T> void debug(vector<T>&, bool);
template<typename T, typename U> void debug(pair<T, U>&);
template<typename T, typename U> void debug(pair<T, U>&, bool);

template<typename T>
void debug(T& obj) {
	debug(obj, true);
}

template<typename T>
void debug(T& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << obj;
	if (lnFlag) cout << endl;
}

template<typename T>
void debug(vector<T>& obj) {
	debug(obj, true);
}

template<typename T>
void debug(vector<T>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "[";
	rep(i, obj.size()) {
		if (i != 0) cout << ",";
		debug(obj[i], false);
	}
	cout << "]";
	if (lnFlag) cout << endl;
}

template<typename T, typename U>
void debug(pair<T, U>& obj) {
	debug(obj, true);
}

template<typename T, typename U>
void debug(pair<T, U>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "(";
	debug(obj.first, false);
	cout << ",";
	debug(obj.second, false);
	cout << ")";
	if (lnFlag) cout << endl;
}

void solve() {
	
	unsigned ll T1, T2, A1, A2, B1, B2;
	cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;

	if ((A1 > B1 && A2 > B2) || (A1 < B1 && A2 < B2)) {
		cout << 0;
		return;
	}
	if (T1*(A1 - B1) + T2 * (A2 - B2) == 0) {
		cout << "infinity";
		return;
	}
	if ((T1*A1 < T1*B1) == (T1*A1 + T2*A2 < T1*B1 + T2*B2)) {
		cout << 0;
		return;
	}

	if (A1 > B1) {
		unsigned ll tmp = A1;
		A1 = B1;
		B1 = tmp;
		tmp = A2;
		A2 = B2;
		B2 = tmp;
	}

	unsigned ll SA = T1 * (B1 - A1);
	unsigned ll SA2 = T1 * (A1 - B1) + T2 * (A2 - B2);

	if (SA%SA2 == 0) {
		cout << SA / SA2 * 2;
	}
	else {
		cout << SA / SA2 * 2 + 1;
	}

}


int main(int argc, char* argv[]) {
	if (argc == 2 && string(argv[1]) == "debug") debugFlag = true;
	solve();
	return 0;
}


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

int main()
{
    ll n;
    cin >> n;
    ll m;
    vector<ll> data(n);
    vector<ll> ans(n);
    rep(i, n) cin >> data[i];
    for (int i = n; i > 0; i--)
    { //n〜1までの倍数を調べていく
        //ただし、全探索を愚直にしてしまってもギリギリいけそう
        if (2 * i > n)
        {
            ans[i - 1] = data[i - 1];
            continue;
        }
        ll count = 0;
        for (int j = 2; j * i <= n; j++)
        {
            count += ans[j * i - 1];
        }
        if (count % 2 == data[i - 1])
        {
            ans[i - 1] = 0;
        }
        else
        {
            ans[i - 1] = 1;
        }
    }
    for (int x : ans)
    {
        if (x == 1)
        {
            m++;
        }
    }
    cout << m << endl;
    for (int i = 0; i < ans.size(); i++)
    {
        if (ans[i] == 1)
        {
            cout << i + 1<<" ";
        }
    }
}


Measured memory_bytes: 3968
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
using namespace std;

int main(){
	long long n,k;
	cin >> n >> k;
	vector<pair<long long,long long>> pa(n);

	long long first,second;
	for(long long i=0;i<n;i++){
		cin >> pa[i].first >> pa[i].second;
	}
	
	sort(pa.begin(),pa.end());
	
	long long sum=0;
	for(long long i=0;i<n;i++){
		sum+=pa[i].second;
		if(sum>=k){
			cout << pa[i].first << endl;
			return 0;
		}
	}
}


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

int main() {
  int n,m;cin>>n>>m;
  vector<int> h(n);
  vector<bool> vec(n,true);
  rep(i,n)cin>>h[i];
  rep(i,m){
    int a,b;cin>>a>>b;
    a--;b--;
    if(h[a]<=h[b])vec[a]=false;
    if(h[b]<=h[a])vec[b]=false;
  }
  int cnt=0;
  rep(i,n){
    if(vec[i])cnt++;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 3800
#include<iostream>
using namespace std;
int main() {
	int a, b;
	for (int h = 0;; h++)
	{
		cin >> a >> b;
		if (a != 0)
		{
			for (int i = 0; i < a; i++) {

				for (int j = 0; j < b; j++)
				{
					if ((i + j) % 2 == 0)
					{
						cout << "#";
					}
					else { cout << "."; }
					if(j==b-1)
						cout<<endl;
				}
			}
			cout << endl;
		}
		else
		{
			break;
		}

	}
	return 0;
}

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

int main() {
    char input[10001] = "";
    while (cin >> input) {
        int joi = 0, ioi = 0;
        for (int i = 2; input[i] != '\0'; i++) {
            if (input[i - 1] == 'O' && input[i] == 'I') {
                switch (input[i - 2]) {
                case 'J':
                    joi++;
                    break;
                case 'I':
                    ioi++;
                    break;
                }
            }
        }
        cout << joi << endl
             << ioi << endl;
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())
#define sortdown(V) sort(V.rbegin(), V.rend())
#define MOD 998244353 //1000000007

ll gcd(ll A, ll B){
    if(A<B) swap(A,B);
    while(B){
        ll w = A%B;
        A = B;
        B = w;
    }
    return A;
}

ll lcm(ll A, ll B){return A*B/gcd(A,B);}

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

    // solution comes here

    string S;
    ll N, K, i;
    cin >> S >> K;
    N = S.size();
    bool ans1=true;
    for(i=0; i<K and i<N; i++) {
        if(S[i]!='1') {
            ans1=false;
            break;
        }
    }
    if(ans1) cout << ans1 << nl;
    else cout << S[i] << nl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define p(s) cout<<(s)<<endl
#define REP(i,n,N) for(int i=n;i<N;i++)
#define RREP(i,n,N) for(int i=N-1;i>=n;i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define F first
#define S second
typedef long long ll;
using namespace std;
const ll inf = 1e18;

ll N;
ll a[200010];
set<ll> s;
ll ans;
int main(){
    cin>>N;
    REP(i,0,N) {
        int A;
        cin>>A;
        a[A] = i+1;
    }
    s.insert(0);
    s.insert(N+1);

    for(ll i=1; i<N+1; i++){
        s.insert(a[i]);
        auto l = s.find(a[i]);
        auto r = l;
        l--;
        r++;
        ans += (a[i]-*l)*(*r-a[i])*i;
    }
    p(ans);
    return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int memo[10][10];

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

  REP(i, 1, 10) REP(j, 1, 10) {
    int cnt = 0;
    rep(k, n + 1) {
      if (k % 10 == 0) continue;
      int a = k % 10;
      int b = k;
      while (b >= 10) b /= 10;
      if (i == b && j == a) cnt++;
    }
    memo[i][j] = cnt;
  }

  ll ans = 0;
  rep(i, n + 1) {
    if (i % 10 == 0) continue;
    int a = i % 10;
    int b = i;
    while (b >= 10) b /= 10;
    ans += memo[a][b];
  }

  cout << ans << endl;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



double r;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    const double pi = 3.14159265359;
    cin>>r;
    double ans = 2.0*pi*r;
    cout<<fixed<<setprecision(9)<<ans<<endl;
  

    return 0;
}


Measured memory_bytes: 3780
#include<stdio.h>

int main(void)
{
  int takasa[10];
  int i;
  int a = 0, b = 0, c = 0;
  int temp;

  for(i = 0; i < 10; i++){
    scanf("%d", &takasa[i]);
    if(takasa[i] > a){
      temp = a;
      a = takasa[i];
      c = b;
      b = temp;

    }else if(takasa[i] > b){
      temp = b;
      b = takasa[i];
      c = temp;
    }else if(takasa[i] > c)
      c = takasa[i];
  }

  printf("%d\n%d\n%d\n", a, b, c);

  return 0;
}

Measured memory_bytes: 600
"""
実際にN!を計算するわけには行かない。
memo[n] => nの素因数分解の結果

sum(memo[N])の素因数分解の結果から
"""
from collections import Counter
N = int(input())
memo = [None]*(N+1)

for i in range(2,N+1):
    tmp = []
    n = i
    d = 2
    while n!=1:
        while n%d==0:
            tmp.append(d)
            n//=d
        d += 1
    memo[i] = Counter(tmp)

count = Counter([])
for i in range(2,N+1):
    count += memo[i]

ans = 0
#数が74個以上ある素因数の数
c74 = 0
#数が24個以上ある素因数の数
c24 = 0
#数が14個以上ある素因数の数
c14 = 0
#数が4個以上ある素因数の数
c4 = 0
#数が2個以上ある素因数の数
c2 = 0

for v in count.values():
    if v >= 2:
        c2 += 1
    if v >= 4:
        c4 += 1
    if v >= 14:
        c14 += 1
    if v >= 24:
        c24 += 1
    if v >= 74:
        c74 += 1

ans += c74
ans += c24 * (c2-1)
ans += (c4*(c4-1))//2 * (c2-2)
ans += c14 * (c4-1)


"""
#1つの素因数で75数を形成できるパターンをみつける
for k,v in count.items():
    if v >= 74:
        ans += 1
    
#2つの素因数(a,b)で3,25のパターンで、75数を形成できるパターンを見つける
for k,v in count.items():
    if v >= 24:
        for k2,v2 in count.items():
            if k2 != k and v2 >= 2:
                ans += 1

#2つの素因数(a,b)で5,15のパターンで、75数を形成できるパターンを見つける
for k,v in count.items():
    if v >= 14:
        for k2,v2 in count.items():
            if k2 != k and v2 >= 4:
                ans += 1

#2つの素因数(a,b)で3,25のパターンで、75数を形成できるパターンを見つける
for k,v in count.items():
    if v >= 4:
        for k2,v2 in count.items():
            if k2 != k and v2 >= 4:
                for k3,v3 in count.items():
                    if k3 != k and k3!=k2 and v3 >= 2:
                        ans += 1
"""

print(ans)



Measured memory_bytes: 67828