akhauriyash/Code-Regression huggingface dataset:
// B - Guidebook

#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const long double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define Vec(K, L, N, S) vector<L> K(N, S)
#define rt sqrt
#define pb push_back
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using P = pair<lli, lli>;
// vector<P> vp;
// vp.emplace_back(a[i], b[i]);
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, k, n, w, ans = 0, count = 1;
  string s, t;
  cin >> n;
  vector<pair<string, pair<lli, lli>>> pr;

  rep(i, 0, n)
  {
    cin >> s >> a;
    pr.emplace_back(make_pair(s, make_pair(-a, i)));
  }
  SORT(pr);
  for (auto v : pr)
  {
    cout << v.second.second + 1 << endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve();
			Console.Out.Flush();
		}

		const int mod = 1000000007;  // 10^9+7
		static int Mod(long x, int m) { return (int)((x % m + m) % m); }
		static long Mod(long x, long m) { return (x % m + m) % m; }

		static public void Solve()
		{
			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();

			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			int d = vs[0];
			int n = vs[1];

			long x = 1;
			for (int i = 0; i < d; i++) {
				x *= 100;
			}
			long ans = n * x + n / 100 * x;

			Console.WriteLine(ans);

		}
	}
}


Measured memory_bytes: 28148
class Main
{
	public static void main( String[] args )
	{
		java.util.Scanner sc = new java.util.Scanner( System.in );
		int sum;
		int digitNum = 0;
		
		while( sc.hasNext() )
		{
			sum = sc.nextInt() +  sc.nextInt();
			
			digitNum = 0;
			while( sum > 0 )
			{
				sum /= 10;
				digitNum++;
			}
			System.out.println( digitNum );
		}
	}
}

Measured memory_bytes: 26492
package main

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

var (
	dp []int
	g  [][]int
)

func rec(now int) int {
	if dp[now] != -1 {
		return dp[now]
	}

	ret := 0
	for _, next := range g[now] {
		ret = max(ret, rec(next)+1)
	}

	dp[now] = ret
	return ret
}

func solve() {
	n, m := getInt(), getInt()

	dp = make([]int, n+1)
	for i := range dp {
		dp[i] = -1
	}

	g = make([][]int, n)
	for i := range g {
		g[i] = make([]int, 0)
	}
	for i := 0; i < m; i++ {
		x, y := getInt()-1, getInt()-1
		g[x] = append(g[x], y)
	}

	for now := 0; now < n; now++ {
		rec(now)
	}

	ans := max(dp...)
	fmt.Fprintln(wr, ans)
}

func max(ns ...int) int {
	max := ns[0]
	for i := 1; i < len(ns); i++ {
		if max < ns[i] {
			max = ns[i]
		}
	}
	return max
}

// -----------------------------------------

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	// buf := 200001
	// sc.Buffer(make([]byte, buf), buf)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func getIntSlice(n int) []int {
	is := make([]int, n)
	for i := range is {
		is[i] = getInt()
	}
	return is
}

func getString() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func getRunes() []rune {
	return []rune(getString())
}


Measured memory_bytes: 22912
# coding: utf-8
import itertools
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
    
def main():
    k = int(input())
    array = list(range(1, k+1))
    ans = sum(array)
    for i in range(2, 4):
        for x in itertools.combinations(array, i):
            x = list(x)
            tmp = gcd(*x)
            ans += tmp * 6
    print(ans)
    
main()


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

#include <string>
void _150() {
    int n;
    string s;
    cin >> n;
    cin >> s;

    int count = 0;
    for (int i = 0; i < s.size() - 2; ++i) {
        if (s.substr(i, 3) == "ABC") {
            count++;
        }
    }
    cout << count << endl;
}

void _151() {
    int n, k, m;
    cin >> n >> k >> m;
    int a[100];
    int goal = m * n;
    for (int i = 0; i < n - 1; ++i) {
        cin >> a[i];
        goal -= a[i];
    }

    if (goal > k) {
        cout << -1 << endl;
    } else {
        cout << max(goal, 0) << endl;
    }
}

void _152() {
    int a, b;
    cin >> a >> b;

    string result("");
    if (a < b) {
        for (int i = 0; i < b; ++i) {
            result += to_string(a);
        }
    } else {
        for (int i = 0; i < a; ++i) {
            result += to_string(b);
        }
    }
    cout << result << endl;
}

void _153() {
    long long h;
    int n, a;
    cin >> h >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        h -= a;
        if (h <=0) {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
    return;
}

void _154() {
    string s;
    cin >> s;

    for (int i = 0; i < s.size(); ++i) {
        cout << 'x';
    }
    cout << endl;
}

void _155() {
    int n, a;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        if (a % 2 == 0) {
            if ((a % 3 != 0) && (a % 5 != 0)) {
                cout <<"DENIED" << endl;
                return;
            }
        }
    }

    cout << "APPROVED" << endl;
}

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



