akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def factorize(num: int) -> dict:
    """ 素因数分解 """
    from math import sqrt
    from collections import Counter

    d = Counter()
    # 終点はルート切り捨て+1
    for i in range(2, int(sqrt(num))+1):
        # 素因数分解：小さい方から割れるだけ割って素数をカウント
        while num % i == 0:
            num //= i
            d[i] += 1
        # 1まで分解したら終了
        if num == 1:
            break
    # 最後に残ったnumは素数(ただし1^1は1^0なので数に入れない)
    if num != 1:
        d[num] += 1
    return d

N = INT()

# N!までを全部素数冪でまとめる
primes = Counter()
for i in range(2, N+1):
    primes.update(factorize(i))

# 約数が75になる素数冪の組み合わせを数える
primes = sorted(primes.values())
M = len(primes)
cnt = 0
# 3種類使う
for i, v1 in enumerate(primes):
    for j, v2 in enumerate(primes[i+1:], i+1):
        for k, v3 in enumerate(primes[j+1:], j+1):
            if v1 >= 2 and v2 >= 4 and v3 >= 4:
                cnt += 1
            if v1 >= 4 and v2 >= 2 and v3 >= 4:
                cnt += 1
            if v1 >= 4 and v2 >= 4 and v3 >= 2:
                cnt += 1
# 2種類使う
for i, v1 in enumerate(primes):
    for j, v2 in enumerate(primes[i+1:], i+1):
        if v1 >= 2 and v2 >= 24:
            cnt += 1
        if v1 >= 4 and v2 >= 14:
            cnt += 1
        if v1 >= 24 and v2 >= 2:
            cnt += 1
        if v1 >= 14 and v2 >= 4:
            cnt += 1
# 1種類使う
for i, v1 in enumerate(primes):
    if v1 >= 74:
        cnt += 1
print(cnt)


