akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <algorithm> // sort
#include <map> // pair
using namespace std;

int main(){
  int N,M;
  cin >> N >> M;
  vector<long long int> f(N + 1,0);
  vector<int> a(M + 1,0);

  for(int i = 0;i < M;i++){
    cin >> a[i];
  }
  
  long long int temp1,temp2; 
  int j = 0;

  f[0] = 1;
  temp1 = f[0];
  temp2 = 0;

  for(int i = 1;i < N + 1;i++){
    //f[i] がaと一致しない場合は行う
    if(i != a[j]){
      f[i] = temp1 + temp2;
    }else{
      j++;
    }
    temp2 = f[i - 1];
    temp1 = f[i];
    f[i] %= 1000000007;
  }

  cout << f[N] << endl;
}


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

typedef long long ll;

const int mod = 1000000007;
struct mint {
  ll x; 
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

bool is_prime(int x) {
    if(x<=1) return false;
    for(int i=2;i*i<=x;i++){
        if(x%i==0) return false;
    }
    return true;
}

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

    int n; cin >> n;
    mint ans = 1;
    for(int i=2;i<=n;i++){
        if(is_prime(i)){
            int cnt = 0;
            for(int j=2;j<=n;j++){
                int now = j;
                while(now>0){
                    if(now%i==0) cnt++;
                    else break;
                    now /= i;
                }
            }
            ans *= cnt + 1;
        }
    }
    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
a, b, c, x, y = gets.split.map(&:to_i)

ans = 0

if a >= 2 * c && b >= 2 * c
  ans = [x, y].max * 2 * c
  x = y = 0
elsif a >= 2 * c
  ans += x * 2 * c
  y -= x
  x = 0
elsif b >= 2 * c
  ans += y * 2 * c
  x -= y
  y = 0
elsif a + b >= 2 * c
  # a, bを１こずつ買うよりもcを買った方が安い
  n = [x, y].min
  ans += n * 2 * c
  x -= n
  y -= n
end

if x > 0
  ans += x * a
end

if y > 0
  ans += y * b
end

puts ans


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	string str;
	cin >> str;

	if (str[2] == str[3] && str[4] == str[5])
		cout << "Yes";
	else
		cout << "No";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include  <queue>
#include <vector>
#include  <cstdio>
#include <cstring>
#include<map>
#include<set>
//#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define I(a) scanf("%d",&a)
#define I2(a,b) scanf("%d%d",&a,&b)
#define I3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define L(a) scanf("%lld",&a)
#define L2(a,b) scanf("%lld%lld",&a,&b)
#define L3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define PI(a) printf("%d",a)
#define PL(a) printf("%lld",a)
#define PT(t) printf("Case %d: ",t)
#define PB push_back
#define x first
#define y second
#define xx first.first
#define xy first.second
#define yx second.first
#define yy second.second
#define SC scanf
#define PC printf
#define NL printf("\n")
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define SZ(a) ((int)a.size())-1
#define f(i,a,b) for(int i=a;i<=b; i++)
#define fr(i,a,b) for(int i=a;i<=b; i++)
#define frr(i,a,b) for(int i=a;i>=b; i--)
#define frv(i,a)  for(int i=0;i<a.size();i++)
#define pi 2.0*acos(0.0)
#define R(a) freopen(a, "r", stdin);
#define W(a) freopen(a, "w", stdout);
#define CB(x) __builtin_popcount(x)
#define STN(a) stringtonumber<ll>(a)
#define lol printf("BUG\n")
#define Endl "\n"
#define mk make_pair
using namespace std;
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T mul(T p, T e, T M)
{
    ll ret = 0;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret + p) ;
        p = (p + p) ;
        if(ret>=M)ret-=M;
        if(p>=M)p-=M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}
 

#define  mx 200004
#define base 193ll
 
typedef pair<int,int >P;
//////////////////////////
////////////////////////
#define F(i,a,b) for(int i=a;i<b; i++)
#define LL long long
#define MX  200007
#define md 998244353ll
///////////////////////////
///////////////////////////
///