Measured memory_bytes: 256
#![allow(
  non_snake_case,
  unused_variables,
  unused_assignments,
  unused_mut,
  unused_imports,
  unused_macros,
  dead_code
)]
use proconio::fastout;
use proconio::input;
use proconio::marker::*;
use std::cmp::*;
use std::collections::*;
//use std::collections::VecDeque;
macro_rules! debug {
  ($($a:expr),* $(,)*) => {
      #[cfg(debug_assertions)]
      eprintln!(concat!($("| ", stringify!($a), "={:?} "),*, "|"), $(&$a),*);
  };
}
#[fastout]
fn main() {
  input! {
    N:usize,
    A:[usize;N]
  }
  let N: usize = N;
  let mut nmax = 1000_000usize;
  let mut h = vec![0usize; nmax + 1];
  for i in 0..N {
    h[A[i]] += 1;
  }
  let mut mx = 0;
  let mut isprime = vec![true; nmax + 1];
  let mut i = 2;
  while i * i <= nmax {
    if isprime[i] {
      let mut j = i * 2;
      while j <= nmax {
        isprime[j] = false;
        j += j;
      }
      let mut f = 0usize;
      let mut j = i;
      while j <= nmax {
        f += h[j];
        j += i;
      }
      mx = max(mx, f);
    }
    i += 1;
  }
  let mut pflag = true;
  for p in i + 1..=nmax {
    if isprime[p] {
      let mut f = 0usize;
      let mut j = p;
      while j <= nmax {
        f += h[j];
        j += p;
      }
      mx = max(mx, f);
    }
  }
  if mx <= 1 {
    println!("pairwise coprime");
    return;
  } else if mx < N {
    println!("setwise coprime");
  } else {
    println!("not coprime")
  }
}


Measured memory_bytes: 25160
import sys
readline = sys.stdin.readline

def main():
    N = int(readline())
    F = []
    for _ in range(N):
        inp = list(map(int, readline().rstrip().split()))
        F.append(set([i for i, e in enumerate(inp) if e]))

    P = [list(map(int, readline().rstrip().split())) for _ in range(N)]
    ans = -10**10
    for i in range(1, 2**10):
        b = bin(i)[2:].zfill(10)
        t = set([j for j, e in enumerate(b) if e == '1'])
        pro = 0
        for f, p in zip(F, P):
            d = f & t
            pro += p[len(d)]
        ans = max(ans, pro)
    
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
long long int x = 1000000000000000000, ans=1;
long long int a[100000];
int n;
int main(){
	scanf("%d", &n);
	for(int i=0; i<n; i++){
		scanf("%lld", &a[i]);
		if(a[i] == 0){
			printf("0");
			return 0;
		}
	}
	for(int i=0; i<n; i++){
		if(x < a[i]){
			printf("-1");
			return 0;
		}
		else{
			ans *= a[i];
			x /= a[i];
		}
	}
	printf("%lld", ans);
	return 0;
} 

Measured memory_bytes: 4604
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a , b , c;
    cin >> a >> b >> c;
    if( ( 100 * a + 10 * b + c ) % 4 == 0 ) cout << "YES";
    else cout << "NO";
}


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

int main() {

	int N,x;
	std::cin >> N >> x;
	std::vector< int> a(N);
	for (int i = 0; i < N; i++)std::cin >> a[i];
	std::sort(a.begin(), a.end());
	int ans = 0;
	long long int res = 0;
	long long int sum = std::accumulate(a.begin(), a.end(),0LL);
	if (sum < x) ans = N - 1;
	else {
		for (int i = 0; i < N; i++) {
			res += a[i];
			if (res > x) break;
			else ans++;
		}
	}

	std::cout << ans << std::endl;
		}

Measured memory_bytes: 256
import java.util.Arrays;

public class Main {

