akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

const int MaxN = 200005;

int n, m;
int a[MaxN], dd[MaxN];
vector<int> Adj[MaxN];
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    for (int i = 1; i <= m; i++)
    {
        int u, v;
        cin >> u >> v;
        Adj[u].push_back(v);
        Adj[v].push_back(u);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++)
    {
        if (!Adj[i].size())
        {
            dd[i] = 1;
            ans++;
        }
    }
    for (int i = 1; i <= n; i++)
    {
        for (auto v : Adj[i])
        {
            if (a[i] <= a[v])
            {
                dd[i] = 1;
                break;
            }
        }
    }
    ans += count(dd + 1, dd + n + 1, 0);
    cout << ans;
    return 0;
}


Measured memory_bytes: 11932
<?php
while (true) {
    
   list($height, $width) = getInputExplodeBySpaces();
    
    if ($height == 0 && $width == 0) {
       break;
    }
    
    $chessRectangle = new ChessRectangle($height, $width);
    echo $chessRectangle->drawChessRectangle(), PHP_EOL;
}

function getInputExplodeBySpaces()
{
    return explode(' ', trim(fgets(STDIN)));
}
 
class Rectangle
{
    public $height;
    public $width;
    public $output;
    public $hashSymbol  = '#';
    
    public function __construct($height, $width)
    {
        $this->height = $height;
        $this->width  = $width;
    }
    
    public function drawRectangle()
    {
        for ($i = 0; $i < $this->height; $i++) {
            $lines[] = $this->drawHashSymbolLine();
        }
        return $lines;
    }
    
    public function drawHashSymbolLine()
    {
        return str_repeat($this->hashSymbol, $this->width).PHP_EOL;
    }
}

class FrameRectangle extends Rectangle
{
    public $dotSymbol = '.';
    
    public function drawFrameRectangle()
    {
        for ($i = 0; $i < $this->height; $i++) {
            if ($i == 0 || ($i == $this->height - 1)) {
                $lines[] = $this->drawHashSymbolLine();
            } else {
                $lines[] = $this->drawMiddleLine();
            }
        }
        return $lines;
    }
    
    public function drawMiddleLine()
    {
         return $this->hashSymbol.str_repeat($this->dotSymbol, $this->width - 2).$this->hashSymbol.PHP_EOL;
    }
}

class ChessRectangle extends FrameRectangle
{
    public function drawChessRectangle()
    {
        for ($i = 0; $i < $this->height; $i++) {
            if ($i % 2 == 0) {
                $lines[] = $this->drawChessLine($this->hashSymbol, $this->dotSymbol);
            } else {
                $lines[] = $this->drawChessLine($this->dotSymbol, $this->hashSymbol);
            }
        }
        
        return implode($lines);
    }
    
    private function drawChessLine($firstSymbol, $secondSymbol)
    {
        for ($i = 0; $i < $this->width; $i++) {
            if ($i % 2 == 0) {
                $lines[] = $firstSymbol;
            } else {
                $lines[] = $secondSymbol;
            }
        }
         
        return implode($lines).PHP_EOL;
    }
}

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

int main() {
  int num;
  int mod = 1000000007;
  cin >> num;
  long sum=0;
  vector<int> kazu(num);
  vector<long long> sum_i(num+1,0);
  for(int i = 0;i < num;i++)
  {
    cin >>kazu.at(i);
    sum_i.at(i+1) = sum_i.at(i)+ kazu.at(i);
  }
  for(int i = 0;i < num; i++)
  {
    long long sub_sum = (sum_i.at(num)-sum_i.at(i+1))%mod;
    sum += kazu.at(i)*sub_sum;
    sum %= mod;
  }
  cout << sum;
}


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

int n, m, k, cnt, com;
int b[8][8];
bool a[8][8];
string s;

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> n >> m >> k;
	for (int i = 1; i <= n; i++) {
		cin >> s;
		for (int j = 1; j <= m; j++) {
			a[i][j] = (s[j-1] == '#');
			b[i][j] = b[i-1][j] + b[i][j-1] - b[i-1][j-1] + a[i][j];
		}
	}
	
	cnt = b[n][m];

	int ti = 1 << n;
	int tj = 1 << m;

	for (int i = 1; i < ti; i++) {					// all horizontal line case
		int sum = cnt;
		for (int j = 1; j <= n; j++) {
			if (i & (1 << (j - 1)))  sum -= b[j][m] - b[j-1][m];
		}
		if (sum == k)  com++;
	}

	for (int i = 1; i < tj; i++) {					// all vertical line case
		int sum = cnt;
		for (int j = 1; j <= m; j++) {
			if (i & (1 << (j - 1)))  sum -= b[n][j] - b[n][j-1];
		}
		if (sum == k)  com++;
	}

	for (int i = 1; i < ti; i++) {
		for (int j = 1; j < tj; j++) {				// cross lines cases
			int sum = cnt;
			for (int z = 1; z <= n; z++) {
				if (i & (1 << (z - 1)))  sum -= b[z][m] - b[z-1][m];
			}
			for (int z = 1; z <= m; z++) {
				if (j & (1 << (z - 1)))  sum -= b[n][z] - b[n][z-1];
			}
			for (int z = 1; z <= n; z++) {
				for (int l = 1; l <= m; l++) {
					if (i & (1 << (z - 1)) && j & (1 << (l - 1))) {
						sum += a[z][l];
					}
				}
			}

			if (sum == k)  com++;
		}
	}

	if (cnt == k)  com++;
	cout << com << endl;
	return 0;
}

