akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
	int H,W;
	for(int a=0;a<10000;a++){
		cin>>H>>W;
		if(H==0&&W==0){
			a=10000;
		}
		else{
		for(int b=0;b<H;b++){
			for(int c=0;c<W;c++){
				if((b%2==0&&c%2==0)||(b%2==1&&c%2==1)){
					cout<<"#";
				}
				else{
					cout<<".";
				}
			}
			cout<<endl;
		}
		cout<<endl;
	}
}
}
					
				
			



Measured memory_bytes: 3056
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;
ll inf=1e10;

int main(){
  int N,A[2][100];
  cin>>N;
  for (int i(0);i<N;i++) cin>>A[0][i];
  for (int i(0);i<N;i++) cin>>A[1][i];
  int ans(0);
  for (int i(0);i<N;i++){
    int cnt(0);
    for (int j(0);j<N;j++){
      if (j<=i) cnt += A[0][j];
      if (j>=i) cnt += A[1][j];
    }
    ans = max(ans,cnt);
  }
  cout << ans << endl;
  return 0;
}


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

typedef long long ll;

ll Num[23333];
ll x;

	
int main(){
	for(ll i = 1; i <= 500; i++) Num[i] = i * i * i * i * i;
	cin >> x;
	for(int i = 1; i <= 500; i++){
		if(x == Num[i]){
			printf("%d 0\n", i);
			break;
		}
		else{
			for(int j = 1; j <= i; j++){
				if(x == Num[i] + Num[j]){
					printf("%d %d\n", i, -j);
					exit(0);
				}
				if(x == Num[i] - Num[j]){
					printf("%d %d\n", i, j);
					exit(0);
				}
			}
		}
	}	
	return 0;
}

Measured memory_bytes: 3752
x, y = map(int, input().split())
score1 = 300000
score2 = 200000
score3 = 100000
plus = 400000

ans1 = 0
ans2 = 0
if x == 1:
    ans1 = score1
elif x == 2:
    ans1 = score2
elif x == 3:
    ans1 = score3
else:
    ans1 = 0
if y == 1:
    ans2 = score1
elif y == 2:
    ans2 = score2
elif y == 3:
    ans2 = score3
else:
    ans2 = 0

if x == 1 and y == 1:
    print(ans1 + ans2 + plus)
else:
    print(ans1 + ans2)

Measured memory_bytes: 3064
from collections import deque

H, W = map(lambda x: int(x)+4, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())

grid = '#' * W * 2
for _ in range(H-4):
  grid += '##' + input() + '##'
grid += '#' * W * 2

magic_list = []
for i in range(5):
  for j in range(5):
    if (i, j) in [(2, 2), (1, 2), (2, 1), (2, 3), (3, 2)]:
      continue
    else:
      magic_list.append(i-2 + W*(j-2))

move_list = [-1, 1, W, -W]

def bfs(start):
  INF = 10 ** 9
  dist = [INF] * (H*W)
  dist[start] = 0
  qw = deque([start])
  qm = deque([])
  while qw or qm:
    while qw:
      v = qw.popleft()
      dv = dist[v]
      magic_flag = True
      for move in move_list:
        w = v + move
        if grid[w] == '#':
          if magic_flag:
            qm.append(v)
            magic_flag = False
          continue
        dw = dv
        if dw >= dist[w]:
          continue
        dist[w] = dw
        qw.append(w)
    while qm:
      v = qm.popleft()
      dv = dist[v]
      for magic in magic_list:
        w = v + magic
        if grid[w] == '#':
          continue
        dw = dv + 1
        if dw >= dist[w]:
          continue
        dist[w] = dw
        qw.append(w)
  return dist

ans = bfs( (Ch+1)*W + Cw+1 )[(Dh+1)*W + Dw+1]

if ans == 10**9:
  print(-1)
else:
  print(ans)

Measured memory_bytes: 218128
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

LL k, a, b;

int main(){
	cin >> k >> a >> b;
	if(b - a >= 2){
		if(k <= a){
			cout << k + 1LL << endl;
			return 0;
		}
		cout << a + (k - (a - 1))/2 * (b - a) + (k - (a - 1))%2 << endl;
	}else{
		cout << k + 1LL << endl;
	}
}

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

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (S.substr(i, 3) == "ABC") {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3576
use std::cmp::*;
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, k) = i.read2::<usize, usize>();
    let x = i.read_vec::<isize>(n);

    writeln!(o, "{}", solve(k, &x)).unwrap();
}
fn solve(k: usize, x: &[isize]) -> isize {
    let mut result = isize::max_value();
    for i in 0..(x.len() - k + 1) {
        let first = x[i];
        let last = x[i + k - 1];

        let r = if first <= 0 && last <= 0 {
            -first
        } else if first >= 0 && last >= 0 {
            last
        } else {
            min(-first + (last - first), last + last - first)
        };
        if r < result {
            result = r;
        }
    }
    result
}

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()
        }

        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) }

        pub fn read_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            self.read_line()
                .split(' ')
                .take(n)
                .map(|x| x.parse().ok().unwrap())
                .collect()
        }
    }
    fn read_next<'a, T: FromStr, I: Iterator<Item = &'a str>>(i: &mut I) -> T {
        i.next().unwrap().parse().ok().unwrap()
    }
}


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

