akhauriyash/Code-Regression huggingface dataset:
/**
 * AtCoder 081 A
 * 標準入力: 3の数値（'0' or '1'） s1, s2, s3 を `s1s2s3` の形で受け取る
 * 処理: '1' の数を求める
 * 標準出力: 求めた数を出力する
 */

/**
 * 標準入力 => String マクロ: https://techracho.bpsinc.jp/jhonda/2019_08_05/78537
 */
macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

/**
 * 標準入力マクロ by https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
 */
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)*}
    };
}

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)*}
    };
}

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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

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

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

/**
 * Test Code マクロ: https://techracho.bpsinc.jp/jhonda/2019_08_05/78537
 */
macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

/**
 * 解法
 */
fn solve(src: &str) -> usize {
    input! {
        source = src,
        s: String,
    }
    // Rust は文字列走査を index で行うことはできないため、以下の手法を使う
    // - String.chars() -> Iterator<char> で走査する
    // - String.match_indices(String) -> RMatchIndices<'index, Pattern> で検索する
    return s.match_indices("1").count();
    // return s.chars().filter(|&c| c == '1').count();
}

/**
 * Test Code: $ cargo test --bin 081
 */
#[test]
test! {
    "101" => 2,
    "000" => 0,
}

/**
 * Main
 */
fn main() {
    println!("{}", solve(&stdin!()));
}

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

using namespace std;

//------------------------------- Libraries --------------------------------//

//------------------------------- Type Names -------------------------------//

using i64 = int_fast64_t;

using seika = string;
//akari : 1D, yukari : 2D, maki : 3D vector
template <class kizuna>
using akari = vector<kizuna>;
template <class yuzuki>
using yukari = akari<akari<yuzuki>>;
template <class tsurumaki>
using maki = akari<yukari<tsurumaki>>;
//akane : ascending order, aoi : decending order
template <class kotonoha>
using akane = priority_queue<kotonoha, akari<kotonoha>, greater<kotonoha>>;
template <class kotonoha>
using aoi = priority_queue<kotonoha>;

//------------------------------- Dubug Functions ---------------------------//
inline void print()
{
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest)
{
    cout << first << ' ';
    print(rest...);
}
//------------------------------- Solver ------------------------------------//

void solve()
{
    int h, w, x, ans = 0;
    cin >> h >> w;
    akari<int> dp(w + 1);
    for (int i = 0; i < h; i++)
    {
        akari<int> nx(dp);
        for (int j = 0; j < w; j++)
        {
            cin >> x;
            if (x)
            {
                nx[j + 1] = 0;
                continue;
            }
            nx[j+1] = min({dp[j], dp[j+1], nx[j]}) + 1;
            ans = max(ans, nx[j+1]);
        }
        swap(dp, nx);
    }
    cout << ans * ans << endl;
}

int main()
{
    solve();
    return 0;
}



Measured memory_bytes: 3152
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)*}
    };
}

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)*}
    };
}

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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

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

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

const MOD: usize = 7 + 1e9 as usize;

fn main() {
    input! {
        n: usize,
        m: usize,
        a: [usize; m],
    }

    let mut stairs = vec![true; n + 5];
    for ai in a {
        stairs[ai] = false;
    }
    let mut dp = vec![0; n + 5];
    dp[0] = 1;
    for i in 0..n {
        if i + 1 <= n && stairs[i + 1] {
            dp[i + 1] = (dp[i + 1] + dp[i]) % MOD;
        }
        if i + 2 <= n && stairs[i + 2] {
            dp[i + 2] = (dp[i + 2] + dp[i]) % MOD;
        }
    }
    println!("{}", dp[n]);
}


Measured memory_bytes: 6396
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int numberOfMatches = 0;
        int[] firstArray = new int[a];
        for(int i = 0; i < firstArray.length;i++) 
        {
        
        	firstArray[i] = in.nextInt();
        }
        int c = in.nextInt(); 
        int[] secondArray = new int[c];
        for(int j = 0; j < secondArray.length;j++) 
        {
        	int d = in.nextInt();
        	secondArray[j] = d;
        }
        
        for(int h = 0; h < secondArray.length;h++) 
        {
        	for(int g = 0; g < firstArray.length;g++) 
        	{
        	if(secondArray[h] == firstArray[g]) {numberOfMatches++;break;} 
        	}
        }
        
        
        System.out.println(numberOfMatches);
	}

}


Measured memory_bytes: 40200
#include <bits/stdc++.h>
#define REP(i, a, b) for (long long i = a; i <= b; ++i)
#define ll long long
#define N 110
using namespace std;

ll n, a[N];

inline ll read(){
	ll s = 0, w = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9'){
		if (ch == '-') w *= -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9'){
		s = s * 10 + ch - '0';
		ch = getchar();
	}
	return s * w;
}

inline void work(){
	n = read();
	REP(i, 1, n){
		a[i] = read();
		if (a[i] % 2 == 0)
			if (a[i] % 3 != 0 && a[i] % 5 != 0){
				puts("DENIED");
				exit(0);
			}
	}
	puts("APPROVED");
}

int main(){
	work();
	return 0;
}

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

#define long unsigned long
class BIT {
  int n;
  vector<int> v;
public:
  BIT(int n) : n(n), v(n + 1) {}
  void add(int i) {
    for (++i; i <= n; i += i & -i) {
      ++v[i];
    }
  }
  int get(int r) {
    int sum = 0;
    for (; r > 0; r -= r & -r) {
      sum += v[r];
    }
    return sum;
  }
};