Measured memory_bytes: 3572
use std::io::{BufRead, Write};
use std::io;

fn solve<R: BufRead, W: Write>(mut input: R, mut output: W) {
    let mut s = String::new();
    input.read_line(&mut s).unwrap();
    let _: usize = s.trim().parse().unwrap();
    s.clear();
    input.read_line(&mut s).unwrap();
    let a: Vec<usize> = s.split_whitespace().map(|x| x.parse().unwrap()).collect();
    let mut four = 0;
    let mut even = 0;
    let mut odd = 0;
    for x in a {
        match x % 4 {
            0 => four += 1,
            2 => even += 1,
            1 | 3 => odd += 1,
            _ => unreachable!(),
        }
    }
    let result = odd <= four || (odd == four + 1 && even == 0);
    writeln!(output, "{}", if result { "Yes" } else { "No" }).unwrap();
}

fn main() {
    let stdin = io::stdin();
    let stdout = io::stdout();
    solve(stdin.lock(), stdout.lock());
}

#[cfg(test)]
mod tests {
    fn test(input: &str, output: &str) {
        let mut v: Vec<u8> = Vec::new();
        ::solve(input.as_bytes(), &mut v);
        assert_eq!(String::from_utf8(v).unwrap(), output);
    }

    #[test]
    fn case1() {
        test(
            "3
1 10 100\n",
            "Yes\n",
        );
    }
    #[test]
    fn case2() {
        test(
            "4
1 2 3 4\n",
            "No\n",
        );
    }
    #[test]
    fn case3() {
        test(
            "3
1 4 1\n",
            "Yes\n",
        );
    }
    #[test]
    fn case4() {
        test(
            "2
1 1\n",
            "No\n",
        );
    }
    #[test]
    fn case5() {
        test(
            "6
2 7 1 8 2 8\n",
            "Yes\n",
        );
    }
}


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

int main() {
  string s;
  long long p;
  int cmpflg,allflg;
  
  cin >> s;

  p=s.length();
  allflg=0;
  while (1)
  {
    	cmpflg=0;
    	if (p>=7)
        {
	    	if (strncmp(s.substr(p-7,7).c_str(),"dreamer",7)==0)
            {
              ++cmpflg;
    	      p -= 7;
            }
        }
    	
    	if (p>=5)
        {
          if (strncmp(s.substr(p-5,5).c_str(),"dream",5)==0)
            {
              ++cmpflg;
    	      p -= 5;
            }
        }
    
    	if (p>=6)
        {
    		if (strncmp(s.substr(p-6,6).c_str(),"eraser",6)==0)
            {
              ++cmpflg;
    	      p -= 6;
            }
        }
    
    	if (p>=5)
        {
    		if (strncmp(s.substr(p-5,5).c_str(),"erase",5)==0)
            {
              ++cmpflg;
    	      p -= 5;
            }
        }
    	
	    if (cmpflg==0)
        {	//不一致
          allflg = -1;
          break;
        }
    	
    	//先頭チェック
    	if (p<=0)
        {
          break;
        }
  }

  if (allflg==0)
	  cout << "YES" << endl;
  else
	  cout << "NO" << endl;
}


Measured memory_bytes: 512
def win(n):
	if n=='r':
		return p
	elif n=='s':
		return r
	else:
		return s

n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()
score=0
for i in t:
	score += win(i)

hands=list(t)

for i in range(n):
	if i+k<n:
		if hands[i]==hands[i+k]:
			score-=win(hands[i+k])
			hands[i+k]='x'
print(score)

Measured memory_bytes: 4084
import java.util.Scanner;
class Main
{
    public static void main(String args[])
    {
	Scanner scan=new Scanner(System.in);
	while(true)
	    {
		String r,a;
		r=scan.next();
		a=scan.next();
		if(r.equals("0") && a.equals("0"))break;
		int hit=0,blow=0;
		for(int i=0;i<4;i++)
		    {
			if(r.charAt(i)==a.charAt(i))hit++;
			for(int j=0;j<4;j++)
			    {
				if((r.charAt(i)==a.charAt(j)) && i!=j)blow++;
			    }
		    }
		System.out.println(hit+" "+blow);
	    }
    }
}

Measured memory_bytes: 41956
import sys
input = sys.stdin.readline



def main():
    N, K = map(int, input().split())
    R, S, P = map(int, input().split())
    T = list(input().rstrip())

    D = [[] for _ in range(K)]
    for i, t in enumerate(T):
        D[i%K].append(t)

    ans = 0
    for List in D:
        pre = -1
        for i, p in enumerate(List):
            if p == "r":
                s = P
            elif p == "s":
                s = R
            else:
                s = S
            if pre != p:
                ans += s
                pre = p
            else:
                pre = -1
    print(ans)
            

if __name__ == "__main__":
    main()

Measured memory_bytes: 18680
#include <bits/stdc++.h>
using namespace std;
int main() {
  int p, q, r;
  cin >> p >> q >> r;

  int sum = INT_MAX;
  sum = min(sum, p + q);
  sum = min(sum, p + r);
  sum = min(sum, q + r);

  cout << sum << endl;

  return 0;
}


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

int H, W, A, B;
int mod = 1e9 + 7;

int power(int a, int n){
    if (n == 0) {
        return 1;
    } else if (n % 2 == 0) {
        int b = power(a, n / 2);
        return 1ll * b * b % mod;
    } else {
        return 1ll * a * power(a, n - 1) % mod;
    }
}

int inverse(int a) {
    if (a == 1) {
        return 1;
    }
    return power(a, mod - 2);
}

