akhauriyash/Code-Regression huggingface dataset:
'''aizu 0309
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0309
'''
# encoding: 'utf-8'

N = 1000000007

def main():
    '''main func.
    '''

    node_n = int(input())
    nodes = list()
    for _ in range(node_n):
        nodes.append(Node(input()))
    for _ in range(node_n - 1):
        i, j = tuple([int(x) for x in input().split()])
        nodes[i-1].children.append(nodes[j-1])
        nodes[i-1].index.append(j-1)

    print(reduce_to_top(nodes).n % N)

def product(iterator):
    '''product for iterator
    '''
    result = 1
    for element in iterator:
        result *= element % N
        result %= N
    return result

def step_reducing(nodes):
    last_parents = [node for node in nodes if node is not None and node.is_last_parent()]
    for parent in last_parents:
        parent.n = parent.number_of_cases()
        parent.children = list()
        for i in parent.index:
            nodes[i] = None
    return nodes

def reduce_to_top(nodes):
    while nodes[1:] != [None]*(len(nodes)-1):
        nodes = step_reducing(nodes)
    return nodes[0]


class Node:
    '''Node class
    '''

    def __init__(self, kind, children=None, n=None, index=None):
        self.kind = kind
        if children is None:
            children = list()
        if index is None:
            index = list()
        self.children = children
        self.index = index
        self.n = None

    def number_of_cases(self):
        ''' calc the number of cases.
        '''
        if self.n is not None:
            return self.n

        cases = self.generate_cases()
        if "E" in self.kind:
            result = product(cases)
            if "?" in self.kind:
                result += 1
            return result % N

        elif "A" in self.kind:
            result = sum(cases)
            if "?" in self.kind:
                result += 1
            return result % N

        elif "R" in self.kind:
            result = product((x+1 for x in cases))
            if "?" not in self.kind:
                result -= 1
            return result % N

        else:
            raise Exception("unreachable.")

    def generate_cases(self):
        '''generate cases
        '''
        for child in self.children:
            yield child.number_of_cases()

    def is_last_parent(self):
        bools = [child.children == [] for child in self.children]
        return bools and all(bools)

if __name__ == '__main__':
    main()

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

#define pb push_back

using VI = vector <int>;
using ll = long long;

const int MXT = 26;
const int MXD = 365;

int D;
int C[MXT+10], S[MXD+10][MXT+10];

VI best;
ll best_score;

void update(VI &current, ll &new_score) {
	if (best.empty() || best_score < new_score) {
		best_score = new_score;
		best = current;
	}
	return;
}

void input() {
	scanf("%d", &D);
	for (int i = 1; i <= MXT; i ++) scanf("%d", &C[i]);
	for (int i = 1; i <= D; i ++) {
		for (int j = 1; j <= MXT; j ++) scanf("%d", &S[i][j]);
	}
	return;
}
void output() {
	for (auto x : best) printf("%d\n", x);
}

namespace Greedy {
	int last[MXT+10];
	VI greedy() {
		fill_n(last, MXT+1, 0);
		ll delta[MXT + 1] = {0};
		VI greedy_ans;
		ll score = 0;
		for (int i = 1; i <= D; i ++) {
			ll sum = 0;
			for (int j = 1; j <= MXT; j ++) delta[j] += C[j];
			sum = accumulate(delta + 1, delta + MXT + 1, 0ll);
			ll mx = -2e18;
			int ansd = -1;
			for (int j = 1; j <= MXT; j ++) {
				ll val = - sum + delta[j] + S[i][j];
				if (mx < val) mx = val, ansd = j;
			}
			delta[ansd] = 0;
			score += mx;
			greedy_ans.pb(ansd);
		}
		update(greedy_ans, score);
		return greedy_ans;
	}
}

int main() {
//	freopen("sample2.in", "r", stdin);
	input();
	Greedy::greedy();
	output();
	return 0;
}


Measured memory_bytes: 3812
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <climits>
#include <cfloat>
 
using namespace std;
 
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RREP(i,n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();++i)
#define ALL(c) (c).begin(), (c).end()
#define eps 10e-5
#define INF 1e8
 
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > pipii;
typedef vector<int> vi;
 
 
#define M INT_MAX
string s;
int id;
int dfs(){
	vector<int> p;
	int num = 0;
	while(1){
//cout << s[id] << endl;
		if(s[id] == ']'){ id++; break;}
		else if(s[id] == '[') id++, p.push_back(dfs());
		else {
			while(s[id] != ']') num = num*10 + (int)(s[id++]-'0');
			id++;
			return num / 2 + 1;
		}
	}
	int ret = 0;
	sort(ALL(p));
//	REP(i,p.size()) cout << p[i] << ":";
	REP(i,p.size()/2 + 1) ret += p[i];
//	cout << "      :        " << id << ":" << ret << endl;
	return ret;
}

int main(void){
	int n;
	cin >> n;
	while(n--){
		cin >> s;
		id = 1;
		cout << dfs() << endl;
	}
  return 0;
}

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

