akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
  int n,i,j,k=0;
  int A[100001];
  scanf("%d",&n);
  for(i=0;i<100001;i++)A[i]=0;
  for(i=0;i<n;i++){scanf("%d",&j);if(!A[j])k++,A[j]++;}
  printf("%d",k-!(k%2));
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    ll n,k,i;
    ll sum=0;
    cin >> n;
    cin >> k;
    for(i=0;i<n;i++){
        ll h;
        cin >> h;
        if(h>=k)sum++;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#abc167c
n,m,x=map(int,input().split())
mt=[list(map(int,input().split())) for i in range(n)]
res=[-1]*(m+1)
temp=[0]*(m+1)
for i in range(1<<n):
  for j in range(n):
    if (i>>j)&1:
      for k in range(m+1):
        temp[k]+=mt[j][k]
  for j in range(1,m+1):
    if temp[j]<x:
      break
  else:
    if res[0]>temp[0] or res[0]<0:
      res=temp
  temp=[0]*(m+1)
print(res[0])


Measured memory_bytes: 9212
#include <cstdio>
#include <algorithm>
using namespace std;

typedef long long ll;

const ll INF = (ll)1e18;

ll N, S;
ll sol = INF;

void load() {
    scanf("%lld%lld", &N, &S);
}

void check(ll base) {
    ll sum = 0;
    for (ll x = N; x; x /= base)
        sum += x % base;
    if (sum == S) sol = min(sol, base);
}

ll solve() {
    if (N < S) return -1;
    if (N == S) return N + 1;
    ll diff = N - S;
    for (ll i = 1; i * i <= diff; i++) {
        if (diff % i) continue;
        check(i + 1);
        check(diff / i + 1);    
    }
    return sol == INF ? -1 : sol;
}

int main() {
    load();
    printf("%lld\n", solve());
    return 0;
}
    


Measured memory_bytes: 128
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

//macro
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define EPS (1e-8)
#define equals(a,b)(fabs((a)-(b))<EPS)

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;
//func
template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

bool check(char c) {
	char A[5] = { 'a', 'i', 'u', 'e', 'o' };
	REP(i, 5) {
		if (c == A[i])return true;
	}
	return false;
}

int main() {
	char c;
	cin >> c;
	cout << (check(c) ? "vowel" : "consonant") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

using P = pair<int, int>;

int n;
vector< vector< P > > g;
vs32 ans;

bool dfs(int s, int c)
{
    bool ret = true;
    ans[s] = c;

    for (auto& p : g[s])
    {
        int to = p.first;
        int w = p.second;
        if (ans[to] == -1)
        {
            if (w)
            {
                ret = dfs(to, c ^ 1);
            }
            else
            {
                ret = dfs(to, c);
            }
        }
        else
        {
            if (w)
            {
                ret = ans[s] != ans[to];
            }
            else
            {
                ret = ans[s] == ans[to];
            }
        }
        if (!ret) break;
    }

    return ret;
}

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

    cin >> n;
    g.resize(n);
    rep (i, n - 1)
    {
        int u, v, w;
        cin >> u >> v >> w;
        --u, --v;
        w %= 2;
        g[u].emplace_back(v, w);
        g[v].emplace_back(u, w);
    }

    ans.resize(n, -1);
    if (!dfs(0, 1))
    {
        cout << "-1\n";
        return 0;
    }

    rep (i, n)
    {
        cout << ans[i] << "\n";
    }

    return 0;
}



Measured memory_bytes: 8192
using System;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var input = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var height = input[0];
        var width = input[1];
        var strs = new string[height];
        for(var i = 0; i < height; i++)
        {
            strs[i] = ReadLine();
        }
        for(var i = 0; i < height; i++)
        {
            WriteLine($"{strs[i]}\n{strs[i]}");
        }
    }
}


Measured memory_bytes: 13268
#include<cstdio>
#include<cstring>

typedef long long LL;
const int N = 1e5 + 10;
int n, m, L, a[N], ans[N];
LL sum, sum1;

bool ok(){
	if(sum < L)	return 0;
	sum1 = sum;
	bool flag = 1;
    for(int i=1; i<n; i++){
        if(sum < L){
			flag = 0;
			break;
        }
        ans[i] = i;
        sum -= a[i];
    }
    if(flag)	return 1;
    sum = sum1;
    flag = 1;
    m = 0;
    for(int i=n; i>1; i--){
		if(sum < L){
			flag = 0;
			break;
		}
		ans[++m] = i-1;
		sum -= a[i];
    }
    if(flag)	return 1;
    flag = 1;
    for(int i=1; i<=n; i++){
		if(a[i] >= L){
            m = 0;
            for(int j=1; j<i; j++)	ans[++m] = j;
            for(int j=n; j>i; j--)	ans[++m] = j-1;
            return 1;
		}
    }

    for(int i=1; i<n; i++){
		if(a[i]+a[i+1] >= L){
            m = 0;
            for(int j=1; j<i; j++)	ans[++m] = j;
            for(int j=n; j>i+1; j--)	ans[++m] = j-1;
            ans[++m] = i;
            return 1;
		}
    }

    return 0;
}