int main() {
    cin >> H >> W >> A >> B;
    int C = min(A, B), M = max(H, W);
    vector<int> fact(H + W, 1), fact_inv(M, 1);
    for (int i = 1; i < H + W; i++) {
        fact[i] = 1ll * fact[i - 1] * i % mod;
        if (i < M) {
            fact_inv[i] = inverse(fact[i]);
        }
    }
    int all = 1ll * fact[H + W - 2] * fact_inv[H - 1] % mod * fact_inv[W - 1] % mod;
    
    int block = 0;
    for (int i = 0; i < C; i++) { //(下からA - i, 左からB - i)番目のブロックを通る経路
        block += 1ll * fact[H - A + B - 1] * fact_inv[H - A + i] % mod * fact_inv[B - i - 1] % mod
                * fact[W - B + A - 1] % mod * fact_inv[W - B + i] % mod * fact_inv[A - i - 1] % mod;
        block %= mod;
    }
    cout << (all - block + mod) % mod << endl;
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
  
  public static void Print_Array(int[] A){
    int n = A.length;
    for(int i=0;i<n-1;i++){
      System.out.print(A[i] + " ");
    }
    System.out.println(A[n-1]);
  }
  
  public static void Sellection_Sort(int[] A){
    int minj;
    int count = 0;
    for(int i=0;i<A.length;i++){
      minj = i;
      for(int j=i+1;j<A.length;j++){
        if(A[j]<A[minj]){
          minj = j;
        }
      }
      if(i != minj){
        swap(A, i, minj);
        count++;
      }
    }
    Print_Array(A);
    System.out.println(count);
  }

  public static void swap(int[] A, int a, int b){
    int m = A[a];
    A[a] = A[b];
    A[b] = m;
  }
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] A = new int[N];
    for(int i=0;i<N;i++){
      A[i] = sc.nextInt();
    }
    sc.close();
    Sellection_Sort(A);
  }
}


Measured memory_bytes: 26440
#include <bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vp = vector<P>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vvb = vector<vb>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll  INFL = 1e18;
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 N, M;
vvi G;
vb used;
vi tsorted;
vi depth;

void dfs(int n)
{
    if(used[n]) return;
    used[n] = true;
    REP(i, G[n].size()) dfs(G[n][i]);
    tsorted.push_back(n);
}

void tsort()
{
    REP(i, N) dfs(i);
    reverse(ALL(tsorted));
}

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    ll H, W; cin >> H >> W;
    vs grid(H); REP(i, H) cin >> grid[i];
    vvl dp(H, vl(W, 0));
    REPS(i, H-1)
    {
        if(grid[i][0] == '#') break;
        dp[i][0] = 1;
    }
    REPS(j, W-1)
    {
        if(grid[0][j] == '#') break;
        dp[0][j] = 1;
    }
    REPS(i, H-1)
    {
        REPS(j, W-1)
        {
            if(grid[i][j] == '#') continue;
            int y = i-1, x = j-1;
            if(grid[y][j] != '#') dp[i][j] += dp[y][j];
            if(grid[i][x] != '#') dp[i][j] += dp[i][x];
            dp[i][j] %= MOD;
        }
    }
    cout << dp[H-1][W-1] << endl;
}

Measured memory_bytes: 9216
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
    ($t:ty ;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty ;; $n:expr) => {
        (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
    };
}

fn main() {
    let a = get!(usize);
    let b = get!(usize);
    let h = get!(usize);
    println!("{}", (a + b) * h / 2);
}

Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int main(){
  int n;
  int array[100005];
  
  cin>>n;
  for(int i = 0; i < n; i++){
    cin>>array[i];
  }
  
  int sum = 0;
  for(int i = 0; i < n - 1; i++){
    for(int j = i + 1; j < n; j++){
      sum += array[i] * array[j];
    }
  }
  cout<<sum<<endl;
  return(0);
}


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

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
ll LINF = numeric_limits<ll>::max() / 2;
int MOD = 1e9 + 7;
#define rep(i,n) for(int i = 0; i < n; i++)
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'

vector<vector<pair<int, int> > > edge;//edge[i][j] firstがiからj番目のノード、secondがその重み
vector<int> d(100005,INF);

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,m;
	ll res;
	cin >> n >> m;
	if(n == 1){
		if(m == 1) res = 1;
		else res = m - 2;
	}else{
		if(m == 1) res = n-2;
		else res = (n-2) * (m-2);
	}
	cout << res << endl;
}

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