int main()
{
  int N, cnt=0, A=0, B=0;
  cin >> N;
  vector<int> P(N);
  rep(i,N) cin >> P.at(i);
  rep(i,N-1){
    if(P.at(i)>P.at(i+1) && cnt==0){
      cnt++;
      A=i;
    }
    else if(P.at(i)>P.at(i+1) && cnt==1){
      cnt++;
      B=i+1;
    }
  }
  if(cnt=2){
    swap(P.at(A), P.at(B));
    cnt=0;
    rep(i, N-1){
      if(P.at(i)>P.at(i+1)){
        cnt++;
        break;
      }
    }
  }
  if(cnt==0) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
int n,m;
char s[505][505],a1[505][505],a2[505][505];
int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
		scanf("%s",s[i]);
	for (int i=1;i<=n;i++)
		for (int j=0;j<m;j++) a1[i][j]=a2[i][j]='.';
	for (int i=1;i<=n;i++)
		for (int j=0;j<m;j++)
			if (s[i][j]=='#') a1[i][j]=a2[i][j]='#';
	for (int i=1;i<=m;i++)a1[i][0]=a2[i][m-1]='#';
	for (int i=1;i<=n;i+=2)
		for (int j=0;j<m-1;j++) a1[i][j]='#';
	for (int i=2;i<=n;i+=2)
		for (int j=1;j<m;j++) a2[i][j]='#';
	for (int i=1;i<=n;i++){
	 	for (int j=0;j<m;j++) printf("%c",a1[i][j]);
	 	printf("\n"); 
	}
	printf("\n");
	for (int i=1;i<=n;i++){
	 	for (int j=0;j<m;j++) printf("%c",a2[i][j]);
	 	printf("\n"); 
	}
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define N 1000000007
using namespace std;

long long n, m;
long long dp[100005] = {0};
bool ch[100005] = {0};

long long solve();

int main() {
  cin >> n >> m;
  for(int i = 0; i < m; ++i) {
    int x;
    cin >> x;
    ch[x] = 1;
  }
  cout << solve() << endl;
  return 0;
}

long long solve() {
  dp[0] = 1;
  for(int i = 0; i < n; ++i) {
    if(!ch[i + 1]) dp[i + 1] += dp[i];
    dp[i + 1] %= N;
    if(!ch[i + 2]) dp[i + 2] += dp[i];
    dp[i + 2] %= N;
  }
  return dp[n];
}

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

int main(int argc, char const *argv[])
{
	int n,h,w;
	cin>>n>>h>>w;
	int a,b,ans=0;
	for (int i = 0; i < n; ++i)
	{
		cin>>a>>b;
		if (h<=a&&w<=b)
		{
			++ans;
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;


int main() {
	long long int N;
	cin >> N;
	for( long long int index = 0; index < N; index++ ) {
		long long int A, B;
		cin >> A >> B;
		vector<string>D( A );
		map<char, pair<pair<int, int>, pair<int, int>>>memo;
		for( int i = 0; i < A; i++ ) {
			cin >> D[i];
			for( int j = 0; j < B; j++ ) {
				if( D[i][j] != '.' ) {
					if( memo.count( D[i][j] ) ) {
						memo[D[i][j]].first.first = min( memo[D[i][j]].first.first, i );
						memo[D[i][j]].first.second = min( memo[D[i][j]].first.second, j );
						memo[D[i][j]].second.first = max( memo[D[i][j]].second.first, i + 1 );
						memo[D[i][j]].second.second = max( memo[D[i][j]].second.second, j + 1 );
					} else {
						memo[D[i][j]] = make_pair( make_pair( i, j ), make_pair( i, j ) );
					}
				}
			}
		}
		bool f = true;
		while( f ) {
			f = false;
			for( auto now : memo ) {
				if( now.second != make_pair( make_pair( 0, 0 ), make_pair( 0, 0 ) ) ) {


					bool flag = true;
					for( int i = now.second.first.first; flag&& i < now.second.second.first; i++ ) {
						for( int j = now.second.first.second; j < now.second.second.second; j++ ) {
							if( D[i][j] != '#' &&D[i][j] != now.first ) {
								flag = false;
								break;
							}
						}
					}
					if( flag ) {
						f = true;
						for( int i = now.second.first.first; flag&& i < now.second.second.first; i++ ) {
							for( int j = now.second.first.second; j < now.second.second.second; j++ ) {
								if( D[i][j] == now.first ) {
									D[i][j] = '#';
								}
							}
						}
						memo[now.first] = make_pair( make_pair( 0, 0 ), make_pair( 0, 0 ) );
					}
				}
			}
		}
		f = true;
		for( auto now : memo ) {
			//cout << now.first << endl;
			//cout << now.second.first.first << " " << now.second.first.second << " " << now.second.second.first << " " << now.second.second.second << endl;
			if( now.second != make_pair( make_pair( 0, 0 ), make_pair( 0, 0 ) ) ) {
				cout << "SUSPICIOUS" << endl;
				f = false;
				break;
			}
		}
		if( f ) {
			cout << "SAFE" << endl;
		}
	}
}

Measured memory_bytes: 3132
use std::cmp;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let m: usize = sc.read();
    let a: Vec<usize> = sc.vec(n);
    let mut start = vec![0; m + 1];
    let mut end = vec![vec![]; m + 1];
    let mut total = 0;
    let mut carry = 0;
    let mut segments = 0;
    for i in 1..n {
        let from = a[i - 1] % m + 1;
        let to = a[i];
        start[from] += 1;
        if from > to {
            total += m - from + to;
            end[to].push(m - from + to);
            carry += m - from;
            segments += 1;
        } else {
            total += to - from;
            end[to].push(to - from);
        }
        total += 1;
    }

    let mut min = total;
    for i in 1..(m + 1) {
        carry += segments;
        min = cmp::min(min, total - carry);
        segments -= end[i].len();
        for &length in end[i].iter() {
            carry -= length;
        }
        segments += start[i];
    }
    println!("{}", min);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

int main()
{
    int n, m, sum=0, ans=0;
    cin >> n >> m;
    vector<int> a(n);
    for (int i=0; i<n; i++) {
        cin >> a.at(i);
        sum += a.at(i);
    }
    for (int i : a) {
        if (double(i) >= double(sum) / double((4*m))) ans++;
    }

    cout << (ans >= m ? "Yes" : "No") << endl;

    return 0;
}

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

using namespace std; 

const int maxn = 5e5, inf = 9e18; 

int n, q, A, B; 
int x[maxn + 5]; 

struct node {
    int mn, mnp, mnq, tag; 
    // mnp: dp[j] + j
    // mnq: dp[j] - j
    node operator + (const node &x) const {
        node ret; 
        ret.mn = min(mn, x.mn); 
        ret.mnp = min(mnp, x.mnp); 
        ret.mnq = min(mnq, x.mnq); 
        return ret; 

    }
} a[(maxn << 2) + maxn + 5];

void settag(int x, int d) {
    a[x].tag += d; 
    a[x].mn += d; a[x].mnp += d; a[x].mnq += d; 
} 

void push(int x) {
    if (!a[x].tag) return ;
    settag(x + x, a[x].tag);
    settag(x + x + 1, a[x].tag); 
    a[x].tag = 0; 
}

void build(int p, int l, int r) {
    a[p].mn = a[p].mnp = a[p].mnq = inf; 
    if (l == r) {
        return ; 
    }
    int mid = (l + r) >> 1; 
    build(p + p, l, mid); 
    build(p + p + 1, mid + 1, r); 
}

void modify(int p, int l, int r, int pos, int d) {
    if (l == r) {
        if (a[p].mn > d) {
            a[p].mn = d; 
            a[p].mnp = d + pos; 
            a[p].mnq = d - pos; 
        }
        return ; 
    }
    push(p); 
    int mid = (l + r) >> 1; 
    if (pos <= mid) modify(p + p, l, mid, pos, d); 
    else modify(p + p + 1, mid + 1, r, pos, d); 
    a[p] = a[p + p] + a[p + p + 1]; 
}

void add(int p, int l, int r, int ql, int qr, int d) {
    if (ql == l && qr == r) {
        settag(p, d); 
        return ; 
    }
    push(p); 
    int mid = (l + r) >> 1; 
    if (qr <= mid) add(p + p, l, mid, ql, qr, d); 
    else if (mid < ql) add(p + p + 1, mid + 1, r, ql, qr, d); 
    else add(p + p, l, mid, ql, mid, d), add(p + p + 1, mid + 1, r, mid + 1, qr, d); 
    a[p] = a[p + p] + a[p + p + 1]; 
}

node query(int p, int l, int r, int ql, int qr) {
    push(p); 
    if (l == ql && r == qr) {
        return a[p]; 
    }
    int mid = (l + r) >> 1; 
    if (qr <= mid) return query(p + p, l, mid, ql, qr);
    else if (mid < ql) return query(p + p + 1, mid + 1, r, ql, qr); 
    else return query(p + p, l, mid, ql, mid) + query(p + p + 1, mid + 1, r, mid + 1, qr); 
}

signed main() {
    scanf("%lld %lld %lld %lld", &n, &q, &A, &B); 
    x[0] = A; 
    build(1, 1, n); 
    modify(1, 1, n, B, 0); 
    for (int i = 1; i <= q; i++) {
        scanf("%lld", &x[i]); 
        node t = query(1, 1, n, 1, x[i]); 
        int d1 = t.mnq + x[i], d2 = inf; 
        if (x[i] + 1 <= n) {
            t = query(1, 1, n, x[i] + 1, n); 
            d2 = t.mnp - x[i]; 
        }
        add(1, 1, n, 1, n, abs(x[i] - x[i - 1])); 
        modify(1, 1, n, x[i - 1], min(d1, d2)); 
    }
    printf("%lld\n", query(1, 1, n, 1, n).mn); 
    return 0; 
} 

Measured memory_bytes: 37120
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
#include <set>

using namespace std;
using ll = long long;
#define rep(i,a,b) for(ll i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define pai 3.14159265358979323846
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
void printVec(std::vector<char> &vec) {
  std::cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    std::cout << *it << " ";
  }
  std::cout << std::endl;
}
 
int main() {
    string s,t;
    cin >> s >>t;
    int count =0;
    int mi = t.size();
    for(int i =0;i < s.size()- t.size()+1;i++) {
        count = 0;
        for(int j =0; j < t.size(); j++) {
            if (s[i+j] == t[j]) {
                count++;
            }
        }
        if (mi > (t.size() - count)){
            mi = t.size() - count;
        }
    }
    cout << mi << endl;
}

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

int main() {
    int n;
    cin >> n;
    int ans = n;
    for (int i = 0; i <= n; i++) {
        int res = 0;
        int tmp = i;
        while(tmp > 0) {
            res += tmp % 6;
            tmp /= 6;
        }
        tmp = n - i;
        while(tmp > 0) {
            res += tmp % 9;
            tmp /= 9;
        }
        ans = min(ans, res);
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb(in,tmp) in.push_back(tmp)
#define all(in) in.begin(),in.end()
#define PI acos(-1)
using namespace std;
int main(){
  int n,m;
  vector<int>in;
  cin>>n>>m;
  vector<int>han(n,0);
  rep(i,n){
    int tmp;
    cin>>tmp;
    pb(in,tmp);
  }
  rep(i,m){
    int tmp;
    cin>>tmp;
    rep(j,n)if(in[j]<=tmp){han[j]++;break;}
  }
  int max=0;
  int mai=0;
  rep(i,n)if(max<han[i]){max=han[i];mai=i;}
    cout<<mai+1<<endl;
}

Measured memory_bytes: 1228
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto n = readln.chomp.to!int;
  auto f = new int[](n);
  foreach (i; 0..n) f[i] = readln.split.to!(int[]).toBit;
  auto p = new int[][](n, 11);
  foreach (i; 0..n) p[i] = readln.split.to!(int[]);

  auto ans = long.min;
  foreach (i; 1..1<<10) {
    auto r = 0;
    foreach (j; 0..n)
      r += p[j][(i&f[j]).popcnt];
    ans = max(ans, r);
  }

  writeln(ans);
}

auto toBit(int[] a)
{
  auto r = 0;
  foreach (i, ai; a)
    if (ai) r = r.bitSet(i);
  return r;
}

pragma(inline) {
  pure bool bitTest(T)(T n, size_t i) { return (n & (T(1) << i)) != 0; }
  pure T bitSet(T)(T n, size_t i) { return n | (T(1) << i); }
  pure T bitReset(T)(T n, size_t i) { return n & ~(T(1) << i); }
  pure T bitComp(T)(T n, size_t i) { return n ^ (T(1) << i); }

  pure T bitSet(T)(T n, size_t s, size_t e) { return n | ((T(1) << e) - 1) & ~((T(1) << s) - 1); }
  pure T bitReset(T)(T n, size_t s, size_t e) { return n & (~((T(1) << e) - 1) | ((T(1) << s) - 1)); }
  pure T bitComp(T)(T n, size_t s, size_t e) { return n ^ ((T(1) << e) - 1) & ~((T(1) << s) - 1); }

  import core.bitop;
  pure int bsf(T)(T n) { return core.bitop.bsf(ulong(n)); }
  pure int bsr(T)(T n) { return core.bitop.bsr(ulong(n)); }
  pure int popcnt(T)(T n) { return core.bitop.popcnt(ulong(n)); }
}


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

int main(){
    int H,W,K;
    cin >> H >> W >> K;
    string c[H];
    int i,j;
    for(i=0; i<H; i++){
        cin >> c[i];
    }
    int counta,ans=0;
    int bith, bitw;
    for(bith=0; bith<(1<<H); bith++){
        for(bitw=0; bitw<(1<<W);bitw++){
            counta=0;
            for(i=0; i<H; i++){
                for(j=0; j<W; j++){ 
                    if(((bith&(1<<i))>0)||((bitw&(1<<j))>0)) continue;
                    if(c[i][j]=='#') counta++;
                }
            }
            if(counta==K) ans++;
        }
    }
    cout << ans << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 3684
import Data.List
import Control.Monad

main = do
  [n, m] <- map read . words <$> getLine
  as <- map read . words <$> getLine :: IO [Int]
  bc <- map (map read . words) <$> replicateM m getLine :: IO [[Int]]
  print $ sum $ solve bc as

solve bc as =
  f (sort as) (reverse (sortOn (\[_, x] -> x) bc))
  where
    f [] _ = []
    f xs [] = xs
    f xs ([0, _]:ys) = f xs ys
    f (x:xs) zs@([a, b]:ys)
        | x < b = b : f xs ([a-1, b]:ys)
        | otherwise = x : f xs zs

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

int main(){                                                                                 
  std::vector<int> a(4),b(4);                                                               
                                                                                            
  while(std::cin >> a[0] >> a[1] >> a[2] >> a[3]){                                          
    std::cin >> b[0] >> b[1] >> b[2] >> b[3];                                               
    int hit = 0, blow = 0;                                                                  
                                                                                            
    for(int i = 0; i < 4; ++i){                                                             
      for(int j = 0; j < 4; ++j){                                                           
        if(a[i] == b[j]){                                                                   
          if(i == j) ++hit;                                                                 
          else ++blow;                                                                      
        }                                                                                   
      }                                                                                     
    }                                                                                       
    std::cout << hit << " " << blow << std::endl;                                           
  }                                                                                         
  return 0;                                                                                 
}

Measured memory_bytes: 1192
#include<stdio.h>

int main(){
  
  int item[100];
  int kazu;
  int pop;
  int ok=0;
  double all=0;
  
  scanf("%d %d",&kazu,&pop);
  
  for(int i=0;i<kazu;i++){
    scanf("%d",&item[i]);
    all+=item[i];
  }
  
  for (int i=0;i<kazu;i++){
    if((double)item[i]>= (all/(double)(4*pop))) ok++;
       }
       
    
  if(ok>=pop) printf("Yes");
  else printf("No");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;
int main(void)
{
    int n;
    cin >> n;
    vector<int> array(n);
    vector<int> sorted(n);
    for (size_t i = 0; i < n; i++)
    {
        cin >> array[i];
    }
    copy(array.begin(), array.end(), sorted.begin());
    sort(sorted.begin(), sorted.end());
    for (size_t i = 0; i < n; i++)
    {
        if (sorted[n-1] == array[i])
        {
            cout << sorted[n-2] << endl;
        }
        else
        {
            cout << sorted[n-1] << endl;
        }
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define sz(x) ((long long)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define oo 1e15;
const ld eps = 1e-9;
const ld pi = acosl(-1);
const int mod = 998244353;
const int mod1 = 1e9 + 7;


mt19937_64 rnd(time(0));

void faster()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios::sync_with_stdio(false);
}

signed main() {
    faster();
    // freopen("in", "r", stdin);
    // freopen("out", "w", stdout);
    //______________________________________
    ///*__*/double start = clock();/*__*/
    //_____________________________________
    int n;
    cin >> n;
    vector <int> a[n];
    vector <int> dp[n];
    for (int i = 0; i < n; i++)
    {
        a[i].resize(3);
        dp[i].resize(3, 0);
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            int maxn = 0;
            if (i != 0)
                for (int k = 0; k < 3; k++)
                {
                    if (k == j) continue;
                    maxn = max(maxn, dp[i - 1][k]);
                }
            dp[i][j] = maxn + a[i][j];
        }
    }
    cout << max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]});
    //______________________________________
    //  cerr << "Time " << (clock() - start)  * 1.0 / CLOCKS_PER_SEC << "s\n";
    return 0;
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();
            var front = int.Parse(S.Substring(0,2));
            var back = int.Parse(S.Substring(2, 2));

            if (front > 12 || front ==0)
            {
                if (back > 12 || back == 0)
                {
                    Console.WriteLine("NA");
                }
                else
                {
                    Console.WriteLine("YYMM");

                }

            }
            else
            {
                if (back > 12 || back == 0)
                {
                    Console.WriteLine("MMYY");
                }
                else
                {
                    Console.WriteLine("AMBIGUOUS");

                }
            }

        }
    }
}


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

int main() {
	int n; cin >> n;
	string s; cin >> s;
	if (n % 2) {
		cout << "No\n";
		return 0;
	}
	else {
		int h = n / 2;
		for (int i = 0; i < h; i++) {
			if (s[i] != s[h + i]) {
				cout << "No\n";
				return 0;
			}
		}
		cout << "Yes\n";
	}
}


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

int main() {
	int a, b;
	string s;
	cin >> a >> b >> s;

	bool flag = true;
	for (int i = 0; i < s.size(); i++) {
		if (i != a && (s[i] - '0' < 0 || s[i] - '0' > 9)) {
			flag = false;
		}
		if (i == a && s[i] != '-') {
			flag = false;
		}
	}

	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
struct Dice{
  int s[6];
  void roll(char c){
    int b;
    if(c=='E'){
      b=s[0];
      s[0]=s[3];
      s[3]=s[5];
      s[5]=s[2];
      s[2]=b;
    }
    if(c=='W'){
      b=s[0];
      s[0]=s[2];
      s[2]=s[5];
      s[5]=s[3];
      s[3]=b;
    }
    if(c=='N'){
      b=s[0];
      s[0]=s[1];
      s[1]=s[5];
      s[5]=s[4];
      s[4]=b;
    }
    if(c=='S'){
      b=s[0];
      s[0]=s[4];
      s[4]=s[5];
      s[5]=s[1];
      s[1]=b;
    }
    if(c=='R'){
      b=s[1];
      s[1]=s[2];
      s[2]=s[4];
      s[4]=s[3];
      s[3]=b;
    }
  }
  int top(){return s[0];}
  int right(){return s[2];}
  int left(){return s[3];}
  int front(){return s[1];}
};
bool same(Dice a,Dice b){
  for(int i=0;i<6;i++)if(a.s[i]!=b.s[i])return false;
  return true;
}
int main(){
  Dice d[2];
  for(int j=0;j<2;j++)for(int i=0;i<6;i++)cin>>d[j].s[i];

  bool f=false;
  for(int i=0;i<4;i++){
    d[1].roll('R');
    for(int j=0;j<4;j++){
      d[1].roll('N');
      if(same(d[0],d[1]))f=true;
    }
  }
  d[1].roll('E');
  for(int j=0;j<4;j++){
    d[1].roll('N');
    if(same(d[0],d[1]))f=true;
  }
  d[1].roll('W');
  d[1].roll('W');
  for(int j=0;j<4;j++){
    d[1].roll('N');
    if(same(d[0],d[1]))f=true;
  }

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



Measured memory_bytes: 3124
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var varList = new Variable[N];
        for (int i = 0; i < N; i++)
        {
            var inputs = Console.ReadLine().Split(' ');
            var x = int.Parse(inputs[0]);
            var y = int.Parse(inputs[1]);
            var h = long.Parse(inputs[2]);
            var var = new Variable(x, y, h);
            varList[i] = var;
        }

        Ans ans = new Ans(0, 0, 0);
        for (int cx = 0; cx <= 100; cx++)
        {
            for (int cy = 0; cy <= 100; cy++)
            {
                long currentH = -1;
                long limitH = long.MaxValue;
                bool found = true;
                for (int i = 0; i < varList.Length; i++)
                {
                    var var = varList[i];
                    var diffX = Math.Abs(var.x - cx);
                    var diffY = Math.Abs(var.y - cy);
                    if (var.h == 0)
                    {
                        limitH = Math.Min(diffX + diffY, limitH);
                    }
                    else
                    {
                        var H = var.h + diffX + diffY;
                        if (currentH < 0)
                        {
                            currentH = H;
                        }
                        else
                        {
                            if (currentH != H)
                            {
                                // Hが異なるので不正解
                                found = false;
                                break;
                            }
                        }
                    }
                }

                if (found)
                {
                    // 最終チェック
                    if (1 <= currentH && currentH <= limitH)
                    {
                        if (currentH < 0) currentH = limitH;
                        ans = new Ans(cx, cy, currentH);
                    }
                }
            }
        }

        Console.WriteLine(ans.cx + " " + ans.cy + " " + ans.H);

    }

    struct Ans
    {
        internal int cx;
        internal int cy;
        internal long H;
        internal Ans(int cx, int cy, long H)
        {
            this.cx = cx;
            this.cy = cy;
            this.H = H;
        }
    }
    struct Variable
    {
        internal int x;
        internal int y;
        internal long h;
        internal Variable(int x, int y, long h)
        {
            this.x = x;
            this.y = y;
            this.h = h;
        }
    }

}



Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
int main()
{
    ll curr = 1000;
    ll n;
    cin >> n;
    vector<ll> a(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    for (ll i = 1; i < n; i++)
    {
        if (a[i] > a[i - 1])
        {
            ll p = curr / a[i - 1];
            ll rem = curr % a[i - 1];
            curr = p * a[i] + rem;
        }
    }
    cout << curr << endl;
}

Measured memory_bytes: 3592
use std::cmp::max;
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        n: usize,
        m: i32,
        a: [usize; m],
    }

    let mut dp: Vec<i32> = vec![0; n + 3];
    let mod_number: i32 = 1000000007;

    for i in a{
        dp[i] = -1;
    }
    dp[0] = 1;
    if dp[1] != -1{
        dp[1] = 1;
    }
    for i in 2..n + 1 {
        if dp[i] != -1 {
            dp[i] = max(0, dp[i - 1]) + max(0, dp[i - 2]);
            dp[i] %= mod_number;
        }
    }
    println!("{}", dp[n]);
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N, M;
    cin >> N >> M;
    Vl H(N);
    for (ll i = 0; i < N; i++) {
        cin >> H[i];
    }

    vector<Vl> hs(N);

    for (ll i = 0; i < M; i++) {
        ll a, b;
        cin >> a >> b;
        --a, --b;
        hs[a].emplace_back(H[b]);
        hs[b].emplace_back(H[a]);
    }

    ll ans = 0;
    for (ll i = 0; i < N; i++) {
        if (hs[i].size() == 0) {
            ++ans;
            continue;
        }
        sort(hs[i].begin(), hs[i].end(), greater<ll>());
        if (H[i] > hs[i][0]) ++ans;
    }

    cout << ans << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 9800
import sys
N,M = map(int,input().split())
array = list(map(int,input().split()))

if not ( 1 <= M <= 100 and M <= N <= 100 ): sys.exit()
if not (len(array) == len(set(array))): sys.exit()

count = 0
standard = sum(array) * (1/(4*M))
for I in array:
    if I >= standard:
        count += 1
print('Yes') if count >= M else print('No')

Measured memory_bytes: 9172
#include<bits/stdc++.h>
//#include<iostream>
using namespace std;
//type
typedef long long ll;
#define pii pair<int, int>
#define vi vector<int>
//x * y * 1.0 can cause overflow
//constant
#define inf (int)(1e9+7)
#define mod (ll)(1e9+7)
#define eps 1e-10
//omission
#define eb emplace_back
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define all(v) v.begin(), v.end()
#define ios cin.tie(0); ios::sync_with_stdio(false)
#define FIX(a) cout << fixed << setprecision(a)
#define mp make_pair
//manip
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(unique(v.begin(), v.end(), v.end());
#define fill(x, y) memset(x, y, sizeof(x))
#define ceil(a, b) a / b + !!(a % b)
template<class T> T power_mod(T a, T b) {return b ? power(a * a % inf, b / 2) * (b % 2 ? a : 1) % inf : 1;}
template<class T> T power(T a, T b) {return b ? power(a * a, b / 2) * (b % 2 ? a : 1) : 1;}
#define LB(v, x) (int)(lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (int)(upper_bound(v.begin(), v.end(), x) - v.begin())
template<typename T> T gcd(T a, T b) {if (b == 0) return a; return gcd(b, a % b);}
template<typename T> T lcm(T a, T b) {return a / gcd(max(a, b), min(a, b)) * b;} //先に割る!!
#define outa(a, n) rep(i_, n) cout << a[i_] << " "; cout << endl
#define out(a) cout << a << endl
#define outv(v) rep(i, SZ(v)) cout << v[i] << " "; cout << endl
//loop
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep3(i, st, n) for (int i = st; i < n; ++i)
//algorithm
//double pointer, l start, how many adds, can be 0 -> init r = l, sum = 0
//bfs, not x, y, i, j
//not !(i % 2), i % 2 == 0
//minimal required terms
//cast caution
//look constraints always



int main() {
    
    
    
    
    int n, m, p;
    
    while (cin >> n >> m >> p && n) {
        int num_people = 0;
        int x[n]; rep(i, n) {cin >> x[i]; num_people += x[i];}
        
        int money = num_people * 100;
        money *= (100 - p) * 0.01;
        //out(money);
        if (x[m - 1] == 0) {
            out(0);
            continue;
        }
        out(money / x[m - 1]);
        
        
        
        
        
    }
    
    
    
    
}




Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  SORT(a);
  int count = 1;
  int total = 0;
  rep(i, n) {
    if (a[i] != a[i + 1]) {
      if (count % 2 == 1) total++;
      count = 1;
    } else {
      count++;
    }
  }
  cout << total << endl;
}

Measured memory_bytes: 640
def main():
    atgc = ["A", "T", "G", "C"]
    s=input()
    #=[int(i) for i in input().split()]
    cnt = 0
    ans = 0
    for i in range(len(s)):
        if s[i] in atgc:
            cnt += 1
        else:
            cnt = 0
        ans = max(ans, cnt)
    print(ans)

main()

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
using Graph = vector<vector<int>>;

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

  ll s, w;
  cin >> s >> w;
  if(s <= w) cout << "unsafe" << endl;
  else cout << "safe" << endl;

  return 0;
}


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


using namespace std;
const int N=1e5+55;
int a[N];
int dp[N];

int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>a[i];
	dp[0]=0;
	for(int i=1;i<n;i++)
	{
		dp[i]=1e9+55;
		for(int j=i-1;j>=i-k&&j>=0;j--)
			dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
	}
	cout<<dp[n-1]<<endl;
	
	
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main() {
	string str;
	cin >> str;

	if ((str.at(0) == str.at(1)) && (str.at(1) == str.at(2)) || (str.at(1) == str.at(2)) && (str.at(2) == str.at(3)))
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s; long long n = 0;
    cin >> s;
    for(int i=0; i<s.size(); ++i){
        n += s[i] - '0';
    }
    if(n%9==0) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 3700
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
int main(){
    int64_t N, A, B, digits_A, digits_B, ans = 10000000000;
    vector<int64_t> divisor;
    cin >> N;
    for(int i = 1; i <= sqrt(N); i++){

        if(N % i == 0) divisor.push_back(i);

    }

    for(int64_t x : divisor){
        A = x;
        digits_A = 0;
        digits_B = 0;
        B = N / A;

        while(A > 0){
            digits_A++;
            A /= 10;
        }

        while(B > 0){
            digits_B++;
            B /= 10;
        }

        if(digits_A >= digits_B){
            if(digits_A < ans) ans = digits_A;
        }

        if(digits_A <= digits_B){
            if(digits_B < ans) ans = digits_B;
        }

    }

    cout << ans << endl;
}

Measured memory_bytes: 3708
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, a, n) for(int i=a; i<n; i++)
#define ll long long
#define all(x) begin(x), end(x)
#define toInt(x) (x - '0')
#define pll pair<ll, ll>
#define pli pair<ll, int>
// #define int long long

#define INF 1e+9
#define MAX_V 100008

vector<pair<ll, int>> factrized(ll num){
  vector<pair<ll, int>>  res;
 
  for(ll i = 2; i * i <= num; i++){
    if(num % i)continue;
    res.emplace_back(i, 0);
    while(num % i == 0){
          num /= i;
      res.back().second++;
    }
  }
  if(num != 1) res.emplace_back(num, 1);
  return res;
}

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

vector< int > divisor(int n) {
  vector< int > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> v(1000006, 0);
    for(int i=0; i<n; i++){
        cin >> a[i];
        v[a[i]] += 1;
    }
    // sort(all(a));
    int ans = 0;
    if(v[1] >= 2){
        cout << 0 << endl;
        return 0;
    }
    
    if(v[1] == 1){
        cout << 1 << endl;
        return 0;
    }
    for (int i=0; i<n; i++){
        vector<int> res = divisor(a[i]);
        if(res.size() == 2 && v[a[i]] == 1)ans++;
        else if(res.size() != 2){
            // cout << a[i] << ":" << endl;
            res.pop_back();
            bool f = true;
            for(auto it: res){
                // cout << it << endl;
                if(v[it] >= 1) f = false;
            }
            if(f && v[a[i]] == 1) ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 8012
/**
 *    author:  otera    
**/
#include<iostream>
#include<string> 
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm> 
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	string t; cin >> t;
    int n = (int)t.size();
    rep(i, n) {
        if(t[i] != '?') cout << t[i];
        else cout << 'D';
    }
    cout << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 3780
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <tuple>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    int n;cin>>n;
    vector<string> ws(n);
    rep(i,n)cin>>ws[i];
    bool ok = true;
    set<string> al;
    al.insert(ws[0]);
    rep(i,n-1){
        if(al.count(ws[i+1]) != 0)ok =false;
        else al.insert(ws[i+1]);
        if(ws[i][ws[i].size()-1] != ws[i+1][0])ok = false;
    }
    cout<<((ok)?"Yes":"No")<<endl ;return 0;
}


Measured memory_bytes: 256
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

a, b = ri_()
if a == 0 or b == 0 or (a < 0 and b > 0):
    ans = 'Zero'
elif a > 0 and b > 0:
    ans = 'Positive'
else:
    if (b - a + 1) % 2 == 0:
        ans = 'Positive'
    else:
        ans = 'Negative'
print(ans)

Measured memory_bytes: 9180
// Author: 23forever
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
typedef long long LL;
const int MAXN = 200000;
using namespace std;

inline void enableFileIO() {
  freopen("test.in", "r", stdin);
  freopen("test.out", "w", stdout);
}

inline int read() {
  int x = 0, w = 1;
  char c = ' ';

  while (c < '0' || c > '9') {
    c = getchar();
    if (c == '-') w = -1;
  }
  while (c >= '0' && c <= '9') {
    x = (x << 1) + (x << 3) + (c ^ 48);
    c = getchar();
  }
  return x * w;
}

int n;
LL a[MAXN + 5];

void init() {
//  enableFileIO();

  n = read();
  for (int i = 1; i <= n; ++i) a[i] = read() - i;
}

int main() {
  init();
  
  sort(a + 1, a + 1 + n);
  int res = a[n / 2 + 1];
  LL ans = 0;
  for (int i = 1; i <= n; ++i) {
    ans += fabs(a[i] - res); 
  }

  printf("%lld\n", ans);
  return 0;
}


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

int main(){
    int n; cin >> n;
    int mi = INT_MAX, c = 0;
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        if(mi > a){
            mi = a; c++;
        }
    }
    cout << c << endl;
    return 0;
}

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

int main() {
    int x, y;
    cin >> x >> y;
    int ab = abs(abs(x) - abs(y));
    if((x <= 0 && y <= 0 || x >= 0 && y >= 0) && x <= y) {
        cout << ab << endl;
    } else if(x == 0 || y == 0 || (!(x >= 0 && y >= 0 && x > y) && ((abs(x) <= abs(y) && !(x <= 0 && y <= 0)) || (abs(x) >= abs(y) && !(x >= 0 && y <= 0)) || (x >= 0 && y <= 0 && x >= -y)))) {
        cout << ab + 1 << endl;
    } else {
        cout << ab + 2 << endl;
    }
}


Measured memory_bytes: 256
<?php
	$output = array();
	while( true ) {
		list( $n, $x ) = explode( ' ', trim( fgets( STDIN ) ) );
		if( 0 == $n && 0== $x ) { break; }
		
		$cnt = 0;
		$ave = $x/3;
		for( $i=1; $i<$ave; $i++ ) {
			$t = ($x-$i)/2;
			for( $j=$i+1; $j<$t; $j++ ) {
				$k = $x-$i-$j;
				if( $j < $k && $k <= $n ) { $cnt++; }
			}
		}
		array_push( $output, $cnt );
    }
	print implode( "\n", $output );
?>

Measured memory_bytes: 6600
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

//#define MOD (int)(1e5 + 7)
#define MOD (100007)

void invalid(void)
{
	printf("-1\n");
	exit(0);
}

static inline int *readNint(int n)
{
	int *a = calloc(sizeof(int), n);
	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);
	return a;
}

static inline int comp(const void *a, const void *b)
{
	return *(int *)a > *(int *)b;
}

int main(int argc, char **argv)
{
	int N, K;
	scanf("%d%d", &N, &K);
	int *H = readNint(N);
	qsort(H, N, sizeof(int), comp);
	int Na = N - K;
	uint64_t n = 0;
	for (int i = 0; i < Na; i++) {
		n += H[i];
	}
	printf("%ld\n", n);
	return 0;
}


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

int n;
int a[40000],b[40000];

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

    sort(a,a+n,greater<int>()); sort(b,b+n,greater<int>());

    int i;
    for(i=0;i<n/2;i++){
      if(a[2*i]>b[i]){
	cout << 2*i+1 << endl;
	break;
      }
    }
    if(i==n/2)cout << "NA\n";
  }
}

Measured memory_bytes: 1492
d, n = (int(i) for i in input().split())

if d == 0:
    if n < 100:
        print(n)
    else:
        print(n+1)
elif d == 1:
    if n < 100:
        print(100 * n)
    else:
        print(100*(n+1))
elif d == 2:
    if n < 100:
        print(100 * 100 * n)
    else:
        print(100 * 100 * (n+1))



Measured memory_bytes: 3316
import sys, math, collections, heapq, itertools
F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0: a, b = b, a % b
    return b
  
def solve():
    r, d, x = map(int, line_input())
    ans = x
    for i in range(10):
        ans = r * ans - d
        print(ans)
    return 0
  
if __name__ == "__main__":
    solve()

Measured memory_bytes: 3568