  private static void solve() {
    int n = ni();
    int[][] a = new int[n][2];
    for (int i = 0; i < n; i++) {
      a[i][0] = i + 1;
      a[i][1] = ni();
    }
    Arrays.sort(a, (o1, o2) -> o1[1] - o2[1]);

    for (int i = 0; i < n; i++) {
      out.print(a[i][0] + " ");
    }
    out.println();

  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 46208
import java.util.Scanner;

class Main {

	int H = 0,W = 0,i,j,a,b;

	public void ch() {

		Scanner sc = new Scanner(System.in);

		H = sc.nextInt();

		W = sc.nextInt();

		while(H != 0 || W != 0) {

			for(i = 1; i <= H;i++) {

				for(j = 1; j <= W;j++) {

					a = i % 2;

					b = j % 2;

					if(b == 1) {

						if(a == 1) {

							System.out.print("#");

						} else {

							System.out.print(".");

						}

					} else if(a == 0) {

						System.out.print("#");

					} else {

						System.out.print(".");

					}

				}

			System.out.println();

			}

			System.out.println();

			H = sc.nextInt();

			W = sc.nextInt();

		}

	}

	public static void main(String[] args) {

		new Main().ch();

	}

}

Measured memory_bytes: 33036
#include<iostream> 
using namespace std;
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	while (a > 0 && c > 0) {
		c = c - b;
		if (c <= 0) {
			cout << "Yes";
			break;
		}
		a = a - d;
		if (a <= 0)
		{
			cout << "No";
		}
	}
	return 0;
}

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

#define fileIO freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout)
#define booster ios::sync_with_stdio(false);cin.tie(NULL)
#define forn(i,n) for(i=0;i<n;i++)
#define forin(i,s,n) for(i=s;i<n;i++)
#define pb push_back
#define ll long long
#define vv(i) vector<vector<i>>
#define vvp(i,j) vector<vector<pair<i,j>>>
#define umap unordered_map
#define ldd long double
#define ld double
#define mod 1000000007
#define endl "\n"
#define PI 3.14159265
int main()
{
  string s;
  cin>>s;
  if(s[2]==s[3] && s[4]==s[5])
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  return 0;
}

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 mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N;
    int A[N+1]; rep(i, N) cin >> A[i+1];
    int ball[N+1] = {};
    for(int i = N; i >= 1; i--){
        int acc = 0;
        for(int j = i; j <= N; j+=i){
            acc += ball[j];
        }
        if(acc % 2 == A[i]) ball[i] = 0;
        else ball[i] = 1;
    }
    int m = 0;
    rep(i, N+1) m += ball[i];
    cout << m << endl;
    rep(i, N+1){
        if(ball[i]) cout << i << " ";
    }
    if(m > 0) cout << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
 
using namespace std;
 
const int P=1000000007;
const int N=2000000;
 
int fact[N+5],invf[N+5];
int f[4][3],g[4][3];
int X1,X2,X3,X4,X5,X6,Y1,Y2,Y3,Y4,Y5,Y6,ans;
 
inline int C(int n,int m){return 1ll*fact[n+m]*invf[n]%P*invf[m]%P;}
 
inline void add(int &x,int y){(x+=y)%=P;}
 
int quick_power(int x,int y)
{
	int ret=1;
	for (;y;y>>=1,x=1ll*x*x%P) if (y&1) ret=1ll*ret*x%P;
	return ret;
}
 
void pre()
{
	fact[0]=1;
	for (int i=1;i<=N;++i) fact[i]=1ll*fact[i-1]*i%P;
	invf[N]=quick_power(fact[N],P-2);
	for (int i=N;i>=1;--i) invf[i-1]=1ll*invf[i]*i%P;
}
 
int calc(int x1,int y1,int sig1,int x2,int y2,int sig2)
{
	int ret=0;
	for(int x=X3;x<=X4;++x)
		add(ret,P-1ll*C(x-x1,Y3-1-y1)*(x+Y3)%P*C(x2-x,y2-Y3)%P),add(ret,1ll*C(x2-x,y2-Y4-1)*(x+Y4+1)%P*C(x-x1,Y4-y1)%P);
	for(int y=Y3;y<=Y4;++y)
		add(ret,P-1ll*C(y-y1,X3-1-x1)*(y+X3)%P*C(y2-y,x2-X3)%P),add(ret,1ll*C(y2-y,x2-X4-1)*(y+X4+1)%P*C(y-y1,X4-x1)%P);
	return ((ret*=sig1*sig2)+=P)%=P;
}
 
int main()
{
	pre();
	scanf("%d%d%d%d%d%d",&X1,&X2,&X3,&X4,&X5,&X6),scanf("%d%d%d%d%d%d",&Y1,&Y2,&Y3,&Y4,&Y5,&Y6),ans=0;
	f[0][0]=1,f[0][1]=X1-1,f[0][2]=Y1-1;
	f[1][0]=-1,f[1][1]=X1-1,f[1][2]=Y2;
	f[2][0]=-1,f[2][1]=X2,f[2][2]=Y1-1;
	f[3][0]=1,f[3][1]=X2,f[3][2]=Y2;
	g[0][0]=1,g[0][1]=X6+1,g[0][2]=Y6+1;
	g[1][0]=-1,g[1][1]=X6+1,g[1][2]=Y5;
	g[2][0]=-1,g[2][1]=X5,g[2][2]=Y6+1;
	g[3][0]=1,g[3][1]=X5,g[3][2]=Y5;
	for (int i=0;i<4;++i)
		for (int j=0;j<4;++j)
			add(ans,calc(f[i][1],f[i][2],f[i][0],g[j][1],g[j][2],g[j][0]));
	printf("%d\n",ans);
	fclose(stdin),fclose(stdout);
	return 0;
}

Measured memory_bytes: 15872
import std.stdio;
import std.conv;
import std.string;
import std.algorithm;
import std.array;
import std.math;


void main()
{
	foreach (line; stdin.byLine) {
    auto a = line.chomp.split.map!(to!double).array;
    if (a[7] < a[1] || a[6] < a[0] || a[2] < a[4] || a[3] < a[5]) {
      writeln("NO");
    } else {
      writeln("YES");
    }
  }
}

Measured memory_bytes: 1076
#include<bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define REPvec(itr, mp) for(auto itr = mp.begin();itr != mp.end(); itr ++)
#define all(x) x.begin(), x.end()
#define MOD 1000000007//1e9+7
using namespace std;
typedef long long ll;
typedef vector<int >    vecint;
typedef vector<vector<int> >  vec2int;
typedef vector<ll >     vecll;
typedef vector<string > vecstr;
typedef vector<bool > vecbool;
typedef vector<bool > vecbool;
////////////////////////////////////////////////
int main()
{
  ///////////////
  int n, m; cin >> n >> m;
  vecint k(m);
  vec2int s(m);
  int tmp = 0;
  REP(i,m){
    cin >> k[i];
    REP(j, k[i]){
      cin >> tmp;
      s[i].push_back(tmp);
    }
  }
  vecint p(m,0);
  REP(i,m) cin >> p[i];
  ///////////////
  // cout << endl;
  int ans = 0;
  for(int i = 0; i < (1 << n); i ++){
    /////on
    vecbool on(n, false);
    REP(j,n){
      if(i&(1 << j)){
	on[j] = true;
      }
    }
    /////on
    /////judge
    // cout << "onoff ";
    // REP(j,n) cout << on[j] << " ";
    // cout << endl;
    bool ok = true;
    REP(j,m){
      // cout << j << " " << p[j] << endl;
      int ns = s[j].size();
      int lnum = 0;
      REP(k, ns){
	lnum += on[s[j][k]-1];
      }
      if(lnum%2 != p[j]){
	ok = false;
	break;
      }
    }
    if(ok) ans ++;
    /////judge
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#C

N = int(input())
P = []
ans = 0

for i in range(N):
  A = int(input())
  p = []
  for j in range(A):
    x, y = map(int, input().split())
    p.append([x-1, y])
  P.append(p)

#全探索
for i in range(2**N):
  Flag = True
  for j in range(N): #N人の〇×を順に見る
    
    if (i >> j) & 1 == 1: #j桁目が1、つまりj番目が正直者→チェック
      for YN in P[j]:
        if (i >> YN[0]) & 1 != YN[1]:
          Flag = False
          break

    if Flag:
      continue
    else:
      break

  if Flag:
    ans = max(ans, bin(i).count("1"))

print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
 
using namespace std;
 
typedef long long ll;
 
int num[500005],a[500005];
ll b[500005];
 
int main() {
  int n;
  scanf("%d%d",&n,&a[0]);
  for(int i=1;i<=n;i++) {
    scanf("%d",&num[i]);
    a[i]=min(a[i-1],abs(a[i-1]-num[i]));
  }
  b[n+1]=1;
  for(int i=n;i>0;i--)
    if (b[i+1]*2>num[i]) b[i]=b[i+1]+num[i];
    else b[i]=b[i+1];
  int m;
  scanf("%d",&m);
  for(int i=1;i<=m;i++) {
    int x;
    scanf("%d",&x);
    printf("%s\n",(a[x-1]>=b[x+1])?"YES":"NO");
  }
  return 0;
}


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

int main(){
    int n;
    ll ans = 1;
    cin >> n ;
    
    bool over = false;
    bool zero = false;
    rep(i, n){
        ll a;
        cin >> a;
        if(a==0){
            zero=true;
            ans = 0;
            continue;
        }
        if(ans > 1000000000000000000/a){
            ans = -1;
            over = true;
        }else{
            ans *= a;
        }
        
        if(a==0)zero=true;
    }
    
    if(!zero && over)ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 3588
n = int(input())
max = 100000
dp = [max for i in range(n+1)]
dp[0] = 0
div_list = [1]
j = 1
k = 1
while(j*6 <= n):
    if 6**j <= n:
        if 6**j not in div_list:
            div_list.append(6**j)
    if 9**k <= n:
        if 9**k not in div_list:
            div_list.append(9**j)
    if 6**k > n and 9**j > n:
        break
    j += 1
    k+= 1
sorted(div_list)

for i in range(n):
    for n in div_list:
        dp[n] = 1
        if i+1-n > 0:
            dp[i+1] = min(dp[i+1],dp[i+1-n]+1)
        else:
            break

print(dp[len(dp)-1])


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

#define ll long long 
#define mkp make_pair 
#define fi first 
#define se second

using namespace std ;

int z ;

int	 main ( ) {

	int n ;
	cin >> n ;
	vector<int>vc(n);
	int k ;
	cin >> k ;
	for(int i = 0 ; i < n ; i ++ ){
		cin >> vc[i] ;
	}
	sort(vc.rbegin(),vc.rend());
	for(int i = 0; i < k ; i ++ ){
		z += vc[i] ;
	}

	cout << z ;

}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int E, Y;
	cin >> E >> Y;
	int year[] = { 1867,1911,1925,1988 };
	if (!E) {
		if (Y >= 1868 && Y <= 1911) {
			cout << "M" << Y - 1867 << endl;
		}
		else if (Y >= 1912 && Y <= 1925) {
			cout << "T" << Y - 1911 << endl;
		}
		else if (Y >= 1926 && Y <= 1988) {
			cout << "S" << Y - 1925 << endl;
		}
		else if (Y >= 1989 && Y <= 2016) {
			cout << "H" << Y - 1988 << endl;
		}
	}
	else {
		cout << year[E - 1] + Y << endl;
	}

	return 0;
}




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

const int N = 2 * 1000 + 10;

int n, k, ans = N * 2;
vector <int> adj[N];
queue <int> Q;
bool mark[N];
int Lvl[N];

void input() {
    int u, v;
    cin >> n >> k;
    for (int i = 0; i < n - 1; i++) {
        cin >> u >> v;
        u--, v--;
        adj[v].push_back(u) ;
        adj[u].push_back(v) ;
    }
    return;
}

void Clean() {
    for (int i = 0; i < n; i++) {
        mark[i] = false;
        Lvl[i] = 0;
    }
    return;
}

void UpdateAns() {
    int cnt = 0;
    for (int i = 0; i < n; i++)
        if (Lvl[i] > k / 2)
            cnt++;
    ans = min(cnt, ans) ;
    return;
}

void bfs() {
        while (!Q.empty()) {
            int v = Q.front() ;
            Q.pop() ;
            for (int i = 0; i < adj[v].size() ; i++) {
                int u = adj[v][i];
                if (!mark[u]) {
                    Lvl[u] = Lvl[v] + 1;
                    mark[u] = true;
                    Q.push(u) ;
                }
            }
        }
    UpdateAns() ;
    Clean() ;
    return;
}

void solve() {
    if (k % 2)
        for (int i = 0; i < n; i++)
            for (int j = 0; j < adj[i].size() ; j++) {
                Q.push(i) ;
                Q.push(adj[i][j]) ;
                mark[i] = mark[adj[i][j]] = true;
                bfs() ;
            }
    else
        for (int i = 0; i < n; i++) {
            Q.push(i) ;
            mark[i] = true;
            bfs() ;
        }
    return;
}

int main() {
    input() ;
    solve() ;
    cout << ans << endl;
    return 0;
}


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

int main() {
  unsigned long long int n,a,b;
  cin >> n >> a >> b;
  unsigned long long int rem = n%(a+b),ans=(n/(a+b))*a;
  ans += min(rem,a);
  cout << ans << endl;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
const int mod= 1e+9+7;

int main(){
    vector<ll>a(100000+10);
    a[0]=0;
    a[1]=0;
    a[2]=0;
    a[3]=1;
    a[4]=1;
    a[5]=2;
    a[6]=2;
    bool jud;
    for(ll i=7;i<=100000+10;i+=2){
        jud=true;
        for(ll j=2;j<=sqrt(i);j++){
            if(i%j==0){
                jud=false;
                break;
            }
        }
        for(ll k=2;k<=sqrt((i+1)/2);k++){
            if(((i+1)/2)%k==0){
                jud=false;
                break;
            }
        }
        if(jud){
            a[i]=a[i-1]+1;
            a[i+1]=a[i];
        }
        else{
            a[i]=a[i-1];
            a[i+1]=a[i];
        }
    }
    /*rep(i,10){
        cout<<a[i]<<endl;
        
    }
    return 0;*/
    ll q; cin>>q;
    vector<ll>l(q);
    vector<ll>r(q);
    rep(i,q){
        cin>>l[i]>>r[i];
    }
    rep(i,q){
        cout<<a[r[i]]-a[l[i]-1]<<endl;
    }

}



















































Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;

int main(){
    int n, m;
    scanf("%d%d", &n, &m);
    pii p[n];
    rep(i, n){
        int a, b;
        scanf("%d%d", &a, &b);
        p[i] = pii(a, b);
    }
    sort(p, p+n);
    priority_queue<int> que;
    int ans = 0;
    int cur = 0;
    rep(i, m+1){
        while(cur < n && p[cur].fi == i) que.push(p[cur++].se);
        if(!que.empty()){
            ans += que.top();
            que.pop();
        }
    }
    printf("%d\n", ans);
}

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

int main(){
    long int N,M;
    cin>>N;

    if(65<=N&&N<=90){
        M=1;
    }
    else if(97<=N&&N<=122){
        M=2;
    }
    else{
        M=0;
    }
    cout<<M<<endl;

    return 0;
}


Measured memory_bytes: 3088
#include "bits/stdc++.h"
using namespace std;

using ll = long long;

void max_self(ll& a, ll b) {
    a = max(a, b);
}

// O(n * W)

int main() {
    int n, W;
    scanf("%d%d", &n, &W);
    vector<ll> dp(W + 1); // 0 ... W
    // dp[i] - the maximum total value of items with total weight exactly i
    for(int item = 0; item < n; ++item) {
        int weight, value;
        scanf("%d%d", &weight, &value);
        // dp[0] -> dp[3] -> dp[6]
        for(int weight_already = W - weight; weight_already >= 0; --weight_already) {
        //~ for(int weight_already = 0; weight_already <= W - weight; ++weight_already) {
            max_self(dp[weight_already+weight], dp[weight_already] + value);
        }
    }
    ll answer = 0;
    for(int i = 0; i <= W; ++i) {
        max_self(answer, dp[i]);
    }
    printf("%lld\n", answer);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int n;
int M = 1000000007;
int dp[101][4][4][4];
int main()
{
    cin >> n;
    dp[0][0][0][0] = 1;
    for (int l = 0; l < n; l++)
    {
        for (int i = 0; i < 4; i++)
        {
            for (int j = 0; j < 4; j++)
            {
                for (int k = 0; k < 4; k++)
                {
                    if (dp[l][i][j][k] == 0)
                        continue;
                    for (int a = 0; a < 4; a++)
                    {
                        if (j == 1 && k == 2 && a == 3)
                            continue;
                        if (j == 1 && k == 3 && a == 2)
                            continue;
                        if (j == 2 && k == 1 && a == 3)
                            continue;
                        if (i == 1 && j == 2 && a == 3)
                            continue;
                        if (i == 1 && k == 2 && a == 3)
                            continue;
                        dp[l + 1][j][k][a] += dp[l][i][j][k];
                        dp[l + 1][j][k][a] %= M;
                    }
                }
            }
        }
    }
    int ans = 0;
    for (int i = 0; i < 4; i++)
    {
        for (int j = 0; j < 4; j++)
        {
            for (int k = 0; k < 4; k++)
            {
                ans += dp[n][i][j][k];
                ans %= M;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
using namespace std;
char s[100001],s2[100010],s3[100001];
int flag=1,len,L,R;
int main(){
    cin>>s;
    len=strlen(s);
    for(int i=len-1;i>=0;i--){
        L=i,R=len-i-1;
        if(s[L]==s[R])
        flag=0;
        else {
            flag=1;
            break;
        }
    }
    if(!flag){
        cout<<"Yes"<<endl;
        return 0;
    }
    int cnt=0;
    for(int i=0;i<len;i++){
        s2[len-i-1]=s[i];
        if(s2[len-i-1]=='b')
        s2[len-i-1]='d';
        else if(s2[len-i-1]=='d')
        s2[len-i-1]='b';
        else if(s2[len-i-1]=='p')
        s2[len-i-1]='q';
        else if(s2[len-i-1]=='q')
        s2[len-i-1]='p';
        if(s2[len-i-1]==s[len-i-1])
         cnt=1;
         else
         {
         	cnt=0;
         	break;
		 }
    }
    if(cnt==1){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
    return 0;
}

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

int main() {
  string s, t;
  cin>>s>>t;
  int db = 0;
  for(int i=0; i<s.size(); i++) {
    if (s[i] != t[i]){
      db = db + 1;
    }
  }
  
  cout<<db;

  
  return 0;
}

Measured memory_bytes: 3828
extension Collection {
    func mapToTuple() -> (Element, Element, Element, Element) {
        var iterator = makeIterator()
        return (iterator.next()!, iterator.next()!, iterator.next()!, iterator.next()!)
    }
}
var (A, B, C, K) = readLine()!.split(separator: " ").map { Int($0)! }.mapToTuple()

var result = 0

if 0 < K {
    result += min(A, K)
    K -= A
}
if 0 < K {
    K -= B
}
if 0 < K {
    result -= min(C, K)
    K -= C
}

print(result)


Measured memory_bytes: 8316
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
class SuffixArray(object):
    """
    construct:
        suffix array: O(N(logN)^2)
        lcp array: O(N)
        sparse table: O(NlogN)
    query:
        lcp: O(1)
    """
    def __init__(self,s):
        """
        s: str
        """
        self.__s=s
        self.__n=len(s)
        self.__suffix_array()
        self.__lcp_array()
        self.__sparse_table()

    # suffix array
    def __suffix_array(self):
        s=self.__s; n=self.__n
        # initialize
        sa=list(range(n))
        rank=[ord(s[i]) for i in range(n)]
        tmp=[0]*n
        k=1
        cmp_key=lambda i:(rank[i],rank[i+k] if i+k<n else -1)
        # iterate
        while(k<=n):
            sa.sort(key=cmp_key)
            tmp[sa[0]]=0
            for i in range(1,n):
                tmp[sa[i]]=tmp[sa[i-1]]+(cmp_key(sa[i-1])<cmp_key(sa[i]))
            rank=tmp[:]
            k<<=1
        self.__sa=sa
        self.__rank=rank

    # LCP array
    def __lcp_array(self):
        s=self.__s; n=self.__n
        sa=self.__sa; rank=self.__rank
        lcp=[0]*n
        h=0
        for i in range(n):
            j=sa[rank[i]-1]
            if h>0: h-=1
            if rank[i]==0: continue
            while j+h<n and i+h<n and s[j+h]==s[i+h]: h+=1
            lcp[rank[i]]=h
        self.__lcp=lcp

    # sparse table
    def __sparse_table(self):
        n=self.__n
        logn=max(0,(n-1).bit_length())
        table=[[0]*n for _ in range(logn)]
        table[0]=self.__lcp[:]
        # construct
        from itertools import product
        for i,k in product(range(1,logn),range(n)):
            if k+(1<<(i-1))>=n:
                table[i][k]=table[i-1][k]
            else:
                table[i][k]=min(table[i-1][k],table[i-1][k+(1<<(i-1))])
        self.__table=table

    def lcp(self,a,b):
        """
        a,b: int 0<=a,b<n
        return LCP length between s[a:] and s[b:]
        """
        if a==b: return self.__n-a
        l,r=self.__rank[a],self.__rank[b]
        l,r=min(l,r)+1,max(l,r)+1
        i=max(0,(r-l-1).bit_length()-1)
        table=self.__table
        return min(table[i][l],table[i][r-(1<<i)])
def resolve():
    n=int(input())
    s=input()
    sa=SuffixArray(s)
    ans=0
    for i in range(n):
        for j in range(i+1,n):
            ans=max(min(j-i,sa.lcp(i,j)),ans)
    print(ans)
resolve()

Measured memory_bytes: 54468
#include <iostream>
#include <stdio.h>
#include <vector>

typedef long long ll;

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

using namespace std;
 
const ll INF = ll(1e18)+1;
const double PI=3.14159265358979323846;

int main(){
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  if(s[k-1]=='A') s[k-1] = 'a';
  if(s[k-1]=='B') s[k-1] = 'b';
  if(s[k-1]=='C') s[k-1] = 'c';  
  cout << s << endl;
}

Measured memory_bytes: 256
# ABC090B - Palindromic Numbers
a, b = list(map(int, input().rstrip().split()))
count = 0
for i in range(a, b + 1):
    lst = list(map(int, list(str(i))))
    if lst[0] == lst[4] and lst[1] == lst[3]:
        count += 1
print(count)

Measured memory_bytes: 40940
#python3
x1,y1,x2,y2 = map(int,input().split())

def rtcc2(x,y,z):
    z = z*1j
    a,b = (x+z.real),y+z.imag
    z = z*1j
    c,d = (a+z.real),(b+z.imag)
    return(int(a),int(b),int(c),int(d))

vector = x2-x1 + (y2-y1)*1j
a,b,c,d = rtcc2(x2,y2,vector)
    
print(a,b,c,d)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
using P = pair<int,int>;
const int MOD = 1000000007;
#define inf 1e9

int main() {
    int a,b;
    cin>>a>>b;
    if ((a+b)%2==0) cout<<(a+b)/2<<endl;
    else cout<<(a+b)/2+1<<endl;
} 


Measured memory_bytes: 256
//  @ /\/\ BESH //

#include <bits/stdc++.h>
#define inp_out_work ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define testCase    int T; cin>>T; while(T--)
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,s,e) for(int i=s;i<=e;i++)
#define endl '\n'
#define debug(P) cout<<#P<<" = "<<P<<endl;
#define pb push_back


using namespace std;

typedef long long ll;
typedef long double ld;

const int MAXN = 100001;
const int mod = 1000000007;


int main(){
    int n;
    cin>>n;
    ll a[n];
    fr(i,n)cin>>a[i];

    ll sum[n];
    sum[0] = a[0];
    fro(i,1,n-1)sum[i] =sum[i-1] + a[i];

    ll dp[n][n];    // min cost incurred for slime joining a[i..j]

    // no cost for single slime
    fr(i,n)dp[i][i] = 0;

    // cost of two slimes join
    fr(i,n-1)dp[i][i+1] = a[i] + a[i+1];

    for(int len = 3; len <= n; len++){
        for(int i = 0; i <= n - len; i++){
            int j = i + len - 1;

            dp[i][j] = 1e18;

            for(int k = i; k < j; k++){
                dp[i][j] = min(dp[i][j] , dp[i][k] + dp[k+1][j] + sum[j]-sum[i]+a[i]);
            }
        }
    }

    cout<< dp[0][n-1] << endl;

}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using i64 = long long;

i64 s[60];

i64 calc(i64 l, i64 j) {
    if (!j) return 0;
    if (!l) return 1;
    if (j <= (s[l] - 1) / 2) return calc(l - 1, j - 1);
    if (j == (s[l] - 1) / 2 + 1) return calc(l - 1, s[l - 1]) + 1;
    if (j == s[l]) return 2 * calc(l - 1, s[l - 1]) + 1;
    return calc(l - 1, s[l - 1]) + calc(l - 1, j - s[l - 1] - 2) + 1;
}

int main() {
    i64 n, x;
    std::cin >> n >> x;
    s[0] = 1;
    for (int i = 1; i <= n; i++) {
        s[i] = s[i - 1] * 2 + 3;
    }
    std::cout << calc(n, x) << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <map>

#define REP(i,n) for(int i=0;i<n;i++)
#define maxi(a,b) (((a) > (b)) ? (a) : (b))
#define mini(a,b) (((a) > (b)) ? (b) : (a))

using namespace std;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/********************************************************/
	unsigned int n;
	cin >> n;

	vector<int> a(n), b(n);
	REP(i, n) {
		cin >> a[i];
	}
	REP(i, n) {
		cin >> b[i];
	}

	if (a[n - 1] != b[0]) {
		cout << 0 << endl;
		return 0;
	}
	if (n < 3) {
		cout << 1 << endl;
		return 0;
	}
	vector<int> v(n);
	int c = a[0];
	v[0] = a[0];

	for (int i = 1; i < n; i++) {
		if (c < a[i]) {
			v[i] = a[i];
			c = a[i];
		}
		else {
			continue;
		}
	}
	c = b[n - 1];
	v[n - 1] = b[n - 1];
	for (int i = n - 2; i >= 0; i--) {
		if (c < b[i]) {
			if (v[i] > 0 && b[i] != v[i]) {
				cout << 0 << endl;
				return 0;
			}
			if (a[i] < b[i]) {
				cout << 0 << endl;
				return 0;
			}
			v[i] = b[i];
			c = b[i];
		}
		else {
			continue;
		}
	}

	long long int ans = 1;
	for (int i = 0; i < n; i++) {
		if (v[i] > 0) {
			continue;
		}
		else {
			ans *= mini(a[i], b[i]);
			ans = ans % 1000000007;
		}
	}

	cout << ans << endl;

	/********************************************************/
	return 0;
}

Measured memory_bytes: 1408
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
//typedef complex<double>P;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
	for (auto &e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS*(abs(a) + abs(b))) { return 0; }
	return a + b;
}


//↑template↑

int main() {
	int n;
	cin >> n;
	cout << 3 * n*n << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int A,B,a,b,c,N,S;
  cin >> A >> B;
  S=0;
  for(int i=1;i< 10; i++){
    a =i;
    for(int j=0;j<10; j++){
      b = j;
      for(int k=0;k<10;k++){
        c = k;
        N =10000*a+1000*b+100*c+10*b+1*a;
        if(A<=N && N <=B){
          S++;}
      }
    }
  }  
  cout << S << endl;
}

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

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] intInputNum = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            int[,] intDataTableArry = new int[intInputNum[0] + 1, intInputNum[1] + 1];

            for (int row = 0; row < intInputNum[0]; row++)
            {
                int[] intInputDataArray = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

                for (int col = 0; col < intInputNum[1]; col++)
                {
                    intDataTableArry[row, col] = intInputDataArray[col];
                    intDataTableArry[row, intInputNum[1]] += intInputDataArray[col];
                    intDataTableArry[intInputNum[0], col] += intInputDataArray[col];
                    intDataTableArry[intInputNum[0], intInputNum[1]] += intInputDataArray[col];
                }
            }

            for (int row = 0; row < intInputNum[0]+1; row++)
            {
                for (int col = 0; col < intInputNum[1]+1; col++)
                {
                    if(col != intInputNum[1])
                    {
                        Console.Write(intDataTableArry[row, col] + " ");
                    }
                    else
                    {
                        Console.Write(intDataTableArry[row, col]);
                    }
                    
                }
                    Console.Write("\r\n");
            }
        }
    }
}



Measured memory_bytes: 16360
using System;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        // 整数の入力
        int n = int.Parse(Console.ReadLine());

        long[] a = new long[n];

        // スペース区切りの整数の入力
        string[] input = Console.ReadLine().Split(' ');
        for (int i = 0; i < n; i++)
        {
            a[i] = long.Parse(input[i]);
            if(a[i] == 0){
                Console.WriteLine(a[i]);
                return;
            }
        }

        long result = 1;
        long limit = (long)Math.Pow(10, 18);

        for (int i = 0; i < n; i++)
        {
            if (a[i] == 0)
            {
                result = 0;
                break;
            }
            else if (result <= limit / a[i])
            {
                result = result * a[i];
            }
            else
            {
                result = -1;
                break;
            }

        }
        //出力
        Console.WriteLine(result.ToString("0"));
    }
}


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

int main() {
    int n;
    cin >> n;
    if(n%2 == 0)cout << n/2;
    if(n%2 == 1)cout << (n+1)/2;
}

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

long long min(long long A, long long B);

int main(){
  int N,A;
  cin >> N;
  long long S[N];
  cin >> A;
  S[0] = A;
  for(int i = 0; i < N-1; i++){
    cin >> A;
    S[i+1] = S[i] + A;
  }

  long long Amin;
  Amin = abs(S[N-1]-S[0]-S[0]);
  for(int i = 1; i < N-1; i++){
    Amin = min(Amin,abs(S[N-1]-S[i]-S[i]));

  }

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

long long min(long long A, long long B){
  if(A<=B) return A;
  else return B;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
const LL MOD = 1000000007LL;
vector<int> G[2000];
int dist[2000];
void calc(int v, int p, int d) {
	dist[v] = min(dist[v], d);
	for (int to : G[v]) {
		if (to == p) continue;
		calc(to, v, d + 1);
	}
}
int main() {
	int N, K;
	cin >> N >> K;
	for (int i = 0; i < N - 1; i++) {
		int A, B;
		cin >> A >> B; A--; B--;
		G[A].push_back(B);
		G[B].push_back(A);
	}
	int ans = 1 << 30;
	if (K % 2 == 0) {
		for (int i = 0; i < N; i++) {
			fill((int*)dist, (int*)(dist + N), 1 << 30);
			calc(i, -1, 0);
			int cnt = 0;
			for (int j = 0; j < N; j++) {
				if (dist[j] > K / 2) cnt++;
			}
			ans = min(ans, cnt);
		}
	}
	else {
		for (int i = 0; i < N; i++) {
			for (int j : G[i]) {
				fill((int*)dist, (int*)(dist + N), 1 << 30);
				calc(i, -1, 0);
				calc(j, -1, 0);
				int cnt = 0;
				for (int k = 0; k < N; k++) {
					if (dist[k] > K / 2) cnt++;
				}
				ans = min(ans, cnt);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

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

  string ans = "";
  if (a == 0 || b == 0 || (a < 0 && b > 0)) {
    ans = "Zero";
  } else if (a > 0 && b > 0) {
    ans = "Positive";
  } else {
    int diff = abs(a - b) + 1;

    if (diff % 2 == 0) {
      ans = "Positive";
    } else {
      ans = "Negative";
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
typedef long long ll;
using namespace std;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    ll h, w;
    cin >> h >> w;
    ll ans = INF;
    if(w == 2 && h == 2){
        ans = 1;
    }
    repi(j, 2, 0)
    {
        repi(i, h - 1, 1)
        {
            ll s1, s2, s3;
            s1 = i * w;
            s2 = (h - i) / 2 * w;
            s3 = (h - (h - i) / 2 - i) * w;
            // cout << s1 << " " << s2 << " " << s3 << endl;
            ans = min(ans, max({s1, s2, s3}) - min({s1, s2, s3}));
            s2 = (h - i) * (w / 2);
            s3 = (h - i) * (w - w / 2);
            // cout << s1 << " " << s2 << " " << s3 << endl;
            ans = min(ans, max({s1, s2, s3}) - min({s1, s2, s3}));
        }
        swap(h, w);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
using namespace std;
typedef map<string,int> M;

int main(){
	M words;
	vector<int> pages[100];
	string word;
	int page,idx=0;

	while(cin>>word){
		cin>>page;
		if(words.empty() || words.find(word)==words.end()) words[word]=idx++;
		pages[words[word]].push_back(page);
	}

	for(M::iterator it=words.begin();it!=words.end();it++){
		cout<<(*it).first<<endl;
		sort(pages[(*it).second].begin(),pages[(*it).second].end());
		for(int i=0;i<pages[(*it).second].size();i++){
			cout<<pages[(*it).second][i];
			if(i!=pages[(*it).second].size()-1) cout<<" ";
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1244
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

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

    vector<int> p,sorted_p;
    for(int i = 0;i < N;i++) {
        int a;
        cin>>a;
        p.push_back(a);
        sorted_p.push_back(a);
    }

    sort(sorted_p.begin(),sorted_p.end());
    int counter = 0;
    for(int i = 0;i < N;i++) {
        if(p[i] != sorted_p[i]) {
            counter++;
        }
    }

    if(counter == 0 || counter == 2) {
        cout<<"YES"<<endl;
    } else {
        cout<<"NO"<<endl;
    }

    return 0;
}




Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int A[2], i, sub, Ans = 0;
	for (i = 0; i < 2; i++)
		cin >> A[i];

	if (A[0] < A[1]) {
		sub = A[0];
		A[0] = A[1];
		A[1] = sub;
	}
	for (i = 0; i < 2; i++) {
		Ans += A[0];
		A[0] -= 1;
		if (A[0] < A[1]) {
			sub = A[0];
			A[0] = A[1];
			A[1] = sub;
		}
	}

	cout << Ans;
	return 0;
}

Measured memory_bytes: 256