const long mod = 998244353;
struct Point {
  int x;
  int y;
  bool operator<(const Point& p) const {
    return x < p.x || x == p.x && y < p.y;
  }
};

int n;
Point ps[200000];
long bin[200001];

long corner() {
  BIT bit(n);
  sort(ps, ps + n);
  
  long sum = 0;
  for (int i = 0; i < n; ++i) {
    int j = ps[i].y;
    int cnt = bit.get(j);
    sum = (sum + bin[cnt]) % mod;
    bit.add(j);
  }
  return sum;
}

void compress() {
  map<int, int> mx;
  map<int, int> my;
  for (int i = 0; i < n; ++i) {
    int s = mx.size();
    int t = my.size();
    mx[ps[i].x];
    my[ps[i].y];
  }
  
  int cnt = 0;
  for (auto&& p : mx) p.second = cnt++;
  cnt = 0;
  for (auto&& p : my) p.second = cnt++;
  
  for (int i = 0; i < n; ++i) {
    ps[i].x = mx[ps[i].x];
    ps[i].y = my[ps[i].y];
  }
}

void pre() {
  bin[0] = 1;
  for (int i = 0; i < n; ++i) {
    bin[i + 1] = bin[i] * 2 % mod; 
  }
}

int main() {
  cin >> n;
  pre();
  
  for (int i = 0; i < n; ++i) cin >> ps[i].x >> ps[i].y; 
  compress();
  
  long sum = (n - 4 + mod) % mod * (bin[n] - 1) % mod;
  for (int k = 0; k < 4; ++k) {
    sum = (sum + corner()) % mod;
    for (int i = 0; i < n; ++i) {
      int x = ps[i].x;
      int y = ps[i].y;
      ps[i].x = (n - 1) - y;
      ps[i].y = x;
    }
  }
  cout << sum << endl;
}


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

int main()
{
    int X;
    cin >> X;
  
    vector<int> A(X+1);
    A.at(0) = 0;
    A.at(1) = 1;
    
    if(X != 1){
    for(int b=2; b<=X; b++){
      int a = b;
      if(b*b <= X){ 
      	while(a<=X){
          a = a*b;
        }
     A.at(b) = a / b;
      }
      else if (b*b > X)
        A.at(b) = 0;
    }
    sort(A.begin(), A.end());
    cout << A.at(X) << endl;
    }
    else if(X == 1)
      cout << 1 << endl;
}

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

using namespace std;

vector<vector<int>> C(3, vector<int>(3));
vector<vector<int>> D(3, vector<int>(3));
vector<vector<int>> E(3, vector<int>(3));

bool check(){
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            if(D[i][j]!=D[(i+1)%3][j]) return false;
            if(E[i][j]!=E[i][(j+1)%3]) return false;
        }
    }
    return true;
}


int main() {

    for(vector<int> &v:C)
        for(int &c:v) cin >> c;

    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            D[i][j] = C[i][j] - C[i][(j+1)%3];
            E[i][j] = C[i][j] - C[(i+1)%3][j];
        }
    }
    
    if(check()) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
template<typename T1, typename T2> istream& operator>>(istream& is, pair<T1,T2>& a){ return is >> a.first >> a.second; }
template<typename T1, typename T2> ostream& operator<<(ostream& os, pair<T1,T2>& a){ return os << a.first << " " << a.second; }
template<typename T> istream& operator>>(istream& is, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) is >> vc[i]; return is; }
template<typename T> ostream& operator<<(ostream& os, vector< T >& vc){ for(int i = 0; i < vc.size(); i++) os << vc[i] << endl; return os; }
 
#define ForEach(it,c) for(__typeof (c).begin() it = (c).begin(); it != (c).end(); it++)
#define ALL(v) (v).begin(), (v).end()
#define UNQ(s) { sort(ALL(s)); (s).erase( unique( ALL(s)), (s).end());}

typedef long long int64;
typedef pair< int , int > Pi;
typedef pair< int , Pi > Pii;
const int INF = 1 << 30;

typedef vector< vector< int > > Graph;
 
int V;
Graph g, rg; //グラフの隣接リストと逆辺の隣接リスト
vector< int > vs; //帰りがけ順の並び
vector< bool > used; //すでに調べたか
vector< int > cmp; // 強連結成分のトポロジカル順序

void init(int size){
  V = size;
  g.resize(V), rg.resize(V);
}
void add_edge(int from, int to){
  g[from].push_back(to);
  rg[to].push_back(from);
}
void dfs(int v){
  used[v] = true;
  for(int i = 0; i < g[v].size(); i++){
    if(!used[g[v][i]]) dfs(g[v][i]);
  }
  vs.push_back(v);
}
void rdfs(int v, int k){
  used[v] = true;
  cmp[v] = k;
  for(int i = 0; i < rg[v].size(); i++){
    if(!used[rg[v][i]]) rdfs( rg[v][i], k);
  }
}
int scc(){
  cmp.resize( V, -1);
  vs.clear();
  used = vector< bool >( V, false);
  for(int v = 0; v < V; v++){
    if(!used[v]) dfs(v);
  }
  used = vector< bool >( V, false);
  int k = 0;
  for(int i = vs.size() - 1; i >= 0; i--){
    if(!used[vs[i]]) rdfs( vs[i], k++);
  }
  return k;
}

