akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

int main()
{
  int age;
  cin >> age;
  
  if(age == 3 || age == 5 || age == 7)
  {
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO"  << endl;
  }
  return 0;
}

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

int main()
{
       int x;cin>>x;
       long long y;
       vector<int>v;
       v.push_back(1);
       for(long long i=2;i*i<=x;i++)
       {
           y=i*i;
           if(y<=x)
            v.push_back(y);
           while(y*i<=x){
            v.push_back(y*i);
            y*=i;
           }
       }
      sort(v.begin(),v.end());
       cout<<v[v.size()-1];
    return 0;
   }

Measured memory_bytes: 3596
#include <algorithm>
#include <iostream>
#include <vector>
#define N 3

int main(){
	std::vector<int> num_vector;
	int i;
	int scan_num;

	for (i = 0; i < N; i++){
		std::cin >> scan_num;
		num_vector.push_back(scan_num);
	}

	std::sort(num_vector.begin(), num_vector.end());

	for (i = 0; i < N-1 ; i++){
		std::cout << num_vector[i] << ' ';
	};
	std::cout << num_vector[N-1] << '\n';
	return 0;
}


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

int main() {
	int A, B;
	cin >> A >> B;
	if ((1 == A % 2) && (1 == B % 2)) {
		cout << "Odd" << endl;
	}
	else {
		cout << "Even" << endl;
	}
	return 0;
}

Measured memory_bytes: 3560
#### import ####
import sys
sys.setrecursionlimit(10**7)
import math
from collections import defaultdict

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
  read_all = [tuple(map(int, input().split())) for _ in range(N)]
  return map(list,zip(*read_all))

#################

N,K = II()
V = III()

ans = -float('inf')
for i in range(min(N+1,K+1)):
  for j in range(min(N-i+1,K-i+1)):
    V2 = V[:i] + V[N-j:]
    V2.sort()
    temp = sum(V2)
    for k in range(min(K-(i+j),len(V2))):
      if V2[k]<0:
        temp -= V2[k]
    if ans < temp:
      ans = temp
print(ans)

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

int main() {
  int n;cin>>n;
  vector<ll> a(n);
  rep(i,n)cin>>a[i];
  ll ans=0,cnt=a[0];
  for(int i=1;i<n;i++){
    if(cnt>a[i])ans+=cnt-a[i];
    cnt=max(cnt,a[i]);
  }
  cout<<ans<<endl;
}

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

int main(){
    int n; cin >> n;
    string s; cin >> s;
    if(n % 2 != 0){
        cout << "No";
    }else {
        string a = s.substr(0, n / 2);
        string b = s.substr(n / 2);
        if (a == b) cout << "Yes"; else cout << "No";
    }

}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    sc.nextLine();
    int a = sc.nextInt();
    for(int i = 0;i<20;i++){
      n -= 500;
      if(n <0){
        n += 500;
        break;
      }
    }
    if(n>a){
      System.out.println("No");
    }else{
      System.out.println("Yes");
    }
  }
}

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

using namespace std;
using ll = long long;

const int MOD = 2019;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int L, R;
  cin >> L >> R;
  ll res = MOD;
  if (R - L >= 2018) {
    res = 0;
  } else {
    for (int i = L; i < R; i++) {
      for (int j = i + 1; j <= R; j++) {
        res = min(res, 1LL * i % MOD * j % MOD);
      }
    }
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::*;
use std::str::FromStr;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;
#[allow(dead_code)]
const MOD:i64 = 1e9 as i64 + 7;


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

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}


#[allow(unused_imports)]
use std::f64;


fn main() {
    input!{h:i64, w:i64, n:i64};
    println!("{}", f64::ceil(n as f64 / max(h,w) as f64));
}

Measured memory_bytes: 4352
H, W  = map(int, input().split())
fields = []
# 初期値が決まったフラグ
flg = False
for i in range(H):
    ls = list(input())
    fields.append(ls)

mvs = [(0,1),(0,-1),(1,0),(-1,0)]
for h in range(H):
    for w in range(W):
        if fields[h][w] == "#":
            flg = False #つながっているかどうか
            for dh,dw in mvs:
                h_new = h + dh
                w_new = w + dw
                if 0 <= h_new < H and 0 <= w_new < W:
                    if fields[h_new][w_new] == "#":
                        flg = True
            if not flg:
                print("No")
                exit()
print("Yes")        


Measured memory_bytes: 3064
#include <stdio.h>
#include <string>
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

int main(void){
    string s;
    int i,j;
    cin >> s;
    int flag=0;
    for(int i=0; i<s.size(); i++){
        if(s[i]=='Z')j=i;
    }
    i=s.find("A");
    cout << j-i+1 << endl;
    return 0;
}

Measured memory_bytes: 644
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());
        List<Long> numList = new ArrayList<>();
        List<Long> queryList = new ArrayList<>();
        for(int i=0;i<N;i++){
            numList.add(Long.parseLong(sc.next()));
        }
        long volume = 0;
        for(int i=0;i<N;i++){
            volume += numList.get(i);
            queryList.add(volume);
        }
        long max = 0;
        for(int i=0;i<N-K+1;i++){
            long sectionMax = 0;
            if(i == 0){
                sectionMax = queryList.get(i+K-1);
            }else{
                sectionMax =  queryList.get(i+K-1) - queryList.get(i -1);
            }
            max = Math.max(sectionMax,max);
        }
        double result = (max + K)/2.0;
        System.out.println(String.format("%.12f",result));
}
}

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