int main(){
	while(~scanf("%d %d", &n, &L)){
		sum = 0;
		for(int i=1; i<=n; i++){
			scanf("%d", a+i);
			sum += a[i];
		}
		if(ok()){
			puts("Possible");
			for(int i=1; i<n; i++)	printf("%d\n", ans[i]);
		} else {
			puts("Impossible");
		}
	}
	return 0;
}


Measured memory_bytes: 1664
#include <stdio.h>
#include <stdlib.h>

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main(){
   int i,k,n,m,p[1000];

   scanf("%d %d",&n,&k);
   for (i=0;i<n;i++) scanf("%d",&p[i]);
   qsort(p,n,sizeof(int),asc);
   for (i=m=0;i<k;i++) m+=p[i];
   printf("%d\n",m);
   return 0;
}

Measured memory_bytes: 1744
#include<iostream>
#include<cstring>
#define N 100000
using namespace std;

long long dp[N];
int h[N];
int n;

int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    for(int i=2;i<n;i++){
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n-1]<<endl;
}

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

typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;

int main() {
  char a;
  cin >> a;

  if (isupper(a)) {
    cout << 'A' << endl;
  } else {
    cout << 'a' << endl;
  }
  return 0;
}

Measured memory_bytes: 3592
#include <iostream>
using namespace std;
int main(void)
{
	int a,b,c,d,e,f,g,h,i,j,k;
	float A;
	cin>>a>>b>>c>>d>>e;
	A=b-d;
	g=0;
	g++;
	for (;;)
	{
		A=A-d;
		if (A<=0)
		{
			g++;
			break;
		}
		else if (A>0)
		{
			g++;
		}
	}
	A=c-e;
	f=0;
	f++;
	for (;;)
	{
		A=A-e;
		 if (A<=0)
		{
			f++;
			break;
		}
		else if (A>0)
		{
			f++;
		}
	}
	if (f<=g)
	{
		g=a-g;
		cout<<g<<endl;
	}
	else if(f>=g)
	{ 
		f=a-f;
		cout<<f<<endl;
	}
	return 0;
}

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

#define int long long
#define MAX_N (300005)
#define INF (1LL<<60)
#define EPS (1e-7)
#define DEBUG(x) cerr << #x <<":"<< x << endl;
#define DEBUGVC(x) cerr << #x <<": "; for(auto p:(x)) cerr << p <<" "; cerr << endl;
#define DEBUGVCP(x) for(auto p:(x)) cerr << #x <<": "<< p.first <<", "<< p.second << endl;
#define DEBUG2(x, y) cerr << #x <<" : "<< x <<", "<< #y <<" : "<< y << endl;
#define DEBUG3(x, y, z) cerr << #x <<" : "<< x <<", "<< #y <<" : "<< y <<", "<< #z <<" : "<< z << endl;
const int MOD = (int)1e9+7;

int gcd(int a, int b){
    //cout << a <<" "<< b << endl;
    if(b==0) return a;
    return gcd(b, a%b);
}

signed main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];

    vector<vector<int>> g(3, vector<int>(N));
    g[0][0] = A[0];
    g[1][0] = 0;
    g[1][0] = 0;
    for(int i=1; i<N; i++){
        g[0][i] = gcd(g[0][i-1],A[i]);
        g[1][i] = g[0][i-1];
        g[2][i] = max(gcd(g[1][i-1],A[i]), gcd(g[2][i-1],A[i]));
    }

    cout << max(g[0][N-1], max(g[1][N-1],g[2][N-1])) << endl;

}

Measured memory_bytes: 4096
#!/usr/bin/env pypy3
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    N,M=MI()
    st=pow(10,N-1)
    en=pow(10,N)
    
    if N==1:
        st=0
   
    s=[0]*M
    c=[0]*M
    for i in range(M):
        s[i],c[i]=MI()
        s[i]-=1
   
    ans=-1

   
    for i in range(st,en):
        flag=1
        i2=str(i)
        
        for j in range(M):
            aaa=int(i2[s[j]])
            if aaa!=c[j]:
                flag=0
                break
               
        if flag:
            ans=i
            break
        
    print(ans)
       
   
main()


Measured memory_bytes: 63100
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define _GLIBCXX_DEBUG
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
int n,m,q;
vint a(100),b(100),c(100),d(100);
int dfs(int k,int tight,vint len){
  if(k>n){
    int sum=0;
    rep(i,q){
      if(len[b[i]-1]-len[a[i]-1]==c[i]){
        sum+=d[i];
      }
    }
    return (sum);
  }
  len.push_back(tight);
  int max=0;
  REP(i,tight,m+1){
    int tmp=dfs(k+1,i,len);
    chmax(max,tmp);
  }
  return (max);
}
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cin>>n>>m>>q;
  rep(i,q){
    cin>>a[i]>>b[i]>>c[i]>>d[i];
  }
  int max=0;
  vint len;
  REP(i,1,11){
    chmax(max,dfs(0,i,len));
  }
  cout<<max<<'\n';
  return(0);
}


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