int main(){
  int n, m;
  cin >> n;
  init(n);
  cin >> m;
  for(int i = 0; i < m; i++){
    int a, b;
    cin >> a >> b;
    --a, --b;
    add_edge( a, b);
  }
  bool flag = false;
  int cnt = scc();
  for(int i = n - 1; i >= 0; i--){
    cout << vs[i] + 1 << endl;
    if(i > 0){
      bool hoge = true;
      for(int j = 0; j < g[vs[i]].size(); j++){
        if(g[vs[i]][j] == vs[i - 1]){
          hoge = false;
          break;
        }
      }
      flag |= hoge;
    }
  }
  cout << flag << endl;
}

Measured memory_bytes: 2932
import sys

A, B, C, X, Y = map(int, input().split())

if A+B <= 2*C:
	print(A*X + B*Y)
	sys.exit()

else:
	ans = 0
	temp = min(X,Y)
	ans = 2*C*temp
	X -= temp
	Y -= temp

	if X > 0:
		ans += X * min(A, 2*C)
	else:
		ans += Y * min(B, 2*C)

	print(ans)

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

using namespace std;

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

typedef long long int ll;


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

	int n,m,start;
	int arr[101];
	cin >> n >> m >> start;
	rep(i , m)
		cin >> arr[i];
    
    int left=0,right=0;
    for(int i=0 ; i<m ; i++)    
    {
        if(arr[i] < start)
            left++;
        else
            break;
    }

	cout << min(left , m-left);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <deque>
#include <functional>
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#define ll long long int
#define FOR(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, n)

using namespace std;

int main() {
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
    return 0;
}


Measured memory_bytes: 3640
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
5
0 3 2 3 3 1 1 2
1 2 0 2 3 4
2 3 0 3 3 1 4 1
3 4 2 1 0 1 1 4 4 3
4 2 2 1 3 3