#define sz(a)      (int)((a).size())
#define rep(i,n)   for(int i=0;i<n;++i)
#define REP(i,j,k) for(int i=j;i<k;++i)
#define each(a,b)  for(__typeof((a).begin()) b=(a).begin();b!=(a).end();b++)

using ll = long long;

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

  int n = sz(s);

  if (s[0] != '1' || s[n-1] != '0') {
    puts("-1");
    return 0;
  }

  rep(i, n-1) {
    if (s[i] != s[n-1-1-i]) {
      puts("-1");
      return 0;
    }
  }

  map<int, int> nodes;
  int root = 1;
  REP(i, 0, n-1) {
    int id = i + 1 + 1;
    if (s[i] == '0') {
      // puts("0: add child to parent");
      nodes[id] = root;
    } else {
      // puts("1: add parent to parent");
      nodes[root] = id;
      root = id;
    }
  }

  each(nodes, it) {
    cout << it->first << " " << it->second << " " << endl;
  }

  return 0;
}


Measured memory_bytes: 7452
#include <bits/stdc++.h>
#define il inline
#define RG register
#define ll long long
#define rhl (1000000007)
#define N (5000010)

using namespace std;

int fac[N],ifac[N],inv[N];
int f[2010][2010],n,k;

il int C(RG int n,RG int m){
  return 1LL*fac[n]*ifac[m]%rhl*ifac[n-m]%rhl;
}

il void add(RG int &x,RG int v){
  x+=v; if (x>=rhl) x-=rhl; return;
}

int main(){
  cin>>n>>k;
  if (k==1) puts("1"),exit(0); f[0][0]=fac[0]=ifac[0]=1;
  for (RG int i=1;i<=(n+1)*k;++i){
    inv[i]=i==1 ? 1 : 1LL*(rhl-rhl/i)*inv[rhl%i]%rhl;
    fac[i]=1LL*fac[i-1]*i%rhl,ifac[i]=1LL*ifac[i-1]*inv[i]%rhl;
  }
  for (RG int i=0;i<=n;++i)
    for (RG int j=0;j<=n;++j){
      if (i<j) add(f[i+1][j],f[i][j]);
      add(f[i][j+1],1LL*f[i][j]*C(i+(j+1)*(k-1)-1,k-2)%rhl);
    }
  cout<<1LL*f[n][n]*fac[n]%rhl; return 0;
}


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

int c[8][8], N;

class DP{
public:
	int cost;
	string data;
	
	DP(){}
	DP(int c, string d){
		cost=c;data=d;
	}
	
	bool operator< (const DP &opp) const {
		return cost>opp.cost;
	}
};

main(){
	int i,j,k;
	cin >> N;
	for(i=0;i<N;i++)
		for(j=0;j<N;j++)
			cin >> c[i][j];
	string data = string("01234567").substr(0,N);
	map<string, int> list;
	
	priority_queue<DP> dp;
	dp.push(DP(0,data));
	list[data] = 0;
	DP S;
	while(!dp.empty()){
		S = dp.top();
		dp.pop();
		for(i=0;i<N;i++)
			for(j=i+1;j<N;j++){
				DP T = S;
				T.cost += c[i][j];
				swap(T.data[i], T.data[j]);
				if(list.end() == list.find(T.data) || T.cost < list[T.data]){
					list[T.data] = T.cost;
					dp.push(T);
				//	cout << T.data << ":" << T.cost << endl;
				}
			}
	}
	int max = 0;
	data = string("01234567").substr(0,N);
	do{
		int ret = list[data];
		if(max < ret) max = ret;
	
	}while(next_permutation(data.begin(), data.end()));
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 9044
n=int(input())
ab=[]
for i in range(n):
    a,b=map(int,input().split())
    ab.append((a,b))
ab.sort(key=lambda x:x[1])
ans='Yes'
time=0
for i in range(n):
    time+=ab[i][0]
    if time>ab[i][1]:
        ans='No'
        break
print(ans)


Measured memory_bytes: 31860
S=input()
T=input()
if(len(S)==len(T)):
    length=len(S)
    i=0
    while(i<length):
        if(S==T):
            print('Yes')
            break
        S=S[-1]+S[0:-1]
        i+=1
    if i==length:
        print('No')
else:
    print('No')
    

Measured memory_bytes: 3060
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int pa=0,pb=0;
		int n=sc.nextInt();
		for(int i=0;i<n;i++){
			String A = sc.next();
			String B = sc.next();
			if(A.compareTo(B)>0){
				pa+=3;
			}else if(A.compareTo(B)<0){
				pb+=3;
			}else{
				pa++;
				pb++;
			}
		}
		System.out.println(pa+" "+pb);
	}
}

Measured memory_bytes: 30428
n=int(input())
a=[list(map(int,input().split())) for _ in range(n)]
dp=[[0]*3 for i in range(n)]
dp[0][0]=a[0][0]
dp[0][1]=a[0][1]
dp[0][2]=a[0][2]
for i in range(1,n):
    dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2])
    dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2])
    dp[i][2]=a[i][2]+max(dp[i-1][1],dp[i-1][0])
print(max(dp[n-1]))   

Measured memory_bytes: 74456
#include <iostream>
#include <cmath>
#include <utility>