flowers = []

for _ in range(n):
    tmp = [int(x) for x in input().split()]
    flowers.append(tmp)

def aaa(p, l):
    count = 0
    for x in l:
        w, d = x[0], x[1]
        if p - w < 0:
            pass
        else:
            count += (p - w) // d + 1
    return count

flag = True
left, right = 1, 10 ** 19
ans = 0

while flag:
    point = (right + left) // 2
    if point == left:
        flag = False
        if aaa(left, flowers) >= k:
            ans = left
        else:
            ans = right
    else:
        if aaa(point, flowers) < k:
            left = point
        else:
            right = point

print(ans)


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion
#pragma region chminmax
template <typename T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

ll dp[3005][3005][5];

int main()
{
    int r, c, k;
    cin >> r >> c >> k;

    vvint g(r, vint(c));
    rep(i, k)
    {
        int y, x, v;
        cin >> y >> x >> v;
        g[y - 1][x - 1] = v;
    }

    rep(y, r) rep(x, c) rep(i, 4)
    {
        // carry over
        chmax(dp[y][x + 1][i], dp[y][x][i]);
        // take the one we're looking at
        //  came from above
        chmax(dp[y][x + 1][i + 1], dp[y][x + 1][0] + g[y][x]);
        //  came from left
        chmax(dp[y][x + 1][i + 1], dp[y][x][i] + g[y][x]);
        // move down
        chmax(dp[y + 1][x + 1][0], dp[y][x + 1][i]);
    }

    // view(g);
    // rep(y, r + 2)
    // {
    //     rep(x, c + 2)
    //     {
    //         cout << "[";
    //         rep(i, 4)
    //         {
    //             cout << dp[y][x][i] << " ";
    //         }
    //         cout << "]";
    //     }
    //     cout << endl;
    // }

    cout << dp[r][c][0] << endl;

    return 0;
}

Measured memory_bytes: 390760
import java.util.*;
// import java.util.stream.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    try {
      int a = sc.nextInt();
      int b = sc.nextInt();
      int c = sc.nextInt();
      System.out.println(query(a,b,c));
    } finally {
      sc.close();
    }
  }

  private static String query(int a, int b, int c) {
    if (a < c && c < b) return "Yes";
    if (b < c && c < a) return "Yes";
    return "No";
  }
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL << (n))
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define en '\n'
#define pb push_back
#define mp make_pair
#define P pair<int, int>

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;

struct aaa {
	aaa() {
		cin.tie(0);
		ios::sync_with_stdio(0);
		cout << fixed << setprecision(20);
	};
}aaaaa;