output:
0 0
1 2
2 2
3 1
4 3
"""

import sys
import heapq as hp

WHITE, GRAY, BLACK = 0, 1, 2
D_MAX = int(5e10 + 1)


def generate_adj_table(v_table):
    for each in v_table:
        v_index, v_adj_length, *v_adj_list = map(int, each)
        assert len(v_adj_list) == v_adj_length * 2
        for pair in zip(v_adj_list[::2], v_adj_list[1::2]):
            init_adj_table[v_index][pair[0]] = pair[1]

    return init_adj_table


def dijkstra_path_heap():
    # path search init
    path_list[init_vertex] = 0
    path_heap = []
    # heapq: rank by tuple[0], at here it's d[u]
    hp.heappush(path_heap, (0, init_vertex))

    while len(path_heap) >= 1:
        current_vertex = hp.heappop(path_heap)[1]

        color[current_vertex] = BLACK

        for adj_vertex, adj_weight in adj_table[current_vertex].items():
            if color[adj_vertex] is not BLACK:
                # alt: d[u] + w[u,v]
                alt_path = path_list[current_vertex] + adj_weight
                if alt_path < path_list[adj_vertex]:
                    # update path_list
                    path_list[adj_vertex] = alt_path
                    # update heap
                    hp.heappush(path_heap, (alt_path, adj_vertex))
                    parent_list[adj_vertex] = current_vertex
                    color[adj_vertex] = GRAY

    return path_list


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices_num = int(_input[0])
    init_vertices_table = map(lambda x: x.split(), _input[1:])
    # assert len(init_vertices_table) == vertices_num

    parent_list, path_list = [-1] * vertices_num, [D_MAX] * vertices_num
    color = [WHITE] * vertices_num
    init_adj_table = tuple(dict() for _ in range(vertices_num))
    init_vertex = 0

    adj_table = generate_adj_table(init_vertices_table)
    ans = dijkstra_path_heap()
    for i, v in enumerate(ans):
        print(i, v)

Measured memory_bytes: 62908
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <stack>
#include <vector>
#include <math.h>
#include <queue>

using namespace std;

char translate(int ch, int succeed_num){
	switch(ch){
	case 1:
		switch(succeed_num%5){
		case 1:return '.';
		case 2:return ',';
		case 3:return '!';
		case 4:return '?';
		case 0:return ' ';
		}
		break;
	case 2:
		switch(succeed_num%3){
		case 1:return 'a';
		case 2:return 'b';
		case 0:return 'c';
		}
		break;
	case 3:
		switch(succeed_num%3){
		case 1:return 'd';
		case 2:return 'e';
		case 0:return 'f';
		}
		break;
	case 4:
		switch(succeed_num%3){
		case 1:return 'g';
		case 2:return 'h';
		case 0:return 'i';
		}
		break;
	case 5:
		switch(succeed_num%3){
		case 1:return 'j';
		case 2:return 'k';
		case 0:return 'l';
		}
		break;
	case 6:
		switch(succeed_num%3){
		case 1:return 'm';
		case 2:return 'n';
		case 0:return 'o';
		}
		break;
	case 7:
		switch(succeed_num%4){
		case 1:return 'p';
		case 2:return 'q';
		case 3:return 'r';
		case 0:return 's';
		}
		break;
	case 8:
		switch(succeed_num%3){
		case 1:return 't';
		case 2:return 'u';
		case 0:return 'v';
		}
		break;
	case 9:
		switch(succeed_num%4){
		case 1:return 'w';
		case 2:return 'x';
		case 3:return 'y';
		case 0:return 'z';
		}
		break;
	}
	return '\0';	//must not reach here
}

int main(){

	int n,index,pre,count;
	char buf[1025],result[100];

	scanf("%d",&n);

	for(int loop = 0; loop < n; loop++){
		scanf("%s",buf);
		index = 0;
		pre = -1;
		count = 0;

		for(int k = 0; buf[k] != '\0'; k++){
			if(buf[k] >= '1' && buf[k] <= '9'){ //1???9?????´???
				count++;
				if(pre == -1){
					pre = buf[k] - '0';
				}
				//???????????¨????¬????'\0'??§???????¢?????????????????????????????????°????????????????????????????????§???????????????
			}else{ //buf[k] == '0' ?¢?????????????
				if(pre == -1){
					//Do nothing
				}else{
					result[index++] = translate(pre,count);
					result[index] = '\0';
					pre = -1;	//???????????????????????§???????????????
				}
				count = 0;
			}
		}
		printf("%s\n",result);
	}
    return 0;
}

Measured memory_bytes: 3120
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAXN 2005
#define LL long long
LL n,x;
LL a[MAXN],dp[MAXN][MAXN];
int main()
{
	LL ans=1LL<<60LL;
	scanf("%lld %lld",&n,&x);
	for(int i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
		dp[i][0]=a[i];
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n-1;j++)
		{
			int pos=i-j;
			if(pos<=0) pos=n+pos;
			dp[i][j]=min(dp[i][j-1],a[pos]);
		}
	for(int j=0;j<n;j++)
	{
		LL sum=0;
		for(int i=1;i<=n;i++)
			sum+=dp[i][j];
		ans=min(ans,sum+x*j);//x必须要开long long 否则x和j都是int 乘起来要爆掉的
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 31488
def solve():
    from sys import stdin
    f_i = stdin
    
    N = int(f_i.readline())
    U = f_i.readline()
    U
    Q = int(f_i.readline())
    
    ans = []
    for i in range(Q):
        query = f_i.readline().split()
        if query[0] == 'set':
            x, y = map(int, query[1:3])
            x -= 1
            z = query[3]
            U = U[:x] + z * (y - x) + U[y:]
        else:
            a, b, c, d = map(int, query[1:])
            S = U[a-1:b]
            T = U[c-1:d]
            if S < T:
                ans.append('s')
            elif T < S:
                ans.append('t')
            else:
                ans.append('e')
    print('\n'.join(ans))

solve()


Measured memory_bytes: 7632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //10^19 < 9223372036854775807
typedef unsigned long long ull; //10^20 < 18446744073709551615

#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 

#define MOD 1000000007

struct result {
    string state;
    int pena;
};

int main(void)
{
    ll N,M;
    cin >> N >> M;

    vector<pair<int,string>> ps(M+1);
    vector<result> A(N);
    A.push_back({"",0});

    int ok = 0;
    int ng = 0;

    REP (i,M) {
        cin >> ps[i].first >> ps[i].second;
    }

    REP (i,M) {
        if ( A[ps[i].first].state != "AC" ) {
            A[ps[i].first].state = ps[i].second;
        
            if ( A[ps[i].first].state == "WA" ) {
                A[ps[i].first].pena++;
            }
            else if ( A[ps[i].first].state == "AC" ) {
                ok++;
                ng += A[ps[i].first].pena;
            }
        }
    }

    cout << ok << " " << ng << endl;

    return 0;
}


Measured memory_bytes: 14872
sa = input()
sb = input()
sc = input()
ia = 0
ib = 0
ic = 0
na = len(sa)
nb = len(sb)
nc = len(sc)
now = "a"
while True:
    if now == "a":
        now = sa[ia]
        ia += 1
    elif now == "b":
        now = sb[ib]
        ib += 1
    else:
        now = sc[ic]
        ic += 1
    if na == ia and now == "a":
        print("A")
        exit()
    elif nb == ib and now == "b":
        print("B")
        exit()
    elif nc == ic and now == "c":
        print("C")
        exit()


Measured memory_bytes: 3064
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int a,b;
        String op;

        while(true){
          a = scanner.nextInt();
          op = scanner.next();
          b = scanner.nextInt();

          if(op.equals("+")){
            System.out.println(a+b);
          }else if(op.equals("-")){
            System.out.println(a-b);
          }else if(op.equals("*")){
            System.out.println(a*b);
          }else if(op.equals("/")){
            System.out.println(a/b);
          }else if(op.equals("?")){
            break;
          }else{
            break;
          }
        }
    }
}



Measured memory_bytes: 26204
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define ll long long


int main() {
 int t;
 cin>>t;
ll ar[t+5];
REP(i,t)
{
    cin>>ar[i];
}
sort(ar,ar+t);int i=0;
while(1)
{ if(ar[t-1]==1){cout<<1<<endl;return 0;}
    sort(ar,ar+t);
   if(i==t-1) break;
   while(ar[i]==0) i++;
   if(i==t-1) break;
 for(int j=i+1;j<t;j++)
 {ar[j]%=ar[i];
 
 if(ar[j]==1) {cout<<1<<endl;return 0;}
}
}
cout<<ar[t-1]<<endl;
}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    ll N,M;
    cin>>N>>M;
    ll ans = (1900*M + 100*(N-M))*(1<<M);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    string s;
    vector<int> count(4);
    for(int i = 0; i < N; i++){
        cin >> s;
        if(s == "AC") count[0]++;
        else if(s == "WA") count[1]++;
        else if(s == "TLE") count[2]++;
        else if(s == "RE") count[3]++;
        else break;
    }

    cout << "AC x " << count[0] << endl;
    cout << "WA x " << count[1] << endl;
    cout << "TLE x " << count[2] << endl;
    cout << "RE x " << count[3] << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

typedef pair<int,int> P;
typedef long long ll; 

ll mod = 1e9 + 7;


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

	if(n%2!=0){
		cout << "No" << endl;
		return 0;
	}
	for(int i=0;i<n/2;i++){
		if(s[i]!=s[i+n/2]){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = [int(i) for i in input().split()]
d = []
for i in range(n):
    d.append(a[i]- (i+1))
import statistics as s
b = s.median(d)
c = 0
for i in range(n):
    c += abs(d[i] - b)
print(int(c))

Measured memory_bytes: 26356
#include <stdio.h>

int A[1000000], n;


int binarySearch(int key) {
  int left = 0;
  int right = n;
  int mid;
  while(left < right) {
    mid = (left + right) / 2;
    if(key == A[mid]) return 1; 
    if(key > A[mid]) left = mid + 1; 
    else if(key < A[mid]) right = mid; 
  }
  return 0;
}

int main(void) {
  int i, q, k, sum = 0;
  scanf("%d",&n);
  for(i=0; i<n; i++) {
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++) {
    scanf("%d",&k);
    if(binarySearch(k))
      sum++;
  }
  printf("%d\n",sum);
  return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define ll long long
//#define cccgift
//#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
template<typename T>
inline void read(T &x)
{
    static char ch;bool f=1;
    for(x=0,ch=getchar();!isdigit(ch);ch=getchar()) if(ch=='-') f=0;
    for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=getchar());x=f?x:-x;
}
template<typename T>
void print(T x)
{
    if (x<0) x=-x,putchar('-');
    if (x>9) print(x/10);
    putchar(x%10+48);
}
template<typename T>
inline void print(T x,char ap) {print(x);if (ap) putchar(ap);}
template<typename T>
inline void chkmax(T &x,const T &y) {x=x<y?y:x;}
template<typename T>
inline void chkmin(T &x,const T &y) {x=x<y?x:y;}

int main()
{
	ios::sync_with_stdio(false);
	ll a,b,k;cin>>a>>b>>k;
	ll now=min(a,k);a-=now,k-=now;
	now=min(b,k);b-=now,k-=now;
	cout<<a<<' '<<b<<'\n';
	cout<<flush;	
	return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do something instead of nothing and stay organized
*/ 

Measured memory_bytes: 256
n, k = [int(a) for a in input().split()]

count = [0 for _ in range(n)]

for i in range(k):
    input()
    snk = [int(a)-1 for a in input().split()]
    for j in snk:
        count[j] += 1

ans = 0
for c in count:
    if c == 0:
        ans += 1

print(ans)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

struct node{ll x, y, cost;};
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n, m;
    cin >> n >> m;
    ll dis[n][n];
    for(int i=0;i<n;i++)for(int j=0;j<n;j++){
    	if(i == j) dis[i][j] = 0;
    	else dis[i][j] = INF;
    }
    vector<node> v;
    ll a, b, c;
    for(int i=0;i<m;i++){
    	cin >> a >> b >> c;
    	a--;b--;
        v.push_back({a, b, c});
        dis[a][b] = min(dis[a][b], c);
        dis[b][a] = min(dis[b][a], c);
    }
    for(int k=0;k<n;k++){
    	for(int i=0;i<n;i++){
    		for(int j=0;j<n;j++){
    			dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]); 
    		}
    	}
    }
    ll ans = 0;
    for(int k=0;k<m;k++){
    	a = v[k].x;
    	b = v[k].y;
    	c = v[k].cost;
    	bool maki = false;
        for(int i=0;i<n;i++){
        	for(int j=0;j<n;j++){
        		if(dis[i][j] == dis[i][a] + dis[b][j] + c) maki = true;
        	}
        }
        if(maki) ans++;
    }
    cout << m - ans << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> edge;

ll A[1000000];
ll B[1000000];
double C[100][100];
ll n;
bool comp(const ll& left, const ll& right) {
        return A[left] < A[right];
}

int main(){
    ll res;
    string ss;
    cin >> ss;


    if( ss == "SUN") res = 7;
    else if ( ss == "MON" ) res = 6;
    else if ( ss == "TUE" ) res = 5;
    else if ( ss == "WED" ) res = 4;
    else if ( ss == "THU" ) res = 3;
    else if ( ss == "FRI" ) res = 2;
    else res = 1;

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        boolean[][] judg = new boolean[n+1][n+1];

        for(int i=0;i<n+1;i++){
            Arrays.fill(judg[i],false);
        }

        for(int i=0;i<n;i++){
            int u = sc.nextInt();
            int k = sc.nextInt();
            for(int j=0;j<k;j++){
                int v = sc.nextInt();
                judg[u][v] = true;
            }
        }

        int[] d = new int[n+1];
        int[] f = new int[n+1];
        int count = 0;

        for(int i=1;i<=n;i++){
            count = func(judg,d,f,i,count);
        }

        for(int i=1;i<=n;i++){
            System.out.println(i+" "+d[i]+" "+f[i]);
        }
    }

    static int func(boolean[][] judge,int[] d,int[] f,int now,int count){
        if(d[now]!=0){
            return count;
        }
        d[now] = ++count;
        for(int i=1;i<judge.length;i++){
            if(judge[now][i]){
                count = func(judge,d,f,i,count);
            }
        }
        f[now] = ++count;
        return count;
    }
}

Measured memory_bytes: 28236
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    int arr[n+1];
    arr[0]=0;
    for(int i=1;i<=n;i++) cin>>arr[i];
    vector<long long int> dp(n+1,0);
    int turn=((n-1)%2);
    for(int i=n;i>0;i--){
        for(int j=i;j<=n;j++){
            if((i+j)%2==0){
                if(turn==0){
                    dp[j]=max(dp[j]+arr[i],dp[j-1]+arr[j]);
                }
                else{
                    dp[j]=min(dp[j]-arr[i],dp[j-1]-arr[j]);
                }
            }
            else{
                if(turn==1){
                    dp[j]=max(dp[j]+arr[i],dp[j-1]+arr[j]);
                }
                else{
                    dp[j]=min(dp[j]-arr[i],dp[j-1]-arr[j]);
                }
            }
        }
    }
    cout<<dp[n]<<"\n";
}

Measured memory_bytes: 256
import Data.Bits (xor)

main :: IO ()
main = putStrLn . yesno . solve =<< getLine

solve :: String -> Bool
solve xs = check 'N' 'S' xs && check 'W' 'E' xs

check :: Char -> Char -> String -> Bool
check x y xs = (x `elem` xs) `xor` (y `notElem` xs)

yesno :: Bool -> String
yesno True = "Yes"
yesno _ = "No"


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

int compare(P a, P b){
    if(a.first == b.first){
        return a.second > b.second;
    }else{
        return a.first < b.first;
    }
}

int main() {

    int n;
    cin >> n;

    vector<P> p;
    rep(i, n){
        int a, b;
        cin >> a >> b;
        p.emplace_back(b, a);
    }

    bool ok = true;
    sort(all(p), compare);

    ll time = 0;
    rep(i, n){
        time += p[i].second;
        if(p[i].first < time){
            ok = false;
            break;
        }
    }
    if(ok){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 2420
import numpy as np

N = int(input())
lst = np.array(list(map(int, input().split())))

cnt = 1
flag = True
for i in range(1, N):
    mount = lst[i]
    flag = True
    for j in range(0, i):
        if lst[j] > mount:
            flag = False
            break
    if flag == True:
        cnt = cnt + 1
print(cnt)

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

#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define MAX (int)1e9 + 99
#define maxof(a,b,c) max(a,max(b,c))
#define minof(a,b,c) min(a,min(b,c))
#define vi vector<int>
#define vvi vector<vector<int>>
#define vb vector<bool>
#define ll long long
#define ull unsigned long long
#define vll vector<ll>
#define pa pair<int, int>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define bitcnt(x) __builtin_popcount(x)
#define gcd(a,b) __gcd(a,b)
#define all(x) (x).begin(),(x).end()
#define ts(x) to_string(x)
#define rsort(a) sort(all(a)); reverse(all(a))
#define set0(x) memset(x, 0, sizeof(x))
const double pi = 3.14159265358979323846;
ll binpow(ll, ll);
ll mult(ll, ll);
ll add(ll , ll);
ll division(ll, ll);
ll nCr(ll, ll);
ll inv(ll);
void calc();
void maxi(int &a, int b) {if(a<b) a = b;}
void mini(int &a, int b) {if(a>b) a = b;}
template<class T> istream &operator>>(istream &is, vector<T> &v) { for (T &x : v) is >> x; return is;}
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) {if (!v.empty()) {os << v.front();for (int i = 1; i < v.size(); ++i) os << ' ' << v[i];} return os;}
const int N=50010;
const int MOD = 1e9+7;
//ll fact[N];






void solve()
{
    int n;
    cin>>n;
    
    ll ans = 0;
    for(int a = 1; a<n; a++) {
        ans += n/a - (n%a  == 0);
    }

    cout<<ans;
}

int main()
{
    fastio;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    // cin>>t;
    
    rep(i,t)
    {
        solve();
        cout<<"\n";
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}








ll add(ll a, ll b){
    a+=b;
    while(a>=MOD) a-=MOD;
    while(a<0) a+=MOD;
    return a;
}

ll mult(ll a, ll b){
    return (a * 1ll * b) % MOD;
}


ll binpow(ll a, ll b){
    ll c = 1;
    while(b > 0)
    {
        if(b % 2 == 1)
            c = mult(c, a);
        a = mult(a, a);
        b /= 2;
    }
    return c;   
}

ll inv(ll a){
    return binpow(a, MOD-2);
}

ll division(ll a, ll b){
    return mult(a, inv(b));
}
/*
ll nCr(ll n, ll r){
    if(r > n) return 0;
    return division(fact[n], mult(fact[n-r], fact[r]));
}

void calc(){
    fact[0] = 1;
    srep(i,1,N-1)
        fact[i] = (i*1ll*fac[i-1])%MOD;

}*/

Measured memory_bytes: 3808
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>
#include <ios>
#include <iomanip>
#include <functional>
#include <queue>

#define int long long
int inf = (1LL <<  62);
using namespace std;

int re(string s, vector<vector <int>> p, int n){
    if(s.size() == n){
        for(int i = 0; i < p.size(); i++){
            int cnt = 0;
            for(int j = 0; j < p[i].size() - 1; j++){
                if(s[p[i][j] - 1] == '1'){
                    cnt++;
                }
            }
            if(cnt % 2 != p[i][p[i].size() - 1]){
                return 0;
            }
        }
        return 1;
    }
    else{
        return (re(s+"0", p, n) + re(s+"1", p, n));
    }
}

signed main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int>> v(m);
    for(int i = 0; i < m; i++){
        int k;
        cin >> k;
        for(int j = 0; j < k; j++){
            int x;
            cin >> x;
            v[i].push_back(x);
        }
    }
    for(int i = 0; i < m; i++){
        int x;
        cin >> x;
        v[i].push_back(x);
    }
    cout << re("", v, n);
}

Measured memory_bytes: 256
mod = 10**9 + 7
def sum(a, b):
    r = (a + b)*(b - a + 1) / 2
    return int(r)

def main():
    sum_num = 0
    N, K = list(map(int, input().split(" ")))
    for i in range(K, N+2):
        mi = sum(0, i - 1)
        ma = sum(N-i+1, N)
        sum_num += ma - mi + 1

    print(sum_num % mod)

if __name__ == "__main__":
    main()

    

Measured memory_bytes: 9200
#include <bits/stdc++.h>
using namespace std;
     
#define int  long long
#define endl '\n'
using pii = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const int N = 1e6 + 10;

struct IOsetup{
  IOsetup(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
}IO;

int32_t main(){
  int a, b;
  cin >> a >> b;
  int g = __gcd(a, b);
  int ret = a / g * b;
  cout << ret << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not (a))
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
const int MAX = (int)2e5 + 5;

double v;

int main() {
	while (cin >> v) {
		double t = v / 9.8;
		double y = 4.9*t*t;
		int floor = ceil( y / 5 + 1 + 1e-8);
		cout << floor << endl;
	}
	return 0;
}

Measured memory_bytes: 3196
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long N = (long) scanner.nextInt();
        int[] theOne = new int[3500];
        for (int i = 0; i < 3500; i++) theOne[i] = i+1;

        for (long j = 1; j <= 3500; j++) {
            for (long k = 1; k <= 3500;k++) {
                long x = (j * k * N);
                long y = 4 * j * k - N * (j + k);
                if (y != 0) {
                    int thatOne = binarySearch(theOne, x, y, 0, theOne.length - 1);
                    if (thatOne > 0) {
                        System.out.println(j + " " + k + " " + thatOne);
                        return;
                    }
                }
            }
        }
    }

    private static int binarySearch(int[] field, long x, long y, int start, int end) {
        if (start > end || start >= field.length || end < 0) return -1;
        int mid = (start + end) / 2;
        if (field[mid] * y < x) return binarySearch(field, x, y, mid + 1, end);
        else if (field[mid] * y > x) return binarySearch(field, x, y, start, mid - 1);
        else return field[mid];
    }

}




Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define int long long int
#define mod(x) ((x % MOD) + MOD) % MOD
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define RFORE(i,a,b) for(int i=(b);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) (UB(c,x)-LB(c,x))
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (bool)((s).find(e)!=(s).end())
#define PB push_back
#define MP make_pair
#define DEL(v) decltype(v)().swap(v)
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
using namespace std;
template<typename T1, typename T2> using P = pair<T1,T2>;
template<typename T> using V = vector<T>;
struct edge { int from, to; int cost; };
bool operator< (const edge &edge1, const edge &edge2) { return edge1.cost < edge2.cost; };
const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator << (ostream& s, const V<T>& v) {
   s << "[";
   for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
   s << "]";
   return s;
}

void bellman(const V<V<int>>& A, V<int>& d)
{
   int N = SZ(A);
   REP(k, N) REP(i, N) REP(j, N) d[i] = min(d[i], d[j] + A[i][j]);
}

void warshall_floyd(vector< vector<int> >& d)
{
   int N = d.size();
   for (int k = 0; k < N; k++) {
      for (int i = 0; i < N; i++) {
         for (int j = 0; j < N; j++) {
            d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
         }
      }
   }
}


template<typename T1, typename T2> ostream& operator << (ostream& s, const P<T1,T2>& p) {
   s << "(" << p.first << "," << p.second << ")";
   return s;
}

signed main()
{
   int N; cin >> N;
   V<V<int>> A(N,V<int>(N));
   REP(i,N) REP(j,N) cin >> A[i][j];

   V<V<int>> d(N,V<int>(N));
   REP(i, N) COPY(A, d);
   warshall_floyd(d);

   bool flag = true;
   FOR(i, 0, N) FOR(j, i+1, N) if (d[i][j] < A[i][j]) flag = false;
   if (!flag) {
      cout << -1 << endl; return 0;
   }

   int ans = 0;
   FOR(i, 0, N) {
      FOR(j, i+1, N) {
         bool canRemove = false;
         REP(k, N) {
            if (i == k || j == k) continue;
            if (d[i][j] == d[i][k] + d[k][j]) {
               canRemove = true;
               break;
            }
         }
         if (!canRemove) ans += A[i][j];
      }
   }
   cout << ans << endl;

   return 0;
}


Measured memory_bytes: 1664
first_f :: Double -> Bool
first_f = (>) 165

last_f :: Double -> Bool
last_f = (<) 185

func :: Double -> Double -> Bool
func i d = (i <= d) && (d < i + 5)

toS :: (Double -> Bool) -> [Double] -> String
toS _ [] = ""
toS f (d:dr)
  |f d = '*':(toS f dr)
  |otherwise = toS f dr

functions :: [(String, (Double -> Bool))]
functions = [("1:", first_f), ("2:", func 165), ("3:", func 170), ("4:", func 175), ("5:", func 180), ("6:", last_f)]

solve :: [(String, Double -> Bool)] -> [Double] -> [String]
solve [] _ = []
solve ((s, f):fr) l = (s ++ (toS f l)) : (solve fr l)



main :: IO()
main = do
  (n:arg) <- fmap lines getContents
  mapM_ putStrLn (solve functions (map (\n -> read n :: Double) arg))

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

int n,m;
int res[100002];
int par[100002];
vector<int> chi[100002];

signed main(){
  cin>>n>>m;
  for(int i=0;i<n+m-1;i++){
    int a,b;
    cin>>a>>b;
    par[b]++;
    chi[a].push_back(b);
  }
  queue<int> que;
  for(int i=1;i<=n;i++){
    res[i]=-1;
    if(par[i]==0){
      res[i]=0;
      que.push(i);
    }
  }
  while(!que.empty()){
    int nd=que.front(); que.pop();
    for(int ch : chi[nd]){
      if(--par[ch]==0){
        res[ch]=nd;
        que.push(ch);
      }
    }
  }
  for(int i=1;i<=n;i++){
    cout<<res[i]<<"\n";
  }
}


Measured memory_bytes: 7040
#include <bits/stdc++.h>
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
template<class T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

bool calc(vector<int> &AA,int p){
  if(p>=sz(AA)) return true;
  if(p==-1) return false;

  if(AA.at(p)==p){
    if(p==0)  AA.at(p)=-1;
    else  AA.at(p)=AA.at(p-1);
    return true;
  }
  if(calc(AA,AA.at(p))) return true;
  else{
    AA.at(p)=-1;
    return false;
  }
}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int T;
  cin >> T;
  for(int _=0;_<T;_++){
    int N;
    cin >> N;
    vector<pair<ll,int>> XX;
    vector<pair<ll,int>> YY;
    ll ans=0;
    for(int i=0;i<N;i++){
      int K;
      ll L,R;
      cin >> K >> L >> R;
      K--;

      ans+=R;
      ll tmp=L-R;
      if(tmp>=0)  XX.p_b(m_p(tmp,K));
      else  YY.p_b(m_p(tmp,N-1-K-1));
    }
    sort(all(XX));
    reverse(all(XX));
    sort(all(YY));

    int sizeX=sz(XX);
    vector<int> AA(sizeX);
    for(int i=0;i<sizeX;i++)  AA.at(i)=i;
    for(int i=0;i<sizeX;i++){
      if(calc(AA,XX.at(i).se))  ans+=XX.at(i).fi;
    }
    int sizeY=sz(YY);
    vector<int> BB(sizeY);
    for(int i=0;i<sizeY;i++)  BB.at(i)=i;
    for(int i=0;i<sizeY;i++){
      if(!calc(BB,YY.at(i).se))  ans+=YY.at(i).fi;
    }
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 7168
#include<bits/stdc++.h>
#define lli long long
#define rep0(i,j) for(int i=0;i<j;i++)
using namespace std;
int main(){
    lli k, n;
    cin >> n >> k;
    vector<lli> vec(n);
    double ans=-1,num=0;
    rep0(i,k){
        cin >> vec[i];
        num+=(double)(vec[i]+1)/2;
    }
    ans=num;
    rep0(i,n-k){
        cin >> vec[i+k];
        num += (double)(vec[i+k]+1)/2-(double)(vec[i]+1)/2;
        if(ans < num)ans=num;
    }
    printf("%lf", ans);

    
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

class Tree {
	using T = pair<ll, int>;
	int n;
	vector<vector<T>> edge;
	vector<ll> d;

public:
	Tree(int N) : n(N), edge(N), d(N, INT64_MAX) {}
	void add(int a, int b, ll c) {
		edge[a].emplace_back(c, b);
		edge[b].emplace_back(c, a);
	}
	void dfs(int k, int p = -1) {
		if (p < 0) d[k] = 0;
		for (auto &t : edge[k]) {
			ll c;
			int j;
			tie(c, j) = t;
			if (j == p) continue;
			d[j] = d[k] + c;
			dfs(j, k);
		}
	}
	ll distance(int i) {
		return d[i];
	}
};

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

	int N;
	cin >> N;
	Tree tree(N);
	REP(i, N - 1) {
		int a, b;
		ll c;
		cin >> a >> b >> c;
		--a;
		--b;
		tree.add(a, b, c);
	}
	int Q, K;
	cin >> Q >> K;
	--K;
	tree.dfs(K);
	REP(i, Q) {
		int x, y;
		cin >> x >> y;
		--x;
		--y;
		cout << tree.distance(x) + tree.distance(y) << endl;
	}

	return 0;
}

Measured memory_bytes: 12800
#include<bits/stdc++.h>
#define rush() int T;scanf("%d",&T);int kase=1;while(T--)
#define all(x) (x).begin(),(x).End()
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define pb(x) push_back(x)
#define mem(a) memset(a,0,sizeof(a))
using namespace std;
using std::bitset;
typedef long long ll;
const ll maxn=1e6+5;
const ll mod=998244353;
const ll INF=0x3f3f3f3f3f3f3f3f;
const long double PI=acos(-1.0);
const long double eps=1e-5;
inline ll read(){ll ans=0,flag=1;char c;c=getchar();while(c<'0' || c>'9'){if(c=='-')flag=-1;c=getchar();}while(c>='0' && c<='9'){ans=ans*10+(ll)(c-'0');c=getchar();}return ans*flag;}
ll quickpow(ll x,ll y,ll mod){ll ans=1;while(y){if(y&1)ans=ans*x%mod;x=x*x%mod;y>>=1;}return ans;}

int main()
{
    ll n;
    while(cin>>n)
    {
    int num=0;
    ll t=1;
    while(t<=n)
    {
        num++;
        t=t<<1;
    }
    t=t-1;
    cout<<t;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char* argv[]){
    short a,b,c,d,e,k;
    cin >> a >> b >> c >> d >> e >> k;
    if ( e - a <= k){
        cout << "Yay!" << endl;
    } else {
        cout << ":(" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
N = int(input())
*A, = map(int, input().split())
X = [0]*N
total = sum(A)
X[0] = total - 2*sum([a for a in A[1::2]])
for i in range(1, N):
    X[i] = 2*A[i-1] - X[i-1]
print(*X)

Measured memory_bytes: 14092