akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int gcd( int x, int y ){ return y ? gcd(y, x%y) : x; }
signed main() {
int x=0,y=0,z=0,w=0,n=0,m=0;
std::cin >> x>>y;
std::cout << x-y+1 << '\n';
}


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N, 0);
  
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
    vec.at(i)--;
  }

  int now = 0, count = 0;
  while(true) {
    if (now == 1) {
      cout << count << endl;
      break;
    }
    if (count >= N) {
      cout << "-1" << endl;
      break;
    }
    count++;
    now = vec.at(now);
  }
}


Measured memory_bytes: 640
A=input()
ans=0
a=A.count("a")
b=A.count("b")
c=A.count("c")
d=A.count("d")
e=A.count("e")
f=A.count("f")
g=A.count("g")
h=A.count("h")
i=A.count("i")
j=A.count("j")
k=A.count("k")
l=A.count("l")
m=A.count("m")
n=A.count("n")
o=A.count("o")
p=A.count("p")
q=A.count("q")
r=A.count("r")
s=A.count("s")
t=A.count("t")
u=A.count("u")
v=A.count("v")
w=A.count("w")
x=A.count("x")
y=A.count("y")
z=A.count("z")
B=[a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z]
for aa in range(26):
  ans=ans+B[aa]*(len(A)-B[aa])