int main() {
	int h, w;
	while (true) {
		cin >> h >> w;
		if (h == 0 && w == 0)break;
		for (int i = 0; i < w; i++)cout << '#';
		cout << endl;
		for (int j = 0; j < h - 2; j++) {
			cout << '#';
			for (int k = 0; k < w - 2; k++)cout << '.';
			cout << '#' << endl;
		}
		for (int l = 0; l < w; l++)cout << '#';
		cout << endl << endl;
	}
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    string s;cin>>s;
    if(s.size()==3)reverse(all(s));
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
N, H, W = map(x -> parse(Int64,x), split(readline(STDIN)))
data = [map(x -> parse(Int64,x), split(readline(STDIN))) for _ in 1:N]
function cuttable(h, w, board)    
    return board[1] >= h && board[2] >= w
end
println(length(filter(board -> cuttable(H, W, board), data)))

Measured memory_bytes: 127700
#include <bits/stdc++.h>
#define arep(a,i,n) for(ll i=(a);i<(n);i++)
#define rep(i,n) for(ll i=0;i<(n);i++)
#define cinf(x,n) for(ll i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(ll i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

ll cnt1,cnt2,cnt3;//奇数、2、4

int main(){
	ll n;
	cin >> n;
	ll a[n];
	cinf(a,n);
	rep(i,n){
		if(a[i]%4==0)
			cnt3++;
		else if(a[i]%2==0)
			cnt2++;
		else
			cnt1++;
	}
	if(n%2){
		if(cnt3>=cnt1-1)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}else{
		if(cnt3>=cnt1)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
}

Measured memory_bytes: 4388
#!/usr/bin/env python3
import sys
try: from typing import Any, Union, List, Tuple, Dict
except ImportError: pass
sys.setrecursionlimit(10**6)
def debug(*args): print(*args, file=sys.stderr)
def exit(): sys.exit(0)


class UnionFind:
    def __init__(self, N):
        # type: (int) -> None
        self.N = N
        self.parent = list(range(N))  # type: List[int]

    def root(self, x):
        # type: (int) -> int
        path_to_root = []
        while self.parent[x] != x:
            path_to_root.append(x)
            x = self.parent[x]
        for node in path_to_root:
            self.parent[node] = x  # パス圧縮
        return x

    def same(self, x, y):
        # type: (int, int) -> bool
        return self.root(x) == self.root(y)

    def unite(self, x, y):
        # type: (int, int) -> None
        self.parent[self.root(x)] = self.root(y)

    def __str__(self):
        # type: () -> str
        groups = {}  # type: Dict[int, List[int]]
        for x in range(self.N):
            root = self.root(x)
            if root in groups.keys():
                groups[root].append(x)
            else:
                groups[root] = [x]
        result = ""
        for root in groups.keys():
            result += str(groups[root]) + "\n"
        return result

    def __len__(self):
        # type: () -> int
        roots = list(map(lambda x: self.root(x),
                         range(self.N)))
        return len(set(roots))


N, M = map(int, input().split())
K = []
L = []
for i in range(N):
    temp = list(map(int, input().split()))
    K.append(temp[0])
    L.append(list(map(lambda x: x-1,
                      temp[1:])))


speaker = [[] for i in range(M)]  # type: List[List[int]]


for i in range(N):
    for k in range(K[i]):
        speaker[L[i][k]].append(i)

u = UnionFind(N)
for l in range(M):
    sp = speaker[l]
    if len(sp) > 0:
        for i in range(1, len(sp)):
            u.unite(sp[0], sp[i])
if len(u) == 1:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 83160
#include <stdio.h>
#include <string.h>

#define N 100000

int main() {
	static char s[N + 1];
	int n, i;

	scanf("%s", s);
	n = strlen(s);
	for (i = 0; i < n; i += 2)
		printf("%c", s[i]);
	printf("\n");
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		sc.useDelimiter("[\n ,]");
		int rect = 0;
		int loz = 0;
		
		while(sc.hasNext()){
			int x1 = sc.nextInt();
			int x2 = sc.nextInt();
			int y = sc.nextInt();
			rect = (x1*x1 + x2*x2 == y*y) ? rect + 1 : rect;
			loz = ((x1*x1 == x2*x2)&&(x1+x2>y)) ? loz + 1: loz;
		}
		System.out.printf("%d\n%d\n",rect,loz);
		sc.close();
	}
}

Measured memory_bytes: 17388
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO.Compression;
using System.Linq;
using System.Numerics;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        private const long COMDIV = 1000000007;

        static void Main(string[] args)
        {
            BigInteger limit = 1000000000000000000;
            var N = int.Parse(Console.ReadLine());
            var As = Console.ReadLine().Split().Select(BigInteger.Parse).OrderBy(x => x).ToArray();
            BigInteger ret = 1;
            if (As[0] == 0)
            {
                Console.WriteLine(0);
                return;
            }

            for (int i = 0; i < N; i++)
            {
                ret *= As[i];
                if (ret > limit)
                {
                    Console.WriteLine(-1);
                    return;
                }
            }

            Console.WriteLine(ret);
        }
    }
}

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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

class FordFulkerson
{
public:
    FordFulkerson(int n) : _n(n), _graph(n), _used(n, false) {}

    void add_edge(int from, int to, ll cap)
    {
        _graph[from].emplace_back(to, cap, (int)_graph[to].size());
        _graph[to].emplace_back(from, 0, (int)_graph[from].size() - 1);
    }

    ll operator()(int s, int t)
    {
        ll flow = 0;
        while (true) {
            fill(_used.begin(), _used.end(), false);
            ll f = dfs(s, t, linf);
            if (f == 0) return flow;
            flow += f;
        }
    }

private:
    struct edge
    {
        int to; ll cap; int rev;
        edge(int to, ll cap, int rev) : to(to), cap(cap), rev(rev) {}
    };

    int _n;
    vector<vector<edge>> _graph;
    vector<bool> _used;

