akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func main() {
	list1 := getStdinIntArr64()
	N := list1[0]
	A := getStdinIntArr64()
	list2 := getStdinIntArr64()
	Q := list2[0]

	AMap := make(map[int64]int64, N+Q)
	var ASum int64 = 0
	for _, val := range A {
		AMap[val]++
		ASum += val
	}

	var i int64 = 0
	sumlist := make([]int64, 0)
	for ; i < Q; i++ {
		list3 := getStdinIntArr64()
		B := list3[0]
		C := list3[1]

		sum := ASum
		num := AMap[B]
		sum -= num * B
		sum += num * C
		ASum = sum
		AMap[B] = 0
		AMap[C] += num

		sumlist = append(sumlist, sum)

	}

	for i = 0; i < Q; i++ {
		fmt.Printf("%d\n", sumlist[i])
	}
}

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}

func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}

func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, e := sc.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func gcdimpl(n, m int64) int64 {
	var i int64 = 0
	for i = 0; i < 10; i++ {
		var t int64 = n - m
		q := false
		if m > t {
			q = true
		}
		if q {
			n = m
		} else {
			n = t
		}
		if q {
			m = t
		} else {
		}
		if m == 0 {
			return n
		}
	}
	return gcdimpl(m, n%m)
}

func gcd(n, m int64) int64 {
	if n > m {
		return gcdimpl(n, m)
	}
	return gcdimpl(m, n)
}

func reduce(x, N int64) int64 {
	return (x * N) >> 32
}


Measured memory_bytes: 23500
N = input()
papers = input().split(" ")
papers = [int(n) for n in papers]
accepted = True
for paper in papers:
    if (paper % 2 == 0):
        if (paper % 3 == 0) | (paper % 5 == 0):
            pass
        else:
            accepted = False
    else:
        pass

if accepted:
    print("APPROVED")
else:
    print("DENIED")


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