int main(){
  int n, m;
  I2(n,m);
  for(int i = 0;i<=n;i++){
    if(i * 2 + (n-i) * 4 == m){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
    
    return 0;
}


Measured memory_bytes: 3792
def x(p0, p1):
    d = abs(p0 - p1)
    if d > 2:
        return []
    elif d == 2:
        return [(p0 + p1) / 2]
    else:
        m = (p0 + p1) / 2
        v = m - p0
        w = complex(v.imag, -v.real)
        l = abs(w)
        h = (1 - l ** 2) ** .5 * w / l
        return [m + h, m - h]

for e in iter(input, '0'):
    n = int(e)
    P = [complex(*map(float, input().split(','))) for _ in [0] * n]
    Q = []
    for i in range(n):
        for j in range(i + 1, n):
            Q += x(P[i], P[j])
    print(max(sum(1.01 >= abs(q - p) for p in P) for q in Q) if Q else 1)


Measured memory_bytes: 5732
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <functional>
#include <queue>
#include <map>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
const int INF = 100000000;

int main(){
  double l;
  cin >> l;

  double m = l / 3;
  double x = m*m*m;
  printf("%.10f", x);
}

Measured memory_bytes: 256
import itertools as ite
import math

INF = 10 ** 18
MOD = 10 ** 9 + 7

while True:
    N = input()
    if N == 0:
        break
    ls = []
    a = map(int, raw_input().split())
    for num in a:
        ls.append(num * 2)
    b = map(int, raw_input().split())
    for num in b:
        ls.append(num * 2 + 1)
    ls.sort(reverse = True)
    cnt1 = cnt2 = 0
    ans = "NA"
    for num in ls:
        if num % 2 == 1:
            cnt2 += 1
        else:
            cnt1 += 1
            if (cnt1 - cnt2) * 2 > cnt1 and cnt1 != N:
                ans = cnt1
                break
    print ans



Measured memory_bytes: 12916
#![allow(unused_imports)]
use std::io::{ self, Write };
use std::str::FromStr;
use std::cmp::{ min, max };
use std::collections::{ BinaryHeap, VecDeque };

#[allow(unused_macros)]
macro_rules! trace {
    ($var:expr) => {
        let _ = writeln!(&mut std::io::stderr(), ">>> {} = {:?}", stringify!($var), $var);
    };
    ($($args:expr),*) => {
        let _ = writeln!(&mut std::io::stderr(), ">>> {} = {:?}", stringify!($($args),*), ($($args),*));
    };
}

const M: usize = 1_000_000_007;

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

    let n: usize = sc.cin();
    let m: usize = sc.cin();

    let INF: i32 = 100000000;
    let mut d = vec![vec![INF; n]; n];
    for i in 0..n {
        d[i][i] = 0;
    }
    let mut edges = vec![];

    for _ in 0..m {
        let a = sc.cin::<usize>() - 1;
        let b = sc.cin::<usize>() - 1;
        d[a][b] = 1;
        d[b][a] = 1;
        edges.push((a, b));
    }

    let mut ans = 0;
    for e in edges.iter() {

        let mut c = vec![vec![INF; n]; n];
        for i in 0..n {
            for j in 0..n {
                c[i][j] = d[i][j];
            }
        }
        c[e.0][e.1] = INF;
        c[e.1][e.0] = INF;

        for k in 0..n {
            for i in 0..n {
                for j in 0..n {
                    c[i][j] = min::<i32>(
                        c[i][j],
                        c[i][k] + c[k][j]
                    );
                }
            }
        }

        if c[e.0][e.1] == INF {
            ans += 1;
        }

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

}

#[allow(dead_code)]
struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn reserve(&mut self) {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
    }
    fn cin<T: FromStr>(&mut self) -> T {
        self.reserve();
        match self.buffer.pop_front().unwrap().parse::<T>() {
            Ok(a) => a,
            Err(_) => panic!("parse err")
        }
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define AC ios::sync_with_stdio(0),cin.tie(0);
const int N=1e5+5;
int dp[N];
int a[N];
int main(){
	AC
	int n;
	cin>>n;
	int k;
	cin>>k;
	for(int i=1;i<n+1;i++){
		cin>>a[i];
		dp[i]=1e9+10;
	}
	dp[1]=0;
	for(int i=2;i<n+1;i++){
		for(int j=1;j<k+1;j++){
			if(i-j>=1)dp[i]=min(dp[i-j]+abs(a[i-j]-a[i]),dp[i]);
		}
	}
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 4376
import numpy as np

c = [list(map(int, input().split())) for i in range(3)]

A = np.array([
    [1, 0, 0, 1, 0, 0],
    [1, 0, 0, 0, 1, 0],
    [1, 0, 0, 0, 0, 1],
    [0, 1, 0, 1, 0, 0],
    [0, 1, 0, 0, 1, 0],
    [0, 1, 0, 0, 0, 1],
    [0, 0, 1, 1, 0, 0],
    [0, 0, 1, 0, 1, 0],
    [0, 0, 1, 0, 0, 1]])

B = np.array([
    [1, 0, 0, 1, 0, 0, c[0][0]],
    [1, 0, 0, 0, 1, 0, c[0][1]],
    [1, 0, 0, 0, 0, 1, c[0][2]],
    [0, 1, 0, 1, 0, 0, c[1][0]],
    [0, 1, 0, 0, 1, 0, c[1][1]],
    [0, 1, 0, 0, 0, 1, c[1][2]],
    [0, 0, 1, 1, 0, 0, c[2][0]],
    [0, 0, 1, 0, 1, 0, c[2][1]],
    [0, 0, 1, 0, 0, 1, c[2][2]]])

rankA = np.linalg.matrix_rank(A)
rankB = np.linalg.matrix_rank(B)

if rankA == rankB:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 21052
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
struct edge { int to, cost; };
signed main() {
	int n, k;
	cin >> n >> k;
	int memo = 1;
	rep(i, n) {
		memo = min(memo * 2, memo + k);
	}
	cout << memo << endl;
	ggr
}


Measured memory_bytes: 256
require 'set'

s = gets.chomp
x, y = gets.chomp.split(' ').map(&:to_i)

a = s.split('T').map(&:length)

xcs = Set[a[0] || 0]
ycs = Set[0]

(1...a.length).each do |i|
  tmp = Set.new
  d = a[i]
  next if d.zero?
  if (i % 2).odd?
    ycs.each do |yc|
      tmp << yc + d
      tmp << yc - d
    end
    ycs = tmp
  else
    xcs.each do |xc|
      tmp << xc + d
      tmp << xc - d
    end
    xcs = tmp
  end
end

puts({ true => 'Yes', false => 'No' }[xcs.include?(x) && ycs.include?(y)])


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

vector<vector<int>> g;
vector<int> vis;

int dfs(int node)
{
    vis[node]=1;
    int cnt = 1;
    for(int x : g[node])
        if(!vis[x])
            cnt+=dfs(x);            
    
    return cnt;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,m;
    cin>>n>>m;
    g = vector<vector<int>>(n+1, vector<int>(0));
    vis = vector<int>(n+1,0);

    int a, b;
    for(int i=0;i<m;i++)
    {
        cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    int cnt, ans = 0;
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            cnt = dfs(i);
        }
        ans = max(ans, cnt);
    }
    cout<<ans<<'\n';        
    return 0;
}



Measured memory_bytes: 21056
/*{{{*/
#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>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
using namespace std;
typedef pair<int, int> PP;
typedef long long LL;
#define pb push_back
#define fr first
#define sc second
#define bitcnt __builtin_popcount
#define all(x) x.begin(), x.end()
inline int ri() {int x; scanf("%d", &x); return x;}
#define rep2(i, n, ...) for (int i = 0; i < (n); i ++) 
#define rep3(i, a, b, ...) for (int i = (a); i < (b); i ++)
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define drep2(i, n, ...) for (int i = (n) - 1; i >= 0; i --)
#define drep3(i, a, b) for (int i = (a) - 1; i >= (b); i --)
#define drep(...) GET_MACRO(__VA_ARGS__, drep3, drep2)(__VA_ARGS__)
template<typename T>inline bool smax(T&a, T b){if(a<b){a=b;return true;}return false;} 
template<typename T>inline bool smin(T&a, T b){if(a>b){a=b;return true;}return false;} 
/*}}}*/


const int maxn = 100010;
vector<int> g[maxn];
int a[maxn], n, m, d[maxn];

int res = 0;

int dfs(int x, int h) {
  d[x] = h + 1;
  int b = d[x];
  for (int t : g[x]) {
    int r = dfs(t, d[x]);
    smax(b, r);
  }
  if (b - d[x] >= m - 1 && a[x] != 1 && x != 1) {
    res ++;
    return 0;
  }
  return b;
}
int main() {
  #ifdef _TEST_
  freopen("input.txt", "r", stdin);
  //freopen("out.txt", "w", stdout);
  #endif
  cin >> n >> m;
  rep(i, n) {
    int x; cin >> x;
    if (i > 0) g[x].pb(i + 1);
    a[i + 1] = x;
  }
  memset(d, -1, sizeof d);
  res += a[1] != 1;
  dfs(1, 0);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 11136
# -*- coding: utf-8 -*-

N = int(input().strip())
a_list = list(map(int, input().rstrip().split()))
#-----

cumulative_sum=["_"]*len(a_list)
cumulative_sum[0] = a_list[0]
for i in range(1,len(a_list)):
    cumulative_sum[i] = cumulative_sum[i-1] + a_list[i]

diff_list=[]
for v in cumulative_sum[:-1]:
    diff = abs( 2*v - cumulative_sum[N-1] )
    diff_list.append(diff)

print(min(diff_list))


Measured memory_bytes: 29024
#include <iostream>
#include <typeinfo>
#include <cstring>
#include <utility>
#include <vector>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <queue>
using namespace std;


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

    unsigned int digit;
    for (int i = 2; i >= 0; i--) {
        digit = N / pow(10, i);
        if (digit == 7) {
            cout << "Yes" << endl;
            return 0;
        }
        N -= digit * pow(10, i);
    }

    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3768
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
long long a[105], dp[105][105][105], mod = 1000000007;
int main () {
	long long n;
	scanf ("%lld", &n);
	long long m = 2 * n - 1;
	for (long long i = 1; i <= m; i++) scanf ("%lld", &a[i]);
	sort (a + 1, a + 1 + m);
	dp[n][0][0] = 1;
	for (long long i = n - 1; i >= 1; i--) {
		long long x = (a[i] != a[i+1]), y = (a[m-i] != a[m-i+1]);
		for (long long l = 0; l <= m; l++) {
			for (long long r = 0; r <= m; r++) {
				dp[i][l+x][r+y] = (dp[i][l+x][r+y] + dp[i+1][l][r]) % mod;
				for (long long k = 0; k < l + x; k++) dp[i][k][r+y+1] = (dp[i][k][r+y+1] + dp[i+1][l][r]) % mod;
				for (long long k = 0; k < r + y; k++) dp[i][l+x+1][k] = (dp[i][l+x+1][k] + dp[i+1][l][r]) % mod;
			}
		}
	}
	long long ans = 0;
	for (long long i = 0; i <= m; i++) for (long long j = 0; j <= m; j++) ans = (ans + dp[1][i][j]) % mod;
	printf ("%lld", ans); 
	return 0;
}

Measured memory_bytes: 7416
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    ans = 0
    pre = A[0]
    changed = False
    for a in A[1:]:
        if changed:
            changed = False
        elif pre == a:
            ans += 1
            changed = True
        pre = a
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
using namespace std;

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

#define yes cout << "yes" << endl;
#define Yes cout << "Yes" << endl;
#define YES cout << "YES" << endl;

#define no cout << "no" << endl;
#define No cout << "No" << endl;
#define NO cout << "NO" << endl;

#define ll long long

int main() {
    string s;
    int N, M;
    cin >> s;
    if (s[0] == '7' || s[1] == '7' || s[2] == '7') {
        Yes;
    } else {
        No;
    }
}

Measured memory_bytes: 3620
N, M = map(int, input().split())
Price = [tuple(map(int, input().split())) for _ in range(N)]
Price.sort()
ans = 0
for (a, b) in Price:
    if M >= b:
        ans += a * b
        M -= b
    else:
        ans += a * M
        M = 0
        break
print(ans)


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

int main(){
    int N;
    cin>>N;
    for(int i=0; i<3; i++){
        if(N%10==7){
        cout<<"Yes"<<endl;
        return 0;
        }
        N/=10;
    }

    cout<<"No"<<endl;


    return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
long long ans;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    for (int b = K+1; b < N+1; b++) {
        ans += (N/b)*(b-K);
        ans += max(0, N%b-K+(K == 0 ? 0 : 1));
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
  vector<string> vec(H);
  for (int i = 0; i < H; i++) {
    cin >> vec[i];
  }
  
  vector<int> hflag(H, 0);
  vector<int> wflag(W, 0);
  for (int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++){
      if(vec[i][j] == '#'){
        hflag[i] = 1;
        wflag[j] = 1;
      }
    }
  }

  for (int i = 0; i < H; i++) {
    if(hflag[i]){
      for(int j = 0; j < W; j++){
        if(wflag[j]){
          cout << vec[i][j];
        }
      }
 	cout << endl; // 末尾なら改行
    }
 }
}


Measured memory_bytes: 256
### SNIPPET
  # n = gets.split.map(&:to_i)
  # array = n.times.map { gets.split.map(&:to_i) }
  # [].all?(&:even?)
  # a = [*1..m].repeated_combination(n).to_a
  # [1,2,3,4,5].select { |num| num.even? }  # => [2, 4]
  # ["a","a","b"].group_by(&:itself).map{|k,v| [k, v.count]}.to_h #=> {"a"=>2, "b"=>1}
  # 切り捨て: .floor(2).to_f ,切り上げ： .ceil(2).to_f,四捨五入: round(2)
  # 3.upto(6) do |i|, 6.downto(3) do |i|
  # 公約数125.gcd(100)、公倍数125.lcm(100)
  # PI = Math::PI
  # 高さ = a * Math.sin(w / 180.0 * Math::PI), 底辺 = a * Math.cos(w / 180.0 * Math::PI)
  # def chmax(a, b) a > b ? a : b end
  # INF = Float::INFINITY
  # def chmin(a, b) a < b ? a : b end

s = gets.chomp

count = 0
1.upto(s.length/2) do |i|
  count += 1 if s[i-1] != s[-i] 
end

puts count

Measured memory_bytes: 14416
N=int(input())
*H,=map(int,input().split())
D=[-1]*N
D[0]=0
D[1]=abs(H[1]-H[0])
for i in range(2,N):
    D[i]=min(abs(H[i]-H[i-1])+D[i-1],abs(H[i]-H[i-2])+D[i-2])
print(D[-1])

Measured memory_bytes: 20388
#include<stdio.h>
#include<math.h>
int main(void){
  int a,b,ab,i;
  scanf("%d %d",&a,&b);
  if(b < 10){
    ab=a*10+b;
  }
  else if(b >=10 && b < 100){
    ab=a*100+b;
  }
  else{
    ab=a*1000+b;
  }
  i=sqrt(ab);
  //printf("%d %d",ab,i);
  if(ab==i*i){
    printf("Yes");
  }
  else{
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 128
/*input
1000000000000000000
*/
#include "bits/stdc++.h"
using namespace std;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	unsigned long long n, ans = 0; cin >> n;
	if(n % 2)
		return cout << 0 << endl, 0;
	for(unsigned long long now = 10; now <= n; now *= 5){
		ans += n/now;
	}
	cout << ans << endl;
}

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

using namespace std;

#define FOR(v, b, e)   for (int v = (b); v < (e); ++v)
#define REP(v, n)      FOR(v, 0, n)

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

	string A, B;
	cin >> A >> B;

	string result = "EQUAL";
	if (A.size() > B.size()) {
		result = "GREATER";
	} else if (A.size() < B.size()) {
		result = "LESS";
	} else {
		REP (i, A.size()) {
			if (A[i] > B[i]) {
				result = "GREATER";
				break;
			}
			if (A[i] < B[i]) {
				result = "LESS";
				break;
			}
		}
	}

	cout << result << endl;
}

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

typedef long long LL;

LL N;

struct node {
  int price;
  int volum;

  bool operator < (const node &rhs) const {
    return (price / (volum * 1.0)) < (rhs.price / (rhs.volum * 1.0));
  }
};

vector<node> all_node;

int main() {
  int volumn = 25;
  int price;
  for(int i = 0; i < 4; i++) {
    cin >> price;
    all_node.push_back( node{price, volumn });
    volumn *= 2;
  }

  cin >> N;

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

  N *= 100;
  LL total_cost = 0;

  for(auto &n: all_node) {
    if (N % n.volum == 0) {
      total_cost += (N / n.volum) * n.price;
      break;
    } else {
      total_cost += (N / n.volum) * n.price;
      N -= (N / n.volum) * n.volum;
    }
  }

  cout << total_cost << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        List<CheckPoint> checkPoints= new ArrayList<>();
        for (int i=0; i<N; i++) {
            checkPoints.add(new CheckPoint(scanner.nextInt(), scanner.nextInt(), scanner.nextInt()));
        }

        System.out.println(canDo(checkPoints) ? "Yes" : "No");
    }

    private static boolean canDo(List<CheckPoint> checkPoints) {
        CheckPoint from = new CheckPoint(0, 0, 0);
        CheckPoint to;
        for (int i=0; i < checkPoints.size(); i++) {
            to = checkPoints.get(i);
            int differenceTime = to.time - from.time;
            int distance = to.x - from.x + to.y - from.y;

            if (distance > differenceTime) {
                return false;
            }

            if (differenceTime % 2 == 0) {
                // 時間差が偶数
                if (distance % 2 != 0) {
                    return false;
                }
            } else {
                // 時間差が奇数
                if (distance % 2 == 0) {
                    return false;
                }
            }
            from = checkPoints.get(i);
        }
        return true;
    }

    static class CheckPoint {
        private int time;
        private int x;
        private int y;
        public CheckPoint(int time, int x, int y) {
            this.time = time;
            this.x = x;
            this.y = y;
        }
    }
}

Measured memory_bytes: 92296
#include <iostream>
#include <array>
#include <vector>
using namespace std;

int main(){
	int N, M, C;
  	cin >> N >> M >> C;
  	vector<int> B;
  	for(int i=0; i<M; i++){
      	int tmp_b;
      	cin >> tmp_b;
    	B.push_back(tmp_b);
    }
  	
  	int ans = 0;  	
  	for(int i=0; i < N;i++){
       	int sum = 0;
    	for(int j=0; j < M; j++){
          	int tmp_a;
        	cin >> tmp_a;
          	sum += tmp_a*B[j];
        }
      	if(sum > - C){
        	ans++;
        }
    }
  
	cout << ans << endl;
  	return 0;
}

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

const ll INF = 1LL << 60;

struct Doubling
{
  const int LOG;
  vector< vector< int > > table;
  
  Doubling(int sz, int64_t lim_t) : LOG(64 - __builtin_clzll(lim_t))
  {
    table.assign(LOG, vector< int >(sz, -1));
  }

  void set_next(int k, int x)
  {
    table[0][k] = x;
  }

  void build()
  {
    for(int k = 0; k + 1 < LOG; k++) {
      for(int i = 0; i < table[k].size(); i++) {
        if(table[k][i] == -1) table[k + 1][i] = -1;
        else table[k + 1][i] = table[k][table[k][i]];
      }
    }
  }

  int query(int k, int64_t t)
  {
    for(int i = LOG - 1; i >= 0; i--) {
      if((t >> i) & 1) k = table[i][k];
    }
    return k;
  }
};

ll N, K;
const int D = 60;
const int MAX_N = 200005;
int to[D][MAX_N]; // 頂点番号 : N まで

int main() {
    cin >> N >> K;
    rep(i, N) {
        cin >> to[0][i];
        to[0][i]--;
    }

    rep(i, D - 1) {
        rep(j, N) {
            to[i + 1][j] = to[i][to[i][j]];
        }
    }

    int v = 0;
    for (int i = D - 1; i >= 0; i--) {
        ll l = 1ll << i;
        if (l <= K) {
            v = to[i][v];
            K -= l;
        }
    }
    cout << v + 1 << endl;
}


Measured memory_bytes: 50520
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
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;
}
const long long INF = 1LL << 60;

int main()
{
    int a, b, t;
    cin >> a >> b >> t;
    int ans = 0;
    int i = 1;
    while (a * i <= t)
    {
        i++;
        ans += b;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3568
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int N=1e5+100;
struct node
{
    int l,r;
} a[N];
bool cmp(node p1,node p2)
{
    if(p1.l!=p2.l)
        return p1.l<p2.l;
    else
        return p1.r>p2.r;
}

void read(int n)
{
    for(int i=0; i<n; i++)
        scanf("%d %d",&a[i].l,&a[i].r);
    sort(a,a+n,cmp);
}

void findans(int n,int m)
{
    int L,R,ans;
    L=1,R=n,ans=0;
    for(int i=0;i<m;i++)
    {
        if(a[i].l>=L&&a[i].r<=R)
        {
            L= a[i].l;
            R= a[i].r;
        }
        else if(a[i].l>=L&&a[i].l<R)
        {
            L=a[i].l;
        }
        else
        {
            ans++;
            L=a[i].l;
            R=a[i].r;
        }
    }
    printf("%d\n",ans+1);
}

int main()
{
    int n,m;
    while(~scanf("%d %d",&n,&m))
    {
        read(m);
        findans(n,m);
    }
    return 0;
}


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

#define _ ios_base::sync_with_stdio(0);cin.tie(0);

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int main(int argc, char *argv[]) { _
    char c;
    ll i = 0;
    while (1) {
        c = getchar();

        if (c == EOF || c == '\n') {
            break;
        }
        printf("%c", c);
        if (i == 3) {
            printf(" ");
        }
        i++;
    }
    printf("\n");
    return 0;
}


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

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

int main() {

  	// 入力
	int ans=0, n, i;
	int p[30];

	cin >> n;
	REP(i, n){
		cin >> p[i];
	}

	REP(i, n-2){
		if((p[i] < p[i+1] && p[i+1] < p[i+2]) || (p[i] > p[i+1] && p[i+1] > p[i+2])){
			ans++;
		}
	}

  	cout << ans  << endl;
}

/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

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

int main() {
  char c;
  cin >> c;

  // ここにプログラムを追記

  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  }
  else{
    cout << "consonant" << endl;
  }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int32_t INF=1<<29;
int32_t main(){
  int32_t n,m; cin>>m>>n;
  vector<int32_t> coin(n+1);
  for(int32_t i=1; i<n+1; ++i) cin>>coin[i];
  vector<vector<int32_t>> dp(n+1,vector<int32_t>(m+1));
  // i=0
  // j=0 
  dp[0][0]=0;
  for(int32_t j=1; j<m+1; ++j) dp[0][j]=INF;
  for(int32_t i=1; i<n+1; ++i){
    for(int32_t j=0; j<m+1; ++j){
      dp[i][j]=dp[i-1][j];
      if(j>=coin[i]) dp[i][j]=min(dp[i][j],dp[i][j-coin[i]]+1);
    }
  }
  cout<<dp[n][m]<<endl;
}


Measured memory_bytes: 7084
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
  string w;
  cin >> w;

  int cnt = 'z'-'a'+1;
  vector<int> a(cnt, 0);

  for (int i = 0; i < w.length(); i++) {
    a[w[i]-'a']++;
  }

  bool flg = true;
  for (int i = 0; i < cnt; i++) {
    if (a[i] % 2 == 1) {
      flg = false;
      break;
    }
  }

  cout << (flg ? "Yes": "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream> 

using namespace std;

static const long long MOD = 1000000007;

long long fact[100001];

int main(int argc, char *argv[]) {
	int N, M;
	cin >> N >> M;

	fact[0] = 1;
	for (int i = 1; i <= max(N, M); i++) {
		fact[i] = (fact[i-1] * i) % MOD;
	}

	long long ans;
	if (abs(N - M) > 1) ans = 0;
	else if (abs(N - M) == 1) ans = (fact[N] * fact[M]) % MOD;
	else ans = (2 * fact[N] * fact[M]) % MOD;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

cs = 0
for i in range(n-1):
    if a[i+1] == a[i] + 1:
        cs += c[a[i]-1]

print(sum(b)+cs)

Measured memory_bytes: 3064
#include<stdio.h>
int main(void){
    int h,n;
    scanf("%d %d",&h,&n);
    int a[n],sum=0;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(int i=0;i<n;i++){
        sum = sum + a[i];
    }
    if(sum>=h){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;
}

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

int main(){
   int a[4];
   int score,n;
   int out = 0;
   string in;
   cin >> n;
   for(int i=0;i<n;i++){
      a[3] = a[2] = a[1] = a[0] = 0;
      out   = 0;
      score = 0;
      while(out!=3){
	 cin >> in;
	 if(in ==  "HIT"){
	    a[3] = a[2];
	    a[2] = a[1];
	    a[1] = a[0];
	    a[0] = 1;
	    if(a[3] == 1){
	       score++;
	       a[3] = 0;
	    }
	 }
	 else if(in == "HOMERUN"){
	    score += a[2]+a[1]+a[0]+1;
	    a[2] = a[1] = a[0] = 0;
	 }
	 else if(in ==  "OUT"){
	    out++;
	 }
      }
      cout << score << endl;
   }
   return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <stdlib.h>
using namespace std;

#define INF 1e9
#define PI 3.141592653589793238
typedef long long ll;

int main() {
    int n,m;cin>>n>>m;
    int sum=0;
    for(int i=0; i<n; i++) sum+=i;
    for(int i=0; i<m; i++) sum+=i;
    cout<< sum << endl;


    return 0;
}

Measured memory_bytes: 3560
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <map>
 
using namespace std;
 
int main(){
  int i,j,k,n,m;
  cin >> n;
  int v[n];
  int m1[100006]={},m2[100006]={};
  int m1m=0,m2m=0;
  for(i=0;i<n;i++){
    cin >> v[i];
    if(i%2==0)m1[v[i]]++;
    else m2[v[i]]++;
  }
  for(i=0;i<100001;i++){
    if(m1[m1m]<m1[i])m1m=i;
    if(m2[m2m]<m2[i])m2m=i;
  }
  sort(m1,m1+100002);
  reverse(m1,m1+100002);
  sort(m2,m2+100002);
  reverse(m2,m2+100002);
  if(m1m!=m2m){
    cout << n-m1[0]-m2[0] << endl;
  }else{
    cout << n-max(m1[0]+m2[1],m1[1]+m2[0]) << endl;
  }
  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include<cstdio>
#include<string>
#include<cstdlib>
using namespace std;

int s[200];   //入れ物、すたっく
int top;

//int initialize(){
//    top = 0;
//}

//bool isEmpty(){
//    return top == 0;
//}

//bool isFull(){
//    return top == 200;
//}

void push(int x){
    top++;
    s[top] = x;
}

int pop(){
    top--;
    return s[top+1];
}


int main(void){
    // Your code here!
    int a,b;
    top = 0;
    char S[101];
    
    while(scanf("%s", S) != EOF){
        if(S[0] == '+'){
            a = pop();
            b = pop();
            push(a+b);
            
            //cout << "+ " << pop()<< endl;
        }else if(S[0] == '-'){
            a = pop();
            b = pop();
            push(b - a);
            //cout << "- " << pop()<< endl;
            
        }else if(S[0] == '*'){
            a = pop();
            b = pop();
            push(a*b);
            //cout << "* " << pop()<< endl;
            
        }else{
            push(atoi(S));
            //x = atoi(s);
        }
        
    }
    
    cout << pop() << endl;
    
}



Measured memory_bytes: 3216
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
using namespace std;

//typedefリスト
typedef vector<int> vint;
typedef vector<string> vstr;

int main(void) {
	int A, B, C,ma,K,num;
	cin >> A >> B >> C >> K;
	
	ma = max({A,B,C});
	num = ma * 2;
	for (int i = 1; i < K; i++) {
		num = num * 2;
	}
	cout << A + B + C + num - ma << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

const int N = 200005;

int n;
int lst;
int ans;
vector <int> adj[N];

void dfs(int u, int p, int d) {
  if (d > ans) {
    ans = d;
    lst = u;
  }
  for (int v : adj[u]) {
    if (v == p) continue;
    dfs(v, u, d + 1);
  }
}

int main() {
  cin >> n;
  for (int i = 1; i < n; i++) {
    int x, y;
    cin >> x >> y;
    adj[x].push_back(y);
    adj[y].push_back(x);
  }
  dfs(1, -1, 1);
  dfs(lst, -1, 1);
  if (ans % 3 == 2) {
    cout << "Second" << endl;
  } else {
    cout << "First" << endl;
  }
  return 0;
}


Measured memory_bytes: 20608
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;

typedef long long ll;
#define READ(a) int a; cin >> a;
#define READARR(a, n) int a[(n) + 1]; FOR(i, 1, (n)) {cin >> a[i];}
#define READMAT(a, n, m) int a[n + 1][m + 1]; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
#define pb(x) push_back(x)
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	READ(n);
	READARR(p, n);
	
	int sum = 0;
	FOR (i, 1, n) sum += p[i];
	
	int a[n + 1][n + 1] = {}, b[n + 1][n + 1] = {};
	FORD (i, n, 1)
	{
		a[i][i] = p[i];
		b[i][i] = 0;
		
		FOR (j, i + 1, n)
		{
			if (p[i] + b[i + 1][j] > p[j] + b[i][j - 1])
			{
				a[i][j] = p[i] + b[i + 1][j];
				b[i][j] = a[i + 1][j];
			}
			
			else
			{
				a[i][j] = p[j] + b[i][j - 1];
				b[i][j] = a[i][j - 1];
			}
		}
	}
	
	cout << a[1][n] * 2 - sum;
}

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

using namespace std;

typedef long long ll;

template<typename T>
class BinaryIndexedTree {
    int N;
    vector<T> data;
public:
    BinaryIndexedTree(int N) : N(N) {
        data.resize(N + 1, 0);
    }

    T sum(int k) {
        T res = 0;
        for (; k > 0; k -= k & -k) {
            res += data[k];
        }
        return res;
    }

    void add(int k, T x) {
        for (; k <= N; k += k & -k) {
            data[k] += x;
        }
    }

    /**
     * v1 + v2 + ⋯ + vx ≧ W となる最小の 𝑥 を求める
     */
    int lowerBound(int w) {
        if (w <= 0) return 0;
        int x = 0;
        int k = 1;
        while (k * 2 <= N) k *= 2;
        for (; k > 0; k /= 2) {
            if (x + k <= N && data[x + k] < w) {
                w -= data[x + k];
                x += k;
            }
        }
        return x + 1;
    }
};

/**
 * DSL_2_B Range Sum Query (RSQ)
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_B
 */

int main() {
    int N, Q;
    cin >> N >> Q;
    BinaryIndexedTree<ll> bit(N);
    while (Q--) {
        int com, x, y;
        cin >> com >> x >> y;
        if (com == 1) {
            cout << bit.sum(y) - bit.sum(x - 1) << '\n';
        } else {
            bit.add(x, y);
        }
    }
    return 0;
}



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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define mp(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

void Solve(){
	int n,l;
	cin >> n >> l;

	priority_queue<pii,vector<pii>> que;
	rep(i,0,n){
		int in; cin >> in;
		que.push(mp(in,i));
	}

	int ans=0;
	vector<int> t(n);
	while(!que.empty()){
		int len=que.top().first,idx=que.top().second;
		que.pop();

		t[idx]+=l-len;
		ans=max(ans,t[idx]);
		if(idx-1>=0) t[idx-1]=max(t[idx-1],t[idx]);
		if(idx+1<n) t[idx+1]=max(t[idx+1],t[idx]);
	}

	cout << ans << endl;
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	Solve();
	return 0;
}

Measured memory_bytes: 2308
/*
[abc134] D - Preparing Boxes
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 2e5;

int N;
int a[MAX_N + 1];
int ans[MAX_N + 1];

void solve() {
    int M = 0;
    for (int j = N; j > 0; j--) {
        ll s = 0;
        for (int i = j; i <= N; i += j) {
            s += ans[i];
        }
        if (s % 2 != a[j]) {
            ans[j] = 1;
            M++;
        }
    }

    cout << M << endl;
    for (int i = 1; i <= N; i++) {
        if (ans[i]) {
            cout << i << " ";
        }
    }
    cout << endl;
}

int main() {
    cin >> N;
    for (int i = 1; i <= N; i++) {
        cin >> a[i];
    }

    solve();

    return 0;
}


Measured memory_bytes: 2432
import java.util.*;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        Integer N = Integer.parseInt(scanner.next());
        Map<Integer, Integer> map = new HashMap<Integer, Integer>();

        for (int i = 0; i < N-1; i++) {
            Integer A = Integer.parseInt(scanner.next()) -1;
            Integer count = map.get(A);
            map.put(A, (count == null) ? 1 : count + 1);
        }

        Integer[] total = new Integer[N];
        Arrays.fill(total, 0);

        for (Integer nKey: map.keySet()) {
            total[nKey] = map.get(nKey);
        }

        for (int i = 0; i < N; i++) System.out.println(total[i]);
    }
}


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

int main(){
	int N, M;
	cin >> N >> M;
	priority_queue<int> q;
	long long ans = 0;

	for (int i = 0; i < N; i++)
	{
		int a;
		cin >> a;
		q.push(a);
	}
	
	while (M-- > 0) {
		int top = q.top();
		q.pop();
		q.push(top / 2);
	}
	
	while (!q.empty()) {
		ans += q.top();
		q.pop();
	}

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

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
using namespace std;
int a,b,i=0;
signed main()
{
	cin>>a>>b;
	if(a%b==0){
		cout<<-1;
	}else{
		while(1){
			i++;
			if((a*i)%b!=0){
				cout<<a*i;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
import scala.io.StdIn._
import scala.math._
 
object Main extends App{
  val sc = new java.util.Scanner(System.in)
  val x = sc.nextInt
  val t = sc.nextInt
  if(x-t>0){
    println(x-t)
  }
  else{
    println(0)
  }
}

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

long long ans;
int fa[200010],f[200010],n,x;
struct node{int x,y;}a[200010];
bool operator <(node a,node b) {return 1ll*a.x*b.y<1ll*a.y*b.x;}
set<pair<node,int> > s;

int ask(int x) {return fa[x]==x?x:fa[x]=ask(fa[x]);}

int main()
{
	scanf("%d",&n),ans=0;
	for (int i=1; i<=n; i++) fa[i]=i;
	for (int i=2; i<=n; i++) scanf("%d",&f[i]);
	for (int i=1; i<=n; i++) 
	{
		scanf("%d",&x);
		if (x) a[i].x++; else a[i].y++;
	}
	for (int i=2; i<=n; i++) s.insert(make_pair(a[i],i));
	for (int ovo=1; ovo<n; ovo++)
	{
		x=(*s.begin()).second,s.erase(s.begin());
		f[x]=ask(f[x]),ans+=1ll*a[f[x]].x*a[x].y;
		if ((fa[x]=f[x])!=1)
		{
			s.erase(make_pair(a[f[x]],f[x]));
			a[f[x]].x+=a[x].x,a[f[x]].y+=a[x].y;
			s.insert(make_pair(a[f[x]],f[x]));
		} else a[f[x]].x+=a[x].x,a[f[x]].y+=a[x].y;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 15872
import sys
import re
import math
import collections
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
nb = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, k = ns()
    e = [[] for _ in range(n)]
    for _ in range(n - 1):
        a, b = ns()
        a, b = a - 1, b - 1
        e[a].append(b)
        e[b].append(a)

    table = [True for _ in range(n)]
    perm = [1]
    for i in range(k - 2, -1, -1):
        perm.append(perm[-1] * i % MOD)

    table[0] = False
    que = collections.deque(e[0])
    ans = k
    for i in range(len(e[0])):
        table[e[0][i]] = False
        ans *= k - i - 1
        ans %= MOD

    while len(que) > 0:
        for _ in range(len(que)):
            q = que.popleft()
            cnt = 0
            for i in range(len(e[q])):
                tmp = e[q][i]
                if table[tmp]:
                    table[tmp] = False
                    cnt += 1
                    que.appendleft(tmp)
            ans *= perm[min(len(perm) - 1, cnt)]
            ans %= MOD

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 34056
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main() {
    int H, W, h, w;
    cin >> H >> W >> h >> w;

    cout << (H - h) * (W - w) << "\n";
    return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define REP(i, k, n) for(int i = (int)k; i < (int)n; i++)
#define rrep(i, n) RREP(i, 0, n)
#define RREP(i, n, k) for(int i = (int)n-1; i > (int)k-1; i--)
#define mmax(start, end) *max_element(start, end)
#define mmin(start, end) *min_element(start, end)
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " " << x << endl;

typedef long long ll;

int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int dx8[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy8[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

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

    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    REP(u,sy,ty) cout << 'U';
    REP(r,sx,tx) cout << 'R';

    RREP(d,ty,sy) cout << 'D';
    RREP(l,tx,sx) cout << 'L';

    cout << 'L';
    REP(u,sy,ty) cout << 'U';
    cout << 'U';
    REP(r,sx,tx) cout << 'R';
    cout << 'R';
    cout << 'D';

    cout << 'R';
    RREP(d,ty,sy) cout << 'D';
    cout << 'D';
    RREP(l,tx,sx) cout << 'L';
    cout << 'L';
    cout << 'U';

    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include <math.h>

#define MOD 1000000007
#define REP(i,n) for ((i)=0;i<(n);i++)
#define SET(a,c) memset(a,c,sizeof a)
#define CLR(a) memset(a,0,sizeof a)
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define LL long long
#define ULL unsigned long long

int compare_ll(const void *a, const void *b){
	return *(ULL*)b - *(ULL*)a;
}



int main(void) {

	char s[101];
	int flag = 0;
	int i = 0;

	scanf("%s", &s);

	while(s[i]!='\0'){
		if(s[i] == 'C'){
			while(s[i]!='\0'){
				if(s[i]== 'F'){
					flag = 1;
					break;
				}else{
					i++;
				}
			}
		}else{
			i++;
		}
	}

	if(flag == 1){
		puts("Yes");
	}else{
		puts("No");
	}

	return 0;
}

/* 最後の改行忘れるな！！ */


Measured memory_bytes: 128