    ll dfs(int v, int t, ll f)
    {
        if (v == t) return f;
        _used[v] = true;
        for (auto &e: _graph[v]) {
            if (!_used[e.to] && e.cap > 0) {
                ll d = dfs(e.to, t, min(f, e.cap));
                if (d > 0) {
                    e.cap -= d;
                    _graph[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }
};


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

    int X, Y, E; cin >> X >> Y >> E;

    FordFulkerson flow(X + Y + 2);
    int s = X + Y, t = X + Y + 1;
    
    for (int i = 0; i < X; i++) flow.add_edge(s, i, 1);
    for (int i = 0; i < Y; i++) flow.add_edge(X + i, t, 1);

    for (int i = 0; i < E; i++) {
        int x, y; cin >> x >> y;
        flow.add_edge(x, X + y, 1);
    }

    cout << flow(s, t) << endl;
    return 0;
}



Measured memory_bytes: 3692
// https://atcoder.jp/contests/abc157/tasks/abc157_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

struct UnionFind {
    vector<int> par; // 親の番号
    UnionFind(int size) : par(size, -1) {}
    // xとyの木を併合
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x != y) {
            if (par[y] < par[x])
                swap(x, y);
            par[x] += par[y];
            par[y] = x;
            return true;
        } else {
            return false;
        }
    }
    // 2つのデータx, yが属する木が同じならtrueを返す
    bool same(int x, int y) { return root(x) == root(y); }
    // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    int root(int x) { return par[x] < 0 ? x : par[x] = root(par[x]); }
    // 頂点 v が属するグループと同じグループに属する頂点数を得る
    int size(int x) { return -par[root(x)]; }
};

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M, K;
    cin >> N >> M >> K;
    UnionFind uf(N);
    // set<pair<int, int>> st;
    unordered_set<int> st[N];
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        uf.unite(a, b);
        st[a].insert(b);
        st[b].insert(a);
    }
    REP(i, K) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        if (uf.same(a, b)) {
            st[a].insert(b);
            st[b].insert(a);
        }
    }
    REP(i, N) {
        cout << uf.size(i) - st[i].size() - 1 << (i == N - 1 ? "\n" : " ");
    }

    return 0;
}


Measured memory_bytes: 25984
N = 26
ord_a = ord('a')
S = [ord(s) - ord_a for s in input()]
K = int(input())


for i in range(len(S)):
    r = (N - S[i]) % N
    if K >= r:
        K -= r
        S[i] = 0


S[-1] += K % N
S[-1] %= N

answer = ''.join(chr(s + ord_a) for s in S)
print(answer)


Measured memory_bytes: 4836
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    int m,d;
    cin>>m>>d;
    
    int ans=0;
    rep(i,1,m+1){
        rep(j,1,d+1){
            int d10=j/10,d1=j%10;
            if(d1>=2&&d10>=2&&i==d1*d10)  ans++;
        }
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define fst first
#define snd second
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
#define pb push_back
#define for_tests(t, tt) int t; scanf("%d", &t); for(int tt = 1; tt <= t; tt++)
#ifndef ONLINE_JUDGE
#define debug(args...) fprintf(stderr,args)
#else
#define debug(args...)
#endif //ONLINE_JUDGE
template<typename T> inline T abs(T t) { return t < 0? -t : t; }
const ll modn = 1000000007;
inline ll mod(ll x) { return x % modn; }
#define IOS() ios::sync_with_stdio(0),cin.tie(0)

const int MAXN = 5123;

int n, m;
ll k;
ll s[MAXN];
int p[MAXN];


int main (){
	scanf("%d%lld", &n, &k);
    ll ok = k;
    for(int a=0;a<n;a++){
        scanf("%d", p+a);
        p[a]--;
    }
    for(int a=0;a<n;a++)
        scanf("%lld", s+a);
    ll res = LLONG_MIN;
	for(int a=0;a<n;a++){
        int u = p[a];
        ll sum = s[u];
        ll sz = 1;
        res = max(res, sum);
        while(u != a){
            u = p[u];
            sum += s[u];
            sz++;
            if(sz <= k)
                res = max(res, sum);
        }
        ll ans = 0;
        if(k >= 2*sz){
            ans = (k/sz - 1)*sum;
            k %= sz; 
            k += sz;
            res = max(res, ans);
        }
        assert(u == a);
        while(k--){
            u = p[u];
            ans += s[u];
            res = max(res, ans);
        }
        k = ok;
	}
    printf("%lld\n", res);
}



Measured memory_bytes: 3864
#include<bits/stdc++.h>
using namespace std;
int64_t N,K;
string s;
int main(){
  cin>>N>>K>>s;
  if(K==0)
    cout<<s<<endl;
  else{
  string S=s;
  vector<string>A(N+1);
  A[0]=S;
  for(int i=1;i<=N;i++){
  S.erase(0,1);
    S+=s.at(N-i);
  A[i]=S;
  }string S1=A[0];
    for(int i=1;i<=N;i++)
      if(A[i]<S1)S1=A[i];
    int sum=0;
    for(int i=0;i<N;i++){
    if(S1.at(i)==S1.at(0))sum++;
      else break;
    }int count=sum;
    for(int i=0;i<K-1;i++){
    sum*=2;if(N<=sum){sum=N;break;}
    }string ans="";
    for(int i=0;i<sum;i++)
      ans+=S1.at(0);
    for(int i=0;i<N-sum;i++)
      ans+=S1.at(count+i);
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 28084
#include<stdio.h>

int main()

{
     int x,c=0,b=0,i;

     scanf("%d",&x);

     for(i=1;i<=x;i++)
     {
         if(i%2==0)
            c++;
         else
            b++;
     }
     printf("%d\n",c*b);
     return 0;
}


Measured memory_bytes: 128
N, K, Q = map(int, input().split())
A = (int(input()) for _ in range(Q))

points = [0 for _ in range(N)]

for a in A:
    points[a-1] += 1

for p in points:
    if K + p - Q > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 51232
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
		int64_t N,R=0;
    	cin >> N;
    	R=N-1;
    	for(int i=2; i<=sqrt(N); i++){
    		if(N % i ==0){
    			if(i+N/i-2 < R){
    				R = i+N/i-2;
	    		}
    		}
    	}
    	cout << R << endl;
    	
    }

Measured memory_bytes: 384
#pragma GCC optimize(2,3,"Ofast","unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define in inline
namespace fast_io
{
    char buf[1<<12],*p1=buf,*p2=buf,sr[1<<23],z[23],nc;int C=-1,Z=0,Bi=0,ny;
    in char gc() {return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<12,stdin),p1==p2)?EOF:*p1++;}
    in int read()
    {
        int x=0;ny=1;while(nc=gc(),(nc<48||nc>57)&&nc!=EOF)if(nc==45)ny=-1;Bi=1;if(nc<0)return nc;
        x=nc-48;while(nc=gc(),47<nc&&nc<58&&nc!=EOF)x=(x<<3)+(x<<1)+(nc^48),Bi++;return x*ny;
    }
    in db gf() {int a=read(),y=ny,b=(nc!='.')?0:read();return (b?a+(db)b/pow(10,Bi)*y:a);}
    in int gs(char *s) {char c,*t=s;while(c=gc(),c<=32);*s++=c;while(c=gc(),c>32)*s++=c;return s-t;}
    in void ot() {fwrite(sr,1,C+1,stdout);C=-1;}
    in void flush() {if(C>1<<22) ot();}
    template <typename T>
    in void write(T x,char t)
    {
        int y=0;if(x<0)y=1,x=-x;while(z[++Z]=x%10+48,x/=10);
        if(y)z[++Z]='-';while(sr[++C]=z[Z],--Z);sr[++C]=t;flush();
    }
    in void write(char *s) {int l=strlen(s);for(int i=0;i<l;i++)sr[++C]=*s++;sr[++C]='\n';flush();}
};
using namespace fast_io;
const int N=1.5e3+5;
int n,s[N][N],p[N][N],mn[2][N][N],mx[2][N][N];ll ans;
char ch[N][N];
int main()
{
	n=read();for(int i=1;i<=n;i++) gs(ch[i]+1);
	for(int i=n,t=1;i;t^=1,i--) for(int j=n;j;j--) if(ch[i][j]^'#')
	{
		s[i][j]=s[i][j+1]+s[i+1][j]+ch[i][j]-'0';
		p[i][j]=max(max(p[i][j+1],p[i+1][j]),i);
		mn[t][j][i]=j;
		for(int k=i+1;k<=p[i+1][j];k++) mn[t][j][k]=mn[t^1][j][k];
		for(int k=max(p[i+1][j],i)+1;k<=p[i][j+1];k++) mn[t][j][k]=mn[t][j+1][k];
		mx[t][j][i]=j;
		for(int k=i;k<=p[i][j+1];k++) mx[t][j][k]=mx[t][j+1][k];
		for(int k=max(p[i][j+1],i)+1;k<=p[i+1][j];k++) mx[t][j][k]=mx[t^1][j][k];
		int l=i+1,r=min(p[i][j+1],p[i+1][j]);
		while(l<=r)
		{
			if(mx[t^1][j][l]>=mn[t][j+1][l]) s[i][j]-=s[l][mn[t][j+1][l]],l=p[l][mn[t][j+1][l]];
			l++;
		}
		ans+=1ll*(ch[i][j]-'0')*(s[i][j]-(ch[i][j]-'0'));
	}
	write(ans,'\n');
	return ot(),0;
}
//Author: disangan233