int main()
{
  int N,K;
  int a[110];
  int res=0;
  cin >> N>>K;
  rep(i,N) cin >> a[i];

  sort(a,a+N,greater<int>());

  rep(i,K){
    res += a[i];
  }

  cout << res << endl;
}

Measured memory_bytes: 256
if __name__ == '__main__':

	A = ["A","B","C","D","E"]

	while True:
		try:
			n,m = map(int,input().split())
			max_num = n + m
			number = 0

			if n == 0 and m == 0:
				break

			for i in range(4):
				n,m = map(int,input().split())

				if max_num < n + m:
					max_num = n + m
					number = i + 1
			
			print(A[number],max_num)

		except EOFError:
			break



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

class LCA {
public:
  struct edge{
    int to;
    long long cost;
    edge(int to,long long cost):to(to),cost(cost){}
  };
  int logn,n;
  bool isInit = false;
  vector<int> depth;
  vector<long long> distance;
  vector<vector<edge>> es;
  vector<vector<int>> parent;
  LCA(int n):n(n) {
    logn = log2(n) + 1;
    es = vector<vector<edge>>(n);
    parent = vector<vector<int>>(logn,vector<int>(n,-1));
    depth = vector<int>(n);
    distance = vector<long long>(n);
  }
  void add_edge(int u,int v,long long c=1) {
    es[u].emplace_back(v, c);
    es[v].emplace_back(u, c);
    isInit = false;
  }
  void dfs(int u,int prev=-1,int d=0,long long dist=0) {
    depth[u] = d;
    distance[u] = dist;
    parent[0][u] = prev;
    for(const edge& e: es[u]) {
      if( e.to == prev )continue;
      dfs( e.to, u, d+1, dist+e.cost );
    }
  }
  void init() {
    isInit = true;
    dfs(0);
    for(int i=0; i<logn-1; i++)for(int j=0; j<n; j++) {
        if( parent[i][j] == -1 )parent[i+1][j] = -1;
        else parent[i+1][j] = parent[i][parent[i][j]];
      }
  }
  int calc(int u,int v) {
    if(!isInit)init();
    if( depth[u] < depth[v] )swap(u,v);
    for(int i=0; i<depth[u]-depth[v]; i++) {
      if( ((depth[u]-depth[v]) >> i) & 1 )u = parent[i][u];
    }
    if( u == v )return u;
    for(int k=logn-1; k>=0; k--) {
      if( parent[k][u] != parent[k][v] ) {
        u = parent[k][u];   // 共通の親ではないので，そこより親にある(2^kより子ではない)
        v = parent[k][v];
      }
    }
    return parent[0][u];
  }
  long long getDistance(int u,int v) {
    int w = calc(u,v);
    return distance[u]+distance[v]-distance[w]*2;
  }
};

int main(void) {
  int N;
  cin >> N;
  LCA lca(N);
  for(int i=0;i<N-1;i++){
    int a,b,c;
    cin >> a >> b >> c;
    a--;b--;
    lca.add_edge(a,b,c);
  }

  int Q,K;
  cin >> Q >> K;
  K--;
  int x,y;
  for(int i=0;i<Q;i++){
    cin >> x >> y;x--;y--;
    cout << lca.getDistance(x,K) + lca.getDistance(y,K) << endl;
  }

  return 0;
}

Measured memory_bytes: 20344
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<30;

int n, m;
int ba[100][100];
int bi[50][50];

void rotate() {
  int res[50][50];
  REP(y, m)
    REP(x, m)
      res[y][m-x-1] = bi[x][y];
  memcpy(bi, res, sizeof(res));
}

