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

bool judge(string str)
{
    int num = 0;
    for (int i = 0; i < str.length() / 2; i++)
    {
        if (str[i] == str[str.length() - i - 1])
            num++;
    }
    if (num == str.length() / 2)
        return true;
    else
        return false;
}

int main()
{
    string s, s_pre, s_least;
    s_pre = "";
    s_least = "";
    cin >> s;
    for (int i = 0; i < s.length() / 2; i++)
        s_pre += s[i];
    for (int i = s.length() / 2 + 1; i < s.length(); i++)
        s_least += s[i];

    if (judge(s) && judge(s_pre) && judge(s_least))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

constexpr llong mod = 1e9+7;
constexpr llong inf = mod * mod;

struct node {
  llong place;
  llong cost;
  llong before;

  node() {};
  node(llong place, llong cost, llong before) :
    place(place),
    cost(cost),
    before(before)
  {}

  bool operator<(const node &ri) const {
    return cost < ri.cost;
  }
  bool operator<=(const node &ri) const {
    return cost <= ri.cost;
  }
  bool operator>(const node &ri) const {
    return cost > ri.cost;
  }
};

vector<vector<node> > edges;

vector<vector<node>> dijkstra(int start) {
  using np = pair<node, int>;
  priority_queue<np, vector<np>, greater<np> > que;
  vector<vector<node>> dis(edges.size(), vector<node>(3, node(-1, inf, -1)));
  dis[start][0] = node(start, 0, -1);

  que.push(np(dis[start][0], 0));
  while (que.size()) {
    np check = que.top();
    que.pop();
    node now = check.first;
    int idx = check.second;
    if (dis[now.place][idx] < now) continue;
    now = dis[now.place][idx];

    for (auto &edge: edges[now.place]) {
      node next(edge.place, now.cost + edge.cost, now.place);
      if(dis[next.place][(idx + 1) % 3] <= next) continue;
      dis[next.place][(idx + 1) % 3] = next;
      que.push(np(next, (idx + 1) % 3));
    }
  }

  return dis;
}

int main() {
  llong N, M;
  cin >> N >> M;
  edges.resize(N + 1);
  for (int i = 0; i < M; i++) {
    llong u, v;
    cin >> u >> v;
    edges[u].push_back(node(v, 1, v));
  }

  llong S, T;
  cin >> S >> T;
  auto ans = dijkstra(S);

  cout << (ans[T][0].cost == inf ? -1 : ans[T][0].cost / 3) << endl;

  return 0;
}

Measured memory_bytes: 18836
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn f(a:&Vec<i64>, p: &Vec<i64>, n:usize, x:i64) -> i64{
    if n==0 {
        if x<=0 {
            return 0;
        }else{
            return 1;
        }
    }else if x<=1+a[n-1] {
        return f(a, p, n-1, x-1);
    }else{
        return p[n-1] + 1 + f(a,p, n-1, x-2-a[n-1]);
    }

}
fn main() {
    input!{
        n: usize,
        x: i64,
    }
    let mut a:Vec<i64> = vec![0;n+1];
    let mut p:Vec<i64> = vec![0;n+1];
    a[0]=1;
    p[0]=1;
    for i in 0..n {
        a[i+1] = 2*a[i]+3;
        p[i+1] = 2*p[i]+1;
    }
    let ans = f(&a, &p, n,x);
    println!("{}", ans);
}

Measured memory_bytes: 4352
#include<stdio.h>

int main(void){

    int a[100];

    int t,b,temp,s,l,q,r;

    scanf("%d",&b);

    for(t=0;t<b;t++){
       scanf("%d",&a[t]);
    }

    for(s=0;s<b-1;s++){
       printf("%d ",a[s]);
    }
    printf("%d\n",a[b-1]);

    for(t=1;t<b;t++){
       l = t-1;
       q=t;
       r=l;
       while(a[l]>a[t]){
            temp=a[l];
            a[l]=a[t];
            a[t]=temp;
            if(t!=1){
              l--;
              t--;
            }
       }
       t=q;
       l=r;
       for(s=0;s<b-1;s++){
          printf("%d ",a[s]);
       }
       printf("%d\n",a[b-1]);
    }

    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int n;
	cin >> n;
	
	set<string> st;
	for(int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		
		st.insert(s);
	}
	
	cout << st.size() << endl;
	
	return 0;
}


Measured memory_bytes: 19124
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;
using ll = long long;

const ll MOD = 1000000007;
const ll INF = 1e18;
const double pi = acos(-1);
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1,1,0,-1,-1,-1,0,1};
const int dy8[8] = {0,1,1,1,0,-1,-1,-1};


#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()


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



void solve(){
    
    // remove the bottom 3 lines when you submit this code.
    std::ifstream in("sample.txt");
    std::cin.rdbuf(in.rdbuf());

    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    
    bool isExistOne = false;
    int sunuke = n+1;
    rep(i,n){
        if(a[i]==1) {
            isExistOne = true;
            sunuke = 1;
        }
        if(a[i] == sunuke+1 && isExistOne){
            sunuke++;
        }
    }
    
    cout << n - sunuke << endl;
    
}



signed main() {
    solve();
    return 0;
}



Measured memory_bytes: 1024
def popcnt(num):
    return bin(num).count('1')

# a -> bにする手順 (制約なし)
def solve(n, a, b):
    c = a ^ b
    # 0 -> a ^ b, popcnt(c)は奇数である必要がある
    if popcnt(c) % 2 == 0:
        print('NO')
        exit(0)
    return [i ^ a for i in solve2(n, c)]

# 0 -> cにする手順 (c: popcntは奇数)
def solve2(n, c):
    c_1 = popcnt(c)
    d = (1 << c_1) - 1  # 0..01..1
    ret_d = solve3(n, d, c_1)
    ret_c = move(ret_d, n, d, c)
    return ret_c