using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
#define mp make_pair
#define x first
#define y second

int main () {
	ll n;
	cin>>n;
	int tr=0;
	int i=0;
	ll x=100ll;
	while(x<n){
		x+=x/100ll;
		i++;
	}
	cout<<i;
	



return 0;
}

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

typedef long long ll;

using namespace std;

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

    int mi = 1 << 30;
    int ma = -1;

    for (int i = 0; i<n; i++){
        int ai;
        cin >> ai;

        mi = min(mi, ai);
        ma = max(ma, ai);
    }

    cout << ma - mi << endl;
}

Measured memory_bytes: 3576
#include<iostream>
#include<cmath>

using namespace std;

double EPS=1e-10;
double pi=3.1415926535;

double calc(int x) {
  return sin((double)x*pi/180.0);
}
 

int main(void){
  int n,m;
  
  while(true){
    cin >> n;
    if(n==0)break;
    double sum1=0,sum2=0,s1=0,s2=0,v,s=360;
   
    for(int i=0;i<n-1;i++){
      cin >> v;
      s-=v;
      s1+=calc(v);
    }
    s1+=calc(s);
    cin >> m;
    s=360;
    for(int j=0;j<m-1;j++){
      cin >> v;
      s-=v;
      s2+=calc(v);
    }
    s2+=calc(s);
    if(s1>s2+EPS) cout << 1 << endl;
    else if(s1+EPS<s2) cout << 2 << endl;
    else cout << 0 << endl;
  }

  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
using ll =long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;
using vvs = vector<vs>;

ll mod = 1000000000 + 7;
int main(){
    int N, K;
    cin >> N >> K;

    int ans = 1;

    for (int i = 1; i <= N; ++i) {
        if(i == 1){
            ans *= K;
        }
        else{
            ans *= (K-1);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top, S[1000];

void push(int x){
	S[++top]=x;
}

int pop(){
	top--;
	return S[top+1];
}

int main(){
	int a, b;
	top=0;
	char s[100];
	while(scanf("%s", s)!=EOF){
		if(s[0]=='+'){
			a=pop();
			b=pop();
			push(a+b);
		}else if(s[0]=='-'){
			b=pop();
			a=pop();
			push(a-b);
		}else if(s[0]=='*'){
			a=pop();
			b=pop();
			push(a*b);
		}else{
			push(atoi(s));
		}
	}
	printf("%d\n",pop());
	return 0;
}



Measured memory_bytes: 2696
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int ni[1000000], sum[1000000];

int main() {
    ni[0] = ni[1] = 1;
    for (int i = 2; i < 1000000; i++) if (ni[i] == 0) {
        for (int j = i+i; j < 1000000; j+=i) ni[j] = 1;
    }
    for (int i = 1; i < 1000000; i++) sum[i] = sum[i-1] + 1-ni[i];
    int n;
    while (scanf("%d", &n) != EOF) printf("%d\n", sum[n]);
    return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n, flag = 1,sum=0;
	pair<int, int> data[200000];
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> data[i].second >> data[i].first;
	}
	sort(data, data + n);
	for (int i = 0; i < n; ++i) {
		sum += data[i].second;
		if (sum > data[i].first) flag = 0;
	}
	cout << (flag ? "Yes" : "No") << endl;
	return 0;
}

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define F first
#define S second
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
const int MOD = 1e9 + 7; 
const int N = 1e5+10; 
int main(void) 
{
	
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	#endif
	

	int n, m;
	cin >> n >> m;
	
	string a1 = ""; 
	string b2 = ""; 

	string a = to_string(n); 
	string b = to_string(m); 
	for (int i=0; i<m; i++) 
		a1 += a; 

	for (int i=0; i<(n); i++) 
		b2 += b; 

	if (m > n) cout << a1 << '\n'; 
	else if (m< n) cout << b2 << '\n'; 
	else 
	{
		cout << (a>b ? a1 : b2) << '\n';
	}




	return false;   


}


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

int main(void){
    int A, B;
    cin >> A >> B;
    if(A==B){
        cout << "Draw" << endl;
        return 0;
    }
    cout << ((A==1?14:A)>(B==1?14:B)?"Alice":"Bob") <<endl;
}


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

using namespace std;

struct Edge {
  int dst;
  long long cost;
  Edge() {}
  Edge(int x, long long y) : dst(x), cost(y) {}
};

std::vector<long long> dijkstra(int start_v, std::vector<std::vector<Edge>> &G, int L) {
  const long long LINF = 1000000000000000018LL;

  int n = (int)G.size();
  std::vector<std::pair<long long, long long>> dist(n, std::make_pair(LINF, 0));

  dist[start_v] = std::make_pair(0, 0);

  // ((補給回数, 消費燃料), 頂点)
  typedef std::pair<std::pair<long long, long long>, int> P;
  std::priority_queue<P, std::vector<P>, std::greater<P>> que;

  que.push(std::make_pair(std::make_pair(0LL, 0), start_v));

  while (!que.empty()) {
    P now = que.top();
    que.pop();

    int cur_vertex = now.second;
    long long num_charge = (now.first).first;
    long long use_charge = (now.first).second;

    if (now.first > dist[cur_vertex]) {
      continue;
    }

    for (int i = 0; i < (int)G[cur_vertex].size(); i++) {
      int nxt_vertex = G[cur_vertex][i].dst;
      long long cost = G[cur_vertex][i].cost;

      if (cost > L) {
        continue;
      }

      long long nxt_used = use_charge + cost;
      std::pair<long long, long long> nxt_p;
      if (nxt_used > L) {
        nxt_p = {num_charge + 1, cost};
      } else {
        nxt_p = {num_charge, nxt_used};
      }
      if (nxt_p < dist[nxt_vertex]) {
        dist[nxt_vertex] = nxt_p;
        que.push(std::make_pair(nxt_p, nxt_vertex));
      }
    }
  }

  std::vector<long long> res(n);
  for (int i = 0; i < n; i++) {
    res[i] = dist[i].first;
  }

  return res;
}

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

  const long long LINF = 1000000000000000018LL;

  int N, M, L;
  std::cin >> N >> M >> L;

  std::vector<std::vector<Edge>> Graph(N);

  for (int i = 0; i < M; i++) {
    int A, B, C;
    std::cin >> A >> B >> C;
    --A, --B;
    if (C > L) {
      continue;
    }
    Graph[A].push_back(Edge(B, C));
    Graph[B].push_back(Edge(A, C));
  }

  std::vector<std::vector<long long>> ans(N, std::vector<long long>(N, LINF));

  for (int start_v = 0; start_v < N; start_v++) {
    auto dist = dijkstra(start_v, Graph, L);
    for (int i = 0; i < N; i++) {
      ans[start_v][i] = dist[i];
      ans[i][start_v] = dist[i];
    }
  }

  int Q;
  std::cin >> Q;

  while (Q--) {
    int s, t;
    std::cin >> s >> t;
    --s, --t;
    cout << (ans[s][t] == LINF ? -1 : ans[s][t]) << "\n";
  }

  return 0;
}

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


int main(){
  int N;
  cin >> N;
  int cnt=0;
  if(N <=104){
    cout << "0" << endl;
    return 0;
  }
  
  for(int i=105; i<=N; i++){
    int divisor=0;
    if(i%2==1){
      for(int j=1; j<=i; j++){
        if(i%j==0) divisor++;
      }
      if(divisor==8) cnt++;
    }
  }
  cout << cnt << endl;

  return 0;
}


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

#define CIN1(a) long long a;cin >> a;
#define CIN2(a,b) long long a,b;cin >> a >> b;
#define CIN3(a,b,c) long long a,b,c;cin >> a >> b >> c;
#define rep(i,n) for(int i=0,i##_len=(n); i<i##_len; ++i)

int main(){
    CIN1(n)
    cout << 1110-n << endl;
}

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

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> l(n);
  int ans=0;
  for(int i=0;i<n;i++) {
    cin >> l[i];
  }
  sort(l.begin(),l.end());
  for(int i=n-1;i>=n-k;i--) {
    ans += l[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -std=c++11 */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const LL inf = 1e16;
const int maxn = 410;
int A[maxn]; LL sum[maxn], dp[maxn][maxn];

LL dfs(const int i, const int j)
{
    if (i == j)
        return 0;
    LL& ans = dp[i][j];
    if (-1 == ans) {
        ans = inf;
        FOR(k,i+1,j+1) {
            const LL res = dfs(i,k-1) + dfs(k,j) + sum[j]-sum[i-1];
            ans = min(ans,res);
        }
    }
    return ans;
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n;
    while (cin >> n) {
        sum[0] = 0;
        FOR(i,1,n+1) {
            cin >> A[i];
            sum[i] = A[i] + sum[i-1];
        }
        memset(dp,-1,sizeof(dp));
        cout << dfs(1,n) << endl;
    }
    return 0;
}


Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String S = scanner.next();
		System.out.println(S.compareTo("2019/04/30") <= 0 ? "Heisei" : "TBD");
		scanner.close();
	}
}

Measured memory_bytes: 23764
#include <iostream>

using namespace std;

int main () {
    const int M = 50;
	int N=0;
	int p[M] ={0};
	int difference=0;
	
	cin >> N;
	for (int i=0; i<N;i++){
	    cin >> p[i];
		if (p[i]!=i+1){
		  difference++;
		}
	}

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

	return 0;
	
}


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

int main(){
  int a,p;
  cin >> a >> p;
  int x = (3 * a + p)/2 ;
  
  cout <<  x << endl;
  return 0;
  
  
}


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

using namespace std;

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

    string S;
    cin >> S;

    if (N % 2 != 0) {
        cout << "No" << endl;
        return 0;
    }

    vector<char> characters(S.begin(), S.end());

    string a = S.substr(0, N / 2);
    string b = S.substr(N / 2, N / 2);

    cout << (a == b ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 888
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
#include <cstring>

int main() {
  int r, c, x, y, k;
  cin >> r >> c >> k;
  vector<vector<ll> > v(r);
  vector<vector<vector<ll> > > dp(r);
  for (int i = 0; i < r; i++) {
    v[i].resize(c);
    dp[i].resize(c);
    for (int j = 0; j < c; j++) {
      dp[i][j].resize(4);
      dp[i][j] = {0, 0, 0, 0};
      v[i][j] = 0;
    }
  }
  for (int i = 0; i < k; i++) {
    cin >> x >> y;
    x--;
    y--;
    cin >> v[x][y];
  }
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      for (int l = 0; l < 3; l++) {
        dp[i][j][l + 1] = max(dp[i][j][l + 1], dp[i][j][l]);
      }
      if (j != c - 1) {
        for (int l = 0; l < 3; l++) {
          dp[i][j + 1][l + 1] = max(dp[i][j + 1][l + 1], dp[i][j][l] + v[i][j]);
        }
        for (int l = 0; l < 4; l++) {
          dp[i][j + 1][l] = max(dp[i][j + 1][l], dp[i][j][l]);
        }
      }
      if (i != r - 1) {
        dp[i + 1][j][0] =
            max(dp[i + 1][j][0], max(dp[i][j][3], dp[i][j][2] + v[i][j]));
      }
    }
  }
  cout << max(dp[r - 1][c - 1][3], dp[r - 1][c - 1][2] + v[r - 1][c - 1])
       << endl;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    A.at(i)--;
  }
  int now = 0;
  for (int i = 1; i < N * 2; i++) {
    now = A.at(now);
    if (now == 1) return cout << i << "\n", 0;
  }
  cout << -1 << "\n";
}