int main() {
	int H, W;
	cin >> H >> W;
	string S[400];
	rep(i, H) cin >> S[i];

	bool visited[400][400];
	ll ans = 0;

	rep(i, H) {
		rep(j, W) {
			visited[i][j] = false;
		}
	}

	rep(i, H) {
		rep(j, W) {
			if (visited[i][j]) continue;
			visited[i][j] = true;

			vector<ll> num(2, 0);
			queue<P> que;
			que.push(P(i, j));

			while (que.size()) {
				P p = que.front();
				que.pop();
				int x = p.first, y = p.second;
				num[(S[x][y] == '#') ? 1 : 0]++;

				for (int k = 0; k < 4; k++) {
					int x2 = x + dx[k];
					int y2 = y + dy[k];
					if (0 <= x2 && x2 < H && 0 <= y2 && y2 < W && !visited[x2][y2] && S[x][y] != S[x2][y2]) {
						que.push(P(x2, y2));
						visited[x2][y2] = true;
					}
				}
			}
			ans += num[0] * num[1];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(c) c.begin(),c.end()
#define PB push_back

using namespace std;
typedef long long ll;

int main()
{
  int A, B, C; cin >> A >> B >> C;
  int M = max({A, B, C});
  int sum = A + B + C;
  if (M % 2 == sum % 2) {
    cout << (3*M - sum) / 2 << endl;
  } else {
    cout << (3*(M + 1) - sum) / 2 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<map>
using namespace std;
typedef long long int ll;
const int MAXN=100005;
ll ans=0;
int n,mod;
int sum[MAXN];
map<int,int> mp;
int read(){
	int x=0,f=1;char c=getchar();
	for(;c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
	for(;c>='0'&&c<='9';c=getchar()) x=(x<<3)+(x<<1)+c-'0';
	return x*f;
}
int main(){
	n=read();mod=read();
	mp.insert(make_pair(0,1));
	for(int i=1;i<=n;++i){
		sum[i]=(sum[i-1]+read())%mod;
		if(mp.count(sum[i])==false) mp.insert(make_pair(sum[i],1));
		else ++mp[sum[i]];
	}
	map<int,int>::iterator it=mp.begin();
	for(it=mp.begin();it!=mp.end();++it){
		ans+=(ll)it->second*(it->second-1)/2;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
int c;
if(b<10){
    c=10*a+b;
}
else if(b<100){
    c=100*a+b;
}
else{
    c=1000*a+b;
}
int d=pow(c,0.5);
if(pow(d,2)==c){
    cout<<"Yes"<<endl;
}
else{
    cout<<"No"<<endl;
}
}


Measured memory_bytes: 384
N=int(input())
X = list(map(int, input().split()))

ave=sum(X)//N

s1=0
s2=0

for i in range(N):
    s1=s1+(X[i]-ave)**2

for i in range(N):
    s2=s2+(X[i]-ave-1)**2

print(min(s1,s2))

Measured memory_bytes: 3064
k = int(input())

def gcd(a, b, c):
    mini = a
    if a > b:
        mini = b
    if b > c:
        mini = c
    if (a % mini == 0) & (b % mini == 0) & (c % mini == 0):
        return mini
    if mini % 2 == 0:
        h = mini / 2
        if (a % h == 0) & (b % h == 0) & (c % h == 0):
            return h
    for i in range((mini + 1)//3 + 1, 1, -1):
        if (a % i == 0) & (b % i == 0) & (c % i == 0):
            return i
    return 1

s = 0
for i in range(1, k + 1):
    for j in range(1, k + 1):
        for l in range(1, k + 1):
            if i <= j <= l:
                if i < j < l:
                    a = gcd(i, j, l) * 6
                    s += int(a)
                elif ((i == j) & (j != l)) | ((i != j) & (j == l)):
                    a = gcd(i, j, l) * 3
                    s += int(a)
                else:
                    a = gcd(i, j, l) 
                    s += int(a)
            else:
                continue

print(s)

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

int main(){
  int N; cin >> N;
  vector<long long> A(N);
  for (int i=0; i<N; i++) cin >> A[i];
  vector<long long> ans(N);
  for (int i=0; i<N; i++){
    if (i%2==0) ans[0] += A[i];
    else ans[0] -= A[i];
  }
  for (int i=1; i<N; i++){
    ans[i] = A[i-1] - ans[i-1]/2;
    ans[i] *= 2;
  }
  for (int i=0; i<N; i++){
    cout << ans[i];
    if (i<N-1) cout << ' ';
  }
  cout << endl;
}


Measured memory_bytes: 2944
/// meowa 

#pragma GCC optimize("O3")
//#pragma comment(linker, "/STACK:36777216")

#include<bits/stdc++.h>

#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;

using ll = long long;
using pii = pair<int, int>;                                   

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

void stndrtn() {
#ifdef AM
    freopen(".in", "r", stdin);
#endif        
}                   

const bool flag = 0;

void ma1n() {
    int a, b, c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
    while (k && a >= b) {
        b *= 2, k--;
    }        
    while (k && b >= c) {
        c *= 2, k--;
    }
    if (a < b && b < c) 
        cout << "Yes\n";
    else 
        cout << "No\n";
} 

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr), stndrtn();
    int ts = 1;
    if (flag) {
        cin >> ts;
    }
    while (ts--) {
        ma1n(); 
    }
    return 0;
}

Measured memory_bytes: 3648
/*
Arthor : Ender_zzm
E-mail zzm_ender_wiggin@outlook.com
Blog ender-zzm.enbar.cn
*/
#include <bits/stdc++.h>
using namespace std;
 
inline int Isdigit(char c) {
	if (c < '0' || c > '9') return 0;
	return 1;
}
inline int readint(){
    register int x = 0, flag = 1;
    register char ch;
    while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), Isdigit(ch = getchar()));
	return x * flag;
}
 
inline long long readlong() {
	register long long x = 0, flag = 1;
	register char ch;
	while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), Isdigit(ch = getchar()));
	return x * flag;
}
template <class T>
inline void write(T x){
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10); 
    putchar(x % 10 + '0');
}
 
template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }
 
#define For(i, x, y) for (int i = (x); i <= (y); i++) 
#define Rep(i, x, y) for (int i = (x); i >= (y); i--) 
#define ri readint
#define rl readlong
 
