akhauriyash/Code-Regression huggingface dataset:
H, N = map(int, input().split())

A, B = [0] * N, [0] * N

for i in range(N):
    A[i], B[i] = map(int, input().split())

dp = [10**9] * (H+1)
dp[0] = 0

for i in range(N):
    for j in range(H+1):
        nj = min(j+A[i], H)
        dp[nj] = min(dp[nj], dp[j]+B[i])
print(dp[H])

Measured memory_bytes: 41708
let mod_exp x n m =
  let rec aux acc x = function
      0 -> acc
    | n ->
      aux
        (match n land 1 with
         | 1 -> (acc * x) mod m
         | _ -> acc)
        ((x * x) mod m)
        (n asr 1)
  in
  aux 1 x n

let div_pow_2 n =
  let rec aux s d = match d mod 2 with
      0 -> aux (s+1) (d/2)
    | _ -> s,d
  in aux 0 n

let miller_rabin n a =
  let s,d = div_pow_2 (n-1) in
  let a_exp_d = mod_exp a d n in
  let double x = mod_exp x 2 n in
  let rec loop e = function
      0 -> false
    | i ->
      match e with
        r when r = n - 1 -> true
      | r -> loop (double e) (i-1)
  in
  a_exp_d = 1 || loop a_exp_d s

let miller_rabin_test n k =
  let rec loop = function
      0 -> true
    | i ->
      let a = Random.int (n-1) |> (+) 1 in
      match miller_rabin n a with
        true -> loop (i-1)
      | false -> false
  in loop k

let () =
  let n = read_int () in
  let rec loop c = function
      0 -> c
    | i ->
      let x = read_int () in
      loop (c+(match miller_rabin_test x 20 with true -> 1 | _ -> 0)) (i-1)
  in
  Printf.printf "%d\n" (loop 0 n)

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

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

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let a: Vec<_> = (0..n)
        .map(|i| {
            let x: usize = sc.cin();
            let y: usize = sc.cin();
            x == y
        })
        .collect();
    put!(if (0..n - 2).any(|i| a[i] && a[i + 1] && a[i + 2]) {
        "Yes"
    } else {
        "No"
    });
}

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

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


Measured memory_bytes: 2164
#include <bits/stdc++.h>
using namespace std;
int  main(){
        long long  n, w; cin>>n>>w;
        long long wt[10000],val[10000];
        for(int i=0;i<n;i++)cin>>wt[i]>>val[i];
        long long  dp[n+1][w+1];
        memset(dp, 0, sizeof(dp));
        for(int i=1; i<n+1; i++){
        	for(int j=0; j<w+1; j++){
                        dp[i][j]=dp[i-1][j];
        		if(j>=wt[i-1])dp[i][j]=max(dp[i-1][j], val[i-1]+dp[i-1][j-wt[i-1]]);
        		
        	}
        }
        cout<<dp[n][w]<<endl;     
}

Measured memory_bytes: 82512
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
using pii = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1 << 29;
const int N =  1e5 + 10;
 
struct IOsetup{
  IOsetup(){
   ios_base::sync_with_stdio(false);
   cin.tie(nullptr);
   cout.tie(nullptr);
   cout << fixed << setprecision(8);
  }
}IO;

int32_t main(){
 string s;
 cin >> s;
 for (int i = 0; i + 1 < (int)s.length(); i++){
  if (s[i] != s[i + 1]){
    cout << "Yes" << endl;
    return 0;
  }
 }
 cout << "No" << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll nxt[222222];
ll ans[222222];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,q;cin>>n>>q;
  vector<pair<ll,pair<ll,ll>>>pll;
  for(int i=0;i<n;i++){
    ll s,t,x;cin>>s>>t>>x;
    pll.pb(mp(x,mp(s,t)));
  }
  sort(ALL(pll));
  vi D(q);
  for(int i=0;i<222221;i++)
    nxt[i]=i+1;
  for(int i=0;i<q;i++){
    cin>>D[i];
    //  D[i]=-D[i];
  }
  //reverse(ALL(D));
  for(int i=0;i<n;i++){
    ll s,t,x;
    x=pll[i].F;
    s=pll[i].S.F;
    t=pll[i].S.S;
    auto lb=lower_bound(ALL(D),s-x);
    ll sta=(lb-D.begin());
    auto ub=lower_bound(ALL(D),t-x);
    ll en=(ub-D.begin());
    for(ll j=sta;j<en;){
      if(ans[j]){
	j=nxt[j];
      }else{
	ans[j]=x;
	nxt[j]=en;
	j++;
      }
    }
  }
  for(int i=0;i<q;i++){
    if(ans[i]==0)cout<<-1<<endl;
    else 
    cout<<ans[i]<<endl;
  }
  return 0;
}


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