print(ans//2+1)

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main{

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int ans = 3;

		if(a == b){
			ans--;
		}
		if(a == c){
			ans--;
		}
		if(b == c){
			ans--;
		}
		if(a == b && b == c && a == c){
			ans = 1;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 9684
#include<bits/stdc++.h>
using namespace std;
int main()
{
   char c;
   cin>>c;
   if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u')
   {
       cout<<"vowel"<<endl;
   }
   else
   {
       cout<<"consonant"<<endl;
   }
}


Measured memory_bytes: 3552
use std::io::*;
use std::str::FromStr;
use utils::*;

pub fn main() {
    let i = stdin();
    let mut o = Vec::new();
    run(i.lock(), &mut o);
    stdout().write_all(&o).unwrap();
}

fn run<R: BufRead, W: Write>(i: R, o: &mut W) {
    let mut i = CpReader::new(i);
    let n = i.read::<usize>();
    let mut p = Vec::new();
    for _ in 0..n {
        p.push(i.read::<usize>());
    }
    let r: usize = p.iter().sum();
    let r = r - p.iter().max().unwrap() / 2;

    writeln!(o, "{}", r).unwrap();
}

mod utils {
    use super::*;

    pub struct CpReader<R: BufRead> {
        r: R,
        s: String,
    }

    macro_rules! fn_read {
        { $f:ident($($t:ident),*) } => {
            #[allow(dead_code)]
            pub fn $f<$($t: FromStr),*>(&mut self) -> ($($t),*) {
                let i = &mut self.read_line().split(' ');
                ($(read_next::<$t,_>(i)),*)
            }
        };
    }

    impl<R: BufRead> CpReader<R> {
        pub fn new(r: R) -> Self {
            CpReader {
                r: r,
                s: String::new(),
            }
        }
        pub fn read_line(&mut self) -> &str {
            self.s.clear();
            self.r.read_line(&mut self.s).unwrap();
            self.s.trim()
        }

        pub fn read<T: FromStr>(&mut self) -> T {
            self.read_line().parse().ok().unwrap()
        }
        fn_read! { read2(T1, T2) }
        fn_read! { read3(T1, T2, T3) }
        fn_read! { read4(T1, T2, T3, T4) }
        fn_read! { read5(T1, T2, T3, T4, T5) }
    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }

}


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

int a[500009];
string s;

int rec(int i) {
  if (a[i] != -1) return a[i];

  if (i == 0) {
    if (s[i] == '<') return a[i] = 0;
    else return a[i] = rec(i+1) + 1;
  }

  if (i == s.size()) {
    if (s[i-1] == '>') return a[i] = 0;
    else return a[i] = a[i-1] + 1;
  }

  if (s[i-1] == '>' && s[i] == '<') return a[i] = 0;
  if (s[i-1] == '<' && s[i] == '<') return a[i] = a[i-1] + 1;
  if (s[i-1] == '>' && s[i] == '>') return a[i] = rec(i+1) + 1;
  if (s[i-1] == '<' && s[i] == '>') return a[i] = max(a[i-1] + 1, rec(i+1) + 1);
  return 0;
}

int main() {
  cin >> s;
  int n = s.size() + 1;
  rep(i, n) a[i] = -1;
  rep(i, n) rec(i);
  ll ans = 0;
  rep(i, n) ans += a[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 21348
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	int ans = 0;
	for(int i = 0; i < n; i++){
		int l, r;
		cin >> l >> r;
		ans += 1 + (r-l);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 1000001
#define null -1

struct Node{
  int parent;
  int l;
  int r;
};

struct Node S[N];
int count=0;

int depth(int nodeid){
  if(S[nodeid].parent == null)
    return count;

  else{
    count++;
    return depth(S[nodeid].parent);
  }
}

void degree(int nodeid){
  if(nodeid != null){
    if(count != 0){
      printf(", ");
    }
    printf("%d", nodeid);
    count++;
    degree(S[nodeid].r);
  }
}

int main(void){
  int i, j, n, m, new, child, r, l;
  
  scanf("%d", &n);
  
  for(i=0; i<n; i++){
    S[i].parent = S[i].l = S[i].r = null;
  }
  
  for(i=0; i<n; i++){
    scanf("%d%d", &new, &m);
    for(j=0; j<m; j++){
      scanf("%d",&child);
      S[child].parent=new;
      if(j != 0){
	S[l].r=child;
      }
      else{
	S[new].l=child;
      }
      l=child;
    }
  }
  for(i=0; i<n; i++){
    count=0;
    printf("node %d: parent = %d, depth = %d, ", i, S[i].parent, depth(i));
    if(S[i].parent == null){
      printf("root, [");
      }
    else if(S[i].l == null){
      printf("leaf, [");
    }
    else {
      printf("internal node, [");
    }
    count=0;
    degree(S[i].l);
    printf("]\n");
  }
  return 0;
}

Measured memory_bytes: 1784
/* A Counting Sort */

#include<stdio.h>

int n; /* 1<=n<=2000000 */

void CountingSort(short int A[], short int B[], int k);

int main(){
  int i, k=0;

  scanf("%d",&n);
  short int A[n+1]; /* 0<=A[i]<=10000 */
  short int B[n+1];

  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
    if(k<A[i])k=A[i];

  }

  CountingSort(A,B,k);
  
  for(i=1;i<n;i++){
    printf("%d ",B[i]);
  }
  printf("%d\n",B[i]);

  return 0;
}


void CountingSort(short int A[], short int B[], int k){
  int C[k+1];
  int i, j;

  for(i=0;i<=k;i++){
    C[i]=0;
  }
  for(j=1;j<=n;j++){
    C[A[j]]=C[A[j]]+1;
    /* C[i] now contains the number of elements equal to i. */
  }
  for(i=1;i<=k;i++){
    C[i]=C[i]+C[i-1];
    /* C[i] now contains the number of elements less than or equal to i. */
  }
  for(j=n;j>=1;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]=C[A[j]]-1;
  }
}

Measured memory_bytes: 8256
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;

int main() {
  int N, M, C;
  cin >> N >> M >> C;
  
  vector<int> B(M);
  for (int i = 0; i < M; i++) {
    cin >> B[i];
  }
  
  int count = 0;
  for (int i = 0; i < N; i++) {
    vector<int> A(M);
    for (int j = 0; j < M; j++) {
      cin >> A[j];
    }
    int sum = 0;
    for (int j = 0; j < M; j++) {
      sum += B[j] * A[j];
    }
    sum += C;
    if (sum > 0) {
      count++;
    }
  }
  
  cout << count << endl;

  return 0;
}

Measured memory_bytes: 256
A, B, K = [int(x) for x in input().split()]

while True:
    if A % 2 == 1:
        A -= 1
    t = A // 2
    A, B = A - t, B + t

    K -= 1
    if K <= 0:
        break

    if B % 2 == 1:
        B -= 1
    t = B // 2
    A, B = A + t, B - t

    K -= 1
    if K <= 0:
        break

print('{} {}'. format(A, B))


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


int main(){
	int N, M, C;
	cin >> N >> M >> C;
	vector<int> B(M);
	rep(i,M) cin >> B[i];
	int ans = 0;
	rep(i,N){
		int tmp = 0;
		rep(j,M){
			int a;cin >> a;
			tmp += a * B[j];
		}
		if(tmp + C > 0) ans++;
	}
	cout << ans << endl;
}













Measured memory_bytes: 3608
extern crate core;

use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
    ($line:expr, $name:ident, $t:tt) => {
        let $name = value!($line, $t);
    };
}

macro_rules! values_def {
    ($lines:expr, $n:expr, $name:ident, $t:tt) => {
        let $name = {
            let mut vec = Vec::new();
            for i in 0..$n {
                let mut next = $lines.next().unwrap().split_whitespace();
                vec.push(value!(next, $t));
            }
            vec
        };
    };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input => (s: #));

    s.chars()
        .map(|c| (c as u32 - '0' as u32) as i64)
        .rev()
        .scan((0, 1), |(cur, digit10), x| {
            *cur = (*cur + x * *digit10) % 2019;
            *digit10 = (*digit10 * 10) % 2019;
            Some(*cur)
        })
        .fold(
            {
                let mut v = Vec::with_capacity(2019);
                v.resize(2019, 0);
                v[0] = 1;
                v
            },
            |mut acc, x| {
                acc[x as usize] += 1;
                acc
            },
        )
        .into_iter()
        .filter(|&x| x != 0)
        .map(|x| x * (x - 1) / 2)
        .sum::<i64>()
        .to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}
tests! {
    test1: "1817181712114\n" => "3\n",
    test2: "14282668646\n" => "2\n",
    test3: "2119\n" => "0\n",
}


Measured memory_bytes: 2480
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;


#include "boost/multiprecision/cpp_int.hpp"
#include "boost/multiprecision/cpp_dec_float.hpp"
namespace mp = boost::multiprecision;
typedef mp::cpp_int LL;
typedef mp::number<mp::cpp_dec_float<1024>> DD;// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)

 
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define rrep(i,r,l) for(ll i=r;i>=l;i--)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
template<class T,class S>
inline bool chmax(T &a, S b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
template<class T,class S>
inline bool chmin(T &a, S b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

void mod_print(ll k){
    ll P=1000;
    rep(y,1,P){
        ll x=mod(y*k);
        if(x+P>=i_7){
            x-=i_7;
        }
        if(abs(x)<=P){
            cout<<x<<"/"<<y<<endl;
            return;
        }
    }
    cout<<"nun"<<endl;
}
#define all(c) c.begin(),c.end()
//////////////////////////

int main(){fastio
    
    ll x[6];rep(i,1,5)cin>>x[i];
    rep(i,1,5){
        if(x[i]!=i){
            cout<<i<<endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3632
from collections import Counter
n = int(input())
a = list(map(int,input().split()))
a_counter = Counter(a)
a_counter_li = list(a_counter)
if sum(a) == 0:
    print("Yes")
elif len(a)%3 != 0:
    print("No")
elif len(a_counter) > 3 or len(a_counter) <= 1:
    print("No")
elif len(a_counter) == 3:
    if a_counter[a_counter_li[0]] == n // 3 and a_counter[a_counter_li[1]] == n // 3 and a_counter[a_counter_li[2]] == n // 3:
        if a_counter_li[0]^a_counter_li[1]^a_counter_li[2] == 0:
            print("Yes")
        else:
            print('No')
    else:
        print("No")
else:
    a_counter_li.sort()
    if a_counter_li[0] == 0 and a_counter[a_counter_li[0]] == n // 3:
        print("Yes")
    else:
        print("No")

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

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

  
 
    while(A[i] > A[i+1]){
      A[i+1]++;
      sum++;
    
   
    }
    
  }
  
 
  cout << sum << endl;

 
}


Measured memory_bytes: 4040
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int dp[101][11][1001];
signed main() {
	dp[0][0][0] = 1;
	dp[0][1][0] = 1;
	for1(i, 100) {
		for0(j, 11) {
			for0(k, 1001) {
				if (j >= 1 && k - i >= 0)dp[i][j][k] = dp[i - 1][j][k] + dp[i - 1][j - 1][k - i];
				else dp[i][j][k] = dp[i - 1][j][k];
			}
		}
	}
	int a, b; while (cin >> a >> b, a)cout << dp[100][a][b] << endl;
}


Measured memory_bytes: 11696
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const double pi=acos(-1.0);
ll mod=1000000007;

bool cmp(pii a,pii b){
	return a.second>b.second;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	vector<pii> b(100001);
	vector<pii> c(100001);
	rep(i,100001){
		b.at(i).first=i;
		c.at(i).first=i;
	}
	for(int i=0;i<n;i+=2){
		b.at(a.at(i)).second++;
	}
	sort(b.begin(),b.end(),cmp);
	for(int i=1;i<n;i+=2){
		c.at(a.at(i)).second++;
	}
	sort(c.begin(),c.end(),cmp);
	if(n==2){
		if(a.at(0)==a.at(1)) cout << 1 << endl;
		else cout << 0 << endl;
	}
	else if(b.at(0).first==c.at(0).first){
		if(b.at(0).second==c.at(0).second){
			if(b.at(1).second>=c.at(1).second) cout << n-b.at(1).second-c.at(0).second << endl;
			else cout << n-b.at(0).second-c.at(1).second << endl;
		}
		else if(b.at(0).second>c.at(0).second) cout << n-b.at(0).second-c.at(1).second << endl;
		else cout << n-b.at(1).second-c.at(0).second << endl;
	}
	else{
		cout << n-b.at(0).second-c.at(0).second << endl;
	}
}

Measured memory_bytes: 2176
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

typedef unsigned long long UL;
typedef long long LL;
typedef long double LD;
#define LP(i, a, b) for (int i = int(a); i < int(b); i++)
#define LPE(i, a, b) for (int i = int(a); i <= int(b); i++)
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<vector<PII> > WAL;
typedef vector<vector<int> > SAL;
#define Ep 1e-8
#define INF 1e9
#define LINF 1e18

int K;
int const MaxSize = 1e5 + 10;

LL A[MaxSize];

/*
 only consecutive distinct # matters
 */

LL findMin(LL lb, LL d) {
	LL f = lb / d;

	if (lb % d)
		f++;

	return f * d;
}

LL findMax(LL ub, LL d) {
	LL f = ub / d;

	return f * d + d - (LL) 1;
}

int main() {

	ios_base::sync_with_stdio(false);
//	freopen("/Users/george/A_1.in", "r", stdin);

	cin >> K;

	LP(i, 0, K)
	{
		cin >> A[i];
	}

	LL minV = 2;
	LL maxV = 2;

	for (int i = K - 1; i >= 0; i--) {

		LL newMinV = findMin(minV, A[i]);
		LL newMaxV = findMax(maxV, A[i]);

		//cout << newMinV << " " << newMaxV << endl;

		if (newMinV < 0 || newMaxV < 0 || newMinV > newMaxV) {
			cout << -1 << endl;
			return 0;
		}

		minV = newMinV;
		maxV = newMaxV;
	}

	cout << minV << " " << maxV << endl;

	return 0;
}



Measured memory_bytes: 1024
n = gets.to_i
arr = []
5.times{arr << gets.to_i}
arr2 = [n, 0, 0, 0, 0, 0]
a, b = n, 0
5.times{|i|
    b = [a, arr[i]].min
    a = b
}
puts (n.to_f / b).ceil + 4

Measured memory_bytes: 1788
n,m,k = gets.chomp.split.map(&:to_i)
a = gets.chomp.split.map(&:to_i)
b = gets.chomp.split.map(&:to_i)

a_sum = [a.first]

1.upto(n-1) do |i|
  a_sum[i] = a_sum[i-1]+a[i]
end

b_sum = [b.first]

1.upto(m-1) do |i|
  b_sum[i] = b_sum[i-1]+b[i]
end

ans = 0
0.upto(n) do |i|
  if i == 0
    sum = 0
  else
    sum = a_sum[i-1]
  end
  next if sum > k

  nokori = k-sum

  b_max = b_sum.bsearch_index{|x| x > nokori} || m

  ans = [ans, i + b_max].max
end
p ans


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

namespace ConsoleApp8
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            Console.WriteLine(input[1]*Math.Pow(input[1]-1,input[0]-1));

        }
    }
}


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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
  int paSize = printArray.size();
  for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
  if (between != '\n') {cerr << endl;}
}

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

int N, P;
map<int, int> mp;

void bunkai(int num) {
  int i = 2;
  while (i*i <= num) {
    while (num % i == 0) {
      num /= i;
      mp[i]++;
    }
    i++;
  }
  if (num > 1) {
    mp[num]++;
  }
}

int f(int a, int b) {
   int ans = 1;
   while (b > 0) {
      if (b&1) {
         ans *= a;
      }
      a *= a;
      b /= 2;
   }
   return ans;
}

signed main() {
  cin >> N >> P;

  bunkai(P);
  int ans = 1;

   for (auto x : mp) {
    //  dbg2(x.first, x.second)
     if (x.second >= N) {
       int t = x.first;
       int mult = max(1LL, x.second / N);
      //  dbg2(t, mult)
      //  ans *= t * mult;
       ans *= f(t, mult);
     }
   }

   cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

typedef int64_t  ll;
typedef uint64_t ull;

#define rep(i,n)   for (int i = 0; i < (n); i++)
#define rrep(i,n)  for (int i = (n)-1; i >= 0; i--)
#define rep1(i,n)  for (int i = 1; i <= (n); i++)
#define rrep1(i,n) for (int i = (n); i > 0; i--)

int bricks[200000];
int n, ans;
int main(void) {
    cin >> n;
    rep(i,n) {
        cin >> bricks[i];
    }
    int j = 0;
    rep1(i,n) {
        while (j < n && bricks[j] != i) {
            ans++;
            j++;
        }
        if (j >= n) break;
        j++;
    }
    if (ans == n) ans = -1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>

#define rep(j, n) for (int i = j; i < n; i++)
#define repd(j, n) for (int i = j; i > n; i--)

using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

string maxx(string x, string y) {
	if (x.size() > y.size()) {
		return x;
	}
	if (x.size() < y.size()) {
		return y;
	}
	return max(x, y);
}

int main() {
	int n, m;
	cin >> n >> m;
	string dp[10010];
	vector<int> a(m);
	int cost[10] = { 0,2,5,5,4,5,6,3,7,6 };
	rep(0, m) {
		int s;
		cin >> s;
		a[i] = s;
		string ss = to_string(s);
		dp[cost[s]] = max(dp[cost[s]],ss);
	}
	rep(1, n + 1) {
		for (int j = 0; j < m; j++) {
			if (i >= cost[a[j]] && dp[i - cost[a[j]]] != "") {
				string k = to_string(a[j]);
				dp[i] = maxx(dp[i], dp[i - cost[a[j]]] + k);
			}
		}
	}
	cout << dp[n] << endl;
	return 0;
}


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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

//IO accelerate
//--------------------------------------------
struct InitIO {
    InitIO() {
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(30);
    }
} init_io;

//template
//--------------------------------------------
template<typename T>
istream& operator >>(istream& is, vector<T>& vec) {
  for(T& x: vec) is >> x;
  return is;
}
template<typename T>
ostream& operator <<(ostream& os, const vector<T>& vec) {
  for(int i=0; i<vec.size(); i++){
    os << vec[i] << ( i+1 == vec.size() ? "" : "\t" );
  }
  return os;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<vector<T>>& vv) {
	for (int i = 0; i < vv.size(); ++i) {
		s << vv[i] << endl;
	}
	return s;
}
template<typename T>
ostream& operator <<(ostream& s, const vector<pair<T, T>>& vp) {
	for (int i = 0; i < vp.size(); ++i) {
		s << "(" << vp[i].first << "," << vp[i].second << ")" << ( i+1 == vp.size() ? "" : ",\t" );
	}
	return s;
}

// 多重vector
// auto dp=make_v<int>(4,h,w) みたいに使える
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

// 多重vectorのためのfill
// fill_v(dp,0) みたいに使える
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

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

//main code

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		char c = s[i];
		int b = c - 'A';
		b = (b + n) % 26;
		cout << (char)(b+'A');
	}
	cout << endl;
	return 0;
}


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

int main() {
   int V,E,r;
   cin >> V >> E >> r;
   vector<vector<pair<long long,long long>>> G(V);
   for (int i=0; i<E; i++) {
       long long s,t,d;
       cin >> s >> t >> d;
       G[s].push_back({t,d});
   }
   priority_queue<pair<long long,long long>,vector<pair<long long,long long>>,greater<pair<long long,long long>>> q;
   q.push({0,r});
   vector<long long> c;
   c.assign(V,-1);
   while(!q.empty()) {
       pair<long,long> a=q.top();
       q.pop();
       if (c[a.second]==-1) c[a.second]=a.first;
       //cout << a.first << " " << a.second << endl;
       for (auto b:G[a.second]) {
           if (c[b.first]==-1) {
               q.push({a.first+b.second,b.first});
           }
           //cout << b.first << " " << b.second << endl;
       }
   }
   for (int i=0; i<V; i++) {
       if (c[i]==-1) cout << "INF" << endl;
       else cout << c[i] << endl;
   }
}


Measured memory_bytes: 21420
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using pii = pair<int, int>;
const int MOD = (int)1e9 + 7, INF = (1 << 27); const ll INFLL = (1LL << 55);
#define FOR(i,a,b) for(int (i)=(a);(i)<(int)(b);(i)++)
#define rep(i,n) FOR(i,0,n)
template<typename T, typename U> inline void chmax(T &x, U y) { if (x < y) x = y; }
template<typename T, typename U> inline void chmin(T &x, U y) { if (x > y) x = y; }


int main() {
	int n; cin >> n;
	vector<int> a(n);
	for (int &i : a) cin >> i;
	sort(a.begin(), a.end());
	ll ln = 0;
	rep(i, n - 1) ln += a[i];
	puts(ln > a[n - 1] ? "Yes" : "No");
}

Measured memory_bytes: 256
N = int(input())

A = [0] + [a for a in map(int, input().split())]

for i in range(N):
    A[i+1] += A[i]
A.sort()
temp = A[0]
cnt = 0
ans = 0
for a in A:
    if temp == a:
        cnt += 1
    else:
        ans += cnt *(cnt-1) // 2
        cnt = 1
        temp = a
ans += cnt * (cnt-1) // 2

print(int(ans))


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

int main(){
 	int n;
	cin >> n;
  	int a,count=0,tmp,k;
	for(int i = 0; i < n;i++) {
      	cin >> a;
      	if(i == 0) {
          	tmp = a; k=1;
          	continue;
        }
      	if(a == tmp) {
          	k++;
        } else {
          	count += k/2;
          	tmp = a;
          	k = 1;
        }
    }
    count += k/2;
  	cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define f first
#define s second

signed main()
{
    int n;
    cin>>n;
    int k=n%10;
    if(k==2 || k==4 || k==5 || k==7 || k==9)
        cout<<"hon"<<endl;
    else if(k==3)
        cout<<"bon"<<endl;
    else
        cout<<"pon"<<endl;
}


Measured memory_bytes: 3636
<?php

/*while($line = fgets(STDIN)){
	$n = intval($line);
	//$cnt = ($n + 1)*($n*$n + 5*$n + 6)/6;
	
	$cnt = 0;
	for($a = 0; $a <= $n && $a <= 1000; $a++){
		$da = $n - $a;
		//$cnt += ($da + 1)*($da + 2)/2;
		
		for($b = 0; $b <= $da && $b <= 1000; $b++){
			$db = $da - $b;
			for($c = 0; $c <= $db && $c <= 1000; $c++){
				$d = $db - $c;
				if($d <= 1000){
					$cnt++;
				}
			}
		}
	}
	
	echo $cnt."\n";
}*/


// $n = $a ?????¨???????????£????????\
$x = array_fill(0, 1001, 1);


// $n = $a + $b ?????¨???????????£????????\
$y = array_fill(0, 2001, 0);
for($i = 0; $i <= 1000; $i++){
	for($j = 0; $j <= 1000; $j++){
		$y[$i + $j] += $x[$i];
	}
}
$x = $y;	// $x ????????????


// $n = $a + $b + $c ?????¨???????????£????????\
$y = array_fill(0, 3001, 0);
for($i = 0; $i <= 1000; $i++){
	for($j = 0; $j <= 2000; $j++){
		$y[$i + $j] += $x[$j];
	}
}
$x = $y;	// $x ????????????


// $n = $a + $b + $c + $d ?????¨???????????£????????\
$y = array_fill(0, 4001, 0);
for($i = 0; $i <= 1000; $i++){
	for($j = 0; $j <= 3000; $j++){
		$y[$i + $j] += $x[$j];
	}
}


while($line = fgets(STDIN)){
	$n = intval($line);
	echo $y[$n]."\n";
}

Measured memory_bytes: 16236
import java.util.*;
import java.io.*;
import java.lang.*;
public class Main{

public static void main(String[] args) throws FileNotFoundException, IOException{
        Scanner s = new Scanner(System.in);
        StringBuilder sb=new StringBuilder();
       int n=s.nextInt(),m=s.nextInt();
       int[] in_edge=new int[n+1];
       Map<Integer,Set<Integer>> map=new HashMap<>();
       Map<Integer,Set<Integer>> map2=new HashMap<>();
       for(int i=0;i<m;i++){
        int x=s.nextInt(),y=s.nextInt();
        in_edge[y]++;
        if(map.get(x)!=null){map.get(x).add(y);}
        else{
          map.put(x,new HashSet<Integer>());
          map.get(x).add(y);
        }

        if(map2.get(y)!=null){map2.get(y).add(x);}
        else{
          map2.put(y,new HashSet<Integer>());
          map2.get(y).add(x);
        }
       }
       PriorityQueue<Integer> min_heap=new PriorityQueue<>(new Comparator<Integer>(){
        @Override
        public int compare(Integer i, Integer j){
          return i-j;
        }
       });
       for(int i=1;i<=n;i++){
        if(in_edge[i]==0){min_heap.add(i);}
       }
       //boolean[] b=new boolean[n+1];
       List<Integer>ts=new ArrayList<>();
       while(!min_heap.isEmpty()){
        int curr=min_heap.poll();
       // b[curr]=true;
       // sb.append(curr+" ");
        ts.add(curr);
        if(map.get(curr)!=null){
          for(int xx:map.get(curr)){
              in_edge[xx]--;
              if(in_edge[xx]==0){min_heap.add(xx);}
          }
        }
       }
       //System.out.println(ts);
       Map<Integer,Integer>indx=new HashMap<>();
       for(int i=0;i<n;i++){indx.put(ts.get(i),i);}
       int[] dp=new int[n];
       int res=0;
       Set<Integer>ss=new HashSet<>();
       ss.add(ts.get(0));
       for(int j=1;j<n;j++){
        int i=ts.get(j);
           if(map2.get(i)!=null){
            for(int zz:map2.get(i)){
                if(ss.contains(zz)){
                    dp[j]=Math.max(dp[j],dp[indx.get(zz)]+1);
                }
            }
           }
       res=Math.max(res,dp[j]);
       ss.add(i);
       }
       System.out.println(res);
        }
    }


Measured memory_bytes: 154068
// finish date: 2018/02/18

#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000
#define pii pair<int,int>


int main() {
    int N;
    cin>>N;
    vi a(N);
    rep(i,N) cin>>a[i];
    int pa=0,pb=0;
    sort(a.begin(),a.end(),greater<int>());
    rep(i,N){
        if((i+1)%2==1) pa+=a[i];
        else pb+=a[i];
    }
    cout<<pa-pb<<endl;

    return 0;
}




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

int main() {
    int N,ct;
    ct = 0;
    cin >> N;
    int arr[N];

    for(int i = 0; i < N; i++) cin>>arr[i];
    while (true) {
        bool flag = false;
        for (int i = 0; i < N; i++) {
            if (arr[i] % 2 != 0) flag = true;
        }
        if (flag) break;

        for (int i = 0; i < N; i++) arr[i] /= 2;
        ct++;
    }
    cout << ct << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
using namespace std;
typedef long long int ll;

ll a, b, c, d, e, s;
ll N, H, K, W;
ll A[10000010];
unordered_set<ll> SS;

void input()
{
    cin >> s;
}

int f(int n)
{
    if (n % 2 == 0)
    {
        return n / 2;
    }
    else
    {
        return n * 3 + 1;
    }
}
void solve()
{
    SS.insert(s);
    A[1] = s;
    for (int i = 2; i <= 1000000; i++)
    {
        ll a_i = f(A[i - 1]);
        if (SS.count(a_i) == 1)
        {
            cout << i << endl;
            break;
        }
        else
        {
            A[i] = a_i;
            SS.insert(a_i);
        }
    }
}

int main()
{
    input();
    solve();
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const double PI = acos(-1);

vvi WF;
void floyd(int n) {
	REP(k, n)REP(i, n) {
		if (WF[i][k] == INF) continue;
		REP(j, n) {
			if (WF[k][j] == INF) continue;
			WF[i][j] = min(WF[i][j], WF[i][k] + WF[k][j]);
		}
	}
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int V, E;
	cin >> V >> E;
	int R;
	cin >> R;
	vi VR(R);
	REP(i, R) {
		cin >> VR[i];
		VR[i]--;
	}
	WF = vvi(V, vi(V, INF));
	REP(i, E) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		WF[a][b] = c;
		WF[b][a] = c;
	}
	floyd(V);
	vi P(R);
	REP(i, R)P[i] = i;
	int ans = INF;
	do {
		int now = 0;
		REP(i, R-1) {
			now += WF[VR[P[i]]][VR[P[i + 1]]];
		}
		ans = min(ans, now);
	} while (next_permutation(ALL(P)));
	cout << ans << endl;
	PAU;
	return 0;
}


Measured memory_bytes: 632
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.close();
        boolean iii = false;
        while(iii == false){
            if(n % 111 == 0){
                iii = true;
                n--;
            }
            n++;
        }
        System.out.println(n);
    }
}

Measured memory_bytes: 35660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////


int main(){fastio
    ll n;cin>>n;
    ll sum=0;
    rep(i,0,n-1){
        ll k;cin>>k;
        sum+=k;
        sum-=i+1;
        
    }
    cout<<sum<<endl;
    return 0;
}



Measured memory_bytes: 3168
from collections import deque
H,W=map(int,input().split())
s=[list('X'+input()+'X') for i in range(H)]
s.append('X'*(W+2))
s.insert(0,'X'*(W+2))

wnum=0
for i in range(1,H+1):
    for j in range(1,W+1):
        if s[i][j]=='.':
            wnum+=1

sd=[[-1 for i in range(W+2)] for j in range(H+2)]
d=[[0,1],[0,-1],[1,0],[-1,0]]
que=deque([[1,1]])
sd[1][1]=1
while len(que)>0:
    p=que.popleft()
    if p==[H,W]:
        break
    for v in d:
        ny=p[0]+v[0]
        nx=p[1]+v[1]
        if s[ny][nx]=='.' and sd[ny][nx]==-1:
            sd[ny][nx]=sd[p[0]][p[1]]+1
            que.append([ny,nx])

if sd[H][W]==-1:
    print(-1)
    exit()

print(wnum-sd[H][W])


Measured memory_bytes: 40816
#include<iostream>
#include<algorithm>
#include<cassert>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define MAX 31
using namespace std;
int n,m,goal,d;
bool G[MAX][MAX];

bool check()
{
  int ps[n];
  rep(i,n)ps[i] = i;


  rep(i,d)
    rep(j,n-1)
      if(G[i][j])
	  swap(ps[j],ps[j+1]);

  rep(i,n)
    if(ps[i] == m)
      return i == goal;
  assert(false); 
}

void compute()
{
  rep(i,d)
    {
      rep(j,n-1)
	{
	  if(G[i][j] || (i-1 >= 0 && G[i][j-1]) || G[i][j+1])continue;
	  G[i][j] = true;
	  if(check())
	    {
	      cout << i+1 << " " << j+1 << endl;
	      return;
	    }
	  G[i][j] = false;
	}
    }
  cout << 1 << endl;
}

void print()
{
  rep(i,d)
    {
      rep(j,n-1)
	{
	  cout << G[i][j];
	}
      cout << endl;
    }
      cout << endl;
}

int main()
{
  while(cin >> n,n)
    {
      cin >> m >> goal >> d;
      m--,goal--;
      {
	char c;
	rep(i,d)
	  rep(j,n-1)
	  {
	    cin >> c;
	    G[i][j] = c-'0';
	  }	    
      }

      if(check())
	{
	  cout << 0 << endl;
	  goto Skip;
	}

      compute();

    Skip:;

    }
  return 0;
}

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

int x,ta=1,mu=1;
signed main(){
	cin>>x;
	for(int i=2;i<=31;i++){
		mu=1;
		mu=mu*i*i;
		while(mu<=x){
			if(ta<mu)ta=mu;
			mu*=i;
		}
	}
	cout<<ta<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			boolean[][] map = new boolean[21][21];
			for (int i = 0; i < n; i++) {
				int x = scanner.nextInt();
				int y = scanner.nextInt();
				map[y][x] = true;
			}
			int m = scanner.nextInt();
			int x = 10;
			int y = 10;
			while (m-- > 0) {
				char d = scanner.next().charAt(0);
				int ny = (d == 'N' ? 1 : 0) - (d == 'S' ? 1 : 0);
				int nx = (d == 'E' ? 1 : 0) -( d == 'W' ? 1 : 0);
				int num = scanner.nextInt();
				while (num-- > 0) {
					y += ny;
					x += nx;
					if (map[y][x]) {
						n--;
						map[y][x] = false;
					}
				}
			}
			System.out.println(n == 0 ? "Yes" : "No");
		}
	}
}

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))