Measured memory_bytes: 3440
def compute_divisors(num):
    divisors = set()
    for i in range(1, int(num**.5) + 1):
        if num % i == 0:
            divisors.add(i)
            divisors.add(num // i)
    return divisors

print(sum(len(compute_divisors(i))==8 for i in range(1,int(input())+1, 2)))

Measured memory_bytes: 3188
#include <stdio.h>

int main(void) {
	int W, a, b;
	int x, ans;

	scanf("%d %d %d", &W, &a, &b);
	if (a > b) {
		x = a;
		a = b;
		b = x;
	}

	if (b <= a + W) printf("0\n");
	else printf("%d\n", b - (a + W));

	return 0;
}

Measured memory_bytes: 128
function main(input){
  input = input.split("\n");
  var n = parseInt(input[0].split(" ")[0]);
  var m = parseInt(input[0].split(" ")[1]);
  var l = [];
  var r = [];
    
  for (var i = 0; i < m; i++) {
    l[i] = parseInt(input[i+1].split(" ")[0]);
    r[i] = parseInt(input[i+1].split(" ")[1]);
  }

  lmax = Math.max.apply(null,l);
  rmin = Math.min.apply(null,r);

  var answer = (rmin - lmax +1)>0 ? (rmin - lmax +1) : 0 ;
  console.log(answer);

}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using namespace std;

int somaDig(int a, int b){
    int soma = 0;
    while(a){
        soma += a%10;
        a/=10;
    }
    while(b){
        soma += b%10;
        b/=10;
    }
    return soma;
}

int main(int qtd, char* nome[])
{
    ios::sync_with_stdio(false);

    int a, b, n;
    cin >> n;

    int resp = somaDig(n/2, n-(n/2));
    int i = 0;
    while (true){
        int a;
        a = pow(10, i);
        if (resp > somaDig(a, n-a))
            resp = somaDig(a, n-a);
        else
            break;
    }
    cout << resp;

    return 0;
}


Measured memory_bytes: 256
eval"N,K="+`tr \\  ,`
I=r=s=1,1
2.upto([N,K+x=y=1].min){|i|x=x*N*r%M=10**9+7
s+=x*y=y*r%M*N-=1
I<<r=M/i*-I[M%i]%M}
p s%M

Measured memory_bytes: 3724
S = list(input())
rest = [0] * (len(S) + 1)
rest[0] = 0
rd = 1
for i in range(len(S)):
    rest[i+1] = (rest[i] + int(S[-(i+1)]) * rd) % 2019
    rd *= 10
    rd %= 2019
    # print(i, rest[i+1], rest[i], int(S[-(i+2)]), int(S[-(i+2)]) * 10 ** (i+1))
# print(rest)
cnt = [0] * (2019 + 1)
for i in rest: cnt[i] += 1
ans = 0
for i in range(2020):
    ans += cnt[i] * (cnt[i] - 1) // 2
print(ans)

Measured memory_bytes: 79192
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
 
int main() {
	string s; cin >> s;
	REP(i,3){
		if(s[i]=='7'){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=998244353;

template<class T>
inline bool chmax(T &a, T b) {
  if(a < b) {
    a = b;
    return true;
  }
  return false;
}

template<class T>
inline bool chmin(T &a, T b) {
  if(a > b) {
    a = b;
    return true;
  }
  return false;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int i,j;
  ll n,s;
  cin>>n>>s;
  ll a[n+1];
  VI v(3030,0);
  for(i=1;i<=n;i++) {
    cin>>a[i];
  }
  ll ans=0;
  for(i=1;i<=n;i++){
    for(j=s-a[i];j>=1;j--){
      if(j+a[i]==s) {
        ans+=v[j]*(n+1-i);
        ans%=mod;
      }
      v[j+a[i]]+=v[j];
      v[j+a[i]]%=mod;
    }
    v[a[i]]+=i;
    if(a[i]==s) {
        ans+=i*(n+1-i);
        ans%=mod;
    }
    //cout<<ans<<endl;
  }
  cout<<ans<<endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string voting(int n,int m,int a[],int sum)
{
    sort(a,a+n,greater<int>());
    double x;
    x = (double)1/(4*m);
    for(int i=0;i<m;i++)
    {
        double y;
        y = (double)a[i]/sum;
        if(y<x)
        {
            return "No";
        }
    }
    return "Yes";
}
int main()
{
    int n,m,a[101],sum = 0;
    string res;
    cin>>n>>m;
    for(int i = 0;i<n;i++)
    {
        cin>>a[i];
        sum+=a[i];
    }
    res = voting(n,m,a,sum);
    cout<<res;
    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let m = read::<usize>();

    let mut ab = vec![(0usize, 0i64); n];
    let mut c = vec![vec![]; m as usize];

    for i in 0..n {
        ab[i].0 = read::<usize>();
        ab[i].1 = read::<i64>();

        if ab[i].0 <= m {
            c[ab[i].0 - 1].push(ab[i].1);
        }
    }

    let mut pq = std::collections::BinaryHeap::new();
    let mut ans = 0;
    for i in 0..c.len() {
        for &w in c[i].iter() {
            pq.push(w);
        }
        if let Some(w) = pq.pop() {
            ans += w;
        }
    }
    println!("{}", ans);
}

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

int main(){
    int x, y;
    cin >> x >>y;
    
    if (x > y) cout << "a > b" << endl;
    else if (x == y) cout << "a == b" << endl;
    else if (x < y) cout << "a < b" << endl;
    
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define P 1000000007
#define inf 1e18
int main()
{
    ll i, n;
    string s;
    cin >> s;
    n = s.length();

    for (i = s.length() % 2 == 0 ? 2 : 1; i < n; i = i + 2)
    {
        string t;
        for (ll j = 0; j < n - i; j++)
            t = t + s[j];
        ll len = t.length();
        string t1 = t.substr(0, len / 2);
        string t2 = t.substr(len / 2, len / 2);
        if (t1 == t2)
        {
            cout << len << "\n";
            exit(0);
        }
    }

    return (0);
}

Measured memory_bytes: 3584
# coding: utf-8
import sys
input = sys.stdin.readline

N, M = [int(i) for i in input().split()]

plices = [[int(i) for i in input().split()] for _ in range(N)]

plices.sort(key = lambda x:x[0])

m = 0
cost = 0

for i in range(N):
    if m >= M:
        break
    buy = min(M - m, plices[i][1])
    cost += plices[i][0] * buy
    m += buy

print(cost)

Measured memory_bytes: 22800
import java.io.IOException;
import java.io.InputStream;
import java.util.*;

public class Main {
    public static void main(String[] args){
        FastScanner sc = new FastScanner();
        int n = sc.nextInt();
        int[] array = new int[n];
        double cost = 0;
        int flag = 0;
        for(int i=0; i<n; i++){
            array[i] = sc.nextInt();
        }
        Arrays.sort(array);

        for(int j=array[0]; j <= array[array.length -1]; j++){
            int presentCost = 0;
            for(int num : array){
                presentCost +=  Math.pow((num - j), 2);
            }
            if(j == array[0]) cost = presentCost;

            if(presentCost < cost) {
                cost = presentCost;
            }

        }

        System.out.println((int) cost);

    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            }else{
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }else if(b == -1 || !isPrintableChar(b)){
                    return minus ? -n : n;
                }else{
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
    }
}


Measured memory_bytes: 21332
'use strict';

function Main(input) {
  const A = input.split("\n")[0]
  const B = input.split("\n")[1]
  const C = input.split("\n")[2]
  const D = input.split("\n")[3]
  const E = input.split("\n")[4]

  const endA = A.substr(-1, 1)
  const endB = B.substr(-1, 1)
  const endC = C.substr(-1, 1)
  const endD = D.substr(-1, 1)
  const endE = E.substr(-1, 1)
  
  let endMin = 10
  if (endA < endMin && endA != 0) {
      endMin = endA
  }
  if (endB < endMin && endB != 0) {
      endMin = endB
  }
  if (endC < endMin && endC != 0) {
      endMin = endC
  }
  if (endD < endMin && endD != 0) {
      endMin = endD
  }
  if (endE < endMin && endE != 0) {
      endMin = endE
  }

  const roundA = Math.ceil(A / 10) * 10
  const roundB = Math.ceil(B / 10) * 10
  const roundC = Math.ceil(C / 10) * 10
  const roundD = Math.ceil(D / 10) * 10
  const roundE = Math.ceil(E / 10) * 10

  console.log(roundA + roundB + roundC + roundD + roundE - 10 + Number(endMin))
};

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 21064
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void){
    
    double r;
    double a;
    double b;
    
    cin>>r;
    
    a=r*r*3.141592653589;
    b=2*r*3.141592653589;
    
    printf("%f %f\n",a,b);
}



Measured memory_bytes: 3136
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,k,a,d[10001],s[9],t[]={2,5,5,4,5,6,3,7,6};
vector<ll>v;
int main(void){
    cin>>n>>k;
    for(int i=0;i<k;i++){
        cin>>s[i];
        s[i]--;
    }
    sort(s,s+k);
    reverse(s,s+k);
    for(int i=1;i<=n;i++)d[i]=-(1LL<<30);
    for(int i=1;i<=n;i++){
        for(int j=0;j<k;j++){
            if(i-t[s[j]]<0)continue;
            if(d[i-t[s[j]]]<0)continue;
            d[i]=max(d[i],d[i-t[s[j]]]+1);
        }
    }
    while(n){
        for(int i=0;i<k;i++){
            if(n-t[s[i]]<0)continue;
            if(d[n]-1==d[n-t[s[i]]]){
                v.push_back(s[i]);
                n-=t[s[i]];
                break;
            }
        }
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    for(int i=0;i<v.size();i++){
        cout<<v[i]+1;
    }
    cout<<endl;
}


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

vector<int> vec={8,9,5,7,11};
int solve(int n){
    vector<int> d(n);
    vector<vector<int>> q(n);
    for(int i=0;i<n;i++){
        cin>>d[i];
        q[i].resize(d[i]);
        int t;
        cin>>t;
        for(int j=0;j<d[i];j++){
            cin>>q[i][(j+(d[i]-t))%d[i]];
        }
    }
    vector<vector<int>> gcdv(25,vector<int>(25,0));
    for(int i=0;i<25;i++){
        for(int j=0;j<25;j++){
            if(i!=0 && j!=0) gcdv[i][j]=__gcd(i,j);
        }
    }
    vector<vector<int>> tq(24);
    for(int i=0;i<24;i++){
        tq[i].assign(i+1,0);
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<d[i];j++) tq[d[i]-1][j]+=q[i][j];
    }
    int cnt=0;
    auto calc=[&](vector<int> v){
        int res=0;
        for(int i=0;i<24;i++){
            int sc=-1e9;
            for(int j=0;j<i+1;j++){
                bool isok=true;
                for(int k=0;k<vec.size();k++){
                    int g=gcdv[vec[k]][i+1];
                    isok=isok && (v[k]%g==j%g);  
                    cnt++;
                }
                if(isok) sc=max(sc,tq[i][j]);
            }
            res+=sc;
        }
        return res;
    };
    function<int(int,vector<int>)> dfs=[&](int idx,vector<int> v){
        if(idx==vec.size()) return calc(v);
        int res=0;
        for(int i=0;i<vec[idx];i++){
            v[idx]=i;
            res=max(res,dfs(idx+1,v));
        }
        return res;
    };
    
    vector<int> tmp(vec.size());
    int ret=dfs(0,tmp);
    return ret;
}
int main(){
    int n;
    while(cin>>n,n){
        cout<<solve(n)<<endl;
    }
    return 0;
}


Measured memory_bytes: 3128
#include <stdio.h>
#include <stdint.h>

static uint64_t
gcd (
  int a,
  int b
  )
{
  if ( a == 0 ) return ( b );

  return
  gcd ( b % a, a );
}

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  for ( ; ; )
  {
    uint64_t a1, m1, a2, m2, a3, m3;
    uint64_t x1, x2, x3;
    uint64_t n1, n2, n3;

    scanf ( "%llu%llu%llu%llu%llu%llu", &a1, &m1, &a2, &m2, &a3, &m3 );
    if ( !( a1 | m1 | a2 | m2 | a3 | m3 ) ) break ;

    for ( x1 = a1 % m1, n1 = 1; x1 != 1; x1 = ( x1 * a1 ) % m1, ++n1 ) ;
    for ( x2 = a2 % m2, n2 = 1; x2 != 1; x2 = ( x2 * a2 ) % m2, ++n2 ) ;
    for ( x3 = a3 % m3, n3 = 1; x3 != 1; x3 = ( x3 * a3 ) % m3, ++n3 ) ;

    n1 = n1 * n2 / gcd ( n1, n2 );
    n1 = n1 * n3 / gcd ( n1, n3 );
    printf ( "%llu\n", n1 );
  }

  return ( 0 );
}

Measured memory_bytes: 0
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import           Data.Bits             (testBit)
import qualified Data.ByteString.Char8 as BC
import           Data.List             (sortOn)
import           Data.Maybe            (fromJust)
import           Data.Ord              (Down (Down))

main :: IO ()
main = do
  [n, m] <- readInts <$> BC.getLine
  xyzs <- map readInts . BC.lines <$> BC.getContents
  print $ solve n m xyzs

solve :: Int -> Int -> [[Int]] -> Int
solve n m xyzs = maximum $ map solve1 [(0 :: Int) .. 7] where
  solve1 i = sum . take m $ sortOn Down scores where
    scores = map (sum . zipWith (*) (coef i)) xyzs

coef :: Int -> [Int]
coef i = map test [0 .. 2] where
  test k = if testBit i k then 1 else -1

readInt :: BC.ByteString -> Int
readInt = fst . fromJust . BC.readInt

readInts :: BC.ByteString -> [Int]
readInts = map readInt . BC.words


Measured memory_bytes: 1404
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static readonly int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			int n = int.Parse(Console.ReadLine());
			//string s = Console.ReadLine();
			//string[] s = Console.ReadLine().Split();
			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();

			int i = 0;
			int c = 0;
			for (int j = 0; j < n; j++) {
				if (vs[j] == i + 1) {
					i++;
				} else {
					c++;
				}
			}
			if (i > 0) {
				Console.WriteLine(c);
			} else {
				Console.WriteLine(-1);
			}


			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 35676
#include<stdio.h>
int main(){
    int n;
    char s[100000+1][3+1];
    int c=0;
    int c1=0;
    int c2=0;
    int c3=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%s",s[i]);
    }
    for(int i=0;i<n;i++){
        if(s[i][0]=='A'){
            c=c+1;
        }else if(s[i][0]=='W'){
            c1=c1+1;
        }else if(s[i][0]=='T'){
            c2=c2+1;
        }else if(s[i][0]=='R'){
            c3=c3+1;
        }
    }
    printf("AC x %d\n",c);
    printf("WA x %d\n",c1);
    printf("TLE x %d\n",c2);
    printf("RE x %d\n",c3);
}

Measured memory_bytes: 2116
# include <iostream>

using namespace std; 
  
int main() 
{ 
	bool answer = false;
	int num;
	num = 0;
	cin >> num;
	
	for ( int i = 1 ; i <= 9 && answer == false; i++ ) {
		for ( int u = 1; u <= 9 && answer == false && i*u <= num; u++ ) {
			if ( i * u == num )
				answer = true;
		} // for
	} // for
  
  	if ( answer == true )
  		cout << "Yes";
  	else
  		cout << "No";
} // main()

Measured memory_bytes: 256
#!/usr/bin/env python3

from pprint import pprint
from collections import deque, defaultdict
import itertools
import math
import sys

sys.setrecursionlimit(10 ** 6)
INF = float('inf')


N, M = map(int, input().split())
edges = []
for _ in range(M):
    u, v = map(int, input().split())
    # 0-index
    edges.append([u-1, v-1])

# ある辺に着目したとき、それ以外の辺を一つずつグラフに追加し parents を更新する
# u <-> v を繋ぐ辺をグラフに追加した際、parents の u or v の親を更新する
# 全ての辺を繋ぎ終えたときの異なる親を数え、その値が 1 より多きければ着目したその辺は橋である


def root(u):
    if parents[u] < 0:
        return u
    parents[u] = root(parents[u])
    return parents[u]


def has_same_root(u, v):
    return root(u) == root(v)


def size(root_u):
    return -parents[root_u]


def unite(u, v):
    if has_same_root(u, v):
        return
    root_u = root(u)
    root_v = root(v)
    if size(root_u) > size(root_v):
        root_u, root_v = root_v, root_u
    parents[root_v] = root_u


ans = 0
for e_i in edges:
    parents = [-1 for _ in range(N)]
    for e_j in edges:
        if e_i == e_j:
            continue
        u, v = e_j
        unite(u, v)

    count = 0
    for i in range(N):
        if parents[i] < 0:
            count += 1
    if count > 1:
        ans += 1

print(ans)


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

using namespace std;

int main(){
  long long N;
  cin>>N;
  vector<long long> A(N);
  for(int i=0; i<N; i++){
    cin>>A[i];
  }
  long long ans=0;
  long long searchnum=1;
  for(int i=0; i<A.size(); i++){
    if(A[i]==searchnum){
		searchnum++;
    }else{
      	ans++;
    }
  }
  
  if(searchnum==1){
    cout<<-1<<endl;
  }else{
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1792
#!/usr/bin/perl
use Data::Dumper;

my ($h,$w) = map {$_ - 0} split(/\s+/o,<STDIN>);

my @res = ();
my @row = ();
$#row = $w - 1;
for(my $i=0;$i<$h;$i++){
  my @a = map { ( $_ - 0 ) % 2 } split(/\s+/o,<STDIN>);
  for(my $j=0;$j<$w;$j++){
    $row[$j] = (( $a[$j] + $row[$j] ) % 2);
    push(@res,+[1+$i,1+$j,2+$i,1+$j]) if $row[$j] == 1 and $i<$h-1;
  }
}

for(my $j=0;$j<$w-1;$j++){
  if( $row[$j] == 1 ){
    $row[1+$j] = ( ( $row[1+$j] + $row[$j] ) % 2 );
    push(@res,+[$h,1+$j,$h,2+$j]);
  }
}
my $N = 1+$#res;
print "$N\n";
foreach my $re (@res){
  print sprintf("%d %d %d %d\n",$re->[0],$re->[1],$re->[2],$re->[3]);
}

exit(0);



Measured memory_bytes: 33408
/*input
5 6
1 2 0
0 1 1
0 2 2
-3 4 -1
-2 6 3
1 0 1
0 1 2
2 0 2
-1 -4 5
3 -2 4
1 2 4
*/

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

struct L {
  int a, b, c;
  L(int a=0, int b=0, int c=0): a(a), b(b), c(c) {}
};

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

int main() {
  int n, m;
  cin >> n >> m;
  map<int, int> mpX, mpY;
  mpX[0] = 0;
  mpY[0] = 0;


  vector<L> lh, lv;
  rep(i, n) {
    int a, b, c;
    cin >> a >> b >> c;
    mpX[a] = 0;
    mpX[b] = 0;
    mpY[c] = 0;
    lh.emplace_back(a, b, c);
  }
  rep(i, m) {
    int a, b, c;
    cin >> c >> a >> b;
    mpY[a] = 0;
    mpY[b] = 0;
    mpX[c] = 0;
    lv.emplace_back(a, b, c);
  }

  vector<int> xs, ys;
  for (auto& p: mpX) {
    p.second = xs.size();
    xs.push_back(p.first);
  }
  for (auto& p: mpY) {
    p.second = ys.size();
    ys.push_back(p.first);
  }

  int h = xs.size()*2;
  int w = ys.size()*2;

  vector<vector<int>> d(h, vector<int>(w));
  // Construct walls
  rep(i, n) {
    int a = mpX[lh[i].a]*2;
    int b = mpX[lh[i].b]*2;
    int c = mpY[lh[i].c]*2;
    for (int x = a; x <= b; ++x) d[x][c] = -1;
  }
  rep(i, m) {
    int a = mpY[lv[i].a]*2;
    int b = mpY[lv[i].b]*2;
    int c = mpX[lv[i].c]*2;
    for (int y = a; y <= b; ++y) d[c][y] = -1;
  }

  queue<P> q;
  int sx = mpX[0]*2, sy = mpY[0]*2;
  d[sx][sy] = 1;
  q.emplace(sx, sy);
  while (!q.empty()) {
    int x = q.front().first;
    int y = q.front().second;
    q.pop();
    rep(v, 4) {
      int nx = x+dx[v], ny = y+dy[v];
      if (nx < 0 || nx >= h) continue;
      if (ny < 0 || ny >= w) continue;
      if (d[nx][ny] != 0) continue;
      d[nx][ny] = 1;
      q.emplace(nx, ny);
    }
  }
  ll ans = 0;
  rep(x, h) rep(y, w) {
    if (d[x][y] != 1) continue;
    if (x == 0 || x == h-1 || y == 0 || y == w-1) {
      cout << "INF" << endl;
      return 0;
    }
    if (x%2 == 0 || y%2 == 0) continue;
    ll ex = xs[x/2+1]-xs[x/2];
    ll ey = ys[y/2+1]-ys[y/2];
    ans += ex*ey;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 144480
#include<stdio.h>
#include<math.h>
int X,H;
double h;
int main()
{
	for(;scanf("%d%d",&X,&H),X+H;)
	{
		h=sqrt(pow((double)X/2,2)+pow((double)H,2));
		printf("%lf\n",1.0*X*X+(X*h*2));
	}
	return 0;
}

Measured memory_bytes: 632
from sys import exit, stdin

# import copy
# from collections import deque,Counter
# import numpy as np
input = stdin.readline


(N,) = map(int, input().split())

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

ans = 0
lmax = 0
for n in A:
    if n < lmax:
        ans += lmax - n
    else:
        lmax = n

print(ans)


Measured memory_bytes: 31404
N = int(input())
H = [0] + list(map(int, input().split()))

DP = [0]*(N+1)

for i in range(2, N+1):
    if i == 2:
        DP[i] = abs(H[1] - H[2])
        continue
    c1 = abs(H[i-1] - H[i])
    c2 = abs(H[i-2] - H[i])
    DP[i] = min(DP[i-1] + c1, DP[i-2] + c2)


print(DP[N])


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

int main()
{
	int paper_x, paper_y, max, min, N;
	cin >> N;
	cin >> paper_x;
	cin >> paper_y;
	if(paper_x <paper_y){
		max = paper_x;
	}else{
		max = paper_y;
	};
	if(paper_x + paper_y > N){
	min = paper_y -( N - paper_x );
}else{
	min = 0;
}
	cout << max << endl;
	cout << min;

	return 0;
}


Measured memory_bytes: 256
s=input()
q=int(input())

rev = 1
fr = ""
rr = ""

for i in range(q):
    ss=input()
    if int(ss[0])==1:
        rev *= -1
    else:
        f,c=int(ss[2]),ss[4]
        if f == 2:
            f = -1
        
        if f*rev ==1:
            fr+=c
        else:
            rr+=c

if rev == 1:
    ans = fr[::-1]+s+rr
else:
    ans = rr[::-1]+s[::-1]+fr
print(ans)

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

int solve();
int N;
vector<int> p1, p2;

int main(){
  cin >> N;
  p1 = vector<int>(N);
  p2 = vector<int>(N);
  int buf;
  for(int i = 0; i<N; i++){
    cin >> buf;
    p1.at(i) = buf;
    p2.at(i) = buf;
  }

  solve();
}

int solve(){

  sort(p1.begin(), p1.end());
  int count =0;
  for (int i = 0; i<N; i++){
    if(p1.at(i) != p2.at(i)){
      count++;
    }
  }
  if(count == 0 || count ==2){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)
#define forn(i,n) for(int i=0;i<n;i++)
#define forn1(i,n) for(int i=1;i<=n;i++)
#define vll vector <ll>
#define vi vector <int>
#define all(v) v.begin(),v.end()

ll M = 1e9 + 7;
double pi = acos(-1.0);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}

int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int n; ll d; cin>>n>>d;
	d = d*d;
	int c = 0;
	forn(i,n)
	{
		ll a,b; cin>>a>>b;
		if(a*a+b*b<=d) c++;
	}
	cout<<c;

	return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include <string>
using namespace std;
#include<algorithm>
int main(){

string s;
std::cin >> s;
reverse(s.begin(),s.end());

string t[4]={"dream","dreamer","erase","eraser"};
for (int i = 0; i < 4; i++){
  reverse(t[i].begin(),t[i].end());
}

int i,now=0;
do {
  for (i = 0; i < 4; i++) {
    if(s.substr(now,t[i].length())==t[i])
    { now+=t[i].length();
      break;
    }
  }
  if(i==4){break;}
} while(now!=s.length());

if(i==4)std::cout << "NO" << '\n';
else std::cout << "YES" << '\n';


return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <sstream>
#include <cmath>
#include <set>
#include <iomanip>
#include <deque>
#include <stdio.h>
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 iREP(i,Itr) for(auto (i)=(Itr).begin();(i)!=(Itr).end();(i)++)
#define REMOVE(Itr,n) (Itr).erase(remove((Itr).begin(),(Itr).end(),n),(Itr).end())
#define PB_VEC(Itr1,Itr2) (Itr1).insert((Itr1).end(),(Itr2).begin(),(Itr2).end())
#define UNIQUE(Itr) sort((Itr).begin(),(Itr).end()); (Itr).erase(unique((Itr).begin(),(Itr).end()),(Itr).end())
#define LBOUND(Itr,val) lower_bound((Itr).begin(),(Itr).end(),(val))
#define UBOUND(Itr,val) upper_bound((Itr).begin(),(Itr).end(),(val))
typedef long long ll;


int main(){
    
    ll H,W; cin>>W>>H;
    vector< pair<ll,ll> > V;
    vector<ll> a(W),b(H);
    REP(i,W)cin>>a[i];
    REP(i,H)cin>>b[i];
    REP(i,W)V.push_back(make_pair(a[i],0));
    REP(i,H)V.push_back(make_pair(b[i],1));
    
    sort(V.begin(),V.end());
    ll hcnt=H+1,wcnt=W+1;
    ll ans=0;
    REP(i,V.size()){
        if(V[i].second==0){
            ans+=V[i].first*hcnt;
            wcnt--;
        }else{
            ans+=V[i].first*wcnt;
            hcnt--;
        }
        //cout<<ans<<endl;
    }
    
    cout<<ans<<endl;
    
    return 0;
}

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

using namespace std;

typedef long long ll;

int main()
{
  ll N, T, Q;
  cin >> N >> T >> Q;
  vector<ll> A(N), D(N);
  vector<ll> left, right;
  vector<ll> rleft, rright;
  for (int i = 0; i < N; i++) {
    cin >> A[i] >> D[i];
    if (D[i] == 1) {      
      right.push_back(A[i]);
      rleft.push_back(-A[i]);
    } else {
      left.push_back(A[i]);
      rright.push_back(-A[i]);
    }
  } 
  
  sort(left.begin(), left.end());
  sort(right.begin(), right.end());
  
  sort(rleft.begin(), rleft.end());
  sort(rright.begin(), rright.end());

  ll q;
  for (int i = 0; i < Q; i++) {
    cin >> q; q--;    
    if (D[q] == 1) { // go to the right
      // use left 
      ll l = lower_bound(left.begin(), left.end(), A[q]) - left.begin();
      if (l == left.size()) {
	cout << A[q] + T << endl;
	continue;
      }
      // left[l]      
      ll ub = upper_bound(right.begin(), right.end(), left[l]) - right.begin()-1;
      
      // left is now, right is l
      ll now = (right[ub] != A[q] ? right[ub] : A[q]); // right
      if (right[ub] != A[q]) {
	ll g;
	if (now + T >= left[l] - T) {
	  g = (now + left[l]) / 2;
	} else {
	  g = now + T;
	}
	cout << min(A[q] + T, g) << endl;
      } else {
	if (now + T >= left[l] - T) {
	  cout << (now + left[l]) / 2 << endl;
	} else {
	  cout << now + T << endl;
	}
      }   
    } else {  // go to the left
      // use right
      // use left 
      ll l = lower_bound(rleft.begin(), rleft.end(), -A[q]) - rleft.begin();
      if (l == rleft.size()) {
	cout << A[q] - T << endl;
	continue;
      }
      // left[l]      
      ll ub = upper_bound(rright.begin(), rright.end(), rleft[l]) - rright.begin()-1;
      
      // left is now, right is l
      ll now = (-rright[ub] != A[q] ? -rright[ub] : A[q]); // right
      if (-rright[ub] != A[q]) {
	ll g;
	if (now - T <= -rleft[l] + T) {
	  g = (now - rleft[l]) / 2;
	} else {
	  g = now - T;
	}
	cout << max(A[q] - T, g) << endl;
      } else {
	if (now - T <= -rleft[l] + T) {
	  cout << (now - rleft[l]) / 2 << endl;
	} else {
	  cout << now - T << endl;
	}
      } 
    }
  }  
  return 0;
}

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

/*                    ॐ Shree ॐ                     */
/* ॐ ॐ ॐ
ॐ भूर् भुवः स्वः
तत् सवितुर्वरेण्यं
भर्गो देवस्य धीमहि
धियो यो नः प्रचोदयात्
*/
typedef long long ll;
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
// online submission
#endif
	ll n;
	cin>>n;
	vector<ll> v(n);
	for(ll i=0;i<n;i++){
		cin>>v[i];
	}
	sort(v.begin(),v.end());
	ll sum=0;
	ll j=n-1;
	ll k=n-2;
	sum+=v[j];
	j--;
	for(ll i=0;i<k/2;i++){
		sum+=2*v[j];
		j--;
	}
	if(k%2){
		sum+=v[j];
	}
	cout<<sum;
}

Measured memory_bytes: 4780
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

int main() {
	int a, b;
	cin >> a >> b;
	if (a * b % 2 == 1)cout << "Odd" << endl;
	else cout << "Even" << endl;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int A;cin>>A;
  int B;cin>>B;
  int T;cin>>T;
  int cnt;cnt=T/A;
  cout<<B*cnt<<endl;
  return 0;
  
}


Measured memory_bytes: 256
//run: g++ -std=c++14 -o run_sol.exe solution.cpp -DLOCAL_JUDGE
#include<bits/stdc++.h>
#define INF 0x7fffffff
#define INFLL 1e17
#define PI 2*acos(0.0)
#define show(x) cout<< #x <<" is "<< x <<"\n"
using namespace std;

#define FS first
#define SC second
#define PB(t) push_back(t)
#define LEN(t) ((int)t.size())
#define ALL(t) t.begin(),t.end()
#define MP(x, y) make_pair((x), (y))
#define Fill(a,c) memset(&a, c, sizeof(a))
#define POPCOUNT __builtin_popcount

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<PII> VPII;

vector<VI> G;
VI prof;

int dfs (int node) {
    int res = 0;
    if (prof[node] >= 0) {
        return prof[node];
    }

    for (auto v : G[node]) {
        res = max(res, dfs(v) + 1);
    }

    prof[node] = res;
    return res;
}

int main() {
    #ifdef LOCAL_JUDGE
        freopen("../input.txt", "rt", stdin);
        freopen("../output.txt", "wt", stdout);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(NULL);

    for (int n, m, u, v; cin >> n >> m ; ) {
        VI inD(n, 0);
        prof.assign(n, -1);
        G.assign(n, VI());

        for (int i = 0; i < m; i++) {
            cin >> u >> v;
            u--; v--;
            G[u].PB(v);
            inD[v]++;
        }
        int res = 0;
        for (int i = 0; i < n; i++) {
            if (inD[i] == 0) {                
                res = max(res, dfs(i));
            }
        }

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

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

int main() {
  int a,b,c ;
  cin >> a >> b ;
  c = (a*b) % 2;
  
  if (c == 1){
    cout << "Odd" <<endl;
  }
  else {
    cout << "Even" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string S;
int main() {
    cin >> S;
    int slen = S.length();
    // 97よりでかかったら小文字
    int flg = 0;
    int ccnt = 0;

    for(int i = 0; i < slen; ++i) {
        if(i == 0) {
            if(S.at(i) != 'A') {
                flg = 1;
                break;
            }
        }else if(i >= 2 && i <= slen-2) {
            if(S.at(i) == 'C') {
                ccnt++;
            }else {
                if((int)S.at(i) < 97) {
                    flg = 1;
                    break;
                }
            }
        }else {
            if((int)S.at(i) < 97) {
                flg = 1;
                break;
            }
        }
    }

    if(ccnt == 1 && flg == 0) {
        cout << "AC" << endl;
    }else {
        cout << "WA" << endl;
    }
}

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

int main(){
    ll n,a,b;cin>>n>>a>>b;
    ll x = n/(a+b),r = n-x*(a+b);
    ll ans = x*a;
    if(r <= a){
        ans += r;
    }else{
        ans += a;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
// Parallelism
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0021&lang=jp
// 
// 

#include <iostream>
#include <complex>
#include <cmath>
#include <cstdio>

using namespace std;
typedef std::complex<double> xy_t;

int N;
double x[4], y[4];
const double eps = 1e-11;

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }

double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }

xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }

int main(){
    cin >> N;
    for(int i = 0; i < N; ++i){
        for(int i = 0; i < 4; ++i){
            cin >> x[i] >> y[i];
        }

    xy_t a[2] = {
        xy_t(x[0],y[0]) - xy_t(x[1],y[1]),
        xy_t(x[2],y[2]) - xy_t(x[3],y[3])
    };

    bool p = abs(cross_product(a[0],a[1])) < eps;
    
    cout << (p ? "YES" : "NO") << endl;
    }
}


Measured memory_bytes: 3052
#include<iostream>
#include<vector>
#include<algorithm>
int main() {
	int n, m;
	std::cin >> n >> m;
	std::vector<int>d;
	for (int i = 1; i*i <= m; i++) {
		if (m%i != 0)continue;
		d.push_back(i);
		if (m / i != i)d.push_back(m / i);
	}
	std::sort(d.begin(), d.end());
	int ans = 0;
	for (int i : d) {
		if (n > m/i)continue;
		ans = i;
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 256
# encoding: utf-8
import sys
# input = sys.stdin.readline

N = int(input())
p = list(map(int, input().split()))

ans = 0
for i in range(N - 2):
    pool = [p[i], p[i + 1], p[i + 2]]
    if min(pool) == p[i + 1]:
        continue
    if max(pool) == p[i + 1]:
        continue
    #
    ans += 1

print(ans)

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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

#define INF 1e9
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (n); i++)
#define each(x, v) for (auto& x: (v))
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl

void solve();
void in(){} template<class T, class... U> void in(T &t, U &...u){ cin >> t; in(u...); }
int main() { cin.tie(0); ios::sync_with_stdio(0); solve(); }

void solve() {
  int N;
  in(N);
  int ans = 0;
  int mn = INF;
  rep(i, N) {
    int pi;
    in(pi);
    if (pi <= mn) ans++;
    mn = min(mn, pi);
  }
  print(ans);
}


Measured memory_bytes: 256
//A.cpp
#include <iostream>
#include <string>
#include <math.h>
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  int cnt = 1;
  int x = b;
  while(x!=0){
    x /= 10;
    cnt *= 10;
  }

  int A = a*cnt + b;
  int chk = (int)sqrt(A);
  if(A==chk*chk) printf("Yes\n");
  else printf("No\n");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
struct valIndex
{
    int l,r;
};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int sum= 0;
    stack<int> A;
    stack<pair<int,int>> B;
    REP(i,s.size()){
        if(s[i]=='\\'){
            A.push(i);
        }
        else if(s[i]=='/' && A.size()>0){
            int j= A.top();
            A.pop();
            int a= i-j;
            sum+= a;
            while(B.size()>0 && B.top().first>j){
                a+= B.top().second;
                B.pop();
            }
            B.push(make_pair(j,a));
        }
    }
    vector<int> ans;
    while(B.size()>0){
        ans.push_back(B.top().second);
        B.pop();
    }
    reverse(ans.begin(),ans.end());
    cout << sum << endl;
    cout << ans.size();
    REP(i,ans.size()){
        cout << " " << ans[i];
    } cout << endl;
    return 0;
}
    


Measured memory_bytes: 3300
use proconio::{input, fastout};
use proconio::marker::Usize1;

#[fastout]
fn main() {
    input! {
        n: usize,
        q: usize,
        ab: [(Usize1, Usize1); n - 1],
        px: [(Usize1, usize); q]
    }

    let mut c = vec![vec![];n];
    for &(a, b) in &ab {
        c[a].push(b);
        c[b].push(a);
    }

    let mut counter = vec![0; n];
    for &(root, x) in &px {
        counter[root] += x;
    }

    // dfs
    let mut visited = vec![false; n];
    let mut stack = vec![];
    stack.push((0, 0));
    while let Some((node, value)) = stack.pop() {
        if visited[node] {
            continue;
        }
        visited[node] = true;
        counter[node] += value;
        for &child in &c[node] {
            stack.push((child, counter[node]));
        }
    }

    for i in 0..n-1 {
        print!("{} ", counter[i]);
    }
    println!("{}", counter[n-1]);
}


Measured memory_bytes: 29536
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

int main() {
  vector<int> candys(3);
  REP(i, 3) cin >> candys[i];
  sort(ALL(candys));
  cout << (candys[2] == candys[0] + candys[1] ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
//#define _USE_MATH_DEFINES
//#include <math.h>
#include <iostream>
//#include <iomanip>
//#include <bits/stdc++.h>

using namespace std;

int main() {
    int a,b;
    int result = 0;
    string op;
    for (int i = 0;; i++){
        cin >> a >> op >> b;
        if (op == "?") break;
        if (op == "+") result = a + b;
        if (op == "-") result = a - b;
        if (op == "*") result = a * b;
        if (op == "/") result = a / b;
        cout << result << endl;
    }
    return 0;
}


Measured memory_bytes: 3128
import math


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def read_into(*A):
    for a, v in zip(A, read_ints()):
        a.append(v)


def solve():
    N, M, L = read_ints()
    dist = [
        [math.inf for _ in range(N)] for _ in range(N)
    ]
    for i in range(N):
        dist[i][i] = 0
    for _ in range(M):
        a, b, c = read_ints()
        dist[a-1][b-1] = dist[b-1][a-1] = c
    for k in range(N):
        for i in range(N):
            for j in range(N):
                dist[i][j] = dist[j][i] = min(dist[i][j], dist[i][k]+dist[k][j])
    for i in range(N):
        for j in range(N):
            if i == j: continue
            dist[i][j] = 1 if dist[i][j] <= L else math.inf
    for k in range(N):
        for i in range(N):
            for j in range(N):
                dist[i][j] = dist[j][i] = min(dist[i][j], dist[i][k]+dist[k][j])
    Q = read_int()
    for _ in range(Q):
        s, t = read_ints()
        if dist[s-1][t-1] == math.inf:
            print(-1)
        else:
            print(dist[s-1][t-1]-1)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 87212
#include<iostream>
using namespace std;
int main() {
	int n, a, b; cin >> n >> a >> b;
	char s[114514]; cin >> s;
	int cnta = 0, cntb = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'a') {
			if (cnta < a + b) {
				cout << "Yes\n";
				cnta++;
				continue;
			}
		}
		else if (s[i] == 'b') {
			if (cnta < a + b&&cntb < b) {
				cout << "Yes\n";
				cnta++; cntb++;
				continue;
			}
		}
		cout << "No\n";
	}
}

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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

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

    int x;
    cin >> x;
    cout << !x << "\n";

    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    double L[n];
    for (int i=0;i<n;i++)
        cin >> L[i];
    double dp[n+1][n+1];
    for (int i=0;i<n+1;i++){
        for (int j=0;j<n+1;j++){
            dp[i][j]=0;
        }
    }
    dp[0][0]=1;
    for (int i=0;i<n;i++){
        dp[i+1][0]=dp[i][0]*L[i];
        dp[0][i+1]=dp[0][i]*(1-L[i]);
    }
    for (int i=1;i<n+1;i++){
        for (int j=1;j<n+1-i;j++){
            dp[i][j]= (dp[i-1][j]*L[i+j-1]) + (dp[i][j-1] * (1-L[i+j-1]) );
        }
    }
/*    for (int i=0;i<n+1;i++){
        for (int j=0;j<n+1;j++){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }*/
    double koliko=0;
    for (int i=0;i<n+1;i++){
        if (i>n-i)
            koliko+=dp[i][n-i];
        //cout << i << " " << n-i << endl;
    }
    cout.precision(10);
    cout << koliko;
}


Measured memory_bytes: 70528
#include <bits/stdc++.h>
#define r1(i, n) for (int i=0;i<n;i++)
#define r2(i, n) for (int i=1;i<n+1;i++)
#define intc(n) int n; cin >> n;
#define ll long long
#define llc(n) ll n; cin >> n;
#define stringc(s) string s; cin >> s;
using namespace std;
int main() {
  ll n,m,ans;
  cin >> n >> m;
  ans=n;
  vector<ll> h(n),q(n,0);
  r1(i,n) cin >> h.at(i);
  r1(i,m) {
    ll a,b;
    cin >> a >> b;
    q.at(a-1)=max(q.at(a-1),h.at(b-1));
    q.at(b-1)=max(q.at(b-1),h.at(a-1));
  }
  r1(i,n) if(h.at(i)<=q.at(i)) ans--;
  cout << ans << endl;
}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

long long n,a,b,c,d;
map<ll,ll>dp;

ll rec(ll n){
	if(dp.count(n))return dp[n];
	if(n==1)return d;
	
	ll Min=n*(ll)d;
	
	ll A=n%2,B=(2-n%2)%2;
	if(n>=2)Min=min(Min,rec(n/2)+d*A+a);
	Min=min(Min,rec((n+1)/2)+d*B+a);
	
	A=n%3,B=(3-n%3)%3;
	if(n>=3)Min=min(Min,rec(n/3)+d*A+b);
	Min=min(Min,rec((n+2)/3)+d*B+b);
	
	A=n%5,B=(5-n%5)%5;
	if(n>=5)Min=min(Min,rec(n/5)+d*A+c);
	Min=min(Min,rec((n+4)/5)+d*B+c);

	return dp[n]=Min;
}

int main(){
	int T;cin>>T;
	rep(Case,T){
		cin>>n>>a>>b>>c>>d;
		dp.clear();
		cout<<(long long)rec(n)<<endl;
	}
}

Measured memory_bytes: 4568