# 0 -> dにする手順 (d: 0..01..1)
def solve3(n, d, cnt):
    if n == cnt:
        return solve4(n)
    ret = []
    a = graycode(n - cnt)
    a_rev = a[::-1]
    b = solve4(cnt)
    flg = True
    for i in b:
        if flg:
            for j in a:
                ret.append(merge(j, i, cnt))
        else:
            for j in a_rev:
                ret.append(merge(j, i, cnt))
        flg = not flg
    return ret

# 0 -> (1<<n)-1 にする手順 (d: 1..1)
def solve4(n):
    if n == 1:
        return [0, 1]
    # 0 + 0 * (n - 1) -> 0 + 1 + 0 * (n - 2)
    # 1 + 1 + 0 * (n - 2) -> 1 + 1 * (n - 1) : 再帰的に
    ret = graycode(n - 1) + [(1 << (n - 1)) | i for i in solve(n - 1, 1 << n - 2, mask(n - 1))]
    return ret

# nビットのグレイコード
def graycode(n):
    ret = []
    for i in range(1 << n):
        ret.append(i ^ (i >> 1))
    return ret

# bitの移し換え 001111 -> 011011
def move(lst, n, d, c):
    l = [-1] * n
    c_0, c_1 = popcnt(c), 0
    for i in range(n):
        if c & (1 << i):
            l[c_1] = i
            c_1 += 1
        else:
            l[c_0] = i
            c_0 += 1
    ret = []
    for i in lst:
        k = 0
        for j in range(n):
            if i & (1 << j):
                k |= 1 << l[j]
        ret.append(k)
    return ret

# aとbを繋げる
def merge(a, b, margin):
    return (a << margin) + b

# nビットのマスク
def mask(n):
    return (1 << n) - 1

n,a,b = map(int,input().split())
res = solve(n, a, b)
print('YES')
print(*res)
# for i in res:
#     print(bin(2 ** n + i)[3:])
# print("len :", len(res))


Measured memory_bytes: 65792
N, Q = map(int, input().split())
S = input()
A = [0]*(N-1)
B = [0]
C = []
for n in range(N-1):
    if S[n:n+2] == "AC":
        A[n] += 1
for n in range(N-1):
    B.append(B[n]+A[n])
for n in range(Q):
    l, r = map(int, input().split())
    C.append(B[r-1]-B[l-1])