int main() {
  while(cin >> n >> m, n+m) {
    REP(y,n)
      REP(x,n)
      cin >> ba[x][y];
    REP(y,m)
      REP(x,m)
      cin >> bi[x][y];
    int sx, sy;
    bool f;
    REP(y,n-m+1) {
      REP(x,n-m+1) {
        REP(i,4) {
          f = 1;
          sx = -1;
          REP(y1,m) {
            REP(x1,m) {
              int xx = x + x1;
              int yy = y + y1;
              if (bi[x1][y1] == -1) continue;
              if (sx<0) sx = xx, sy = yy;
              if (ba[xx][yy] != bi[x1][y1])
                f = 0;
            }
          }
          if (f) break;
          rotate();
        }
        if (f) break;
      }
      if (f) break;
    }
    if (f) {
      printf("%d %d\n", sx+1, sy+1);
    } else
      cout << "NA" << endl;
  }
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  int n,m;
  cin>>n>>m;
  vector<int> a(n),b(n),c(m),d(m);
  rep(i,n){
    cin>>a[i]>>b[i];
  }
  rep(i,m){
    cin>>c[i]>>d[i];
  }

  rep(i,n){
    int ans = 0;
    int tmp = 1<<28;
    rep(j,m){
      int dist = abs(a[i]-c[j])+abs(b[i]-d[j]);
      if(tmp>dist){
        ans = j+1;
        tmp = dist;
      }
    }
    cout<<(ans)<<endl;
  }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define yn(x, ok, ng) cout << ((x)?(ok):(ng)) << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;


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

int n; cin >> n;
vvi f(n,vi(10));
rep(i,n) rep(j,10) cin >> f[i][j];
vvi p(n,vi(11));
rep(i,n) rep(j,11) cin >> p[i][j];

ll ans = -1001001001001001001;
for(int S = 1; S < (1<<10); ++S) {
    ll sum = 0;
    rep(i,n) {
        int cnt = 0;
        rep(j,10) {
            if(f[i][j] && (S & (1 << j))) cnt++;
        }
        sum += p[i][cnt];
    }
    chmax(ans, sum);
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include <algorithm>
#include <functional>
 
using namespace std;
 
int main (void){
    int H,N,K,temp;
    int sum = 0;
    vector<int> A;
    cin >> H;
    cin >> N;
    for(int i=0; i < N;i++){
        cin >> temp;
        A.push_back(temp);
        sum += temp;
    }
    if(sum >= H) cout << "Yes";
    else        cout << "No";
    
    return 0; 
}

Measured memory_bytes: 892
#include <iostream>
#include <vector>
#include <cmath>
#include <set>
#include <algorithm>
#include <iterator>

using namespace std;

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

    vector<int> d;
    for (int i = 0; i < k; ++i) {
        int a;
        cin >> a;
        d.push_back(a);
    }

    int ans = 0;

    while(true) {
        int n_check = n;
        int kodawari_found = 0;
        while(n_check > 0) {
            int digit = n_check % 10;

            auto itr = std::find(d.begin(), d.end(), digit);
            if( itr != d.end() ) {
                kodawari_found = 1;
                break;
            }

            n_check /= 10;
        }

        if (kodawari_found == 0) {
            ans = n;
            break;
        }

        n++;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}

	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	var count int
	n, m := nextInt(), nextInt()
	hlist := make([]int, n)
	alist, blist := make([]int, m), make([]int, m)
	memo := make([]int, n)
	for i := 0; i < n; i++ {
		hlist[i] = nextInt()
	}
	for i := 0; i < m; i++ {
		alist[i] = nextInt()
		blist[i] = nextInt()
		if hlist[alist[i]-1] <= hlist[blist[i]-1] {
			memo[alist[i]-1] = 1
		}
		if hlist[alist[i]-1] >= hlist[blist[i]-1] {
			memo[blist[i]-1] = 1
		}
	}
	for i := 0; i < n; i++ {
		if memo[i] == 1 {
			count++
		}
	}
	fmt.Print(n - count)
}


Measured memory_bytes: 7132
N,A,B = map(int,input().split())
C = [i for i in range(A,N+1)]
D = [i for i in range(A,10) if i <= B]
for c in C:
    if c >= 10:
        str_c = str(c)
        len_c = len(str_c)
        sum_c = 0
        for i in range(len_c):
            sum_c += int(str_c[i])
        if A <= sum_c <= B:
            D.append(c)
print(sum(D))

Measured memory_bytes: 3444
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

long long N;
long long A;
long long B;
long long ans = 1e9;
long long sum, sum1 = 0;
long long temp, temp1 = 0;


int main()
{
	scanf("%lld", &N);
	for(int i = N - 1; i >= 0; i--) {
		A = N - i;
		B = i;
		sum = 0;
		temp1 = 0;
		temp = 0;
		sum1 = 0; 
		while(A > 0 ) {
			temp = A % 10;
			sum += temp;
			A = A / 10;
		}
		while(B > 0) {
			temp1 = B % 10;
			sum1 += temp1;
			B /= 10;
		}
		if(sum != 0 && sum1 != 0) {
			ans = min(ans, sum + sum1);
			// cout << sum << " " << sum1 << "This";
		}
	}

	printf("%lld\n", ans);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define Int long long
#define pb push_back
using namespace std;


Int N,M,K;
Int X,Y,Z,D;
const int MAXN=105;
Int B,C;


struct DisJointSet{
    vector<int> SZ;
    vector<int> ID;
    int n;

    DisJointSet(int n){
        SZ.resize(n);
        ID.resize(n);
        this->n=n;
        
        for(int i=0;i<n;++i){
            ID[i]=i;
            SZ[i]=1;
        }
    }
    
    int find(int x){
        return (ID[x]==x ? x:find(ID[x]));
    }
    
    void Union_find(int x,int y){
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(SZ[x]>SZ[y]){
            ID[y]=x;
            SZ[x]+=SZ[y];
        }
        else{
            ID[x]=y;
            SZ[y]+=SZ[x];
        }
        return;
    }
};
vector<pair<int,int>> dir{{-1,0},{0,-1},{0,1},{1,0}};
Int shortestPath(vector<vector<int>> grid,pair<int,int> start,pair<int,int> end){
    queue<pair<int,int>> q;
    q.push(start);
    int iter=0;
    while(!q.empty()){
        int tt=q.size();
        while(tt--){
            auto u=q.front();
            q.pop();
            if(u==end) return iter;
            for(auto itr:dir){
                int x=u.first+itr.first;
                int y=u.second+itr.second;
                if(x<0||y<0||x>=grid.size()||y>=grid[0].size()||!grid[x][y]) continue;
                grid[x][y]=0;
                q.push({x,y});
            }
            
        }
        ++iter;
    }
    
}

int main()
{
    cin>>N>>M;
    vector<vector<int>> grid(N,vector<int>(M,0));
    for(int i=0;i<N;++i){
        for(int j=0;j<M;++j){
            char x;cin>>x;
            grid[i][j]=(x=='.' ? 1:0);
        }
    }
    Int ans=-1e9;
    for(int i=0;i<N;++i){
        for(int j=0;j<M;++j){
            for(int x=0;x<N;++x){
                for(int y=0;y<M;++y){
                    if(!grid[i][j]||!grid[x][y]) continue;
                    ans=max(ans,shortestPath(grid,{i,j},{x,y}));
                }
            }
        }
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 3488
#include<cstdio>
#include<vector>
#include<queue>
#include<climits>
#include<algorithm>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
struct edge{int to, cost;};
static const int MAX_N = 5000;
static const int INF = INT_MAX;

int N, K;
int C[MAX_N], R[MAX_N];
vector<int> G1[MAX_N];
vector<edge> G2[MAX_N];
int dist[MAX_N];

void bfs(int s){
	bool visited[MAX_N];
	fill(visited, visited + N, false);
	visited[s] = true;
	queue<P> qa;
	qa.push(P(s, 0));
	while(!qa.empty()){
		P p = qa.front(); qa.pop();
		int u = p.first, d = p.second;
		if(d >= R[s]) continue;
		for(int i = 0; i < G1[u].size(); i++){
			if(visited[G1[u][i]]) continue;
			qa.push(P(G1[u][i], d + 1));
			visited[G1[u][i]] = true;
			G2[s].push_back((edge){G1[u][i], C[s]});
		}
	}
	return ;
}
void dijkstra(int s){
	priority_queue<P, vector<P>, greater<P> > qa;
	fill(dist, dist + N, INF);
	dist[s] = 0;
	qa.push(make_pair(0, s));
	while(!qa.empty()){
		P p = qa.top(); qa.pop();
		int v = p.second;
		if(dist[v] < p.first) continue;
		for(int i = 0; i < G2[v].size(); i++){
			edge e = G2[v][i];
			if(dist[e.to] > dist[v] + e.cost){
				dist[e.to] = dist[v] + e.cost;
				qa.push(make_pair(dist[e.to], e.to));
			}
		}
	}
	return ;
}
int main(){
	scanf("%d %d", &N, &K);
	for(int i = 0; i < N; i++) scanf("%d %d", &C[i], &R[i]);
	for(int i = 0; i < K; i++){
		int A, B;
		scanf("%d %d", &A, &B);
		A--; B--;
		G1[A].push_back(B);
		G1[B].push_back(A);
	}

	for(int i = 0; i < N; i++) bfs(i);
	dijkstra(0);
	printf("%d\n", dist[N - 1]);
	return 0;
}



Measured memory_bytes: 127092
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <unordered_map>
#include <utility>
#include <map>
#include <set>
using namespace std;

int main(){
    int n,k;
    cin >> n >> k;
    int ans = 0;
    
    if(n%k == 0){
        ans = 0;
    }else{
        ans = 1;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <algorithm>

using namespace std;

int main()
{
	//ios::sync_with_stdio(0);
	//cin.tie(NULL);
	const int MAX_VALUES = 101;
	bitset<MAX_VALUES> bits;
	bitset<MAX_VALUES> reversed;
	bits.flip();
	reversed.flip();
	int x, n, t;
	cin >> x >> n;
	if (n == 0) {
		cout << x;
		exit(0);
	}
	for (int i = 0; i < n; i++) {
		cin >> t;
		bits.reset(t);
		reversed.reset(MAX_VALUES - 1 - t);
	}
	if (bits[x]) {
		cout << x;
		exit(0);
	}
	int rV = bits._Find_next(x);
	int lV = MAX_VALUES - 1 - reversed._Find_next(MAX_VALUES - 1 - x);
	int d1 = abs(rV - x);
	int d2 = abs(lV - x);
	if (d1 < d2) {
		cout << rV;
	} else if (d2 < d1) {
		cout << lV;
	} else {
		cout << min(rV, lV);
	}
	return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, K;
//---------------------------------------------------------------------------------------------------
vector<vector<int>> solve() {
	if (K > (N + 1) / 2) return {};

	int a = K;
	int b = K + 2 * N - 1;
	int c = b + K;

	set<int> sa, sb, sc;
	vector<vector<int>> ans;
	while (K + N <= b and K + 2 * N <= c) {
		sa.insert(a);
		sb.insert(b);
		sc.insert(c);
		ans.push_back({ a, b, c });
		a++;
		b -= 2;
		c--;
	}

	b = K + 2 * N - 1;
	c = K + 3 * N - 1;
	while (sb.count(b)) b--;
	while (sc.count(c)) c--;
	while (a < K + N and K + N <= b and K + 2 * N <= c) {
		sa.insert(a);
		sb.insert(b);
		sc.insert(c);
		ans.push_back({ a, b, c });
		a++; b--; c--;
		while (sb.count(b)) b--;
		while (sa.count(c)) c--;
	}
	
	return ans;
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> K;
	auto ans = solve();
	if (ans.size() == 0) {
		cout << -1 << endl;
		return;
	}
	fore(v, ans) printf("%d %d %d\n", v[0], v[1], v[2]);
}






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

int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	vector<ll> x(n);
	rep(i,n) cin >> x[i];

	ll ans = 0;
	rep(i,n-1) {
		ll d = x[i+1] - x[i];
		ans += min(a*d, b);
	}

	cout << ans << endl;

	return 0;
}


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

const int maxn = 100010, P = 998244353;
int n, cnt[maxn];

int qp(int x, int y) {
    int z = 1;
    for (; y; y >>= 1, x = 1LL * x * x % P) {
        if (y & 1) z = 1LL * z * x % P;
    }
    return z;
}

int main() {
    scanf("%d", &n);
    for (int i = 1, d; i <= n; i++) {
        scanf("%d", &d), cnt[d]++;
        if (i == 1 && d) printf("0\n"), exit(0);
    }
    if (cnt[0] ^ 1) printf("0\n"), exit(0);
    int ans = 1;
    for (int i = 1; i < n; i++) {
        ans = 1LL * ans * qp(cnt[i - 1], cnt[i]) % P;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <cstring>
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

int main(){
  fastIO
  int n;
  cin>>n;
  string str;
  cin>>str;
  int size=str.size();
  if(size<=n){
  	cout<<str;
  }
  else{
    
     for(int i=0;i<n;i++){
      cout<<str[i];
     }
      cout<< "...";


  }
  return 0;
}


Measured memory_bytes: 3648
// B.

#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	int x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int x3 = x2 - y2 + y1;
	int y3 = y2 + x2 - x1;
	int x4 = x3 - y3 + y2;
	int y4 = y3 + x3 - x2;
	cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
	return 0;
}


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


def count753(number):

    if int(number) > N:
        return 0

    if number == '0':
        number = ''

    if '7' not in number or '5' not in number or '3' not in number:
        result = 0
    else:
        result = 1

    result += count753('7' + number)
    result += count753('5' + number)
    result += count753('3' + number)

    return result


print(count753('0'))


Measured memory_bytes: 44120
import java.util.*;

public class Main{

    void solve(){
	Scanner sc = new Scanner(System.in);
	
	int MAX = 1000001;
	int[] p = new int[MAX];
	for(int i=2; i<p.length; i++)p[i] = 1;
	for(int i=2; i<Math.sqrt(MAX)+1; i++){
	    for(int j=i*2; j<MAX; j+=i){
		p[j] = 0;
	    }
	}
	
	while(true){
	    int a = sc.nextInt();
	    int b = sc.nextInt();
	    if(a==0 && b==0) break;

	    int maxA = -1;
	    for(int i=a; i>0; i--){
		if(p[i]==0 || a%i!=0) continue;
		if(maxA==-1) maxA = i;
		else maxA -= i;
	    }
	    int maxB = -1;
	    for(int i=b; i>0; i--){
		if(p[i]==0 || b%i!=0) continue;
		if(maxB==-1) maxB = i;
		else maxB -= i;
	    }

	    System.out.println(maxA>maxB ? "a" : "b");
	}
    }

    public static void main(String[] args){
	new Main().solve();
    }
}

Measured memory_bytes: 16000
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

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

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

  int query; cin >> query;
  for (int i = 0; i < query; ++i) {
    int k; cin >> k;
    cout << binary_search(all(a), k) << '\n';
  }

  return 0;
}


Measured memory_bytes: 3320
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string>
int main()
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if((a>=c&&c>=b)||c>=a&&c<=b)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

public static class Prime
{
    public static bool IsPrime(int n)
    {
        return GetPrimes(n).Last() == n;
    }

    // Sieve of Eratosthenes
    public static int[] GetPrimes(int n)
    {
        var sieve = new BitArray(n + 1);
        var end = (int)(Math.Sqrt(n) + 0.1);
        for (int i = 2; i <= end; i++)
        {
            if (!sieve.Get(i))
            {
                for (int j = i * 2; j <= n; j += i)
                {
                    sieve.Set(j, true);
                }
            }
        }

        return Enumerable.Range(2, n - 1).Where(i => !sieve.Get(i)).ToArray();
    }

    public static List<long> PrimeFactorize(long n, IEnumerable<int> primes)
    {
        var factor = new List<long>();
        foreach (var p in primes)
        {
            while (n % p == 0)
            {
                factor.Add(p);
                n /= p;
            }
        }
        if (n > 1)
        {
            factor.Add(n);
        }
        return factor;
    }

    // 要素を各個数で表す
    public static Dictionary<long, int> FactorToDict(IEnumerable<long> factor)
    {
        var dict = new Dictionary<long, int>();

        foreach (var f in factor)
        {
            if (!dict.ContainsKey(f))
            {
                dict[f] = 0;
            }
            dict[f]++;
        }

        return dict;
    }
}

class Solution
{
    static void Main()
    {
        var vals = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var n = vals[0];
        var p = vals[1];

        var primes = Prime.GetPrimes((int)(Math.Sqrt(p) + 1));
        var factors = Prime.FactorToDict(Prime.PrimeFactorize(p, primes));

        var gcd = 1L;
        foreach (var f in factors)
        {
            var count = f.Value / n;
            if (count > 0)
            {
                gcd *= (long)Math.Pow(f.Key, count);
            }
        }

        Console.WriteLine(gcd);
    }
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int a,b;
int main() {
    cin>>a>>b;
    int ans;
    ans = max(a+b,a-b);
    ans = max(ans, a*b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] t = new int[n + 1];
        int[] x = new int[n + 1];
        int[] y = new int[n + 1];
        for(int i = 1;i <= n;i++) {
            t[i] = sc.nextInt();
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
        }

        boolean isPossible = true;
        for(int i = 1;i <= n;i++) {
            int dt = t[i] - t[i - 1];
            int dx = Math.abs(x[i] - x[i - 1]);
            int dy = Math.abs(y[i] - y[i - 1]);

            if(dx + dy > dt) {
                isPossible = false;
                break;
            }
            else if(dt % 2 == 0) {
                if((dx + dy) % 2 != 0) {
                    isPossible = false;
                    break;
                }
            }
            else if(dt % 2 != 0) {
                if((dx + dy) % 2 == 0) {
                    isPossible = false;
                    break;
                }
            }
        }

        String ans = isPossible ? "Yes" : "No";
        System.out.println(ans);
    }
}

Measured memory_bytes: 90776
#include <iostream>
#include <string>
#include <limits.h>
#include <numeric>
#include <math.h>
#include <bits/stdc++.h>
#define rep(i,c) for (int i=0;i<c;i++)
using namespace std;
typedef long long ll;

int main(){
  int n;
  cin >> n;
  n = n % 100;
  n = n % 10;
  if( n ==3) cout << "bon" << endl;
  else if(n == 0 || n == 1|| n == 6 || n== 8) cout << "pon" << endl;
  else cout << "hon" << endl;
}

Measured memory_bytes: 3620
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int N, M, Order[8];
vector <int> Graph[8];

int main(){
  cin >> N >> M;
  for (int i = 0; i < N; i++) Order[i] = i;

  for (int i = 0; i < M; i++){
    int A, B; cin >> A >> B;
    A--; B--;
    Graph[A].push_back(B);
    Graph[B].push_back(A);
  }
  
  int ans = 0;
  do{
    bool flag = true;

    for (int i = 0; i < N - 1; i++){
      flag = false;
      for (int j = 0; j < Graph[Order[i]].size(); j++){
        if (Graph[Order[i]][j] == Order[i + 1]) flag = true;
      }
      if (!flag) break;
    }

    if (flag) ans++;
  }while (next_permutation(Order + 1, Order + N));
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); ++i)

int main()
{
  int N, A[20], B[20], C[19];
  cin >> N;
  rep(i, N) cin >> A[i];
  rep(i, N) cin >> B[i];
  rep(i, N - 1) cin >> C[i];
  rep(i, N) --A[i];

  int ans = 0;

  rep(i, N) ans += B[A[i]];

  rep(i, N - 1) {
    if (A[i] + 1 == A[i + 1]) ans += C[A[i]];
  }

  cout << ans << endl;
}


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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os<<"("<<p.first<<","<<p.second<<")";
    return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os<<"{";
    rep(i, v.size()) {
        if (i) os<<",";
        os<<v[i];
    }
    os<<"}";
    return os;
}

int main() {
    int N; cin >> N;
    V<int> A(N), B(N), C(N-1);
    rep(i, N) {
        cin >> A[i];
        --A[i];
    }
    rep(i, N) cin >> B[i];
    rep(i, N-1) cin >> C[i];
    int ans = 0;
    rep(i, N) {
        ans += B[i];
        if (i && A[i-1] == A[i]-1) {
            ans += C[A[i-1]];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
 int a,b,c,dem;
 scanf("%d%d%d",&a,&b,&c);
 for(a;a<=b;a++)
 {
  if(c%a==0)
   dem++;
 }
 printf("%d\n",dem);
 return 0;
}

Measured memory_bytes: 596
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
using namespace std;
#define rg register
#define LL long long
#define __space putchar(' ')
#define __endl putchar('\n')
template <typename qwq> inline void read(qwq &x)
{
	x = 0;
	rg LL f = 1;
	rg char c = getchar();
	while (c < '0' || c > '9')
	{
		if (c == '-') f = -1;
		c = getchar();
	}
	while (c >= '0' && c <= '9')
	{
		x = (x << 1) + (x << 3) + (c ^ 48);
		c = getchar();
	}
	x *= f;
}
template <typename qaq> inline void print(qaq x)
{
	if (x < 0)
	{
		putchar('-');
		x = -x;
	}
	if (x > 9) print(x / 10);
	putchar(x % 10 + '0');
}
int n, maxx, minax, maxid, minaxid;
struct node
{
	int id, val;
}a[233333];
inline bool cmp(node x, node y)
{
	return x.val < y.val;
}
int main()
{
	read(n);
	for (rg int i = 1; i <= n; ++i) read(a[i].val), a[i].id = i;
	stable_sort(a + 1, a + 1 + n, cmp);
	maxx = a[n].val, minax = a[n - 1].val;
	maxid = a[n].id, minaxid = a[n - 1].id;
	for (rg int i = 1; i <= n; ++i)
	{
		if (i != maxid) print(maxx);
		else print(minax);
		__endl;
	}
	return 0;
}

Measured memory_bytes: 3184
import java.util.Scanner;

class Main {
    public static void main (String args[]) {
	Scanner scanner = new Scanner(System.in);
	int N = scanner.nextInt();
	int A[] = new int[N];
	for(int i = 0;i < N;i++){
	    A[i] = scanner.nextInt();		
	}
	for(int k = 0;k < N;k++){
	    System.out.print(A[k]);
	    if(k == N - 1) break;
	    System.out.print(" ");
	}
	System.out.println();
	int v, j;	    
	for(int i = 1;i < N;i++){
	    v = A[i];
	    j = i - 1;
	    while(j >= 0 && A[j] > v){
		A[j + 1] = A[j];
		j--;
		A[j+1] = v;
	    }
	    for(int k = 0;k < N;k++){
		System.out.print(A[k]);
		if(k == N - 1) break;
		System.out.print(" ");
	    }
	    System.out.println();
	}
    }
}



Measured memory_bytes: 34312
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
//using namespace atcoder;
using ll = long long;
using ld = long double;

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define uniq(x) ((x).erase(unique(all(x)),(x).end()))
#define sz(x) ((int)(x).size())

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

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int x;
  cin >> x;
  if(x==0)  cout << 1 << endl;
  else  cout << 0 << endl;

  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int N;
V<int> a;
ll solve(ll K){
	ll A = 0, B = 0, C = 0;
	ll numb = 0;
	rep(i,N){
		if(i>=K){//erase i-K
			int j = i-K;
			if(a[j]==0){
				B -= numb;
				A--;
			}
			if(a[j]==1){
				numb--;
			}
		}
		//add i
		if(a[i]==0){
			A++;
		}
		if(a[i]==1){
			B += A;
			numb++;
		}
		if(a[i]==2){
			C += B;
		}

	}
	return C;
}
int main(){
	cin>>N;
	a = V<int>(N,-1);
	{
		string s;
		cin>>s;
		rep(i,N){
			if(s[i]=='D') a[i] = 0;
			if(s[i]=='M') a[i] = 1;
			if(s[i]=='C') a[i] = 2;
		}
	}

	int Q;
	cin>>Q;
	rep(_,Q){
		int K;
		cin>>K;
		cout<<solve(K)<<endl;
	}
}

Measured memory_bytes: 5252
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int p[n],i,j,c=0,z=0;
  for(i=0;i<n;i++)
    cin>>p[i];
  for(i=0;i<n;i++)
  {
    if(p[i]<=p[c])
    {
      c=i;
      z++;
    }
  }
  cout<<z<<endl;
  return 0;
}
        


Measured memory_bytes: 1024
#include<iostream>
#include<iostream>
using namespace std;
int main(){
  int n;string s;cin>>n>>s;
  int a[200010]={},b[200010]={};
  for(int i=0;i<n;++i){
	a[i+1]=a[i];
	if(s[i]=='#')a[i+1]++;
  }
  for(int i=0;i<n;++i){
	b[i+1]=b[i];
	if(s[n-i-1]=='.')b[i+1]++;
  }
  int ans=300000;
  for(int i=0;i<=n;++i){
	ans=min(ans,a[i]+b[n-i]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 2180
#include<stdio.h>

int n,cnt,d,maxd,abc[100002];

int main(){
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&d);
    abc[d]++;
    if(maxd<d)maxd=d;
  }
  if(abc[0]==n/2)cnt=1;
  for(int i=1;i<maxd;i++){
    abc[i]+=abc[i-1];
    if(abc[i]==n/2)cnt++;
    if(abc[i]>n/2)break;
  }
  printf("%d\n",cnt);
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
// #include <algorithm>
// #include <cmath>
// #include <math.h>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<long long> a(3*N);
    for (int i=0; i<3*N; ++i) cin >> a[i];

    sort(a.begin(), a.end(), greater<long long>());

    long long res = 0;
    for (int i=0; i<=2*N; ++i){
        if (i % 2 == 1){
            // cout << a[i] << endl;
            res += a[i];
        }
    }

    cout << res << endl;

}

Measured memory_bytes: 2560
N = int(input())
a = list(map(int, input().split()))
b = [0 for i in range(N)]
m = N // 2 + 1
for i in range(N,0,-1):
    if i >= m:
        b[i-1] = a[i-1]
    else:
        kaisu = N // i
        count = 0
        for j in range(2, kaisu+1):
            count += b[j*i-1]
        amari = count % 2
        if amari == 0 and a[i-1] == 1:
            b[i-1] = 1
        elif amari == 1 and a[i-1] == 0:
            b[i-1] = 1
print(sum(b))
for i in range(N):
    if b[i] == 1:
        print(i+1)


Measured memory_bytes: 7276