Measured memory_bytes: 3796
local n, m = io.read("*n", "*n")
local t = {}
for i = 1, n do
  t[i] = {}
  t[i][1], t[i][2] = io.read("*n", "*n")
end
table.sort(t, function(x, y) return x[1] < y[1] end)
local ret = 0
for i = 1, n do
  if t[i][2] < m then
    m = m - t[i][2]
    ret = ret + t[i][1] * t[i][2]
  else
    ret = ret + t[i][1] * m
    m = 0
    break
  end
end
print(ret)


Measured memory_bytes: 13304
#include <stdio.h>

int Partition(int*,int,int);

int main(){
  int n,i,mid;
  int A[100000];

  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&A[i]);
  }

  mid = Partition(A,0,n-1);

  for(i = 0; i < n-1; i++){
    if(i == mid) printf("[%d] ",A[i]);
    else  printf("%d ",A[i]);
  }
  printf("%d\n",A[i]);

  return 0;
}

int Partition(int* A,int p,int r){
  int x;
  int tmp,j,i;
  x = A[r];
  i = p-1;
  for(j = p; j < r; j++){
    if(A[j] <= x){
      i = i + 1;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }
  tmp = A[i+1];
  A[i+1] = A[r];
  A[r] = tmp;
  return i+1;
}

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

struct Node {
	int left;
	int right;
};

void solve(Node node[], int i,vector<int> order[]) {

	order[0].push_back(i);

	if (node[i].left != -1)solve(node, node[i].left, order);
	order[1].push_back(i);

	if (node[i].right != -1)solve(node, node[i].right, order);
	order[2].push_back(i);
}

int main() {
	int n;
	Node node[25];
	bool table[25] = { false };
	vector<int> order[3];
	string str[3] = { "Preorder","Inorder","Postorder" };

	

	cin >> n;
	for (int i = 0; i < n; i++) {
		int id, l, r;
		cin >> id >> l >> r;
		node[id].left = l;
		node[id].right = r;
		
		if (l != -1)table[l] = true;
		if (r != -1)table[r] = true;
	}

	int root;
	for (int i = 0; i < n; i++) {
		if (table[i] == false) {
			root = i;
			break;
		}
	}

	solve(node, root,order);

	for (int i = 0; i < 3; i++) {
		cout << str[i] << endl;
		for (int j = 0; j < n; j++) {
			cout << " " << (order[i])[j];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3184
#include <cstdio>
#include <algorithm>
#include <vector>

int main() {
  size_t n, q;
  scanf("%zu %zu", &n, &q);

  std::vector<int> a(n);
  for (auto& ai: a) scanf("%d", &ai);
  std::sort(a.begin(), a.end());

  for (size_t i = 0; i < q; ++i) {
    int l, r;
    scanf("%d %d", &l, &r);
    printf("%td\n", std::upper_bound(a.begin(), a.end(), r) - std::lower_bound(a.begin(), a.end(), l));
  }
}



Measured memory_bytes: 2788
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
4 5
0 1 2
0 2 1
1 2 1
1 3 1
2 3 2

output:
3
"""

import sys
from collections import deque


def graph_bfs(source, target, parent):
    visited = [False] * vertices
    queue = deque()
    queue.append(source)
    visited[source] = True

    while queue:
        current = queue.popleft()
        for adj, cp in adj_table[current].items():
            if not visited[adj] and cp:
                queue.append(adj)
                visited[adj] = True
                parent[adj] = current

    return True if visited[target] else False


def graphFordFulkerson(source, sink):
    parent = [-1] * vertices
    max_flow = 0

    while graph_bfs(source, sink, parent):
        path_flow = float('inf')

        bk_1 = sink
        while bk_1 is not source:
            path_flow = min(path_flow, adj_table[parent[bk_1]][bk_1])
            bk_1 = parent[bk_1]

        max_flow += path_flow

        bk_2 = sink
        while bk_2 is not source:
            parent_bk_2 = parent[bk_2]
            adj_table[parent_bk_2].setdefault(bk_2, 0)
            adj_table[bk_2].setdefault(parent_bk_2, 0)

            # print(bk_2, parent_bk_2, path_flow, bk_1, parent[bk_1], parent, adj_table)
            adj_table[parent_bk_2][bk_2] -= path_flow
            adj_table[bk_2][parent_bk_2] += path_flow
            bk_2 = parent[bk_2]

    return max_flow


def generate_adj_table(v_table):
    for each in v_table:
        source, target, cp = map(int, each)
        init_adj_table[source][target] = cp

    return init_adj_table


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices, edges = map(int, _input[0].split())
    v_info = map(lambda x: x.split(), _input[1:])

    init_adj_table = [dict() for _ in range(vertices)]
    adj_table = generate_adj_table(v_info)
    ans = graphFordFulkerson(source=0, sink=vertices - 1)
    print(ans)

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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)

int main(void){
  int n;
  cin>>n;
  vector<char> s(n);
  r(i,n){
    cin>>s.at(i);

  }
  int maxi=0;
  vector<int> t(27,0);
  int cnt1=0,cnt2=0;

  for(int i=1;i<n;i++){
    r(j,i){
      for(int k=i;k<n;k++){
        //cout<<s.at(j)-'a'<<endl;
        //cout<<i<<" "<<j<<" "<<k<<endl;
        if(s.at(j)==s.at(k)){t.at(s.at(j)-'a')=1;}
      }
    }

      r(l,27){
        if(t.at(l)==1)cnt1++;
        //cout<<t.at(l)<<endl;
        t.at(l)=0;
      }

      cnt2=max(cnt2,cnt1);
      
      cnt1=0;

  }
  cout<<cnt2<<endl;
return 0;}


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

int main(void){
  int seq, x;
  cin >> seq >> x;
  int min, max;
  min = x - seq + 1;
  max = x + seq - 1;
  int i;
  for(i = min; i <= max; i++){
    cout << i << ' ';
  }
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 384
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    auto s = sread();
    bool[] tmp = [false, false];
    foreach (i; 0 .. s.length)
    {
        foreach (j; 0 .. s.length)
        {
            if (s[i] == 'C' && s[j] == 'F')
            {
                if (i < j)
                {
                    writeln("Yes");
                    return;
                }
            }
        }
    }
    writeln("No");
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
	string s;
	cin>>s;
	if(s[0]!='A'){
		cout<<"WA"<<endl;
		return 0;
	}
	if(s[1]>='A'&&s[1]<='Z'){
		cout<<"WA"<<endl;
		return 0;
	}
	int d=0;
	for(int i=1;i<=s.size();i++){
		if(i>=2&&i<s.size()-1){
            if(s[i]=='C'){
				d++;
			}
        }
		else if(s[i]>='A'&&s[i]<='Z'){
			cout<<"WA"<<endl;
		    return 0;
		}
    }
    if(d!=1)cout<<"WA"<<endl;
    else cout<<"AC"<<endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
using namespace std;
 
#define gc c=getchar()
#define r(x) read(x)
 
template<typename T>
inline void read(T&x){
    x=0;T k=1;char gc;
    while(!isdigit(c)){if(c=='-')k=-1;gc;}
    while(isdigit(c)){x=x*10+c-'0';gc;}x*=k;
}
 
const int N=2005;
 
int gcd(int a,int b){
	return b?gcd(b,a%b):a;
}
 
vector<int>G1[N];
vector<int>G2[N];
 
int a[N];
int deg[N];
bool vis[N];
 
void dfs(int x){
	vis[x]=1;
	for(int i=0;i<G1[x].size();++i){
		int v=G1[x][i];
		if(!vis[v]){
			G2[x].push_back(v);
			deg[v]++;
			dfs(v);
		}
	}
}
 
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	int n;r(n);
	for(int i=1;i<=n;++i)r(a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=n;++i){
		for(int j=i+1;j<=n;++j){
			if(gcd(a[i],a[j])!=1){
				G1[i].push_back(j);
				G1[j].push_back(i);
			}
		}
	}
	for(int i=1;i<=n;++i){
		if(!vis[i]){
			dfs(i);
		}
	}
	priority_queue<int>Q;
	for(int i=1;i<=n;++i){
		if(!deg[i]){
			Q.push(i);
		}
	}
	while(!Q.empty()){
		int x=Q.top();Q.pop();
		printf("%d ",a[x]);
		for(int i=0;i<G2[x].size();++i){
			int v=G2[x][i];
			if(!--deg[v]){
				Q.push(v);
			}
		}
	}
	return 0;
}

Measured memory_bytes: 19584
#include <bits/stdc++.h>
using namespace std;
 
#define fill(a,val) memset(a, (val), sizeof a)
#define pb push_back
#define lli long long int
#define scantype int
#define endl "\n"
#define unique(x) x.erase(unique(x.begin(),x.end()), x.end())
#define debug(x) cerr << #x " = " << (x) << '\n'
#define what_is(x) cerr << #x << " is " << x << endl;
 
lli MOD  = 1000000007;
lli inf = 1e15;
 
void scan(scantype &x);

lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli string_to_number(string s){lli x=0; stringstream convert(s); convert>>x; return x;}
lli add(lli a,lli b){lli x = (a+b)%MOD; return x; }
lli mul(lli a,lli b){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b){lli x = (a-b+MOD)%MOD; return x; }
lli div(lli a,lli b){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}

bool isprime(long long int n)
{
    if(n ==1 )
        return false;
    if(n == 2)
        return true;
    for(long long int i =2;i<=n/i;i++)
    {
        if(n%i == 0)
            return false;
    }
    return true;
}
int main(void)
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);   
    int t;
    t = 1;  
    while(t--)
    {

        int n;
        cin>>n;
        std::map<int,bool> mp;
        int a[n+1];
        for(int i = 1;i<=n;i++)
            cin>>a[i];

        mp[1] = true;
        int ans = 1;
        int  cur = a[1];
        while(cur != 2)
        {
            if(mp[cur])
            {
                cout<<-1;
                return 0;
            }
            mp[cur] = true;
            cur = a[cur];
            ans++;
        }
        cout<<ans;
    }    


    
    return 0;    
}
 

void scan(scantype &x)
{
    register int c = getchar(); //for negative/positive
    x = 0;
    int neg = 0;
    for(;((c<48 || c>57) && c != '-');c = getchar());
    if(c=='-') {neg=1;c=getchar();}
    for(;c>47 && c<58;c = getchar()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}


Measured memory_bytes: 5376
{-# LANGUAGE BangPatterns, MagicHash #-}
import Control.Monad
import Control.Applicative
import Data.List
import Data.Maybe
import Data.Bits
import qualified Data.IntMap.Strict as M
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed as V
-- import Data.Vector.Unboxed ((!))
import Data.Tuple
import Data.Ord (Down(..))
import Data.Coerce

query :: Int -> Int -> Int -> Int -> Bool
query a b c d
  = b <= d && a >= b && b <= c - m + g
  where
    g = b `gcd` d
    m = a `mod` g


main :: IO ()
main = do
  getLine
  ans <- map ((\(a:b:c:d:_)->query a b c d)
              . unfoldr (B.readInt . B.dropWhile (== ' '))) 
         . B.lines <$> B.getContents
  mapM_ (\b -> putStrLn $ if b then "Yes" else "No") ans 


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

int C[1000];
int S[1000];
int F[1000];
int ANS[1000];
int N = 0;

int arvTime(int i, int atime) {  // i番目の駅にいて、その駅にatimeに居たとき、N番目の駅に着く時刻を教えてくれる関数
	if (i == N) return atime;
	if (atime <= S[i]) {
		int time = S[i] + C[i];
		return arvTime(i + 1, time);
	}
	else {
		if (atime % F[i] == 0){
			int time = atime + C[i];
			return arvTime(i + 1, time);
		}
		else {
			int time = (atime / F[i] + 1) * F[i] + C[i];
			return arvTime(i + 1, time);
		}
	}
}

int main()
{
	memset(C, 0, sizeof(C));
	memset(S, 0, sizeof(S));
	memset(F, 0, sizeof(F));
	memset(ANS, 0, sizeof(ANS));

	cin >> N;
	for (int i = 1; i < N; i++) {
		cin >> C[i] >> S[i] >> F[i];
	}
	for (int i = 1; i <= N; i++) {
		ANS[i] = arvTime(i, 0);
		cout << ANS[i] << endl;
	}
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<(n); ++i)
#define rep1(i,n) for(ll i=1; i<=(n); ++i)
#define repi(i,a,b) for(ll i=a; i<=(b); ++i)
#define rrep(i,n) for(ll i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define print(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
using Edge = pair<ll,ll>;
using Graph = vector<vector<Edge>>;
typedef pair<ll,ll> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}

ll solve(ll N){
    ll ans = 0;
    return ans;
}

int main(){
    string S; cin >> S;
    print("ABC"+S);
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	private static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		int[][] c = new int[n][26];
		for (int i = 0;i < n;i++) {
			char[] s = sc.next().toCharArray();
			for (int j = 0;j < s.length;j++) {
				c[i][s[j]-97]++;
			}
		}
		int[] m = new int[26];
		for (int i = 0;i < 26;i++) m[i] = 1010;
		for (int i = 0;i < n;i++) {
			for (int j = 0;j < 26;j++) {
				m[j] = Math.min(m[j], c[i][j]);
			}
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 0;i < 26;i++) {
			int l = m[i];
			for (int j = 0;j < l;j++) {
				sb.append((char)(i+97));
			}
		}
		System.out.println(sb.toString());
	}
}


Measured memory_bytes: 21716
main :: IO ()
main = do ls <- getContents
          putStrLn (compose ls)

compose :: String -> String
compose = unwords . fmap show . mathOp . (\xs -> take (head xs) (tail xs)) . (=<<) (fmap (\x -> read x::Int) . words) . lines

mathOp  :: [Int] -> [Int]
mathOp  xs = fmap ($ xs) [mini, maxi, sumi]

mini :: [Int] -> Int
mini [] = error "Empty list was given"
mini [x] = x
mini (x:y:xs) | x <= y = mini (x:xs)
              | otherwise = mini (y:xs)

maxi :: [Int] -> Int
maxi [] = error "Empty list was given"
maxi [x] = x
maxi (x:y:xs) | x < y = maxi (y:xs)
              | otherwise = maxi (x:xs)

sumi :: [Int] -> Int
sumi = foldr (+) 0

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

using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define pb push_back
#define int long long

signed main(){

	string s;
	cin>>s;

	if(s[0]=='9'||s[1]=='9'){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  int a,b,c;
  cin>>a;
  b=a/500*1000;
  a%=500;
  c=a/5*5;
  cout<<b+c;
}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()
cnt = 0
for i, a in enumerate(A):
    idx = i + 1
    if idx % 2 != 0 and a % 2 != 0:
        cnt += 1
print(cnt)

Measured memory_bytes: 9976
#include<stdio.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define IFY 2000000000
#define MAX 10000
#define NIL -1
struct Node {int parent,left,right;};
Node T[MAX];
int n,D[MAX],H[MAX];
void setdepth(int u,int d){
  if(u==NIL) return;
  D[u]=d;
  setdepth(T[u].left,d+1);
  setdepth(T[u].right,d+1);
}
int setheight(int u){
  int h1=0,h2=0;
  if(T[u].left!=NIL) h1=setheight(T[u].left)+1;
  if(T[u].right!=NIL) h2=setheight(T[u].right)+1;
  return H[u]=(h1>h2?h1:h2);
}
int getsibling(int u){
  if(T[u].parent==NIL) return NIL;
  if(T[T[u].parent].left!=NIL&&T[T[u].parent].left!=u) return T[T[u].parent].left;
  if(T[T[u].parent].right!=NIL&&T[T[u].parent].right!=u) return T[T[u].parent].right;
  return NIL;
}
void print(int u){
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getsibling(u));
  int deg=0;
  if(T[u].left!=NIL) deg++;
  if(T[u].right!=NIL) deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);
  if(T[u].parent==NIL) printf("root\n");
  else if(T[u].left==NIL&&T[u].right==NIL) printf("leaf\n");
  else printf("internal node\n");
}
int main(){
  int root=0,v,l,r;
  scanf("%d",&n);
  REP(i,n) T[i].parent=NIL;
  REP(i,n){
    scanf("%d %d %d",&v,&l,&r);
    T[v].left=l;
    T[v].right=r;
    if(l!=NIL) T[l].parent=v;
    if(r!=NIL) T[r].parent=v;
  }
  REP(i,n) if(T[i].parent==NIL) root=i;
  setdepth(root,0);
  setheight(root);
  REP(i,n) print(i);
  return 0;
}

Measured memory_bytes: 2716
from collections import Counter
S = input()
T = input()

cntS = Counter(S).most_common()
cntT = Counter(T).most_common()

Ans = "Yes"
if len(cntS)==len(cntT):
    for i in range(len(cntT)):
        if cntS[i][1] != cntT[i][1]:
            Ans = "No"
else:
    Ans = "No"

print(Ans)

Measured memory_bytes: 4144
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <numeric>
#include <set>
#include <map>
#include <list>
#include <bitset>
#define debug(x) cout << #x << ": " << (x) << endl
using namespace std;

const double PI  = 3.141592653589793238463;
const int INF = 1000000007;

using ull = unsigned long long;
using ll = long long;

using Int = int;
using Double = double;

using P = pair<Int, Int>;
using V = vector<Int>;
using M = vector<V>;

string solve(int a, int b, int c){
    if(b - a == c - b){
        return "YES";
    }else{
        return "NO";
    }
}


int main(int argc, char* argv[]){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int a, b, c;
    cin >> a >> b >> c;
    cout << solve(a, b, c) << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<algorithm>
#define lk (k<<1)
#define rk (k<<1|1)
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const int N=1e5+10;
int main()
{
    int n;
    ll d;
    cin>>n>>d;
    d=d*d;
    ll x,y,ans=0;
    for(int i=1;i<=n;i++)
    {
        cin>>x>>y;
        x=abs(x);
        y=abs(y);
        if((x*x+y*y)<=d) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3620
//Header files
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;

//Short data-types declaration
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<string> vs;
typedef vector<vector<int> > vii;  
typedef vector<vector<long long> >vll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vbb;

//Macros
#define MK make_pair
#define EB emplace_back
#define PB push_back
#define F first
#define S second
#define rep(i,start,end) for(int i=(int)start;i<(int)end;i++)

void solve()
{
	char c;
	cin>>c;
	if(islower(c))
		cout<<"a\n";
	else
		cout<<"A\n";
}
int main()
{
	auto start = high_resolution_clock::now();
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int t=1;
	while(t--)
		solve();
	auto stop = high_resolution_clock::now(); 
	auto duration = duration_cast<microseconds>(stop - start); 
	cerr<<duration.count()<<" microseconds\n";
	return 0;
}

Measured memory_bytes: 3644
n = int(input())
graph = [[0 for i in range(n)] for j in range(n)]
d = [0] * n
f = [0] * n
queue = [0]


for i in range(n):
   a = list(map(int, input().split()))
   for j in range(0, a[1], 1):
       graph[a[0] - 1][a[2 + j] - 1] = 1

f[0] = 1
while len(queue) != 0:
    i = queue.pop(0)
    for j in range(n):
        if (graph[i][j] == 1) & (f[j] == 0):
            queue.append(j)
            f[j] = 1
            d[j] = d[i] + 1

[print(i+1, d[i] if (i == 0) | (d[i] != 0) else -1) for i in range(n)]


Measured memory_bytes: 5716