for n in range(Q):
    print(C[n])

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> L(N);
  for (int i = 0; i < N; i++) {
    cin >> L[i];
  }
  sort(L.begin(), L.end());
  L.emplace_back(1 << 28);
  int res = 0;
  for (int i = 0; i < N - 2; i++) {
    for (int j = i + 1; j < N - 1; j++) {
      int k = N - (lower_bound(L.begin(), L.end(), L[i] + L[j]) - L.begin());
      res += N - j - k - 1;
    }
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 1e4+5;

int main() {
    int t,n,m;
    scanf("%d %d %d",&n,&m,&t);
    if((n==m||n==t||m==t)&&!(n==m&&n==t&&t==m)){
        printf("Yes\n");
    }
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

p = Array.new(n, 0)
p[0] = a[0]
for i in (1...n)
    p[i] = p[i-1] + a[i]
end

l = Array.new(n, 0)
for i in (0...n)
    l[i] = l[i-1] if i > 0 && l[i-1] > 0
    l[i] += a[i] if a[i] > 0
end
r = Array.new(n, 0)
for i in (n-1).step(0, -1)
    r[i] = r[i+1] if i < n-1 && r[i+1] > 0
    r[i] += a[i] if a[i] > 0
end

sol = 0
for i in (0..(n-k))
    x = 0
    x += l[i-1] if i>0
    x += r[i+k] if i+k<n
    sol = [sol, x].max
    x += p[i+k-1]-p[i]+a[i]
    sol = [sol, x].max
end
puts sol
    
    
    
    
    
    
    
    

Measured memory_bytes: 13588
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
#define pb push_back
#define mk make_pair
#define pi pair<int, int>
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i,a,b) for(int i=a;i>=(b);--i)
using namespace std;
int dt[][2]= {{1,0},{-1,0},{0,1},{0,-1},{0,0}};
//typedef pair<int, int> P;
//priority_queue<int, vector<int>, greater<int> > q;
int main()
{
   string s;
   cin >> s;
   ll sum = 0;
   for(int i=0;i<s.length();++i)
   {
       sum += s[i]-'0';
   }
   if(sum % 9 == 0)cout << "Yes";
   else cout << "No";
}


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


bool ok(int x,vector<long long>&D)
{
    while(x)
    {
        int d = x%10;
        if(find(D.begin(),D.end(),d)!=D.end())
        {
            return false;
        }
        x/=10;
    }
    return true;
}
void solve(long long N, long long K, std::vector<long long> D){
    for(int x=N;;x++)
    {
        if(ok(x,D))
        {
            cout<<x<<endl;
            return;
        }
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> D(K);
    for(int i = 0 ; i < K ; i++){
        scanf("%lld",&D[i]);
    }
    solve(N, K, std::move(D));
    return 0;
}


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

using namespace std;

int main(void){
     int n;
    cin >> n;
    std::vector<int> h;
    int maxx[n]; 
    for(int i=0; i<n; i++){
        int hi;
        cin >> hi;
        h.push_back(hi);
    }
    maxx[n-1] =0;  
    maxx[n-2] = abs(h[n-2]-h[n-1]);
    for(int i=n-3; i>=0; i--){
        maxx[i] = std::min(maxx[i+1]+abs(h[i+1]-h[i]),maxx[i+2]+abs(h[i+2]-h[i]));
    }
    cout << maxx[0];
    return 0;
}


Measured memory_bytes: 1144
#include<iostream>
#include<cstdio>
#include<cassert>
#include<climits>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define IINF (INT_MAX)
#define MAX 5001

using namespace std;

typedef pair<int,int> ii;

struct Data
{
  int cur,cost;
  Data(int cur=IINF,int cost=IINF):cur(cur),cost(cost){}
  bool operator < (const Data& a)const
  {
    return cost > a.cost;
  }
};

int N,E;
int C[MAX],R[MAX];
vector<int> pG[MAX];
vector<Data> G[MAX];
int mincost[MAX];
bool visited[MAX];


void makeGraph()
{
  rep(sp,N)
    {
      rep(i,N)visited[i] = false;
      visited[sp] = true;
      queue<Data> Q;
      Q.push(Data(sp,-R[sp]));
      while(!Q.empty())
	{
	  Data data = Q.front(); Q.pop();
	  int remain = -data.cost;

	  if(remain <= 0)continue;

	  rep(i,pG[data.cur].size())
	    {
	      int next = pG[data.cur][i];
	      if(!visited[next])
		{
		  visited[next] = true;
		  G[sp].push_back(Data(next,C[sp]));
		  Q.push(Data(next,-(remain-1)));
		}
	    }
	}
    }

  rep(i,N)pG[i].clear();

}

void dijkstra()
{
  priority_queue<Data> Q;
  Q.push(Data(0,0));
  rep(i,N)mincost[i] = IINF;
  mincost[0] = 0;

  while(!Q.empty())
    {
      Data data = Q.top(); Q.pop();

      if(data.cur == N-1)
	{
	  cout << data.cost << endl;
	  return;
	}

      rep(i,G[data.cur].size())
	{
	  int next = G[data.cur][i].cur;
	  int cost = G[data.cur][i].cost;
	  if(mincost[next] > data.cost + cost)
	    {
	      mincost[next] = data.cost + cost;
	      Q.push(Data(next,data.cost+cost));
	    }
	}
    }
}

int main()
{
  cin >> N >> E;
  rep(i,N)
    {
      cin >> C[i] >> R[i];
    }

  rep(i,E)
    {
      int A,B;
      cin >> A >> B;

      A--, B--;
      pG[A].push_back(B);
      pG[B].push_back(A);
    }

  makeGraph();

  dijkstra();

  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)n; i++)

using namespace std;
using ll = long long;

bool isPrime(int x) {
  if (x == 2) return true;
  if (x < 2 || x % 2 == 0) return false;

  int i = 3;
  while (i <= sqrt(x)) {
    if (x % i == 0) return false;
    i += 2;
  }

  return true;
}

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

  int a[n];
  rep(i, n) cin >> a[i];

  int result = 0;
  rep(i, n) {
    if (isPrime(a[i])) result++;
  }

  cout << result << endl;

  return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep2(i, a, b) for(int i = (a); i < (b); i++)
typedef long long ll;

int main() {
   int x, a;
   cin >> x >> a;

   if (x < a) cout << 0 << endl;
   else cout << 10 << endl;
}

Measured memory_bytes: 256
n, a = input(), map(int, raw_input().split())

def f(x):
    if x % 4 == 0:
        return 4
    elif x % 2 == 0:
        return 2
    return 1

c = [0] * 5

for i in xrange(n):
    c[f(a[i])] += 1

print 'Yes' if c[4] >= c[1] or (c[2] == 0 and c[4] + 1 == c[1]) else 'No'


Measured memory_bytes: 41068
#include<iostream>

using namespace std;

int main(){
    int n,k,d;
    int snk[n+1]={0};
    cin>>n>>k;
    
    for(int i=0;i<k;i++){
        cin>>d;
        int a[d];
        for(int j=0;j<d;j++){
            cin>>a[j];
            snk[a[j]]++;
        }
    }
    
    int c=0;
    for(int i=1;i<n+1;i++){
        if(snk[i]==0)
            c++;
    }
    
    cout<<c<<endl;
}

Measured memory_bytes: 3676
#include<iostream>
using namespace std;
void solve(string buf){
	string ans="";
	ans+=buf[0];
	int target=0;
	for(string::iterator it=buf.begin()+1;it!=buf.end();){
		//cout<<"ans:"<<ans<<endl;
		//cout<<*it<<endl;
		if(*it=='<'){
			it+=2;
			string tmp="";
			if(target-1<0){
				tmp+=*it;
				tmp+=ans;
				ans=tmp;
			}
			else{
				target--;
			}
			it++;
		}
		else if(*it=='-'){
			it+=2;
			if(target+1>=ans.size())ans+=*it;
			target++;
			it++;
		}
	}
	cout<<ans<<endl;

}
int main(){
	int d;
	
	string buf;
	cin>>d;
	for(int i=0;i<d;i++){
		cin>>buf;
		solve(buf);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;
 
typedef long long i64;
typedef pair<int, int> pi;
 
template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
 
i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

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

  int n;
  string s;
  cin >> n >> s;

  int ans = 0;
  int a = 0, b = 0, c = 0;
  rep(i, 0, 1000) {
    int j = 0;
    bool find = false;
    while(j < n && !find) {
      if((s[j] - '0') == a) find = true;
      j++;
    }

    if(find) {
      find = false;
      while(j < n && !find) {
        if((s[j] - '0') == b) find = true;
        j++;
      }

      if(find) {
        find = false;
        while(j < n && !find) {
          if((s[j] - '0') == c) find = true;
          j++;
        }

        if(find) ans++;
      }
    }

    c++;
    b += c / 10; c %= 10;
    a += b / 10; b %= 10;
  }
  cout << ans << endl;
}

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

using namespace std;

int main()
{
    int n,k;
    cin >> n >> k;
    
    int ans=0;
    for(int i=0;i<n;i++){
        int h;
        cin >> h;
        if(h>=k) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
a,b,c,x,y=gets.split.map(&:to_i)
 
result=[]
max=[x,y].max
min=[x,y].min
max_price=0
if max==x
    max_price=a
else
    max_price=b
end

result<<2*c*max
result<<2*c*min+(x-y).abs*max_price

result<<a*x+b*y
#p result
p result.min


Measured memory_bytes: 14256
#include<bits/stdc++.h>
using namespace std;
int main() {
   cin.tie(0);
   ios::sync_with_stdio(false);
   int n, m;
   cin >> n >> m;
   if(n==m) {
       cout << "Yes" << endl;
   } else {
       cout << "No" << endl;
   }
}

Measured memory_bytes: 256
#include<stdio.h>

main()
{
    int n,flag=0,res;
    scanf("%d",&n);

    while(n!=0)
    {
        res = n%10;
        n/=10;
        if(res==7)
        {
            flag=1;
            break;
        }
    }
    if(flag)
        printf("Yes");
    else
        printf("No");
}


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

int main(){
  int k,s;
  cin>>k>>s;
  int counter=0;
  for(int i=0;i<=k;i++){
    for(int j=0;j<=k;j++){
      if(0<=s-i-j&&s-i-j<=k)counter++;
    }
  }
  cout<<counter<<endl;
}

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

int main(){
    int N, K;
    cin >> N >> K;
    int a[N];
    for(int i = 0; i < N; i++) cin >> a[i];

    ll sum[N];
    ll sumOfPlus[N];
    sum[0] = a[0];
    sumOfPlus[0] = max(0, a[0]);
    for(int i = 1; i < N; i++){
        sum[i] = sum[i-1] + a[i];
        sumOfPlus[i] = sumOfPlus[i-1] + max(0, a[i]);
    }

    ll ans = sum[K-1] + sumOfPlus[N-1] - sumOfPlus[K-1];
    ans = max(ans, sumOfPlus[N-1] - sumOfPlus[K-1]);
    for(int i = 1; i <= N-K; i++){
        ans = max(ans, sum[i+K-1] - sum[i-1] + sumOfPlus[N-1] - sumOfPlus[i+K-1] + sumOfPlus[i-1]);
        ans = max(ans, sumOfPlus[N-1] - sumOfPlus[i+K-1] + sumOfPlus[i-1]);
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 2176
n=int(input())
v=list(map(int,input().split()))
ans=[]
for i in range(n):
    ans.append(v[i])
    a=v[i]+1
    ans.append(a)
    b=v[i]-1
    ans.append(b)
from collections import Counter
data=Counter(ans)
print(data.most_common(1)[0][1])


Measured memory_bytes: 25972
# D
N, Q = map(int, input().split())
A_list = list(map(int, input().split()))
q_list = [0]*Q
for i in range(Q):
    q_list[i] = int(input())

# precompute

# res
M = (N+1)//2
S1 = [0]*M
S2 = [0]*M

s1 = 0
s2 = 0
for i in range(M):
    s1 += A_list[N-1-i]
    S1[i] = s1
    s2 += A_list[N-1-2*i]
    S2[i] = s2

# bins
bins = [0]*(M-1)
for i in range(M-1):
    bins[i] = (A_list[N - (i+2)] + A_list[N - (2*i+3)]) / 2

# function for binary search
def bisearch(q):
    
    if q > bins[0]:
        return 0
    elif q <= bins[M-2]:
        return M - 1
    
    l = 0
    r = M - 2
    while l < r - 1:
        m = (l + r) // 2
        if q > bins[m]:
            r = m
        else:
            l = m
    return l+1
    
    
if N > 2:
    # first conflict
    for q in q_list:
        r = bisearch(q)
        print(S1[r]+s2-S2[r])
else:
    for q in q_list:
        print(A_list[1])

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

# define REP(i,n) for (int i=0;i<(n);++i)

const ll INF = 1LL << 50;

int N, M;
const int NMAX = 1000;
const int MMAX = 2000;
int a[MMAX], b[MMAX];
ll c[MMAX];
ll dist[NMAX];

bool find_negative_loop(){
    REP(i,N) dist[i] = 0;

    REP(i,N) REP(j,M){
      if(dist[b[j]-1] > dist[a[j]-1] + c[j]-1){
        dist[b[j]-1] = dist[a[j]-1] + c[j]-1;

        if(i == N-1) return true;
      }
    }
    return false;
}


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

  for (int i = 0; i < M; ++i) {
    cin >> a[i] >> b[i] >> c[i];
    c[i] = -c[i];
  }
  
  for (int i = 0; i < N; ++i) {
    dist[i] = INF;
  }

  dist[0] = 0;
  for (int loop = 0; loop < N - 1; ++ loop) {
    for (int i = 0; i < M; ++i) {

    if (dist[a[i] - 1] == INF) continue;

    if (dist[b[i] - 1] > dist[a[i] - 1] + c[i]) {
        dist[b[i] - 1] = dist[a[i] - 1] + c[i];
      }
    }
  }

  ll ans = dist[N - 1];

  bool negative[NMAX];

  for (int i = 0; i < N; ++i) {
    negative[i] = false;
  }

  for (int loop = 0; loop < N ; ++ loop) {
    for (int i = 0; i < M; ++i) {
      if (dist[a[i] - 1] == INF) continue;

      if (dist[b[i] - 1] > dist[a[i] - 1] + c[i]) {
        dist[b[i] - 1] = dist[a[i] - 1] + c[i];
        negative[b[i] - 1] = true;
      }

      if (negative[a[i] - 1] == true) {
        negative[b[i] - 1] = true;
      }
    }
  }

  if (negative[N-1])
    cout << "inf" << endl;
  else
    cout << -ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int sum, a, b, temp;
  scanf("%d %d", &a, &b);
  if(a > b) {
    temp = a;
    a = b;
    b = temp;
  }
  sum = (a == b)? a+b : 2*b - 1;
  printf("%d\n", sum);
  return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n + n; i++) {
    cin >> (i < n ? a[i] : b[i - n]);
  }
  priority_queue<pair<int, int>> que;
  for (int i = 0; i < n; i++) {
    que.emplace(b[i], i);
  }
  long long ans = 0;
  while (que.size()) {
    int i = que.top().second;
    que.pop();
    int nbr = b[(i - 1 + n) % n] + b[(i + 1) % n];
    if ((b[i] - a[i]) % nbr == 0) {
      ans += (b[i] - a[i]) / nbr;
      b[i] = a[i];
      continue;
    }
    if (nbr >= b[i]) {
      cout << -1 << endl;
      return 0;
    }
    ans += b[i] / nbr;
    b[i] %= nbr;
    if (b[i] < a[i]) {
      cout << -1 << endl;
      return 0;
    }
    que.emplace(b[i], i);
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
  int n;
  cin >> n;
  vector<int> v(n);
  vector<int> c(n);

  for (int i = 0; i < n * 2; i++)
  {
    if (i < n)
    {
      cin >> v[i];
    }
    else
    {
      cin >> c[i - n];
    }
  }
  int ans = 0;
  for (int i = 0; i < n; i++)
  {
    int buf = v[i] - c[i];
    if (buf > 0)
    {
      ans += buf;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
# Luis Yoichi Morales January 2019

from sys import stdin

h=[]
for i in range (2):
    h.append( stdin.readline().split() )

if h[0][0] == h[1][0][::-1] and h[1][0] == h[0][0][::-1]:
    print 'YES'
else:
    print 'NO'



Measured memory_bytes: 2568
#include <iostream>

using namespace std;
 
typedef long long ll;
const ll mod = 1e9 + 7;

int main() {
    int H, W, K;
    cin >> H >> W >> K;

    ll dp[102][8] = {0};
    dp[0][0] = 1;

    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            // bit の有無で横棒を表現
            for (int bit = 0; bit < 1<<(W-1); bit++) {
                bool is_valid = true;
                for (int k = 0; k < W - 2; k++) {
                    // 連続して bit が立っていたら invalid
                    if ( ((bit >> k) & 1) && ((bit >> (k + 1)) & 1) ) {
                        is_valid = false;
                    }
                }
                if (!is_valid) { continue; }
                // j 番目の bit が立っていた => 右側に遷移する
                if (bit >> j & 1) {
                    dp[i+1][j+1] += dp[i][j];
                    dp[i+1][j+1] %= mod;
                }
                // j-1 番目の bit が立っていた => 左側に遷移する
                else if ((bit >> (j - 1)) & 1) {
                    dp[i+1][j-1] += dp[i][j];
                    dp[i+1][j-1] %= mod;
                }
                // どちらの bit も立っていない => そのまま下に遷移
                else {
                    dp[i+1][j] += dp[i][j];
                    dp[i+1][j] %= mod;
                }
            }
        }
    }

    cout << dp[H][K-1] << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	int height[n];
	for(int i = 0; i<n;i++){
		cin>>height[i];
	}
	int cost[n];
	cost[0] = 0;
	for(int i = 1;i<n;i++){
		int j = i-1;
		int step = 1;
		cost[i] = INT_MAX;
		while(j>=0 && step <=k){
		   cost[i] = min(cost[i], cost[j] + abs(height[i] - height[j]));
		   j--;
		   step++;	
		}
		
	}
	cout<<cost[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,num=0;
  cin>>N;
  vector<int> d(N);
  for(int i=0;i<N;i++){
    cin>>d.at(i);
  }
  sort(d.begin(),d.end());
  for(int i=0;i<N;i++){
    if(i){
      if(d.at(i)==d.at(i-1)) continue;
    }
    num++;
  }
  cout<<num<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define MAXN 100000
int main(int argc,char const* argv[])
{
  int n,i,a,push=0,now=1;
  vector<int>v;
  cin >> n;
  for(i=0;i<n;i++)
    {
      cin >> a;
      v.push_back(a);
    }
  while(1)
    {
      if(now==2)
	{
	  cout << push << endl;
	  break;
	}
      if(push>=n)
	{
	  cout << -1 << endl;
	  break;
	}
      push++;
      now=v[now-1];
    }
  return 0;
}


Measured memory_bytes: 892
import java.util.*;

public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    long m = sc.nextLong();
    long[] A = new long[n+1];

    for (int i = 1; i <= n; i++) {
      A[i] = (A[i-1] + sc.nextLong()) % m;
    }

    Arrays.sort(A);

    long tmp = 0;
    long tmp_count = 1;
    long ans = 0;

    for (int i = 1; i <= n; i++) {
      if (A[i] == tmp) {
        tmp_count++;
      } else {
        ans += tmp_count * (tmp_count - 1) / 2;
        tmp = A[i];
        tmp_count = 1;
      }
    }

    ans += tmp_count * (tmp_count - 1) / 2;

    System.out.println(ans);
  }
}


Measured memory_bytes: 62188
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        long k = sc.nextLong();
        char ans = '1';
        char t;
        for(int i = 0; i < Math.min(k, s.length()); i++){
            if((t = s.charAt(i)) != '1'){
                ans = t;
                break;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23508
#include <iostream>
#include <vector>
#include <cmath>
#define LIM 100002

using namespace std;

int main(void) {
	vector<bool> prime(LIM);
	for (int i = 0; i < LIM; i++) {
		prime[i] = true;
	}
	prime[0] = false;
	prime[1] = false;
	for (int i = 2; i <= sqrt(LIM); i++) {
		if (prime[i]) {
			for (int j = 2; i*j < LIM; j++) {
				prime[i*j] = false;
			}
		}
	}
	for (int i = LIM; i > 2; --i) {
		if (prime[i]) {
			if(!(prime[(i+1)/2])) {
				prime[i] = false;
			}
		}
	}

	vector<int> data(LIM);
	data[1] = 0;
	for (int i = 3; i < LIM; i = i+2) {
		data[i] = data[i-2];
		if (prime[i]) {
			++data[i];
		}
	}

	int Q;
	cin >> Q;
	for (int i = 0; i < Q; ++i) {
		int l,r;
		cin >> l >> r;
		if (l != 1) {
			l -= 2;
		}
		cout << data[r]-data[l] << endl;
	}

	return 0;
}


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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

signed main() {
    int N;
    cin>>N;
    int ans=0;
    for(int i=1;i<=N;i+=2){
        int cur=0;
        for(int j=1;j<=i;j++){
            if(i%j==0)cur++;
        }
        if(cur==8)ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n,m,a[100],ans=0;
  double total=0;
  scanf("%d%d",&n,&m);
  for (int i=0;i<n;i++) {
    scanf("%d",&a[i]);
    total+=a[i];
}
  for (int i=0;i<n;i++){
  if (1.0/(4*m) <= a[i]/ total) ans++;
}
  if (ans>=m)printf("Yes");
  else printf("No");

  return 0;


}


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

int main(){
    int a, b, k;
    cin >> k >> a >> b;
    string ans = "NG";
    for(int i = a; i <= b; i++){
        if(i % k == 0){
            ans = "OK";
            break;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

const int maxn = 110;
const int maxk = 1e5+10;

int dp[maxk], num[maxn];

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

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

	for (int i = 1; i <= k; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			if (num[j] > i) break;

			dp[i] = dp[i] | (!dp[i-num[j]]);
		}
	}

	if (dp[k]) cout << "First\n";
	else cout << "Second\n";
}

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

int main(void){
  int H,W;
  int i,j,k;
  char str[30][30][6];
  char str2[]="snuke";
  scanf("%d %d",&H,&W);
  for(i=0;i<H;i++){
    for(j=0;j<W;j++){
      scanf("%s",str[i][j]);
    }
  }
  for(i=0;i<H;i++){
    for(j=0;j<W;j++){
      if(strcmp(str[i][j],str2) == 0){
	printf("%c%d\n",j+65,i+1);
      }
    }
  }
  return 0;
}


Measured memory_bytes: 128
X, Y = map(int, input().split())
 
prices = {1: 300000, 2: 200000, 3: 100000}
 
ans = 0
if X < 4:
    ans += prices[X]
 
if Y < 4:
    ans += prices[Y]
 
if Y == 1 and X == 1:
    ans += 400000
 
print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int N, K;
  cin >> N >> K;
  vector<int> a(N);
  int sum = 0;
  for(int i = 0; i < N; i++) {
    cin >> a[i];
  }
  
  sort(a.begin(),a.end(), greater<int>());
  
  for(int i = 0; i < K; i++){
    sum += a[i];
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;++x)
#define Red(x,y,z) for(int x=y;x>=z;--x)
using namespace std;
const int MAXN=2005,Mod=924844033;
inline int read(){
	int p=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9')ch=='-'?p=-1:0,ch=getchar();
	while(ch>='0'&&ch<='9')x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return p*x;
}
int n,k,tot,vis[MAXN<<1],F[MAXN<<1][MAXN][2],Fac[MAXN];
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read(),k=read();
	Fac[0]=1;Rep(i,1,n)Fac[i]=1ll*Fac[i-1]*i%Mod;
	Rep(i,1,k)for(int t=1;t<=2;t++)for(int j=i;j<=n;j+=k){
		++tot;if(j!=i)vis[tot]=1;
	}F[0][0][0]=1;
	Rep(i,1,2*n){
		Rep(j,0,n){
			F[i][j][0]=(F[i-1][j][0]+F[i-1][j][1])%Mod;
			if(vis[i]&&j)F[i][j][1]=F[i-1][j-1][0];
		}
	}int Ans=0;
	for(int i=0,t=1;i<=n;i++,t=-t)Ans=(Ans+1ll*t*(F[2*n][i][0]+F[2*n][i][1])*Fac[n-i])%Mod;
	cout<<(Ans+Mod)%Mod;
	return 0;
}


Measured memory_bytes: 66228
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x,y) for(ll i=x;i<=y;i++)
#define imin INT_MIN
#define imax INT_MAX
int mod =1e9+7;
//~ vector<bool> cats;

//~ ll ans;
//~ ll n,m;
//~ void dfs(vector<vector<int>>& graph,int s,int consCats,int parent){
	//~ if(consCats>m) return;
	//~ if(graph[s].size()==1 && graph[s][0]==parent)
	//~ {
		//~ if(cats[s]) consCats++;
		//~ if(consCats<=m) ans++;
		//~ return;
	//~ }
	//~ if(!cats[s]) consCats=0;
	//~ else consCats++;
	//~ for(auto val:graph[s]){
		//~ if(val!=parent)
		//~ dfs(graph,val,consCats,s);
	//~ }


int main(){
	cin.tie(NULL);
    ios_base::sync_with_stdio();

	ll n;
	cin>>n;
	vector<int> a(n);
	
	rep(i,0,n-1) cin>>a[i];
	sort(a.begin(),a.end());
	ll ans=0;
	int i=0;
	while(i<n-2){
		int j=i+1;
		int outer=0;
		
		while(j<n-1){
			int local=0;
			if(a[j]!=a[i])
			rep(k,j+1,n-1){
				if(a[k]!=a[j])
					if(a[i]+a[j]>a[k])
					local++;
			}
			int tmp=a[j];
			while(j<n-1 && a[j]==tmp) { 
				outer+=local;
				j++;
			}
		}
		int tmp=a[i];
		while(i<n-2 && a[i]==tmp){
		ans+=outer;
		i++;}
	}
	cout<<ans;
	
	return 0;
}


Measured memory_bytes: 3616
import java.io.*;
import java.util.*;

public class Main { // "Main" should be used for most online judges
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt(), g = sc.nextInt(), b = sc.nextInt();
		int result = 0;
		result = r * 100 + g * 10 + b;
		if (result % 4 == 0) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

	}
}

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

int n;
int niz[100002];
long long DP[100002][2];

int main() {
    cin >> n;
    for (int i=0; i<n; i++) cin >> niz[i];
    DP[0][0] = DP[0][1] = 0;
    DP[1][0] = DP[1][1] = abs(niz[0]-niz[1]);

    for (int i=2; i<n; i++) {
        DP[i][0] = min(DP[i-1][0], DP[i-1][1]) + abs(niz[i]-niz[i-1]);
        DP[i][1] = min(DP[i-2][0], DP[i-2][1]) +  abs(niz[i]-niz[i-2]);
    }

    cout << min (DP[n-1][0], DP[n-1][1]);
    return 0;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9+7;
const ll 	N 		= 	2*1e6;


// <------------- Declare Variables Here ------------> //

ll T=1;
ll n,x,y,m;
string s,t;
vll a;
// <------------- Implement Functions Here ----------> //

// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> s;
	cout<<s;
	if(s[s.size()-1]=='s') cout<<"e";
	cout<<"s\n";
}

int main() {
	fastio;randomINT;
	//cin>>T;
	while(T--) {
		MAIN();
	}
	return 0;
}



Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <algorithm>
using namespace std;

int main () {
    int n, k; cin >> n >> k;
    int ans = 0;
    while(true) {
        n /= k;
        ans++;
        if (n <= 0) {
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
// #define int long long
#define pb push_back
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;

template <class X> void print(X Target){ cout << Target << '\n'; }

void solve(vi a)
{
  for (int i = 0; i < a.size() - 1; i++){
    cout << a[i] << " ";
  }
  print(a[a.size() - 1]);
}

signed main()
{
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vi array(n);

  for (int i = 0; i < n; i++) cin >> array[i];

  for (int i = 1; i < n; i++){
    solve(array);
    for (int j = i; j >= 0 && array[j - 1] > array[j]; j--){
      swap(array[j - 1], array[j]);
    }
  }
  solve(array);

  return (0);
}

Measured memory_bytes: 1220
#include <bits/stdc++.h>
#define mst(a,b) memset(a,b,sizeof(a))
#define lowbit(x) ((x)&(-x))
#define X first
#define Y second
using namespace std;
typedef long long LL;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
//const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int maxn = 100000+10;
const double eps = 1e-9;
//const int maxm = 2510000+10;
bool is_prime[maxn];
int prime[maxn],id[maxn],tot;
ull seed=131;
ull f[maxn];
map<ull,int> cnt;
pair<ull,ull> a[maxn];
void init(){
    is_prime[1]=true;
    f[0]=1;
    for (int i=2;i*i<=100000;i++)
        if (!is_prime[i])
            for (int j=i*i;j<=100000;j+=i) is_prime[j]=true;
    for (int i=1;i<=100000;i++){
        if (!is_prime[i]) {
            prime[tot]=i;
            id[i]=tot++;
        } else id[i]=-1;
        f[i]=f[i-1]*seed;
    }
}
int main() {
#ifdef local
    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    init();
    int n; cin>>n;
    int ans=0;
    for (int i=0;i<n;i++){
        ll x; cin>>x;
        ull H=0,P=0;
        for (int j=0;j<350 && 1ll*prime[j]*prime[j]<=x;j++){
            if (x%prime[j]==0){
                int c=0;
                while (x%prime[j]==0){
                    c=(c+1)%3;
                    x/=prime[j];
                }
                H+=f[id[prime[j]]]*c;
                P+=f[id[prime[j]]]*((3-c)%3);
            }
        }
        if (x>1){
            if (x<=100000 && !is_prime[x]){
                H+=f[id[x]];
                P+=f[id[x]]*2;
            } else if (x>100000) {
                ll tmp=sqrt(x)+eps;
                if (tmp*tmp==x && !is_prime[tmp]){
                    H+=f[id[tmp]]*2;
                    P+=f[id[tmp]];
                } else {
                    ans++;
                    continue;
                }
            }
        }
        a[i].X=H; a[i].Y=P;
        cnt[H]++;
    }
    if (cnt.count(0)) {
        ans++;
        cnt[0]=0;
    }
    for (int i=0;i<n;i++){
        ull H=a[i].X,P=a[i].Y;
        ans+=max(cnt[H],cnt[P]);
        cnt[H]=0; cnt[P]=0;
    }
    cout<<ans<<"\n";
    return 0;
}


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

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

using namespace std;

typedef long long ll;

#define REP(i, n) for (int i = 0; i < int(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < int(b); i++)
#define FORD(i, a, b) for (int i = b - 1; i >= int(a); i--)
#define WRAP(y, x, h, w) (0 <= y && y < h && 0 <= x && x < w)

#define ALL(x) (x).begin(), (x).end()

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

int main()
{
    ll a, b, n;
    cin >> a >> b >> n;
    ll x=min(b-1,n);
    cout<<(a*x/b)-a*(x/b)<<endl;
}

Measured memory_bytes: 3600
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int main(){
	long long A,B,C;
	scanf("%lld%lld%lld",&A,&B,&C);
	long long ans=0;
	ans=B+min(B+A+1,C);
	printf("%lld\n",ans);
} 

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

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

    int c[N], t[N];
    for(int i=0; i<N; i++){
        cin >> c[i] >> t[i];
    }

    int c_min = 999999;

    for(int i=0; i<N; i++){
        if(t[i] <= T){
            c_min = min(c_min, c[i]);
        }
    }
    
    if(c_min == 999999){
        cout << "TLE" << endl;
    }else{
        cout << c_min << endl;
    }

    return 0;

}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}
func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0
	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}
	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
	writer.Flush()
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	k := getNextInt(scanner)
	mc := newModcom(n + k + 1)
	for i := 1; i <= k; i++ {
		if n-k+1 < 0 || n-k+1 < i {
			fmt.Fprintln(writer, 0)
			continue
		}
		fmt.Fprintln(writer, mc.choose(k-1, i-1).mul(mc.choose(n-k+1, i)))
	}
}

type modcom struct {
	facs, invs []mint
}

func newModcom(n int) modcom {
	facs := make([]mint, n+1)
	invs := make([]mint, n+1)
	facs[0] = 1
	for i := 0; i < n; i++ {
		facs[i+1] = facs[i].mul(mint(i + 1))
	}
	invs[n] = facs[n].inv()
	for i := n - 1; i >= 0; i-- {
		invs[i] = invs[i+1].mul(mint(i + 1))
	}
	return modcom{
		facs: facs,
		invs: invs,
	}
}
func (mc *modcom) choose(n, k int) mint {
	return mc.facs[n].mul(mc.invs[k]).mul(mc.invs[n-k])
}

type mint int64

func (mt mint) mod() mint {
	m := mint(1e9 + 7)
	mt %= m
	if mt < 0 {
		return mt + m
	}
	return mt
}
func (mt mint) inv() mint {
	var m, y mint
	m.subAs(2)
	dbl := mt
	y = 1
	for i := 0; i < 31; i++ {
		if m%2 == 1 {
			y.mulAs(dbl)
		}
		m >>= 1
		dbl.mulAs(dbl)
	}
	return y
}
func (mt mint) add(x mint) mint {
	return (mt + x).mod()
}
func (mt mint) sub(x mint) mint {
	return (mt - x).mod()
}
func (mt mint) mul(x mint) mint {
	return (mt * x).mod()
}
func (mt mint) div(x mint) mint {
	return mt.mul(x.inv())
}
func (mt *mint) addAs(x mint) *mint {
	*mt = mt.add(x)
	return mt
}
func (mt *mint) subAs(x mint) *mint {
	*mt = mt.sub(x)
	return mt
}
func (mt *mint) mulAs(x mint) *mint {
	*mt = mt.mul(x)
	return mt
}
func (mt *mint) divAs(x mint) *mint {
	*mt = mt.div(x)
	return mt
}


Measured memory_bytes: 768
n,m = map(int,input().split())
x_li = [0]*m
y_li = [0]*m
for i in range(m):
    x_li[i],y_li[i]=map(int,input().split())

map_li = [1]*n
red = [False]*n
red[0]=True

for i in range(m):
    x,y = x_li[i],y_li[i]
    x,y = x-1,y-1
    if red[x] and map_li[x]>1:
        red[y]=True
    elif red[x]:
        red[y]=True
        red[x]=False
    map_li[x]-=1
    map_li[y]+=1
#print(map_li)
print(sum(red))

Measured memory_bytes: 12404
#include <iostream>
#include <queue>
#include <map>
#include <algorithm>
#include <vector>
#include <cmath>
#include <numeric>

using namespace std;

const int INF = 100100100;

int main()
{
    int a, b;

    cin >> a >> b;

    cout << a - (a <= b ? 0 : 1) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1e5+5;
typedef long long ll;
const ll mod=1e9+7;
ll n,a,b;
ll s[N];
ll f[N],g[N];
int main()
{
    //freopen("division.in","r",stdin);
    //freopen("division.out","w",stdout);
    scanf("%lld%lld%lld",&n,&a,&b);
    for(ll i=1;i<=n;i++)
        scanf("%lld",&s[i]);
    if(a>b)
        swap(a,b);
    for(ll i=3;i<=n;i++)
        if(s[i]-s[i-2]<a){
            puts("0");
            return 0;
        }
    f[0]=g[0]=1;
    int l=0,r=0;
    for(int i=1;i<=n;i++){
        while(r<i-1&&s[i]-s[r+1]>=b)
            r++;
        if(l<=r)
            f[i]=(g[r]+mod-(l?g[l-1]:0))%mod;
        g[i]=(g[i-1]+f[i])%mod;
        if(i>1&&s[i]-s[i-1]<a)
            l=i-1;
    }
    int ans=0;
    for(int i=n;i>=0;i--){
        ans=(ans+f[i])%mod;
        if(i<n&&s[i+1]-s[i]<a)
            break;
    }
    printf("%d\n",ans);
}


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

using namespace std;

typedef long long int ll;

void solve()
{
	int n;
	cin >> n;
	int freq[n+1] = {0};
	for(int i = 0; i + 1 < n; i++)
	{
		int x;
		cin >> x;
		freq[x]++;
	}
	for(int i = 1; i <= n; i++)
	{
		cout << freq[i] << "\n";
	}
}

int main()
{
	int t = 1;
//	cin >> t;
	while(t--)
	{
		solve();
	}
	return 0;
}



Measured memory_bytes: 4424