#define int long long
#define eps 1e-9
const int maxn = 2e5 + 30;
long long n, k;
long long a[maxn];
long long check(int mid) {
	long long tmp = 0;
	for (int i = 1; i <= n; i++) {
		tmp += (long long)(a[i] + mid - 1) / mid - 1;
	}
	return (tmp <= k);
}
signed main() {
	cin >> n; cin >> k;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	int l = 1, r = (int)1e9 + 5;
	int ans = 0;
	while (l <= r) {
		int mid = (l + r) / 2;
		if (check(mid)) ans = mid, r = mid - 1;
		else l = mid + 1;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 5168
/*
凑行数
*/
#include <bits/stdc++.h>
using namespace std;
const int N=111,M=3*N;
int dp[N][N][M],a[N],b[N];

int main()
{
    int n,W;
    cin>>n>>W;
    int i,j;
    for(i=0;i<n;i++)
    {
        cin>>a[i]>>b[i];
    }
    for(i=0;i<n;i++)
    {
        for(j=0;j<=i;j++)
        {
            for(int h=0;h<=3*j;h++)
            {
                dp[i+1][j][h]=max(dp[i+1][j][h],dp[i][j][h]);
                dp[i+1][j+1][h+a[i]-a[0]]=max(dp[i+1][j+1][h+a[i]-a[0]],dp[i][j][h]+b[i]);
            }
        }
    }
    int ans=0;
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=3*i;j++)
        {
            long long curW=(long long)a[0]*i+j;
            if(curW<=W)
            {
                ans=max(ans,dp[n][i][j]);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main()
{
  int n;
  cin >> n;
  int cnt = 0;
  for (int i = 1; i <= n; i++)
  {
    string s = to_string(i);
    if (s.size() % 2 == 1)
    {
    	cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int N; cin >> N;
    
    string ans = "APPROVED";
    for(int i = 0; i < N; i++) {
        int a; cin >> a;
        if(a % 2 == 0) {
            if(a % 3 != 0 && a % 5 != 0) {
                ans = "DENIED"; break;
            }
        }
    }
    cout << ans << endl;
}

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

int main() {
    int k;cin>>k;
    int ans=0;
    for(int a=1;a<=k;a++)
        for(int b=1;b<=k;b++)
            for(int c=1;c<=k;c++)
                ans+=gcd(b,gcd(a,c));
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3600
import math
#import numpy as np
import queue
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)

def main():
    n,p = map(int,ipt().split())
    s = input()
    ans = 0

    if p == 2:
        for i in range(n):
            if int(s[i])%2 == 0:
                ans += i+1
        print(ans)
    elif p == 5:
        for i in range(n):
            if int(s[i])%5 == 0:
                ans += i+1
        print(ans)
    else:
        d = defaultdict(int)
        pi = 0
        nk = 10%p
        for i in s[::-1]:
            pi = (pi+int(i)*nk)%p
            d[pi] += 1
            nk = (nk*10)%p
        for i in d.values():
            ans += i*(i-1)//2
        ans += d[0]
        print(ans)
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;
#define reverse(s) reverse(s.begin(),s.end())

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;

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

	int ans = 0;
	for (int i = 0; i < N; i++) {
		int n;
		cin >> n;
		ans += n - 1;
	}

	cout << ans << endl;
}

Measured memory_bytes: 3632
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (N, M): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    };
    let S: Vec<char> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().chars().collect()
    };

    let mut res = vec![];
    let mut i = N;
    while i > 0 {
        if let Some(j) = (i.saturating_sub(M)..i).find(|&i| S[i] == '0') {
            res.push(i - j);
            i = j;
        } else {
            break;
        }
    }
    let ans = if i == 0 {
        res.iter()
            .rev()
            .map(|&x| x.to_string())
            .collect::<Vec<_>>()
            .join(" ")
    } else {
        "-1".to_string()
    };

    println!("{}", ans);
}


Measured memory_bytes: 10492
s = input()
count = 0
ans = 0
for i in range(len(s)):
    if 'A' == s[i] or 'C' == s[i] or 'G' == s[i] or 'T' == s[i]:
        count += 1
        ans = max(ans,count)
    else:
        ans = max(ans,count)
        count = 0
print(ans)


Measured memory_bytes: 2940
import Data.List

ans' n a0 [] = Nothing
ans' n a0 (a1:as) =
  if (a1 - a0) `mod` n == 0
  then Just [a0,a1]
  else ans' n a0 as

ans n [] = []
ans n (a0:as) =
  let a = ans' n a0 as
  in
    case a of
      Just x  -> x
      Nothing -> ans n as

main = do
  n <- getLine
  a <- getLine
  let n' = (read n) - 1 :: Int
      a' = sort $ map read $ words a :: [Int]
      o  = ans n' a'
  putStrLn $ unwords $ map show o



Measured memory_bytes: 4448
N, C = map(int, input().split())
channel_list = [[0 for _ in range(10**5+1)]for _ in range(C)]
count_list = [0 for _ in range(10**5+1)]
for i in range(N):
    s, t, c = map(int, input().split())
    channel_list[c-1][s-1] += 1
    channel_list[c-1][t] -= 1

for i in range(C):
    for t in range(1, 10**5+1):
        channel_list[i][t] += channel_list[i][t-1]
        if channel_list[i][t] >= 1:
            count_list[t] += 1

print(max(count_list))


Measured memory_bytes: 27440
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
// using namespace __gnu_pbds;
using namespace std;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
//     tree_order_statistics_node_update>;
 
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
typedef long long int ll;
typedef long double ld;
const ll N = 1e5+1;
// const ll m = 1e9 + 7;
// const ll inf= 1e14;
const ll mod =998244353;
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define pld pair<ld,ld>
ll powm(ll a, ll b) { a = a%mod;ll res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; }
bool a[N];
ll ct[N];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout); 
    #endif  
    int t = 1;
    // cin>>t;
    memset(a,0,sizeof(a));
    while(t--){
        ll n,m;cin>>n>>m;
        for(int i = 0;i<n;i++){
            ct[i] = 1;
        }
        a[0] = 1;
        for(int i = 0;i<m;i++){
            ll x,y;cin>>x>>y;x--;y--;
            if(a[x]){
                if(ct[x]>1){
                    a[y] = 1;
                }
                else{
                    a[y] = 1;
                    a[x] = 0;
                }
            }
            ct[x]--;
            ct[y]++;
        }
        ll ans = 0;
        for(int i = 0;i<n;i++){
            ans+=a[i];
        }
        cout<<ans<<'\n';
    }
}