Measured memory_bytes: 22028
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		while (scan.hasNext()) {
			
			int a = scan.nextInt();
			int b = scan.nextInt();
			
			int c = a + b;
			String d = "" + c;
			
			System.out.println(d.length());
		}
	}
}

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descsort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main(void)
{
    string s;
    cin>>s;
    cout<<count(s.begin(),s.end(),'1')<<endl;
    return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <vector>
#include <string>
using namespace std;
void chmax(int &a, int b) { if (a < b) a = b; }

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

    int res = 0;
    vector<vector<int> > dp(N+1, vector<int>(N+1, 0));
    for (int i = N-1; i >= 0; i--) {
        for (int j = N-1; j > i; j--) {
            if (S[i] == S[j]) chmax(dp[i][j], dp[i+1][j+1] + 1);
            chmax(res, min(dp[i][j], j-i));
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 98176
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        Set<Character> set = new TreeSet<>();
        for (char ch = 'a'; ch <= 'z'; ++ch) {
            set.add(ch);
        }
        String s = sc.next();
        for (char ch : s.toCharArray()) {
            set.remove(ch);
        }
        for (char ch : set) {
            _out.println(ch);
            return;
        }
        _out.println("None");
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 26280
#include <iostream>
#include <fstream>
#include <vector>

#define DEBUG 0

using namespace std;
#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;

int main(){

#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    ll t1,t2,a1,a2,b1,b2;
    ll res;
    cin >> t1 >> t2;
    cin >> a1 >> a2;
    cin >> b1 >> b2;

    ll p,q;
    p = (a1 - b1) * t1;
    q = (a2 - b2) * t2;

    if(p + q == 0)
    {
        cout << "infinity" << endl;
        return 0;
    }

    if(p > 0)
    {
        p *= -1;
        q *= -1;
    }
    if(p + q < 0)res = 0;
    else//p + q > 0
    {
        ll s, t;
        s = (-p) / (p + q);
        t = (-p) % (p + q);
        if(t != 0)
        {
            res = s * 2 + 1;
        }
        else
        {
            res = s * 2;
        }
        
    }

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


Measured memory_bytes: 256
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var h = o.a();
  var w = o.a();
  var y = o.a();
  var x = o.a();
  if(h%y === 0 && w%x === 0)return "No";
  console.log("Yes");
  var ans = xArray(0,h,w);
  var plus = (1e9-1) / (x*y-1) | 0;
  var minus = plus * (1-x*y) - 1;
  for(var i = 0; i < h; i++)for(var j = 0; j < w; j++){
    if(i%y === y-1 && j%x === x-1){
      ans[i][j] = minus;
    }else{
      ans[i][j] = plus;
    }
  }
  return ans.map(a=>a.join(" ")).join("\n");
}

Measured memory_bytes: 33028
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
	int N;

	cin >> N;

	if (N % 2 == 0) {
		cout << N << endl;
	}

	else if (N % 2 == 1) {
		cout << 2 * N << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
ll n,m;

vector<ll> G[10];

ll used[10];

ll dfs(ll i,ll d) {
	if(d == n) {
		return 1;
	}

	ll ret = 0;
	REP(j,G[i].size()) {
		if(!used[G[i][j]]) {
			used[G[i][j]] = true;
			ret += dfs(G[i][j],d + 1);
			used[G[i][j]] = false;
		}
	}
	return ret;
}

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

	REP(i,m) {
		int a,b;
		cin >> a >> b;
		a--;b--;

		G[a].pb(b);
		G[b].pb(a);
	}

	used[0] = true;
	cout << dfs(0,1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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 gcd(int a, int b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

int main(){
  int n; cin >> n;
  vi c(n-1),s(n-1),f(n-1);
  rep(i, n-1) cin >> c[i] >> s[i] >> f[i];

  rep(i, n){
    if(i == n-1) {std::cout << 0 << '\n'; continue;}
    int time = s[i];
    for (int j = i; j < n-1; j++) {
      if(time < s[j]) time = s[j];
      else{
        if(time%f[j] != 0) time += f[j] - (time%f[j]);
      }
      time += c[j];
    }
    std::cout << time << '\n';
  }
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#include <cstdio>
#include <cstring>
#include <string>
#include <string.h>
#include <cmath>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <list>
#include <stack>
#include <bitset>
#include <fstream>
#include <sstream>
#include <random>
#include <assert.h>
#include <unordered_map>
#define eps 1e-7
#define SIZE 1000100
#define rep(i, a, b) for (long long i = a; i <= b; ++i)
#define pi acos(-1.0)
#define mp make_pair
#define ll long long
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
const int maxx = 1000000;
const int mod = 1000003;
ll n, m, k, t, a, b, c, d, x;
ll pre[maxx + 100], inv[maxx + 100];
const int p = 1000003;

long long binpow(long long a, long long b) {
	long long res = 1;
	while (b > 0) {
		if (b & 1) res = res * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return res % mod;
}

void init() {
	pre[0] = pre[1] = 1;
	rep(i, 2, (maxx + 25)) pre[i] = pre[i - 1] * i % mod;
	inv[1] = 1;
	for (ll i = 2; i <= maxx + 25; ++i) {
		inv[i] = (mod - mod / i) * inv[mod % i] % mod;
	}
}

int main() {
	io(); cin >> t;
	init();
	while (t--) {
		cin >> x >> d >> n;
		if (!x) {
			cout << binpow(d, n) * pre[n % mod] % mod << '\n';
			continue;
		}
		if (!d) {
			cout << binpow(x, n) % mod << '\n';
			continue;
		}
		ll id = binpow(d, mod - 2);
		//cout << id << endl;
		ll top = (id * x % mod + n - 1);
		//cout << top << endl;
		if (top >= mod) { cout << 0 << '\n'; continue; }
		if (id * x % mod == 0){
			cout << binpow(d, n) * pre[n] % mod << '\n';
			continue;
		}
		ll ans = binpow(d, n) * pre[top % mod] % mod * inv[pre[((id * x % mod - 1) + mod) % mod]] % mod;
		//cout << ((id * x % mod - 1) + mod) % mod <<' '<< binpow(d,n) << ' ' << pre[top % mod] << endl;
		cout << ans << '\n';
	}
}
/*
2
7 2 4
12345 67890 2019
*/

Measured memory_bytes: 16512
S = list(input())

a = int("".join(S[0:2]))
b = int("".join(S[2:4]))

if 1 <= a <= 12 and 1 <= b <= 12:
    print("AMBIGUOUS")
elif 1 <= a <= 12:
    print("MMYY")
elif 1 <= b <= 12:
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 9176
#include<cstdio>
#include<algorithm>
using namespace std;
int n,k,id,ans=2e9;
int main(){
	scanf("%d%d",&n,&k);
	for (int i=1;i<=n;++i){int x;scanf("%d",&x);if (x==1) id=i;}
	for (int i=id;i<id+k&&i<=n;++i) ans=min(ans,(((i-k)>0)?(((i-k)-1)/(k-1)+1):0)+((i<n)?((n-i-1)/(k-1)+1):0));
	printf("%d",ans+1);
	return 0;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<ll,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	vector<pii> a(n);
	rep(i, n){ cin >>a[i].first; a[i].second = i; }
	sort(a.rbegin(), a.rend());
	ll ans = 0;
	vector<VL> dp(n+1, VL(n+1));
	rep(i, n) rep(j, n){
		if(i+j == n){
			ans = max(ans, dp[i][j]);
			break;
		}
		amax(dp[i+1][j], dp[i][j] + abs(a[i+j].second - i) * a[i+j].first );
		amax(dp[i][j+1], dp[i][j] + abs(a[i+j].second - (n-1-j)) * a[i+j].first );
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 34624
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
   #define PP pair<int,pair<int,int>>
const int MAX = 200004;
const int MOD =998244353
 ;
const int INV2 = (MOD+1)/2;



     signed main(){
int n;
cin>>n;
string s[n];
for(int i=0;i<n;i++)cin>>s[i];
pair<int,int> p[n];int t=0;
for(int i=0;i<n;i++){
  int k=0,mk=0;
  for(int j=0;j<s[i].size();j++){
    if(s[i][j]=='(')k++;
    else k--;
    mk=min(k,mk);
  }
  p[i]=make_pair(k,mk);
  t+=k;
}
if(t!=0){
  cout<<"No"<<endl;
  return 0;
}
int l=0;
sort(p,p+n,greater<pair<int,int>>());
while(l<n&&p[l].first>0)l++;
for(int i=0;i<n;i++)swap(p[i].first,p[i].second);
for(int i=l;i<n;i++)p[i].first-=p[i].second;
sort(p,p+l,greater<pair<int,int>>());sort(p+l,p+n,greater<pair<int,int>>());
int sum=0,i0=0;
priority_queue<int> que;
while(i0!=l){
  while(i0<l&&sum+p[i0].first>=0){
    que.push(p[i0].second);
    i0++;
  }
  if(que.empty()){
    cout<<"No"<<endl;
    return 0;
  }
  sum+=que.top();
  que.pop();

}
while(!que.empty())que.pop();
sum=0;
while(i0!=n){
  while(i0<n&&sum+p[i0].first>=0){
    que.push(-1*p[i0].second);
    i0++;
  }
  if(que.empty()){
    cout<<"No"<<endl;
    return 0;
  }
  sum+=que.top();
  que.pop();

}
cout<<"Yes"<<endl;
return 0;






}


        


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

using namespace std;

void rwFile() {
    freopen("INP.inp", "r", stdin);
    freopen("OUT.out", "w", stdout);
}

void solve() {
    int n, k; cin >> n >> k;
    int arr[n];
    for (int i = 0; i < n; i++) cin >> arr[i];
    int res[k + 1];
    for (int i = 0; i <= k; i++) res[i] = 0;
    for (int i = 1; i <= k; i++) {
        for (int j = 0; j < n; j++) {
            if (i >= arr[j]) {
                if (res[i - arr[j]] == 0) {
                    res[i] = 1;
                    break;
                }
            }
        }
    }
    cout << ((res[k] == 1) ? "First" : "Second");
}

int main()
{
    //rwFile();
    solve();
}


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

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N,K; cin >> N >> K;
    int h[N];
    rep(i,N) cin >> h[i];
    int ans=0;
    rep(i,N) if(K<=h[i]) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 1024
// inputに入力データ全体が入る
function Main(str) {
  const count = str.split('\n')[0];
  const nums = str.split('\n')[1].split(' ');

  const numsCast = nums.map(num => Number(num));

  const max = Number(Math.max(...numsCast));
  const min = Number(Math.min(...numsCast));

  console.log(max - min);

}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
#define   ll    long long int
#define   sz    1000100
#define   pb    push_back
#define   py    printf("Yes\n")
#define   pn    printf("No\n")
#define   sc(a) scanf("%lld",&a)
const  double pi=acos(-1);

using namespace std;

ll num[sz];

int main()
{

     ll n,m,i,j,k,a,b;

     cin>>n;

     for(i=1;i<=n;i++)
     {
         cin>>num[i];
     }

     a=0;

     for(i=1;i<=n;i++)
     {
         for(j=i+1;j<=n;j++)
         {
             a+=(num[i]*num[j]);
         }
     }

     cout<<a<<endl;


    return 0;
}


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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int i = a;i < b;++i) cout << ary[i] << (b-1 == i ? "]\n" : ", "); } while(0)
#define p_map(map,it) do {cout << "{";for (auto it = map.begin();;++it) {if (it == map.end()) {cout << "}\n";break;}else cout << "" << it->first << "=>" << it->second << ", ";}}while(0)

int main () {
    int n,m;
    string s,t;
    cin >> s >> t;
    n = s.size();m = t.size();
    vector<vector<P>> dp(2,vector<P>(m+1,P(0,"")));
    for (int k = 0;k < n;++k) {
        int i = k%2;
        for (int j = 0;j < m;++j) dp[i^1][j+1] = (s[k] == t[j] ? ((dp[i][j].first+1 > dp[i^1][j].first && dp[i][j].first+1 > dp[i][j+1].first) ? P(dp[i][j].first+1,dp[i][j].second+s[k]) : (dp[i^1][j] > dp[i][j+1] ? dp[i^1][j] : dp[i][j+1])) : (dp[i^1][j] > dp[i][j+1] ? dp[i^1][j] : dp[i][j+1]));
    }
    cout << dp[n&1][m].second << endl;
    return 0;
}

Measured memory_bytes: 7908
process.stdin.resume();
process.stdin.setEncoding('utf8');
// Here your code !
process.stdin.on("data",function(chunk){
    var line = chunk.trim().split("\n").map(function(e){return parseInt(e)});
    console.log(line.sort(function(a,b){return b-a}).slice(0,3).join("\n"))
    
})

Measured memory_bytes: 15500
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n;
	scanf("%lld",&n);
	for(int i=sqrt(n);i>0;i--)
	{
		if(n%i==0)
		{
			int flag=n/i;
			int len=1;
			while(flag>=10)
			{
				len++;
				flag/=10;
			}
			cout<<len;
			return 0;
		}
	} 
	return 0;
}

Measured memory_bytes: 256