int main()
{
    long n, m;
    cin >> n >> m;
    vector<pair<long, long>> item(n);
    for (long i = 0; i < n; i++) {
        cin >> item[i].first >> item[i].second;
    }
    sort(item.begin(), item.end());
    long ans = 0;
    for (long i = 0; i < n; i++) {
        long buy = min(item[i].second, m);
        ans += buy * item[i].first;
        m -= buy;
        if (m == 0) {
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <bitset>

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

using namespace std;

int popcnt(int n) {
  n = ((n & 0xAAAAAAAA) >>  1) + (n & 0x55555555);
  n = ((n & 0xCCCCCCCC) >>  2) + (n & 0x33333333);
  n = ((n & 0xF0F0F0F0) >>  4) + (n & 0x0F0F0F0F);
  n = ((n & 0xFF00FF00) >>  8) + (n & 0x00FF00FF);
  n = ((n & 0xFFFF0000) >> 16) + (n & 0x0000FFFF);
  return n;
}

int main() {
  while(1){
    int n,c;
    cin >> n >> c;
    if(!n) break;
    vector<int> a(n);
    vector<int> b(c);
    for (int i = 0; i < n; ++i) {
      bitset<16> bs;
      for (int j = 0; j < 16; ++j) {
        int t;
        cin >> t;
        bs[j] = t == 1;
      }
      a[i] = bs.to_ulong();
    }
    for (int i = 0; i < c; ++i) {
      bitset<16> bs;
      for (int j = 0; j < 16; ++j) {
        int t;
        cin >> t;
        bs[j] = t == 1;
      }
      b[i] = bs.to_ulong();
    }
    vector<vector<int>> dp(n+1, vector<int>(1<<16,-1000000000));
    dp[0][0] = 0;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < (1 << 16); ++j) {
        bitset<16> bs(j);
        for (int k = 0; k < 16; ++k) {
          if ((a[i] >> k) & 1) bs[k] = true;
        }
        for (int k = 0; k < c; ++k) {
          int cp = bs.to_ulong();
          int point = dp[i][j];
          int and_cp = cp & b[k];
          cp ^= and_cp;
          point += popcnt(and_cp);
          dp[i+1][cp] = max(dp[i+1][cp], point);
        }
      }
    }
    cout << *max_element(begin(dp[n]),end(dp[n])) << endl;
  }
  return 0;
}

Measured memory_bytes: 9444
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
int main()
{
    int k, n;
    cin >> n >> k;
    vector<int> a(n);
    map<lli, lli> m;
    rep(i, n)
    {
        cin >> a[i];
        m[a[i]]++;
    }
    vector<int> v;
    for (auto s : m) {
        v.push_back(s.second);
    }
    sort(v.begin(), v.end());
    int g = v.size();
    lli ans = 0;
    rep(i, g - k)
    {
        ans += v[i];
    }
    cout << ans << endl;
}


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

using namespace std;
bool f(long long n)
{
    int a[6],i=0;
    while(n)
    {
        a[i++]=n%10;
        n/=10;
    }
    i--;
    for(int j=0;j<=i;i--,j++)
        if(a[i]!=a[j])return false;
    return true;
}

int main()
{
    long long a,b,n;
    cin>>a>>b;
    for(n=0;a<=b;a++)
        if(f(a))n++;
    cout<<n;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define MAX 100000

int parent(int i)
{
	return i / 2;
}
int left(int i)
{
	return 2 * i;
}
int right(int i)
{
	return 2 * i + 1;
}
int main()
{
	int H, i, A[MAX + 1];
	cin >> H;
	for (i = 1; i <= H; i++)
	{
		cin >> A[i];
	}
	for (i = 1; i <= H; i++)
	{
		cout << "node " << i << ": key = " << A[i] << ", ";
		if (parent(i) >= 1) cout << "parent key = " << A[parent(i)] << ", ";
		if (left(i) <= H) cout << "left key = " << A[left(i)] << ", ";
		if (right(i) <= H) cout << "right key = " << A[right(i)] << ", ";
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define debugP int debug_point; cin>>debug_point;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/

void dfs(ll d){

}


int main(){
    ll n;
    cin>>n;
    ll ans=LLONG_MAX;
    ll b=0;
    ll sum=0;
    vec(a,n);
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    b=a[0];
    sum-=a[0];
    ans=abs(sum-b);
    for(int i=1;i<=n-2;i++){
        b+=a[i];
        sum-=a[i];
        ans=min(ans,abs(b-sum));
    }
    op(ans);
    return 0;
}

Measured memory_bytes: 1792
import sys
readline = sys.stdin.readline
def MAIN():
    n, m = map(int, input().split())
    li = [i for i in range(n)]
    def f(a):
        if li[a] == a:
            return a
        li[a] = f(li[a])
        return li[a]
    def f2(a, b):
        if li[a] == a:
            li[a] = b
        else:
            f2(li[a], b)
            li[a] = b
    def solve(a, b):
        if f(a) == f(b):
            return "yes"
        return "no"
    for _ in range(m):
        x, y = map(int, readline().split())
        if f(x) > f(y):
            f2(x, li[y])
        else:
            f2(y, li[x])
    for _ in range(int(input())):
        x, y = map(int, readline().split())
        print(solve(x, y))
MAIN()


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

int main() {
  string s;
  long k;
  cin >> s >> k;
  string s_new = s;
  for(int i = 0; i < s.size(); i++) {
    int d = 'z' - s[i] + 1;
    if(k >= d && s[i] != 'a') {
      k -= d;
      s_new[i] = 'a';
    }
  }
  s_new[s_new.size() - 1] = 'a' + (s_new[s_new.size() - 1] + k - 'a') % 26;
  cout << s_new << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main() {

  string input;

  cin >> input;

  char firstLetter = input[0];
  bool bDiff = false;

  for(int i = 1; i < 3; i++) {
    if (firstLetter != input[i]) {
      cout << "Yes" << endl;
      bDiff = true;
      break;
    }
  }

  if (bDiff == false) cout << "No" << endl;

  return 0;
}


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

int main(){
    string s, ans;
    cin >> s;
    for(int i = 1; i < s.length(); i++){
        if(s[i-1] == s[i]){
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}

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

typedef long long ll;

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

    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int cnt = 0;
    bool flag = false;
    while(1){
        cnt++;
        if(cnt%2==1) c -= b;
        else a -= d;
        if(c<=0){
            flag = true;
            break;
        }
        else if(a<=0) break;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>
int main(void){
    int n;
    scanf("%d\n",&n);
    int b[n],f[n],r[n],v[n],i;
    for(i=0;i<=n-1;i++){
        scanf("%d %d %d %d\n",&b[i],&f[i],&r[i],&v[i]); 
    }
    int ans[13][11],i1,i2;
    for(i1=0;i1<=12;i1++){
        for(i2=0;i2<=10;i2++){
            ans[i1][i2]=0;
        }
    }
    int x1,x2;
    for(i1=0;i1<=12;i1++){
        for(i2=0;i2<=10;i2++){
            for(i=0;i<=n-1;i++){
                x1=(b[i]-1)*3+f[i]-1;
                x2=r[i]-1;
                if(i1==x1 && i2==x2){
                    ans[i1][i2]=ans[i1][i2]+v[i];
                }
            }
        }
    }
    i=0;
    for(i1=0;i1<=11;i1++){
        for(i2=0;i2<=9;i2++){
            printf(" %d",ans[i1][i2]);
        }
        printf("\n");
        if(i1==2 || i1==5 || i1==8){
            printf("####################\n");
        }
    }
    return 0;
}

Measured memory_bytes: 616
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(true){
			int n=sc.nextInt();
			if(n==0){
				break;
			}
			int count=0;
			int div=5;
			while(n/div!=0){
				count+=n/div;
				div*=5;
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 17176
n = int(input())
a = list(map(int, input().split()))

cnt, su, r = 0, 0, 0
for l in range(n):
    while r < n and su + a[r] == su ^ a[r]:
        su += a[r]
        r += 1
    cnt += r - l
    if l == r:
        r += 1
    else:
        su -= a[l]
print(cnt)


Measured memory_bytes: 32056
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static double moreHeads(double[] p_heads){
        double[] dp = new double[p_heads.length + 1];
        dp[0] = 1;
        for (int i = 0; i < p_heads.length; i++) {
            for (int j = i+1; j >= 0; j--) {
                dp[j] = j==0? dp[0]*(1-p_heads[i]) : dp[j-1]*p_heads[i] + dp[j]*(1-p_heads[i]);
            }
        }
        double ans = 0;
        for (int heads = 0; heads <= p_heads.length; heads++) {
            int tails = p_heads.length - heads;
            if (heads > tails){
                ans += dp[heads];
            }
        }
        return ans;
    }

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        int N = Integer.parseInt(reader.readLine());
        StringTokenizer st = new StringTokenizer(reader.readLine());
        double[] p_heads = new double[N];
        for (int i = 0; i < N; i++) {
            p_heads[i] = Double.parseDouble(st.nextToken());
        }
        System.out.println(moreHeads(p_heads));
    }
}


Measured memory_bytes: 22996
// ＡＢＣのＡ過去問を解くだけだよ

// フォント:Electroharmonix
// x:小文字(ｘ)    X:大文字(Ｘ)
// +:プラス(＋)    &:アンド(＆)

#include <bits/stdc++.h>

using namespace std;

void Main()
{
    int N;
    cin >> N;
    if (N % 2 == 0)
        cout << N;
    else
        cout << N * 2;
}

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

    //std::cout << std::fixed << std::setprecision(10);

#ifdef DEBUG_BUILD
    while (true)
    {
        Main();
        cout << std::endl;
    }
#endif

    Main();
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i < (int)(n); i++)
#define Sort(a) sort(a.begin(), a.end())
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
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(){
    int x, y;
    cin >> x >> y;
    bool f = true;
    if(y%2 == 1){
        f = false;
    }
    if(y > 4*x || y < 2*x) {
        f = false;
    }
    if(f) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

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

int main(){
    char mas[8][8];
    while(1){
        for(int i=0;i<8;i++){
            for(int j=0;j<8;j++){
                cin >> mas[i][j];
            }
        }
        if(cin.eof()) break;
        for(int i=0;i<8;i++){
            for(int j=0;j<8;j++){
                if(mas[i][j] == '1'){
                    if(mas[i+1][j]=='1'&&mas[i][j+1]=='1'&&mas[i+1][j+1]=='1') cout << "A" << endl;
                    else if(mas[i+1][j]=='1'&&mas[i+2][j]=='1'&&mas[i+3][j]=='1') cout << "B" << endl;
                    else if(mas[i][j+1]=='1'&&mas[i][j+2]=='1'&&mas[i][j+3]=='1') cout << "C" << endl;
                    else if(mas[i+1][j]=='1'&&mas[i+1][j-1]=='1'&&mas[i+2][j-1]=='1') cout << "D" << endl;
                    else if(mas[i][j+1]=='1'&&mas[i+1][j+1]=='1'&&mas[i+1][j+2]=='1') cout << "E" << endl;
                    else if(mas[i+1][j]=='1'&&mas[i+1][j+1]=='1'&&mas[i+2][j+1]=='1') cout << "F" << endl;
                    else if(mas[i][j+1]=='1'&&mas[i+1][j]=='1'&&mas[i+1][j-1]=='1') cout << "G" << endl;
                }
            }
        }
    }
}

Measured memory_bytes: 1132
package main

import (
    "fmt"
)

type Universe [][]int

func NewUniverse(height int, width int) Universe{
    u := make(Universe, height)
    for i := range u {
        u[i] = make([]int, width)
    }

    return u
}


func main(){
    var H, W, N int
    fmt.Scan(&H, &W, &N)
    
    a := NewUniverse(H, W)
    
    var black, count int
    if H>=W{
        for i:=0; i<W; i++{
            for j:=0; j<H; j++{
                a[j][i] = 1
                black++
            }
            count++
            if black >= N {
                break
            }
        }
    } else if H<W {
        for i:=0; i<H; i++{
            for j:=0; j<W; j++{
                a[i][j] = 1
                black++
            }
            count++
            if black >= N {
                break
            }
        }
    }
    fmt.Println(count)
}


Measured memory_bytes: 640
s = gets.chomp.chars
count = 0
digits3 = []
(0..s.size-3).each do |num|
  digits3 << (s[num]+s[num+1]+s[num+2]).to_i
end
abs = []
digits3.each do |num|
  abs << (753 - num).abs
end
puts abs.min

Measured memory_bytes: 1788
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn prime_sieve(n: usize) -> Vec<bool> {
    let mut s = vec![true; n];
    s[0] = false; s[1] = false;
    for i in 2..n {
        if i * i > n { break }
        if s[i] {
            for k in 2..(n+i-1)/i { s[k*i] = false }
        }
    }
    s
}

fn main() {
    let ps = prime_sieve(100008);
    let mut ac = vec![0; 100008];
    for x in 3..100008 {
        ac[x] = ac[x - 1] + if ps[x] && ps[(x + 1) / 2] { 1 } else { 0 };
    }
    let mut sc = Scanner::new();
    let q: usize = sc.cin();
    for _ in 0..q {
        let l: usize = sc.cin();
        let r: usize = sc.cin();
        put!(ac[r] - ac[l - 1]);
    }
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 4732
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#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 all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int k;
	cin >> k;
	for(int i = 0; i < s.size(); i++){
		if(s[k-1] == s[i]) cout << s[i];
		else cout << '*';
	}
	cout << endl;
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = 1<<29;
typedef long long int ll;


int main(){
    int N, Y;cin >> N >> Y;
    bool flg = false;
    for(int i = N;i >= 0;--i){
        for(int j = 0;j <= N - i;++j){
            if(10000 * i + 5000 * j + 1000 * (N - i - j) == Y){
                cout << i << ' ' << j << ' ' << N - i - j;
                return 0;
            }
        }
    }
    cout << -1<< ' ' <<-1<<' '<<-1;
}


Measured memory_bytes: 256
import           Control.Applicative
import           Data.Array
import           Data.List

rows :: Array (Int, Int) a -> [[a]]
rows arr = let ((a, b), (c, d)) = bounds arr in [[arr ! (i, j) | j <- [b..d]] | i <- [a..c]]

columns :: Array (Int, Int) a -> [[a]]
columns arr = let ((a, b), (c, d)) = bounds arr in [[arr ! (i, j) | i <- [a..c]] | j <- [b..d]]

possibleSpaces :: Int -> [Bool] -> Int
possibleSpaces d = sum . fmap ((\n -> (n - d + 1) `max` 0) . length). filter head . group

main = do
  [n, m, d] <- fmap read . words <$> getLine
  a <- listArray ((1,1), (n, m)). concatMap (fmap (=='.')) . lines <$> getContents
  print $ sum $ fmap (possibleSpaces d) (rows a ++ columns a)



Measured memory_bytes: 5068
#encoding utf-8

n = int(input())
s = list(str(input()))

reverse = 3*10**5+1
west = []
east = []
west_num = 0
east_num = 0
for i in range(len(s)):
    if s[i] == "W":
        west_num += 1
    elif s[i] == "E":
        east_num += 1
    west.append(west_num)
    east.append(east_num)
# print(west,east)
for i in range(n):
    if i == 0:
        point = east[-1]+east[0]
    elif i == n-1:
        point = west[i-1]
    else:
        point = east[-1]-east[i]+west[i-1]
    # print(point)
    reverse = min(point, reverse)

print(reverse)


Measured memory_bytes: 20120
N, M, Q = map(int, input().split())
query = []
for _ in range(Q):
    query.append(tuple(map(int, input().split())))

ans = []

# 単調増加考慮
def dfs(l):
    if len(l) == N:
        tmp = 0
        for q in query:
            if (l[q[1]-1] - l[q[0]-1]) == q[2]:
                tmp += q[3]
        ans.append(tmp)
        return
    prev = l[-1] if len(l) > 0 else 1
    for v in range(prev, M+1):
        l.append(v)
        dfs(l)
        l.pop()


dfs([])
print(max(ans))

Measured memory_bytes: 12612
// 解説見た
// それでも分からんのでokojomoekoさんの回答みた

#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <forward_list>
using namespace std;

int MSb(int n);

int main() {
	int N, dummy;
	dummy = scanf("%d", &N);

	map<int, int> m;
	vector<int> v;
	int tmp;
	for (int i = 0; i < N; i++) {
		dummy = scanf("%d", &tmp);
		v.push_back(tmp);
		m[tmp]++;
	}

	std::sort(v.begin(), v.end(), std::greater<int>());

	int ans = 0;
	int n;

	// 調査対象
	for (int i = 0; i < N - 1; i++) {
		if (m[v[i]] == 0) continue;
		m[v[i]]--;

		int target = MSb(v[i]) - v[i];
		if (m.count(target) && m[target] != 0) {
			m[target]--;
			ans++;
		}
	}

	printf("%d\n", ans);

	return 0;
}

int MSb(int n){
    // bitシフトを用いて、2の冪乗を求める。
    int ret = 1;
    while (n > 0) { ret <<= 1; n >>= 1; }
    return ret;
}


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

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

const int MAXN = 5e5 + 5;
//#define int long long
const int INF = 1e9;

int f[MAXN], last[MAXN];

void add(int i, int x){
	for (; i < MAXN; i = i | (i + 1))
		f[i] += x;
}

//[l, r)
int sum(int l, int r){
	int res = 0;
	for (int i = r-1; i > -1; i = (i & (i + 1)) - 1)
		res += f[i];
	for (int i = l-1; i > -1; i = (i & (i + 1)) - 1)
		res -= f[i];
	return res;
}

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

    int n, q;
    cin >> n >> q;
    vector<int> c(n + 1);
    for (int i = 1; i <= n; i++)
    	cin >> c[i];

    int l, r;
    vector<vector<pair<int, int>>> a(n + 1);
    for (int i = 0; i < q; i++){
    	cin >> l >> r;
       	a[r].eb(l, i);
    }

    vector<int> ans(q);

    for (int i = 1; i <= n; i++){
    	if (last[c[i]]) add(last[c[i]], -1);
    	last[c[i]] = i;
    	add(last[c[i]], 1);
    	for (auto j: a[i]) ans[j.ss] = sum(j.ff, i + 1);
    }

    for (auto i : ans) cout << i << '\n';
    return 0;
}


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

int main() {
  int a, b, c;
  char temp;
  cin >> a >> temp >> b >> temp >> c;
  if (b <= 4)
    cout << "Heisei" << endl;
  else
    cout << "TBD" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;


int main(){
    ll H,M;
    ll mx = 0;
    ll mn = 0;
    ll c = 1;
    ll count = 0;
    cin >> H >> M;
    if(H == 1 && M == 1){
        cout << 1 << endl;
    }else if(H == 1 || M == 1){
        cout << 1 << endl;
    }else if(H % 2 == 0 || M % 2 == 0){
        cout << (H*M)/2 << endl;
    }else if(H % 2 == 1 && M % 2 == 1){
        count = ((H*M)/2) + 1;
        cout << count << endl;
    }

    

    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#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())
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  int d;
  cin>>d;

  vector<ll> p(26);
  rep(i,26) cin>>p[i];

  vector<vector<ll>> q(d,vector<ll>(26));
  rep(i,d) {
    rep(j,26) {
      cin>>q[i][j];
    }
  }

  vector<int> r(d);
  rep(i,d) {
    cin>>r[i];
    r[i]--;
  }

  int m;
  cin>>m;

  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    r[a]=b;

    vector<ll> ans(d+1,0);
    vector<int> last(26,0);
    rep(i,d){
      ans[i+1]=ans[i]+q[i][r[i]];
      last[r[i]]=i+1;
      rep(j,26){
        ans[i+1]-=p[j]*(i+1-last[j]);
      }
    }
    cout << ans[d] << endl;
  }

}

Measured memory_bytes: 3712
n = int(input())

ab = {}
for i in range(1, n+1):
    t = str(i)
    if (t[0], t[-1]) in ab:
        ab[(t[0], t[-1])] += 1
    else:
        ab[(t[0], t[-1])] = 1
#print(ab)
ans = 0
for i in range(1, n+1):
    t = str(i)
    if (t[-1], t[0]) in ab:
        ans += ab[(t[-1], t[0])]
print(ans)


Measured memory_bytes: 3064
# One Quadrillion and One Dalmetians

N = int(input())

Q = [N]
R = []
name =[]
i = 0

while Q[i] != 0:
    if Q[i] % 26 == 0:
        Q.append(Q[i] // 26 - 1)
    else:
        Q.append(Q[i] // 26)
    R.append((Q[i]-1) % 26 + 1)
    i += 1



while i != 0 :
    i -= 1
    name.append(chr(R[i]+96))

print(''.join(name))



Measured memory_bytes: 9128
#include <iostream>

using namespace std;

int main()
{
  int a, b; cin >> a >> b;
  if (a < b)
    for (int i = 0; i < b; i++)
      cout << a;
  else
    for (int i = 0; i < a; i++)
      cout << b;
  cout << endl;
}

Measured memory_bytes: 3396
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll S;cin>>S;cout<<0<<' '<<0<<' ';
	cout<<1000000000<<' '<<1<<' '<<(1000000000-S%1000000000)%1000000000<<' '<<(S-1)/1000000000+1<<endl;
}


Measured memory_bytes: 256
mod = 998244353
n, s = map(int, input().split())
a = list(map(int, input().split()))
dp = [0] * (s + 1)
ans = 0
for i in range(n):
    dp[0] += 1
    for j in range(a[i], s + 1)[::-1]:
        dp[j] += dp[j - a[i]]
        dp[j] %= mod
    ans += dp[-1]
    ans %= mod
print(ans)

Measured memory_bytes: 72172
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

int bingo[3][3];
bool flag[3][3];
int cnt[2][105];
int h, w;
int choco[1010][1010];
int s[11][11];

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


Measured memory_bytes: 384
#include <iostream>
#include <cstdlib>
#include <string>
#include <typeinfo>
#include <cstring>
#include <iostream>
#define MAX 10000
#define NIL -1
using namespace std;
struct Node{int parent,left,right;};
Node T[MAX];
int n,D[MAX],H[MAX];

void setDepth(int u, int d){
    if(u == NIL) return;
    D[u] = d;
    setDepth(T[u].left, d+1);
    setDepth(T[u].right, d+1);
}

int setHeight(int u){
    int h1 = 0, h2 = 0;
    if(T[u].left != NIL)h1 = setHeight(T[u].left)+1;
    if(T[u].right != NIL)h2 = setHeight(T[u].right)+1;
    return H[u] = (h1 > h2 ? h1 : h2);
}

int getSibling(int u){
    if(T[u].parent == NIL)return NIL;
    if(T[T[u].parent].left != u && T[T[u].parent].left != NIL)return T[T[u].parent].left;
    if(T[T[u].parent].right != u && T[T[u].parent].right != NIL)return T[T[u].parent].right;
    return NIL;
}

void print(int u){
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].parent << ", ";
    cout << "sibling = " << getSibling(u) << ", ";
    int deg = 0;
    if(T[u].left != NIL)deg++;
    if(T[u].right != NIL)deg++;
    cout << "degree = " << deg << ", ";
    cout << "depth = " << D[u] << ", ";
    cout << "height = " << H[u] << ", ";
    
    if(T[u].parent == NIL)cout << "root" << endl;
    else if(T[u].left ==NIL && T[u].right == NIL)cout << "leaf" << endl;
    else cout << "internal node" << endl;
}

int main(){
    int v,l,r,root = 0;
    cin >> n;
    for(int i = 0; i < n; i++)T[i].parent = NIL;
    for(int i = 0; i < n; i++){
        cin >> v >> l >> r;
        T[v].left = l;
        T[v].right = r;
        if(l != NIL)T[l].parent = v;
        if(r != NIL)T[r].parent = v;
    }
    
    for(int i = 0;i < n; i++) if(T[i].parent == NIL)root = i;
    setDepth(root, 0);
    setHeight(root);
    for(int i = 0; i < n; i++)print(i);
    return 0;
}










Measured memory_bytes: 3116
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    size_t n; cin >> n;

    auto matrix = make_v(0, n, n);
    for (size_t i = 0; i < n; ++i) {
        size_t u, k; cin >> u >> k;
        u--;
        for (size_t j = 0; j < k; ++j) {
            size_t v; cin >> v;
            v--;
            matrix[u][v] = 1;
        }
    }

    for (size_t i = 0; i < n; ++i) {
        for (size_t j = 0; j < n; ++j) {
            cout << matrix[i][j] << (j == n - 1)[" \n"];
        }
    }

    return 0;
}



Measured memory_bytes: 3260
#include<stdio.h>
#include<stdlib.h>
#define N_MAX 10001
struct node{
  int key;
  int cost;
  struct node *next;
};
typedef struct node *Gg;
Gg G[N_MAX];
Gg MNode(int key,int cost,Gg Node){
  Gg n;
  n=(Gg)malloc(sizeof(struct node));
  n->key=key;
  n->cost=cost;
  n->next=Node;
  return n;
}
Gg Insert(int s,int t,int u){
  Gg GG;
  GG=MNode(t,u,G[s]->next);
  G[s]->next=GG;
}
int main(){
  int i,j,n,count=0,v,c,c1,v1;
  int color[N_MAX],D[N_MAX],pi[N_MAX],minC,ii;
  Gg GG;
  scanf("%d",&n);
  for(i=0;i<n;i++)G[i]=MNode(0,0,NULL);
  for(i=0;i<n;i++){
    scanf("%d%d",&v,&c);
    for(j=0;j<c;j++){
      scanf("%d%d",&v1,&c1);
    Insert(i,v1,c1);
  }
}
for(i=0;i<n;i++){
  color[i]=0;
  pi[i]=-1;
  D[i]=10000001;
 }
 D[0]=0;

while(1){
  minC=10000001;
  for(i=0;i<n;i++){
    if(color[i]!=2&&D[i]<minC){
      minC=D[i];
      ii=i;
    }
  }
  if(minC==10000001)break;
  color[ii]=2;
  for(GG=G[ii];GG!=NULL;GG=GG->next){
    if(color[GG->key]!=2&&(GG->cost+D[ii])<D[GG->key]){
        pi[GG->key]=ii;
        D[GG->key]=GG->cost+D[ii];
        color[GG->key]=1;
    }
  }
 }
 for(i=0;i<n;i++)printf("%d %d\n",i,D[i]);
return 0;
}

Measured memory_bytes: 16256
while true
    l = gets.to_i
    break if l == 0
    
    s = gets.split.map(&:to_i)
    idx = 0
    while true
        current = s
        s = current.map {|i| current.count(i)}
        break if current == s
        idx += 1
    end
    puts idx
    puts s.join(' ')
end


Measured memory_bytes: 6904
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	int a,i,j,k,cnt=0,x[101];
	scanf("%d",&a);
	for(i=0;i<a;i++){
		scanf("%d",&x[i]);
	}
	sort(x,x+a);
	for(i=0;i<a-2;i++){
		for(j=i+1;j<a-1;j++){
			for(k=j+1;k<a;k++){
				if(x[k]<x[j]+x[i]){
					if(x[i]!=x[j]&&x[i]!=x[k]&&x[j]!=x[k]){
						cnt++;
					}
				}
			}
		}
	}
	printf("%d\n",cnt);
	return 0;
}

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

using namespace std;

int main(){
	char s[5];
	for(int i=0;i<3;i++){
		cin>>s[i];
	}
	if(s[1]=='B'){
		cout<<"ARC"<<endl;
	}else{
		cout<<"ABC"<<endl;
	}

	return 0;
}

Measured memory_bytes: 2964
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <string>

using namespace std;

typedef long long LL;
typedef unsigned int UI;

#define rSort(a) 		sort(a.rbegin(),a.rend())
#define Sort(a) 		sort(a.begin(),a.end())
#define Reverse(a) 		reverse(a.begin(),a.end())
#define Sum(a)  		accumulate(a.begin(), a.end(), 0)
#define REP(i, n) 		for(UI i = 0;i < n;i++)
#define REPR(i, n) 		for(UI i = n;i >= 0;i--)
#define FOR(i, m, n) 	for(UI i = m;i < n;i++)
#define pb(i) 			push_back(i)

#define MOD  			(LL)1e9 + 7;
#define INF  			(LL)1 << 62;

string s;

int get_len(int l, int r) {
    int ct = 0;
    for (int i = l; i <= r; i++) {
        if (s[i] != 'A' && s[i] != 'C' && s[i] != 'T' && s[i] != 'G') break;
        else ct++;
    }
    return ct;
}

int main(int argc, const char * argv[]) {

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

	cin >> s;

	int res = 0;

	for (int i = 0; i < s.length(); i++) {
		res = max(res, get_len(i, int(s.length()) - 1)) ;
	}

	cout << res;

	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7,N=2e3+5;
int mul(int a,int b){return (long long)a*b;}
typedef long long ll;
int n,m,s[N],t[N];
int a[N];
ll dp[N][N];
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)
        scanf("%d",&s[i]);
    for(int i=1;i<=m;i++)
        scanf("%d",&t[i]);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
    {
        dp[i][j]=(dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1])%mod;
        if(s[i]==t[j]) dp[i][j]+=dp[i-1][j-1]+1;
    }
    printf("%lld\n",(dp[n][m]%mod+1+mod)%mod);
}


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

int main()
{
	std::string s;
	std::cin >> s;
	std::vector<int[26]> table(s.size() + 1);
	int delta_min[2][26]{};
	table[1][s.front() - 'a'] = 1;
	for (unsigned int i{}; i + 1 < s.size(); i++)
	{
		if (s[i] == s[i + 1])
		{
			printf("%d %d\n", i + 1, i + 2);
			return 0;
		}
	}
	for (unsigned int i{}; i + 2 < s.size(); i++)
	{
		if (s[i] == s[i + 2])
		{
			printf("%d %d\n", i + 1, i + 3);
			return 0;
		}
	}
	printf("-1 -1\n");

	return 0;
}

Measured memory_bytes: 10624
#include <bits/stdc++.h>
#define FI first
#define SE second
#define PB push_back
#define ll long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define co(i) cout<<(i)<<endl
#define fcout cout<<fixed<<setprecision(10)
#define uni(i) i.erase(unique(i.begin(), i.end()), i.end());
#define all(i) i.begin(),i.end()
using namespace std;

const int INF=1e9+7;
const int MOD=1e9+7;

#define PA pair<int,int>

int main(){
	string s; cin>>s;
	int n=s.size();
	bool flag=true;
	if(s[0]=='0') flag=false;
	if(s[n-1]=='1') flag=false;
	FOR(i,0,n-1){
		if(s[i]!=s[n-2-i]) flag=false;
	}
	if(!flag){
		co(-1);
		return 0;
	}
	vector<int> v;
	FOR(i,1,n-2){
		if(s[i]=='1') v.PB(i+1);
	}
	
	vector<int> v2;
	int k=v.size()/2;
	if(v.size()==0){
		v2.PB(n);
	}else if(v.size()%2){
		v2.PB(v[0]);
		FOR(i,1,k+1){
			v2.PB(v[i]-v[i-1]);
		}
		v2.PB(v[k]);
	}else{
		v2.PB(v[0]);
		FOR(i,1,k){
			v2.PB(v[i]-v[i-1]);
		}
		v2.PB(v[k]);
	}
	int st=1,t=n;
	//FOR(i,0,v2.size()) co(v2[i]);
	
	FOR(i,0,v2.size()){
		FOR(j,0,v2[i]-1){
			printf("%d %d\n",st,t);
			t--;
		}
		if(st>1){
			printf("%d %d\n",st,st-1);
		}
		st++;
	}
	
}


Measured memory_bytes: 2424
#include<stdio.h>
int main(void){
	
	int a,b;
	scanf("%d%d",&a,&b);
	if(a<b)printf("a < b\n");
	if(a>b)printf("a > b\n");
	if(a==b)printf("a == b\n");
	
return 0;
}

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

#define select(_1, _2, x, ...) x

#define repn(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__)

#define rrepn(i, n) for (int i = (n - 1); i >= 0; i--)
#define rrepr(i, a, b) for (int i = (b - 1); i >= (a); i--)
#define rrep(i, ...) select(__VA_ARGS__, rrepr, rrepn)(i, __VA_ARGS__)

#define umax(m, x) (m = max(m, x));
#define umin(m, x) (m = min(m, x));

#define rng(v) v.begin(), v.end()
#define rrng(v) v.rbegin(), v.rend()

#define debug(x) cerr << #x << " = " << x << endl

using namespace std;

using ll = long long int;

using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;

using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;

const int INF = 1e9;
const ll LINF = 1e18;

inline void yn(bool f) { cout << (f ? "Yes" : "No") << endl; }


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

    vl a(n);
    rep(i, 1, n) cin >> a[i];

    vl jou(n, 0);
    rep(i, 1, n) jou[a[i] - 1]++;

    rep(i, n)
        cout << jou[i] << endl;

    return 0;
}


Measured memory_bytes: 6376
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main() {
	int N,M,X,Y;
  cin >> N >> M>>X>>Y;
  int ans=0;
  int x[N];
  int y[M];
  int xmax=X;
  int ymin=Y;


  FOR(i,0,N-1){
  cin >> x[i];
  if(x[i]>xmax){xmax=x[i];}
  }

  FOR(i,0,M-1){
  cin >> y[i];
  if(y[i]<ymin){ymin=y[i];}
  }

  if(xmax<ymin){
 cout << "No War" << endl;
  }else{
 cout << "War" << endl;
  }



}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
   int n;
   cin >> n;
   int a[n+1];
   int i,count=0;
   for(i=1;i<=n;i++){
       cin >> a[i];
       if(a[i]%2!=0 and i%2!=0) count+=1;
   }
   cout << count;
   return 0;
}

Measured memory_bytes: 3596
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
using namespace std;
typedef long long LL;
typedef pair<int,int> P;

int N;
int t[10000+10];
int dp[2][10000+10];
int main() {
	scanf("%d",&N);
	for(int i=0;i<N-1;i++){
		scanf("%d",t+i);
	}
	auto cur=dp[0];
	auto nex=dp[1];
	cur[1]=t[0];
	cur[0]=1<<30;
	nex[0]=1<<30;
	for(int i=1;i<N;i++){
		//cout << i+1 << endl;
		for(int j=1;j<=i+1;j++){
			nex[j]=min(cur[j-1]-t[i-1]+t[i],cur[i-j+1]+t[i]);
			//cout << j << ": " << nex[j] << endl;
		}
		swap(cur,nex);
	}
	printf("%d\n",cur[N/2]);
}

Measured memory_bytes: 1288
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

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

    int k = 1;
    while (k * (k - 1) / 2 < N) k++;

    if (k * (k - 1) / 2 != N) {
        cout << "No" << endl;
        return 0;
    }

    int cur = 1;
    vector<vector<int>> ans(k);
    REP(i, 0, k - 1) {
        int num = k - 1 - i;
        REP(j, 0, num) {
            ans[i].push_back(cur + j);
            ans[i + j + 1].push_back(cur + j);
        }
        cur += num;
    }

    cout << "Yes" << endl;
    cout << k << endl;
    REP(i, 0, k) {
        cout << k - 1 << " ";
        REP(j, 0, k - 1) {
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 2304
import java.util.Scanner;

public class Main {

    static int test(int n, int m, int x, int[][] A, int mask) {
        int[] s = new int[m];
        int cost = 0;
        for (int i=0;i<n;i++) {
            if ((mask & (1<<i)) != 0) {
                cost += A[i][0];
                for (int j=1;j<=m;j++) s[j-1] += A[i][j];
            }
        }

        for (int i=0;i<m;i++) if (s[i] < x) return -1;
        return cost;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), m = in.nextInt(), x = in.nextInt();
        int[][] A = new int[n][m+1];
        for (int i=0;i<n;i++) {
            A[i][0] = in.nextInt();
            for (int j=1;j<=m;j++) A[i][j] = in.nextInt();
        }

        int ret = -1;
        for (int i=0;i<(1<<12);i++) {
            int t = test(n, m, x, A, i);
            if (t != -1) {
                if (ret == -1 || t < ret) ret = t;
            }
        }

        System.out.println(ret);
    }
}


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


using namespace std;


const int MAXN = 100 * 1000 + 123;







int n, a[MAXN], b[MAXN];
pair<int, int> c[MAXN];
long long ans;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i] >> b[i], c[i] = {a[i] + b[i], a[i]};
	sort(c, c + n);
	reverse(c, c + n);
	for (int i = 0; i < n; i++)
		if (i & 1)
			ans = ans - c[i].first + c[i].second;
		else
			ans = ans + c[i].second;
	cout << ans;
	return 0;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
  int a = S.find("A");
  int b = S.find("B");

  cout << ((a != string::npos && b != string::npos) ? YES : NO) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
  std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
  int N;
  std::cin>>N;
  
  bool result=false;
  for(int i=1;i<=9;i++)
  {
    for(int j=i;j<=9;j++)
    {
      if(i*j==N)
      {
        result=true;
      }
    }
  }
  
  if(result)
    std::cout<<"Yes"<<std::endl;
  else
    std::cout<<"No"<<std::endl;
  
  return 0;
}

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

int main(){
    long long int n,i,j;
    long long int ans = 0; 
    long long int siki1;
    long long int yakusuu = 0;
    scanf("%lld",&n);

    for(i = 1; i<n;i++){
        for(j=1;j<n;j++){
            if(i*j<n) ans++;
            else break;
        }
    }
    printf("%d",ans);
}



Measured memory_bytes: 1736
S=input()
size = len(S)
pmlist = [format(i,'0'+str(size-1)+'b').replace('0','+').replace('1', '-') for i in range(2**(size-1))]
for pm in pmlist:
    eq = ''.join([S[i]+pm[i] for i in range(size-1)]+[S[size-1]])
    if eval(eq) == 7:
        break
print(eq+'=7')

Measured memory_bytes: 3064
#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;
#define Mod 998244353
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59

ll modinv(ll a) {
    ll m=Mod;
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


ll th[303];
ll tw[303];

int main(){
  ll i,j;

  ll n;
  cin>>n;
  ll a[n];


  th[0]=1;
  tw[0]=1;
  for(i=1;i<303;i++){
    th[i]=(th[i-1]*3)%Mod;
    tw[i]=(tw[i-1]*2)%Mod;
  }

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

  ll M[n+1];
  M[0]=0;
  for(i=1;i<=n;i++) M[i]=M[i-1]+a[i-1];

  ll sum=M[n];

  ll r=(sum-1)/2;

  ll iv=modinv(2);
  if(iv<0) iv+=Mod;

  VVI v(303,VI(90909,0));
  v[0][0]=1;

  for(i=1;i<=n;i++){
    for(j=90908;j>=0;j--){
        v[i][j]=v[i-1][j];
        v[i][j]%=Mod;
        if(j-a[i-1]>=0){
          v[i][j]+=(v[i-1][j-a[i-1]])*iv;
          v[i][j]%=Mod;
        }
    }
  }


  ll ans=th[n];

  for(j=r+1;j<=sum;j++){
    ans=ans+(((Mod-3)*v[n][j])%Mod)*tw[n];
    while(ans<0) ans+=Mod;
    ans%=Mod;
  }


  if(sum%2==0) {
    ll ss=sum/2;
    ll o=0;
    VVI q(303,VI(ss+10,0));

    q[0][0]=1;

    for(i=1;i<=n;i++){
      for(j=ss-1;j>=0;j--){
        q[i][j]=q[i-1][j];
      }
      for(j=ss-1;j>=0;j--){
        if(j+a[i-1]<ss) q[i][j+a[i-1]]=(q[i][j+a[i-1]]+q[i-1][j])%Mod;
        else if(j+a[i-1]==ss) {
          o+=q[i-1][j];
          o%=Mod;
        }
      }
    }


    ans=ans+3*o;

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

Measured memory_bytes: 322488