Measured memory_bytes: 4480
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
string s;
int main() {
    cin>>s;
    for(int i=0;i<s.length();i+=2)cout<<s[i];
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

int main(){
  int n;
  cin>>n;
  vector<int> x(n),y(n),h(n);

  rep(i,n) cin>>x[i]>>y[i]>>h[i];

  rep(i,101) rep(j,101){
    int canh = -1;
    rep(k,n) if(h[k] != 0){
      canh = h[k] + abs(x[k]-i) + abs(y[k]-j);
    }
    bool ok = true;
    rep(k,n){
      ok &= (h[k] == max(canh - abs(x[k]-i) - abs(y[k]-j), 0));
    }
    if(ok){
      cout << i << " " << j << " " << canh << endl;
      return 0;
    }
  }

  assert(false);

   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
namespace io{
    const int l=1<<20;
    char buf[l],*s,*t,c;
    inline void gc(){
        if(s==t){
            t=(s=buf)+fread(buf,1,l,stdin);
            c=s==t?EOF:*s++;
        }else c=*s++;
    }
    template<class IT>inline void gi(IT &x){
        x=0;gc();while(c<'0'||c>'9')gc();
        while('0'<=c&&c<='9'){x=(x<<1)+(x<<3)+(c^48);gc();}
    }
    char buf0[20];int a;
    template<class IT>inline void pi(IT x){
        if(x<0){putchar('-');x=-x;}
        do buf0[++a]=x%10+48;while(x/=10);
        while(a)putchar(buf0[a--]);
        putchar('\n');
    }
};
using io::gi;
using io::pi;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,ll > pil;
typedef pair<ll ,int> pli;
typedef pair<ll ,ll > pll;
typedef vector<int> vi;
typedef vector<ll > vl;
#define pque priority_queue
#define rep(i,l,r) for(i=(l);i<=(r);++i)
#define per(i,l,r) for(i=(l);i>=(r);--i)
#define REP(i,l,r) for(i=(l);i< (r);++i)
#define PER(i,l,r) for(i=(l);i> (r);--i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fi first
#define se second
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
const int N=200005;

int main(){
    //freopen("a.in","r",stdin);
    //freopen("a.out","w",stdout);
    int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	printf("%d",min(c,a+b+1)+b);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int ans = 0;
		for (int i = 1; i <= N; i++) {
			if (i % 2 != 0) {
				int count = 0;
				for (int j = 1; j <= i; j++) {
					if (i % j == 0) {
						count++;
					}
				}
				if (count == 8) {
					ans++;
				}
			}
		}
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
 
  if (N / 111 % 10 == 0 && N % 111 < 10) {
    cout << "Yes" << endl;
  }
  // 上三桁が同じ数字で、111で割った
  
  else if(N % 1000 % 111 == 0){
    cout << "Yes" << endl; 
  }
 

  
   else {
    cout << "No" << endl;
  }
   
}

Measured memory_bytes: 256
s = gets.strip.split('').reverse.map {|c| c=='?' ? nil : c.to_i}
N=13
MOD = 10**9+7

dp = Array.new(13,0)
dp[0]=1
a9=(0..9).to_a
mul = 1
s.each do |num|
  ndp = Array.new(13,0)


  (num.nil? ? a9 : [num]).each do |candidate|
      bigger=mul*candidate

      N.times do |pre|
        ndp[(bigger + pre)%N] += dp[pre]
      end
    end
  dp=ndp.map {|e| e%MOD }
  mul = 10 * mul % N
end

p dp[5]%MOD


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

int N, K;
vector<int> u, v;
int a[1000010];

int main()
{
    int m = 0, s = 0;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        s += a[i];
        m = (m < a[i] ? a[i] : m);
    }
    cout << s - m / 2 << endl;
}

Measured memory_bytes: 256
n,m,k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
A = [0]
B = [0]
for i in range(n):
    A.append(A[i] + a[i])
for i in range(m):
    B.append(B[i] + b[i])
ans = 0
for i in range(n+1):
    if A[i] > k:
        break
    while B[m] > k-A[i]:
        m -= 1
    ans = max(ans,i+m)
print(ans)





Measured memory_bytes: 47704
N = int(input())
As = list(map(int, input().split()))

res = [0] * N
more = 0
for i in range(0, N):
    j = (i+1) % N
    more = int(As[i] - more)
    res[j] = more * 2

if more > 0:
    for i in range(N):
        j = (i+1) % N
        if i % 2:
            res[j] += more
        else:
            res[j] -= more

print(" ".join(map(str, res)))


Measured memory_bytes: 19376
import java.util.*;
public class Main{
	public static void main(String args[]){
		
		Scanner ob = new Scanner(System.in);
		int N = ob.nextInt();
		boolean C = true; 
		String R = "";
		
		while(C){
			N %= 10;
			C = false;
		}
		
		if((N == 2) || (N == 4) || (N == 5) || (N == 7) || (N ==9)){
			R += "hon";
		}
		else if((N == 0) || (N == 1) || (N == 6) || (N == 8)){
			R += "pon";
		}
		else if(N == 3){
			R += "bon";
		}
		System.out.println(R);
		//R = "";
		//C = true;
	}
}

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

using namespace std;

#define reset(x) memset(x, 0, sizeof(x));
#define recopy(a, b) memcpy(b, a, sizeof(a));
typedef unsigned long long ULL;
typedef long long LL;
const int mod = 1e9 + 7;
const int maxn = 3e5 + 10;
int a[maxn], b[maxn];

int main() {
    ios::sync_with_stdio(false);

    int H, W, M;
    cin >> H >> W >> M;
    pair<int, int> pa;
    map<pair<int, int>, int> ma;
    for (int i = 1; i <= M; i++) {
        int x, y;
        cin >> x >> y;
        a[x]++;
        b[y]++;
        ma[make_pair(x, y)] = true;
    }
    int max1 = 0, max2 = 0;
    for (int i = 1; i <= H; i++) max1 = max(a[i], max1);
    for (int i = 1; i <= M; i++) max2 = max(b[i], max2);
    vector<int> v1, v2;
    for (int i = 1; i <= H; i++) if (a[i] == max1) v1.push_back(i);
    for (int i = 1; i <= W; i++) if (b[i] == max2) v2.push_back(i);
    int flag = false;
    for (int & i : v1) {
        for (int & j : v2) {
            if (!ma[make_pair(i, j)]) {
                flag = true;
                break;
            }

        }
        if (flag) break;
    }
    int ans = max1 + max2;
    if (!flag) ans--;
    cout << ans << endl;

    return 0;
}


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

#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define pb  push_back

typedef vector<int> vi;
typedef vector<pair<int,int> > vii;
typedef long long ll;

const int N = 2e5 + 3;

int main() {

    char c[2];
    scanf("%s", &c);
    c[0]++;
    printf("%s\n", c);

    return 0;
}


Measured memory_bytes: 256
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars};
#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
	input! {
		a: usize,
		b: usize,
	}

	if a <= b {
		println!("{}", a);
	}
	else {
		println!("{}", a-1);
	}
}



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