int main() {
  long long A, B, K;
  cin >> A >> B >> K;
  long long a = max(0LL, A - K);
  long long k = K - (A - a);
  long long b = max(0LL, B - k);
  cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  string S;
  cin>>S;
  int N=S.size();
  int count=0;
  int K=N/2;
  bool flag=1;
  int ans=0;
  rep(i,0,N){
    if(flag){
      if(S[i]=='g'){
        count++;
        if(count==N-K)
          flag=0;
      }
    }
    else{
      if(S[i]=='g')
        ans++;
    }
  }
  cout<<ans<<endl;
  }



Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
#define ii pair<int, int>
#define N 100012
#define vi vector<int>
#define vii vector<ii>
#define vll vector<ll>
#define pb push_back
#define fs first
#define sc second
#define sz(x) ((int)((x).size()))
#define oo 1000000123
#define mod 1000000007

using namespace std;

int n, a, b;

int main(){
    ios_base::sync_with_stdio(0);
    cin >> n >> a >> b;
    for(int i = 1; i <= 1000; ++i){
        if(a <= i * n && i * n <= b){
            cout << "OK\n";
            return 0;
        }
    }
    cout << "NG\n";
    return 0;
}


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

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

// typedef
typedef long long llint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double pi = 3.14159265358979323846;

// conversion
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
//

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

  llint h, w;
  cin >> h >> w;
  if (h == 1 || w == 1) {
    cout << 1 << endl;
  } else {
    cout << ((w + 1) / 2) * ((h + 1) / 2) + (w / 2) * (h / 2) << endl;
  }

  return 0;
}

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

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

  string ans;
  if (c % 2 == 0) {
    ans = "Alice";
  } else {
    ans = "Borys";
  }

  cout << ans << endl;
}


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