ll solve(int N) {
    vector<int> dp(N+1);
    rep(i,N+1) dp[i] = i;

    set<int> aug;
    for (int w=6; w<=N; w*=6) aug.insert(w);
    for (int w=9; w<=N; w*=9) aug.insert(w);
    vector<int> _aug(ALL(aug));
    reverse(ALL(_aug));

    rep(i,N+1){
        int b = dp[i];
        for (int w:_aug){
            if (i+w > N) continue;
            dp[i+w] = min(dp[i+w], b+1);
        }
    }

    return dp[N];
}

int main() {
    int N;cin>>N;
    cout <<solve(N) <<endl;
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
int main(){
	int n,m,a,b,i,t,r[100010],d[100010]={0,1,1};
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++)r[i+1]=i+1;
	i=1;
	while(m--){
		scanf("%d %d",&a,&b);
		t=r[a];
		r[a]=r[b];
		r[b]=t;
		if(a==i||b==i)i=a+b-i;//printf("%d\n",i);
		d[r[i-1]]=d[r[i+1]]=1;
		//for(i=0;i<n;i++)printf("%d ",r[i+1]);printf("\n");
		//for(i=0;i<n;i++)printf("%d ",d[i+1]);printf("\n");
	}
	for(i=a=0;i<n;i++)a+=d[i+1];
	printf("%d\n",a);
	return 0;
}