int main(){
  int N, K;
  string S;
  cin >> N >> K >> S;
  for(int i = 0; i < N; i++){
    if(i == K - 1){
      char tmp = tolower(S[i]);
      cout << tmp;
    }else{
      cout << S[i];
    }
  }
  cout << endl;
}

Measured memory_bytes: 3528
#include <iostream>
using namespace std;
using ll = long long;

int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  
  ll aa = N/(A+B);
  ll bb = N%(A+B);

  cout << aa*A+min(A, bb) << endl;
  
  return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  int n,k;
  cin >> n >> k;

  VI x(n);

  REP(i,n)cin >> x[i];

  int ans = (1<<30);
  for(int l = 0; l + k -1 < n; l++){
    int r = l + k -1;
    ans = min(ans, abs(x[l]) + abs(x[r]-x[l]));
    ans = min(ans, abs(x[r]) + abs(x[l]-x[r]));
  }
  cout << ans << endl;

}



Measured memory_bytes: 640
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;


int main(){
  long ii,jj,kk;
  vector<int> a;

  int n;
  cin >> n;
  a.resize(n);

  for(ii=0;ii<n;ii++){
    cin >> a[ii];
  }
  int v;
  for(ii=0;ii<n;ii++){
    v = a[ii];
    jj = ii-1;
      
    while( jj >= 0 && a[jj] > v){
      a[jj+1] = a[jj];
      jj--;
    }
    a[jj+1] = v;

    for(jj=0;jj<n;jj++){
      cout << a[jj];
      if(jj != n-1){
        cout << " " ;
      }
    }
    cout << endl;
  }
  
  
  return 0;
}



Measured memory_bytes: 3088
import sys
from collections import deque
input = sys.stdin.buffer.readline

n,m = map(int,input().split())
edge = [[] for i in range(n)]

for i in range(m):
    a,b = map(int,input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)

res = [0]*(n-1)
used = [False]*n

tank = deque([0])
while tank:
    q = tank.popleft()
    if used[q]:
        continue
    used[q] = True

    for go in edge[q]:
        if go == 0 or res[go-1] != 0:
            continue
        res[go-1] = q+1
        tank.append(go)
print("Yes")
print(*res,sep='\n')
        


Measured memory_bytes: 92748
N, M = map(int, input().split())
A = list(map(int, input().split()))
 
vote = []
all = 0
 
for j in range(N):
    all += A[j]
 
for i in range(N):
    if A[i] >= all / (4 * M):
        vote.append(A[i])
 
if len(vote) >= M:
    print("Yes")
 
else:
    print("No")

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>

using namespace std;

typedef long long ll;