int main()
{
    int n, m;
    cin >> n >> m;
    ll h[n + 1];
    rep(i, 1, n + 1) cin >> h[i];
    vector<set<pair<int, int>>> g(n + 1);
    rep(i, 0, m)
    {
        int a, b;
        cin >> a >> b;

        g[a].insert({h[b], b});
        g[b].insert({h[a], a});
    }
    int ans = 0;
    rep(i, 1, n + 1)
    {
        if (g[i].empty())
            ans++;
        else
        {
            set<pair<int, int>>::iterator it = g[i].end();
            it--;
            if (h[i] > it->first)
                ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9+7;
const ll INF = 1LL << 60;


int main() {
    int a,b; cin >> a >> b;
    cout << a * b - (a + b - 1) << endl;

    return 0;
}


Measured memory_bytes: 3580
use std::cmp;
use std::fmt::Debug;
use std::str::FromStr;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where
    T: FromStr,
    <T as FromStr>::Err: Debug,
{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim()
        .split_whitespace()
        .map(|c| T::from_str(c).unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_as_string() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let n: usize = read_as_vec()[0];
    let (mut left, mut right) = (0, n);
    println!("0");
    let s = read_as_string();
    let m_origin: bool;
    match s.as_str() {
        "Vacant" => return,
        "Male" => m_origin = true,
        "Female" => m_origin = false,
        _ => unreachable!(),
    }
    while left + 1 < right {
        let mid = (left + right) / 2;
        println!("{}", mid);
        let s = read_as_string();
        let mid_is_male: bool;
        match s.as_str() {
            "Vacant" => return,
            "Male" => mid_is_male = true,
            "Female" => mid_is_male = false,
            _ => unreachable!(),
        }

        if (mid % 2 == 0 && mid_is_male == m_origin) || (mid % 2 != 0 && mid_is_male != m_origin) {
            left = mid + 1;
        } else {
            right = mid;
        }
    }
    println!("{}", left);
}


Measured memory_bytes: 4948
N = int(input())
nums = [int(e) for e in input().split()]
nums.sort()
t=1
ans = 1
t = 10**9
t+=7
i=1
k=0
if(N%2)==1:
    if(nums.count(0) == 1):
        while(i<N):
            if nums[i] == nums[i+1]:
                i+=2
                ans = (ans *2)%t
                continue
            else:
                print('0')
                break
        else:
            print(ans)
    else:
        print('0')
else:
    while(k<N):
        if nums[k] == nums[k+1]:
            k += 2
            ans = (ans * 2)%t
            continue
        else:
            print('0')
            break
    else:
        print(ans)

Measured memory_bytes: 52332
// マップやその他の非常に複雑なタプルは使用しないでください。そして、文字列
// で遊ぶとき、それを整数配列に変換します。それは不思議です。パニックになら
// ないでください。それに慣れているときは常に競争をしてください。評価が下がっ
// たときに強調しないでください、それは起こります。だから、冷静ですが重要なコード:)
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define PI 3.14159265358979323
#define foi(i,n) for(lld i = 0; i < n; i+=1)
#define fod(i,n) for(lld i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main ()
{
      FastIO
      lld n;
      cin >> n;
      lld c = 0;
      while(c < n){
      	c+=1000;
      }
      cout << c-n;
      return 0;
}

Measured memory_bytes: 3616
#include<stdio.h>
#include<string.h>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
 
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
 
int main()
{
    long long int a,b,c;
    scanf("%lld %lld %lld",&a,&b,&c);
    long long int ans=b;
    if(c>=a+b+1)ans+=a+b+1;
    else ans+=c;
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N, H = map(int,input().split())
a = []
b = []
for i in range(N) :
    p, q = map(int,input().split())
    a.append(p)
    b.append(q)

a.sort(reverse = True)
b.sort(reverse = True)

ans = 0
for t in b :
    if t > a[0] :
        H -= t
        ans += 1
        if H <= 0 :
            print(ans)
            exit()

ans += (H+a[0]-1)//a[0]

print(ans)


Measured memory_bytes: 11300
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        int n = Integer.parseInt(reader.readLine());
        int[] numbers = new int[10];
        for (int i = 0; i < n; i++) {
            String[] values = reader.readLine().split(" ");
            for (int j = 0; j < 10; j++) {
                numbers[j] = Integer.parseInt(values[j]);
            }
            int small = 0;
            int large = numbers[0];
            String result = "YES";
            for (int j = 1; j < 10; j++) {
                int number = numbers[j];
                if (number < small) {
                    result = "NO";
                    break;
                }
                if (number < large) {
                    small = number;
                } else {
                    large = number;
                }
            }
            out.println(result);
        }
    }
}

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

int main() {
	int n;
	scanf("%d", &n);
	int arr[2][3] = {};
	for(int i = 0; i < 3; i++) {
		scanf("%d", &arr[0][i]);
	}
	for(int i = 1; i < n; i++) {
		int cur[5];
		for(int j = 0; j < 3; j++) {
			scanf("%d", &cur[j]);
		}
		for(int j = 0; j < 3; j++) {
			for(int k = 0; k < 3; k++) {
				if(j != k) {
					arr[1][j] = max(arr[1][j], arr[0][k]);
					arr[1][j] = max(arr[1][j], arr[0][k]);
				}
			}
			arr[1][j] += cur[j];
		}
//		printf(":: ");
//		for(int k = 0; k < 3; k++) {
//			printf("%d ", arr[1][k]);
//		}
//		printf("\n");
		for(int j = 0; j < 3; j++) {
			arr[0][j] = arr[1][j];
			arr[1][j] = 0;
		}
	}
	
	int maxx = 0;
	for(int j = 0; j < 3; j++) {
		maxx = max(maxx, arr[0][j]);
	}
	printf("%d\n", maxx);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    #define ll long long int
    #define pb push_back
    #define mk make_pair
    #define ft first
    #define sc second
    #define ppb pop_back
    #define sz size
    #define forn(i,a,n) for(i=a;i<n;i++)
    #define M 1000000007
    #define inf 2e18
    
    int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll a,b;
    cin>>a>>b;
    if(a>9||b>9)cout<<"-1\n";
    else
        cout<<a*b<<"\n";

    return 0;
    } 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long

using namespace std;

const int N = 1e5;

int readInt ()
{
    bool minus = false;
    int result = 0;
    char ch;
    ch = getchar();
    while (true)
    {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus = true;
    else result = ch-'0';
    while (true)
    {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus)
        return -result;
    else
        return result;
}
main() {
    int n = readInt(), k = readInt();
    if (k == 1) {
        puts("0");
        return 0;
    }
    cout << n - k;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <stack>
#include <queue>

using namespace std;

typedef vector<vector<int>> Graph;

stack<int> dfs(Graph &g, int s, int t)
{ 
  vector<bool> flag(g.size(), false);
  stack<int> st;
  flag[s] = true;
  st.push(s);
  while(!st.empty())
  {
    int current = st.top();
    if(current == t)
    {
      return st;
    }else{
      bool nv = false;
      for(int i = 0; i < g[current].size(); i++)
      {
        int next = g[current][i];
        if(!flag[next])
        {
          nv = true;
          flag[next] = true;
          st.push(next);
          break;
        }
      }
      if(!nv)
      {
        st.pop();
      }
    }
  }
  return st;
}

void draw_non_path(Graph &g, vector<int> &draw, vector<int> mem, int s, int color)
{
  vector<bool> flag(g.size(), false);
  queue<int> q;
  flag[s] = true;
  q.push(s);
  while(!q.empty())
  {
    int current = q.front();
    q.pop();
    for(int i = 0; i < g[current].size(); i++)
    {
      int next = g[current][i];
      if(mem[next] != 0) continue;
      if(flag[next]) continue;
      flag[next] = true;
      q.push(next);
      draw[next] = color;
    }
  }
}

void draw_in_path(Graph &g, vector<int> &draw, int s, int color)
{
  vector<bool> flag(g.size(), false);
  queue<int> q;
  flag[s] = true;
  q.push(s);
  while(!q.empty())
  {
    int current = q.front();
    q.pop();
    for(int i = 0; i < g[current].size(); i++){
      int next = g[current][i];
      if(flag[next]) continue;
      if(draw[next] != color && draw[next] != 0) continue;
      flag[next] = true;
      draw[next] = color;
      q.push(next);
    }
  }
}

int main()
{
  int n;
  cin >> n;
  Graph tree(n);
  for(int i = 0; i < n - 1; i++)
  {
    int a, b;
    cin >> a >> b;
    tree[a - 1].push_back(b - 1);
    tree[b - 1].push_back(a - 1);
  }
  stack<int> result = dfs(tree, 0, n - 1);
  //パス内の点を登録し色塗り
  vector<int> draw(n, 0);
  vector<int> path;
  draw[0] = 1;  //黒
  draw[n - 1] = -1; //白
  int count = 0;
  vector<int> in_path(n, 0);
  while(!result.empty())
  {
    int temp = result.top();
    result.pop();
    in_path[temp] = 1;
    path.push_back(temp);
    count++;
  }
  reverse(path.begin(), path.end());
  for(int i = 0; i < path.size(); i++)
  {
    if(i < ceil(path.size() * 0.5))
    {
      draw[path[i]] = 1;
    }else{
      draw[path[i]] = -1;
    }
  } 
  //パス外の点を塗る
  draw_non_path(tree, draw, in_path, 0, 1);
  draw_non_path(tree, draw, in_path, n - 1, -1);
  //パス内の点を塗る
  draw_in_path(tree, draw, 0, 1);
  draw_in_path(tree, draw, n - 1, -1);
  /*for(auto e : draw)
  {
    cout << e << endl;
  }*/
  //判定
  int count_b = 0;
  int count_w = 0;
  for(int i = 0; i < n; i++)
  {
    if(draw[i] == 1)
    {
      count_b++;
    }else{
      count_w++;
    }
  }
  if(count_b > count_w)
  {
    cout << "Fennec" << endl;
  }else{
    cout << "Snuke" << endl;
  }
	return 0;
}


Measured memory_bytes: 7680
#include <stdio.h>

int main(){

  int n,m,A[100],count=0,taihi,i,j,k;
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    for(i=0;i<n;i++){
      scanf("%d",&m);
      A[i]=m;
    }
    for(k=n;k>0;k--){
      for(j=0;j<n-1;j++){
	if(A[j]>A[j+1]){
	  taihi=A[j];
	  A[j]=A[j+1];
	  A[j+1]=taihi;
	  count += 1;
	}
      }
    }  
    printf("%d\n",count);
    count=0;
  }
  return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String aString = sc.next();
        String bString = sc.next();
        String cString = sc.next();
        System.out.println("A" + bString.substring(0, 1) + "C");
    }

}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll ,P> P3;
typedef pair<P ,P> PP;
const ll MOD = ll(1e9+7);
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int n, p[105], dp[2][105][500*60];

void solve(){
    REP(i,2)REP(j,n+1) fill(dp[i][j],dp[i][j]+500*60,IINF);
    dp[0][0][0] = 0;
    for(int i=0;i<n;i++){
        for(int j=0;j<=i;j++){
            for(int k=0;k<=500*55;k++){
                if(dp[i%2][j][k]==IINF)continue;

                int chg = (1000-p[i]%1000)%1000;
                if(chg < 500){
                    dp[(i+1)%2][j][k+chg] = min(dp[(i+1)%2][j][k+chg],dp[i%2][j][k]+p[i]);
                    if(500-chg <= k){
                        dp[(i+1)%2][j+1][k+chg-500] = min(dp[(i+1)%2][j+1][k+chg-500],dp[i%2][j][k]+p[i]);
                    }
                }
                else{
                    dp[(i+1)%2][j+1][min(k+chg-500,500*55)] = min(dp[(i+1)%2][j+1][min(k+chg-500,500*55)],dp[i%2][j][k]+p[i]);
                }
                dp[(i+1)%2][j][k] = min(dp[(i+1)%2][j][k],dp[i%2][j][k]);
            }
        }
    }
    int ma = 0, ans = 0;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=500*55;j++){
            if(dp[n%2][i][j] < IINF){
                if(i > ma){
                    ma = i;
                    ans = dp[n%2][i][j];
                }
                else if (i==ma){
                    ans = min(ans, dp[n%2][i][j]);
                }
            }
        }
    }
    cout << ma << " " << ans << endl;
}

int main() {
    while(cin >> n, n){
        REP(i,n){
            cin >> p[i];
        }
        solve();
    }
    return 0;
}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define abs(a) max((a),-(a))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repe(i,n) rep(i,(n)+1)
#define per(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define pere(i,n) rep(i,(n)+1)
#define all(x) (x).begin(),(x).end()
#define SP <<" "<<
#define RET return 0
#define MOD 1000000007
#define INF 1000000000000000000

typedef long long LL;
typedef long double LD;

int main(){
  string s;
  cin >> s;
  int n=s.length();
  LL ans=0,count=0;
  for(int i=0;i<n;i++){
    if(s[i]=='B') count++;
    else ans+=count;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
# AGC003B - Simplified mahjong
import sys
input = sys.stdin.readline

def main():
    # split in subsequences when 0 appears -> sum up cur // 2
    N = int(input())
    A = list(map(int, [input() for _ in range(N)])) + [0]
    ans, cur = 0, 0
    for i in A:
        if i:
            cur += i
        else:
            ans += cur // 2
            cur = 0
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define long long long 
#define PI 3.141592653589793238

#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

typedef trie<string,null_type,trie_string_access_traits<>,pat_trie_tag,trie_prefix_search_node_update> pref_trie;
typedef tree<long int,null_type,less<long int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef cc_hash_table<long int,long int, hash<long int>, equal_to<long int>, direct_mask_range_hashing<long int>, 
hash_standard_resize_policy<hash_exponential_size_policy<>, hash_load_check_resize_trigger<true>, true>> ht;
typedef gp_hash_table<long int,long int> HashTable;

int main(){
   IOS;
 /*    #ifndef ONLINE_JUDGE
         freopen("in.txt",  "r",  stdin);
         freopen("out.txt", "w", stdout);
     #endif */
   
   long int n,d;
   cin>>n>>d;

   d = d*d;
   long int ans = 0;

   while(n--){
        long int dis = 0;
        for(long int i = 0; i < 2; i++){
            long int x;
            cin>>x;
            dis += x*x;
        }
        if(dis <= d)
            ans++;
   }

   cout<<ans;

   return 0;
}

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

int main() {
ll n,k,q,c=0;
cin>>n>>k>>q;
map<ll,ll>m;
for(int i=0;i<q;i++)
  {
    int x;
    cin>>x;
    m[x]++;
  }
  if(k>q)
  { //cout<<"if"<<endl;
    for(int i=0;i<n;i++)
    {
      cout<<"Yes"<<endl;
    }
  }
  else
  {
    ll req=k-q;
    //cout<<"req "<<req<<endl;
    for(int i=1;i<=n;i++)
    {
         if(req+m[i]>0)
         {
           cout<<"Yes"<<endl;
         }
         else
         {
           cout<<"No"<<endl;
         }
    }
    
  }
}

Measured memory_bytes: 6784
using System;

namespace ABC047_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var sss = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var w = sss[0];
            var h = sss[1];
            var n = sss[2];
            var ho = new int[h, w];
            for (var i = 0; i < n; i++)
            {
                var paint = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                var x = paint[0] ; var y = paint[1] ; var a = paint[2] ;
                if (a == 1)
                {
                    for (var j = 0; j < h; j++)
                    {
                        for (var k = 0; k < x; k++)
                        {
                            ho[j, k] = 1;
                        }
                    }
                }
                else if (a == 2)
                {
                    for (var j = 0; j < h; j++)
                    {
                        for (var k = x; k < w; k++)
                        {
                            ho[j, k] = 1;
                        }
                    }
                }
                else if (a == 3)
                {
                    for (var j = 0; j < y; j++)
                    {
                        for (var k = 0; k < w; k++)
                        {
                            ho[j, k] = 1;
                        }
                    }
                }
                else
                {
                    for (var j = y; j < h; j++)
                    {
                        for (var k = 0; k < w; k++)
                        {
                            ho[j, k] = 1;
                        }
                    }
                }
            }
            var ans = 0;
            for (var i = 0; i < h; i++)
            {
                for (var j = 0; j < w; j++)
                {
                    if (ho[i, j] == 0)
                    {
                        ans++;
                    }
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
S = input()
a = int(S[:2])
b = int(S[2:])
if a >= 1 and a <= 12 and b >= 1 and b <= 12:
    print('AMBIGUOUS')

elif a >= 1 and a <= 12:
    print('MMYY')

elif b>= 1 and b <= 12:
    print('YYMM')

else:
    print('NA')

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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) for(int i = 0 ; i < n ; ++i)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(), (x).end())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

struct edge{
    int from, to;
    lint dist, enemy;
};

struct node{
    int id;
    lint cost, enemy;

    bool operator<(const node &right) const {
        return enemy > right.enemy;
    }
};

int main(){
    int n, m, l;
    while(cin >> n >> m >> l, n){
        vector< vector<edge> > g(n);
        rep(i, m){
            int a, b;
            lint d, e;
            cin >> a >> b >> d >> e;
            --a;
            --b;
            g[a].push_back({a, b, d, e});
            g[b].push_back({b, a, d, e});
        }
        vector< vector<lint> > v(n);
        rep(i, n){
            v[i].resize(l + 1, LLINF);
        }
        priority_queue<node> que;
        que.push({0, 0, 0});
        while(!que.empty()){
            node now = que.top();
            que.pop();
            if(v[now.id][l - now.cost] <= now.enemy){
                continue;
            }
            v[now.id][l - now.cost] = now.enemy;
            for(auto x : g[now.id]){
                if(now.cost + x.dist <= l && v[x.to][l - now.cost - x.dist] > now.enemy){
                    que.push({x.to, now.cost + x.dist, now.enemy});
                }
                if(v[x.to][l - now.cost] > now.enemy + x.enemy){
                    que.push({x.to, now.cost, now.enemy + x.enemy});
                }
            }
        }
        lint ans = LLINF;
        rep(j, l + 1){
            ans = min(ans, v[n - 1][j]);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 12308
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
  int n;
  cin>>n;
  string s[n];
  int ans=0;
  for(int i=0;i<n;i++){
    cin>>s[i];
  }
  for(int i=0;i<n-1;i++){
    if(s[i][s[i].size()-1]!=s[i+1][0]){
      ans++;
    }
    for(int j=0;j<i;j++){
      if(s[i]==s[j]){
        ans++;
      }
    }
    if(s[i]==s[n-1]){
      ans++;
    }
  }
  if(ans==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
<?php
$tmp = [];
$file = fopen("./stdin.txt", "r");
if ($file) {
    while ($line = fgets($file)) {
        $tmp[] = trim($line);
    }
}
fclose($file);

$tmp = [];
while ($line = fgets(STDIN)) {
    $tmp[] = trim($line);
}


// 全ての間に+入れておく
$list = str_split(wordwrap($tmp[0], 1, '+', true));

$n = 3;

for ($bit = 0; $bit < (1 << $n); $bit++) {
    $thisList = $list;
    for ($i = 0; $i < $n; $i++) {
        if ($bit & (1 << $i)) {
            $minus = 2 * $i + 1;
            $thisList[$minus] = '-';
        }
    }

    $result = $thisList[0];
    for ($l = 2; $l <= 6; $l = $l + 2) {
        if ($thisList[$l - 1] === '+') {
            $result += $thisList[$l];
        } else {
            $result -= $thisList[$l];
        }
    }

    if ($result === 7) {
        echo implode('', $thisList) . '=7';
        break;
    }
}



Measured memory_bytes: 4732
using System;
namespace atcoder
{
    public class SomeSums
    {
        public static void Main(string[] args)
        {
            string[] arr = Console.ReadLine().Split(' ');
            int n = Int32.Parse(arr[0]);
            int a = Int32.Parse(arr[1]);
            int b = Int32.Parse(arr[2]);
 
            int sum = 0;
 
            for (int i = a;i<=n ;i++)
            {
                string s = i.ToString();
                int t=0;
                foreach (char c in s)
                {
                    t += Int32.Parse(c.ToString());
                }
                if (a<=t && t<=b)
                {
                    sum += i;
                }
                t = 0;
            }
            Console.WriteLine(sum);
        }
    }
}

Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		
		int total = 0;
		if(a>b) {
			total+=a;
			if(a-1>b)total+=a-1;
			else total+=b;
		}
		else{
			total+=b;
			if(b-1>a)total+=b-1;
			else total+=a;
		}
		
		System.out.println(total);
	}		
}

Measured memory_bytes: 21844
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    static long ans = 0;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            int temp = Integer.parseInt(sc.next());
            a[i] = temp;
        }
        Map<Integer, Integer> map = new HashMap<>();
        long ans = 0;
        for (int i = 0; i < n; i++) {
            map.merge(i + a[i], 1, Integer::sum);
            if (map.containsKey(i - a[i])) {
                ans += map.get(i - a[i]);
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 67064
#include<algorithm>
#include<vector>
#include<cstring>
#include<iostream>
#include<cmath>

using namespace std;

int mod;

void dfs(int in, int pi, vector<int> adj[], long long dp[]) {
	dp[in] = 1;
	for(auto node: adj[in]) {
		if(node == pi)
			continue;
		dfs(node, in, adj, dp);
		dp[in] = dp[in] * (1+dp[node]) % mod;
	}
}



void dfs2(int in, int pi, vector<int> adj[], long long dp[], long long dp2[]) {
	vector<long long> pref(adj[in].size());
	vector<long long> suff(adj[in].size());
	long long running_prod = 1;
	for(int j=0; j<adj[in].size(); j++) {
		int node = adj[in][j];
		if(node == pi) {
			pref[j] = running_prod;
			continue;
		}
		running_prod = running_prod * (1+dp[node]) % mod;
		pref[j] = running_prod;
	}
	running_prod = 1;
	for(int j=(int)adj[in].size()-1; j>=0; j--) {
		int node = adj[in][j];
		if(node == pi) {
			suff[j] = running_prod;
			continue;
		}
		running_prod = running_prod * (1+dp[node]) % mod;
		suff[j] = running_prod;
	}
	for(int j=0; j<adj[in].size(); j++) {
		int node = adj[in][j];
		if(node == pi)
			continue;
		dp2[node] = dp2[in];
		dp2[node] = dp2[node] * (j-1>=0 ? pref[j-1] : 1) % mod;
		dp2[node] = dp2[node] * (j+1<adj[in].size() ? suff[j+1] : 1) % mod;
		dp2[node] = 1+dp2[node];
		dfs2(node, in, adj, dp, dp2);
	}
}

int main() {
	int n;
	scanf("%d%d", &n, &mod);

	vector<int> adj[n];
	for(int i=0; i<n-1; i++) {
		int x, y;
		scanf("%d%d", &x, &y);

		x--;
		y--;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}

	long long dp[n], dp2[n];
	dfs(0, -1, adj, dp);
	dp2[0] = 1;
	dfs2(0, -1, adj, dp, dp2);
	for(int i=0; i<n; i++) {
		printf("%lld\n", dp[i]*dp2[i]%mod);
	}
    return 0;
}

Measured memory_bytes: 20608
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define OP ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
typedef long long ll;
typedef std::vector<int> vi;
typedef std::pair<int, int> pii;
const int inf = int(1e9);
const int mod = inf + 7;
const double PI = acos(-1.0);
using namespace std;
const int N = 1e5 + 155;
template<typename T>
inline void read(T&x){
    x=0;int f=1;char ch = getchar();
    while(ch<'0' ||ch>'9'){ if(ch=='-')f=-1;ch=getchar(); }
    while(ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); }
    x*=f;
}

void solve(){
    ll x, y;
    cin >> x >> y;
    ll ans = 0;
    while(x <= y) {
        ans++;
        x *= 2;
    }
    cout << ans;
}
 
int main(){
    OP
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF = 2e9
#define LINF = 1e18
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << "=" << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO")
#define Yes(n) cout << ((n) ? "Yes" : "No")
#define PI 3.141592653589793

int main(){
    char c[2][3];
    rep(i,2){
        rep(j,3)cin >> c[i][j];
    }

    YES(c[0][0] == c[1][2] && c[0][1] == c[1][1] && c[0][2] == c[1][0]) << endl;

}

Measured memory_bytes: 3536
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pllll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
ll dp[10][10];
int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n;
  cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  fi(1, n + 1) {
    // printf("%d: %d, %d\n", i, to_string(i)[0] - '0', i % 10);
    dp[to_string(i)[0] - '0'][i % 10]++;
  }
  fi(0, 10)
    fj(0, 10) {
      ans += dp[i][j] * dp[j][i];
    }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999;
	public static void Main(string[] args)
	{
		var p = Input().ToInt();
		var n = p[0];
		var m = p[1];
		
		var key = new long[n];
		var val = new int[n];
		
		for(int i = 0; i < n; i++)
		{
			var q = Input();
			key[i] = q[0].ToLong();
			val[i] = q[1].ToInt();
		}
		Array.Sort(key, val);
		long wa = 0;
		for(int i = 0; i < n; i++)
		{
			if(val[i] >= m)
			{
				wa += m * key[i];
				break;
			}
			else
			{
				wa += key[i] * val[i];
				m -= val[i];
			}
		}
		Console.WriteLine(wa);
		
	}
	
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	 }
}


Measured memory_bytes: 16332
#include<bits/stdc++.h>
#define INF 1e9+5
using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> H(n);
    for(int i=0; i<n; ++i) cin>>H[i];
    vector<int> dp(n,INF);
    dp[0]=0;
    for(int i=0;i<n; ++i){
        for(int x:{1,2}){
            if(i+x<n){
                dp[i+x]=min(dp[i+x],dp[i]+abs(H[i]-H[i+x]));
            }
        }
    }
    cout<<dp[n-1]<<"\n";
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 1; i < n; i++) cin >> a[i];

    sort(a.begin(), a.end());

    vector<int> x(n, 0);
    for(int i = 1; i < n; i++){
        x[a[i] - 1]++;
    }

    for(int i = 0; i < n; i++) cout << x[i] << endl;
    return 0;
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    string s;
    cin >> s;
    
    bool ok = true;
    if (s[0] != 'A') ok = false;
    int numc = 0;
    REP(i, 1, s.length()) {
        if (i >= 2 && i < s.length() - 1) {
            if (s[i] == 'C') numc++;
            continue;
        }
        if (isupper(s[i])) {
            ok = false;
            break;
        }
    }

    if (numc == 1 && ok) cout << "AC" << endl;
    else cout << "WA" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=2e5;
const int inf=1e9;
int main(){
	int N,K;cin>>N>>K;
	long a; long acm[N+1]; acm[0] = 0;
	rep(i,0,N){ cin>>a; acm[i+1] = acm[i] + a; }
    vector<long> vec[2];
    rep(j,0,N+1)rep(k,0,j) vec[0].push_back(acm[j] - acm[k]);
	long ans = 0;
	for(int i = 50; i >= 0; i--){
		long t;bool flag;
		int cnt = 0;
		for(long t:vec[0]){
            flag = true;
			if(flag && (t & (1ll<<i))){ cnt++; vec[1].push_back(t); }
		}
        if(cnt >= K){
            ans |= (1ll<<i);
            vec[0].clear();
            for(long x:vec[1]) vec[0].push_back(x);
        }vec[1].clear();
	}cout<<ans<<endl;
}

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

int main() {
  ll h, w;
  cin >> h >> w;

  if (h == 1 || w == 1) {
    cout << 1 << endl;
    return 0;
  }

  ll n = h * w;
  ll ans = (n + 1) / 2;
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
b, c = map(int, input().split())
type_short = {11:1,4:1,6:1,9:1}
if(c==b and c==2):
  print("Yes")
elif(((b in type_short) ^ ( c in type_short)) or b == 2 or c == 2):
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll n, k, z = 0; cin >> n >> k;
  z = (n + 1) * (n + 1) * (n + 2) / 2 - (n + 1) * (n + 2) * (2 * n + 3) / 6 + (n + 1);
  z -= ((n + 1) * k * (k - 1) / 2 - (k - 1) * k * (2 * k - 1) / 6 + (k - 1)); 
  z %= 1000000007;
  cout << z << endl;
}

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

#define endl '\n'
#define db(x) cerr << #x << " == " << x << endl
#define dbs(x) cerr << x << endl
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3f

typedef long long ll;
typedef pair <int, int> pii;
typedef vector<int> vi;
const ll MOD = 1e9+7;
const int N = (1<<21)+5;

//1<<21 is 2097152, 1e6...
ll dp[25][N];
int m[25][25], n;

int bit(int p){ 
  int ans=n+1;
  for(int i=0; (1<<i)<=p; i++){
    if(((1<<i)&p)==0) continue;
    if(ans<=n) return n+1;
    ans=i;
  }
  return ans;
}

ll conta(int i, int p){
  if(i==1) return m[1][bit(p)];
  if(~dp[i][p]) return dp[i][p];

  ll ans=0;
  for(int j=0; j<n; j++){
    if(((1<<j)&p) == 0 || m[i][j]==0) continue;
    ans=(ans + conta(i-1, p-(1<<j)))%MOD;
  }
  return dp[i][p]=ans;
}

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  memset(dp, -1, sizeof(dp));
  cin >> n;
  for(int i=1; i<=n; i++)
    for(int j=0; j<n; j++)
      cin >> m[i][j];

  cout << conta(n, (1<<n)-1) << endl;
}

Measured memory_bytes: 409856
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
ll Q=1000000007;
const double PI=3.14159265358979323846;

int main(){
  cout << fixed << setprecision(10);
  double A,B,X,ans;
  cin >> A >> B >> X;
  if(2*X<=A*A*B){
    ans = atan2(A*B*B,2*X);
  }else{
    ans = atan2(2*(A*A*B-X),A*A*A);
  }
  ans = ans/PI*180;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define N 100

void insertionSort(int[] ,int );
void trace(int [] ,int);

int main(){
  int n,i;
  int a[N];
  scanf("%d",&n);
  for(i=0;i<n;i++) {
    scanf("%d",&a[i]);
  }
  trace(a,n);
  insertionSort(a,n);
  return 0;
}

void insertionSort(int a[],int n){
int v;
int i,j;
  for(i=1;i<n;i++){
  v = a[i];
  j = i - 1;
  while(j >= 0 && a[j] > v){
    a[j+1] = a[j];
    j--;
  }
  a[j + 1] = v;
  trace(a,n);
  }
}

void trace(int a[],int n){
  int i;
  for(i=0;i<n;i++){
    if(i>0) printf(" ");
    printf("%d",a[i]);
  }
  printf("\n");
}



Measured memory_bytes: 2064
#include <iostream>
using namespace std;
int main()
{
    int a , b;
    cin >> a >> b;
    if (a > b)
    {
        for (int i = 0 ; i < a ; i++)
            cout << b;
    }
    else
    {
        for (int i = 0 ; i < b ; i++)
            cout << a;
    }
    return 0;
}


Measured memory_bytes: 256