Measured memory_bytes: 896
N = int(input())
A = list(map(int, input().split()))
isFail = False
for i in A:
    if i%2 == 0:
        if not (i%3 == 0 or i%5 == 0):
            isFail = True
if isFail:
    print('DENIED')
else:
    print('APPROVED')

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

int main(){
    int n;
    cin >> n;
    vector <int> k(n,0);

    ll mod=998244353;

    int k2,k3;
    k3=0;
    rep(i,n){
        cin >> k2;
        ++k[k2];
        if(i==0 and k2!=0){
            k3=1;
        }
        else if(i!=0 and k2==0){
            k3=1;
        }
        
    }

    ll ans,ans2;
    int ko;
    ko=0;
    ans=1;
    rep(i,n-1){
        //cout << k[i] << endl;
        ko+=k[i];
        rep(j,k[i+1]){
        ans*=k[i];
        ans=ans%mod;
        }
        if(k[i]==0 and ko!=n){
            //cout << i << ko;
            k3=1;
            break;
            }
        }
    

    if(k3==1){
        cout << 0 << endl;
    }
    else{
        cout << ans << endl;
    }
    

    return 0;
}

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

int main() {
	ll n, ans = 0;
	cin >> n;
	if (n % 2 == 1) ans = 0;
	else {
		n /= 2;
		while (n >= 5) {
			n /= 5;
			ans += n;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3580
n = gets.to_i
s = gets.chomp

a_ord = "a".ord
z = 1 << (n-1).bit_length

st = Array.new(2*z, 0)
s.each_char.with_index(z) {|c,i| st[i] = 1 << c.ord - a_ord}
(z-1).downto(1) {|i| st[i] = st[2*i] | st[2*i+1]}

def calc(st, i, j, k, s, t)
    if s <= j && k <= t
        st[i]
    elsif k < s || t < j
        0
    else
        calc(st, 2*i, j, (j+k)/2, s, t) | calc(st, 2*i+1, (j+k)/2+1, k, s, t)
    end
end

gets
readlines.each do |abc|
    a, b, c = abc.split
    b = b.to_i

    if a == "1"
        c = 1 << c.ord - a_ord
        x = z+b-1
        next if st[x] == c

        st[x] = c
        x /= 2
        while x != 0
            st[x] = st[2*x] | st[2*x+1]
            x /= 2
        end
    else
        x = calc(st, 1, 1, z, b, c.to_i)
        y = 0
        while x != 0
            y += 1
            x &= x - 1
        end
        puts y
    end
end

Measured memory_bytes: 12584
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> w(n),s(n),v(n);
  for(Int i=0;i<n;i++) cin>>w[i]>>s[i]>>v[i];
  
  vector<Int> ord(n);
  iota(ord.begin(),ord.end(),0);
  auto cmp=[&](Int i,Int j){return w[i]+s[i]<w[j]+s[j];};
  sort(ord.begin(),ord.end(),cmp);
  
  const Int MAX = 2e4+100;
  vector<Int> dp(MAX+1,0);
  for(Int p:ord)
    for(Int j=s[p];j>=0;j--)
      chmax(dp[j+w[p]],dp[j]+v[p]);
    
  cout<<*max_element(dp.begin(),dp.end())<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 3e5 + 5, mod = 1e9 + 7;



int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n;
    cin >> n;
    n %= 10;
    if(n == 3) return cout << "bon", 0;
    if(n == 0 || n == 1 || n == 6 || n == 8) return cout << "pon", 0;
    cout << "hon";


    return 0;

}


Measured memory_bytes: 3652
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	LL a,b,n;
    cin>>a>>b>>n;
    if(b<=n){
        cout<<a*(b-1)/b;
    }else{
        cout<<a*n/b;
    }

}


Measured memory_bytes: 3624
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        String s = sc.next();
        int b = sc.nextInt();
        if (s.equals("+")) {
            System.out.println(a+b);
        }else {
            System.out.println(a-b);
        }
    }
}


Measured memory_bytes: 35812
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> time;
  vector<pair<int,int>> pos;

  for(int i = 0;i < N;i++){
    int t,x,y;
    cin >> t >> x >> y;
    time.push_back(t);
    pos.push_back(make_pair(x,y));
  }

  bool flag = true;
  int now_x = 0;
  int now_y = 0;
  int now_t = 0;

  for(int i = 0;i < N;i++){
    int next_t = time[i];
    int next_x = pos[i].first;
    int next_y = pos[i].second;

    int move_dist = abs(next_x - now_x) + abs(next_y - now_y);
    if((next_t - now_t) % 2 != move_dist % 2 || next_t - now_t < move_dist){
      flag = false;
      break;
    }

    now_t = next_t;
    now_x = next_x;
    now_y = next_y;
  }

  cout << (flag ? "Yes" : "No") << endl;

}


Measured memory_bytes: 1780