int N;
int A[200000 + 10], B[200000 + 10];
int cnt[200000 + 10];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		cnt[A[i]]++;
	}
	for (int i = 0; i < N; i++) {
		cin >> B[i];
		cnt[B[i]]++;
	}
	for (int i = 0; i <= 200000; i++) {
		if (cnt[i] > N) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	sort(B, B + N, greater<ll>());
	
	int samel = -1, samer = -1;//半開区間
	for (int i = 0; i < N; i++) {
		if (A[i] == B[i]) {
			if (samel == -1) {
				samel = i;
			}
		}
		else {
			if (samel != -1 && samer == -1) {
				samer = i;
			}
		}
	}
	if (samel != -1 && samer == -1)samer = N;

	int Al = -1, Ar = -1, Bl = -1, Br = -1;
	for (int i = 0; i < N; i++) {
		if (A[i] == A[samel]) {
			if (Al == -1)Al = i;
		}
		else {
			if (Al != -1 && Ar == -1)Ar = i;
		}
	}
	if (Al != -1 && Ar == -1)Ar = N;

	for (int i = 0; i < N; i++) {
		if (B[i] == B[samel]) {
			if (Bl == -1)Bl = i;
		}
		else {
			if (Bl != -1 && Br == -1)Br = i;
		}
	}
	if (Bl != -1 && Br == -1)Br = N;

	int tikanIdx = samel;
	for (int i = 0; i < min(Al, Bl) && tikanIdx < samer; i++, tikanIdx++) {
		swap(B[i], B[tikanIdx]);
	}
	for (int i = max(Ar, Br) + 1; i < N && tikanIdx < samer; i++, tikanIdx++) {
		swap(B[i], B[tikanIdx]);
	}
	for (int i = 0; i < N; i++) {
		cout << B[i];
		if (i != N - 1)cout << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 5896
#include <iostream>

using namespace std;

string s;

bool check(int l, int r)
{
    for (int i = l - 1; i < r; i++)
    {
        if (s[i] == '#' && s[i+1] == '#')
        {
            return false;
        }
    }

    return true;
}

int main()
{
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;

    cin >> s;

    if (!check(a, c) || !check(b, d))
    {
        cout << "No" << endl;
        return 0;
    }

    if (d > c)
    {
        cout << "Yes" << endl;
        return 0;
    }

    for (int i = b - 1; i < d; i++)
    {
        if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.')
        {
            cout << "Yes" << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 640
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int sum = sc.nextInt();
		for(int i = (int)Math.floor(sum / num); i >= 1; i --) {
			if(sum % i == 0) {
				System.out.println(i);
				break;
			}
		}
	}
}

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

int main(){
  
  int a, b, count;
  cin >> a >> b;
  
  for(int i = a; i <= b; i++){
    int k = i, d1, d2, d4, d5;
    
    d1 = k % 10;
    k /= 10;
    d2 = k % 10;
    k /= 100;
    d4 = k % 10;
    k /= 10;
    d5 = k % 10;
    
    if(d1==d5 && d2==d4) count++;
  }
  cout << count << endl;
}

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

bool IsMonth(int n) {
    return (n >= 1) && (n <= 12);
}

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

    int fh, sh;
    fh = 10 * -('0'-S[0]) - ('0'-S[1]);
    sh = 10 * -('0'-S[2]) - ('0'-S[3]);
    
    if (IsMonth(fh) && IsMonth(sh)) {
        std::cout << "AMBIGUOUS\n";
    }
    else if (IsMonth(fh)) {
        std::cout << "MMYY\n";
    }
    else if (IsMonth(sh)) {
        std::cout << "YYMM\n";
    }
    else {
        std::cout << "NA\n";
    }

    return 0;
}

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

int si[200];
int dp_k[1000000];
int dp[1000000];

void mk(){
  for(int i=0;i<200;i++){
    si[i]=(i*(i+1)*(i+2))/6;
    if(si[i]>1000000){break;}
    dp[si[i]]=1;
    if(si[i]%2==1)
      dp_k[si[i]]=1;
  }
}

int main()
{
  int x,y;
  for(int i=0;i<200;i++)si[i]=1000000;
  for(int i=0;i<1000000;i++){dp[i]=100000;dp_k[i]=100000;}
  mk();
  
  
  dp[0]=0;
  dp_k[0]=0;
  for(int i=1;i<1000000;i++){
    for(int j=1;j<200;j++){
      if((i+si[j])<1000000){
	dp[i+si[j]]=min(dp[i+si[j]],dp[i]+1);
	if(si[j]%2==1)
	  dp_k[i+si[j]]=min(dp_k[i+si[j]],dp_k[i]+1);
      }
    }
  }
    


  for(;;){
    cin >> x;
    if(x==0)return 0;
    cout << dp[x] <<" "<<dp_k[x]<<endl;
    
  }
}

Measured memory_bytes: 8972
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s
        .trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect();
}

fn main() {
    let abck: Vec<i64> = read_vec();

    let a = abck[0];
    let b = abck[1];
    let k = abck[3];

    if k <= a {
        println!("{}", k);
    } else if k <= a + b {
        println!("{}", a);
    } else {
        println!("{}", 2 * a + b - k);
    }
}


Measured memory_bytes: 2152
#include <bits/stdc++.h>
#define For(i, l, r) for(register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
using namespace std;

inline bool chkmin(int &a, int b) {return b < a ? a = b, 1 : 0;}
inline bool chkmax(int &a, int b) {return b > a ? a = b, 1 : 0;}

inline int read() {
    int x = 0, fh = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar() ) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar() ) x = (x << 1) + (x << 3) + (ch ^ 48);
    return x * fh;
}

const int N = 2e5 + 1e3;
int n, P[N], V[N], res[N];

int main () {

#ifdef zjp_shadow
	freopen ("B.in", "r", stdin);
	freopen ("B.out", "w", stdout);
#endif

	n = read(); For (i, 1, n) V[P[i] = read()] = i;

	int ans = 0;
	For (i, 1, n)
		chkmax(ans, res[i] = res[V[P[i] - 1]] + 1);
	printf ("%d\n", n - ans);
    return 0;
}


Measured memory_bytes: 2560
// AOJ 2642: Dinner
// 2017.10.12 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

long long a[500003];

char buf[30], *bp;
int getint()
{
	int n = 0;
	if (*bp == '-') {
		bp++;
		while (*bp >= '0') n = (n<<3) + (n<<1) + (*bp++ & 0xf);
		return -n;
	}
	while (*bp >= '0') n = (n<<3) + (n<<1) + (*bp++ & 0xf);
	return n;
}

int cmp(long long *a, long long *b)
{
	if (*a == *b) return 0;
	if (*a < *b) return -1;
	return 1;
}

int main()
{
	int n, q, c, i;
	long long p, s, ans;

	fgets(bp=buf, 30, stdin);
	n = getint(), bp++, p = getint(), bp++, q = getint();
    for (s = 0, i = 0; i < n; i++) {
		fgets(bp=buf, 10, stdin);
		c = getint();
        s += c, a[i] = p * (q - i) - c;
    }
	qsort(a, n, sizeof(long long), cmp);
	ans = s;
    for (i = 0; i < n; i++) {
		s += a[n-i-1] + p*(i << 1);
		if (s > ans) ans = s;
	}
    printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 9328
solver::(Int,Int,Int)->Int
solver (a,b,c) = if (a==b)&&(b==c)&&(c==a) then 1
                                           else if (a==b)||(b==c)||(c==a) then 2
                                                                          else 3

main::IO()
main =do
  dc<-getLine
  let a:b:c:[]= map read (words dc)::[Int]
  print (solver (a,b,c))


Measured memory_bytes: 508
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()

using namespace std;

int N;
int A[50];
int B[50];
int C[50];

signed main()
{
	cin >> N;
	REP(i, N) cin >> A[i];
	REP(i, N) cin >> B[i];
	REP(i, N - 1) cin >> C[i];
	REP(i, N) A[i]--;

	int ans = 0;
	int prev = -10;
	REP(i, N)
	{
		if (prev + 1 == A[i])
			ans += C[prev];
		ans += B[A[i]];
		prev = A[i];
	}

	cout << ans << endl;
}



Measured memory_bytes: 384
N, M = map(int, input().split())

ac = [0] *N
pena = [0] *N

for _ in range(M):
    P, S = map(str, input().split())
    P = int(P) - 1
    if ac[P]: continue
    if S == 'AC':
        ac[P] = 1
    else:
        pena[P] += 1

AC = 0
PENA = 0

for i in range(N):
    AC += ac[i]
    if ac[i]:
        PENA += pena[i]

print('{} {}'.format(AC, PENA))    


Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2;
const ll mod = 1000000007;
const int INF = 1e9;
const ll INFLONG = 1e18;

int main(){
  ll n,w;
  cin >> n >> w;
  vector<pair<ll,ll>> vec(n);
  rep(i,n){
    cin >> t1 >> t2; //price,weight
    vec[i] = make_pair(t1,t2);
  }
  vector<ll> price(w+1,0);
  rep(i,n){
    rep_rev(j,w-vec[i].second+1){
      chmax(price[vec[i].second+j],price[j] + vec[i].first);
    }
  }
  ll ans = 0;
  rep(i,w+1){
    //cout << price[i] << " ";
    chmax(ans,price[i]);
  }
  cout << ans << endl;
}


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

#define rep(x, y) for (int i = (x); i < (y); i++)

typedef long long ll;

using namespace std;

int graph[9][9];

int dfs(int now, int nodes, vector<bool> visited) {
    visited[now] = true;

    int count = 0;
    bool found = false;
    rep(1, nodes) {
        if (graph[now][i] && !visited[i]) {
            found = true;
            count += dfs(i, nodes, visited);
        }
    }

    if (!found) {
        return all_of(visited.begin(), visited.end(), [](bool v) { return v; }) ? 1 : 0;
    } else {
        return count;
    }
}

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

    int a, b;
    bzero(graph, sizeof(graph));
    rep(0, m) {
        cin >> a >> b;
        graph[a][b] = graph[b][a] = 1;
    }

    vector<bool> visited(n + 1, false);
    visited[0] = true;
    int ans = dfs(1, n + 1, visited);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256