akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int const N = 1e5+5;
long long n,m,a[N],d[N],b,gc,c,mi,chn,l,r,t,i,s;



int main() {
	
	cin>>n>>m;
	for(i=0;i<n;i++) { cin>>a[i]; s += a[i]; }
	
	
	sort(a,a+n);
	for(i=0;i<n;i++) d[i] = a[i];
	for(i=1;i<n;i++) d[i] += d[i-1];
	
	vector<pair<int,int>> v;
	for(i=0;i<m;i++){
		cin>>b>>c;
		gc = max(gc,c);
		v.push_back({c,b});
	}
	sort(v.rbegin(),v.rend());
	
	
	
	for(i=0;i<m;i++){	
		b = v[i].second;
		c = v[i].first;
		l = 0;
		r = n;
		while(l<r){
			mi = (l+r)/2;
			if(a[mi]>=c && a[mi-1]<c ) { r = mi; break; }
			else if( a[mi]>c ) r = mi;
			else l = mi+1;
		}
	
		//cout<<i+1<<" : "<<r<<endl;
		if(chn>=r) break;
		t += min(r-chn,b)*c;
		chn += min(r-chn,b);
	}
	//cout<<s<<endl;
	//cout<<t<<endl;
	s -= d[chn-1];
	//cout<<d[chn-1]<<endl;
	s += t;
	cout<<s;
	return 0;
}

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

struct Edge{
  int to;
  int weight;
  Edge(int t,int w) : to(t),weight(w){}
};

using Graph = vector<vector<Edge>>;

int main(){
  int n,m,r;
  cin >> n >> m >> r;
  Graph G(n);

  for(int i=0;i<m;++i){
    int from,to,weight;
    cin >> from >> to >> weight;
    G[from].push_back(Edge(to,weight));
  }
  vector<ll> dist(n,-1);
  queue<int> que;
  dist[r]=0;
  que.push(r);
  while(!que.empty()){
    int v=que.front();
    que.pop();
    for(auto nv : G[v]){
      if(dist[nv.to] == -1 || dist[nv.to]>dist[v]+nv.weight){
        dist[nv.to] = dist[v]+nv.weight;
        que.push(nv.to);
      }
    }
  }
  for(int i=0;i<n;++i){
    if(dist[i]==-1) cout << "INF" << endl;
    else cout << dist[i] << endl;
  }
  return 0;

}



Measured memory_bytes: 12880
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 155;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int n, m, P;
void update(int &x, int y) {
	x += y;
	if (x >= P) x -= P;
}
map <pair <int, int>, int> dp[MAXN][MAXN][MAXN];
int main() {
	read(n), read(m), read(P);
	if (m % 2 == 0) {
		static int dp[MAXN][MAXN];
		m /= 2, dp[0][0] = 1;
		for (int i = 1; i <= n; i++)
		for (int j = 0; j <= m; j++) {
			update(dp[i][0], dp[i - 1][j]);
			if (j != m) update(dp[i][j + 1], dp[i - 1][j]);
		}
		int ans = 0, bns = 0;
		for (int i = 0; i <= m; i++) {
			update(ans, dp[n / 2][i]);
			update(bns, dp[(n + 1) / 2][i]);
		}
		writeln(1ll * ans * bns % P);
	} else {
		dp[0][0][0][make_pair(n + 1, n + 1)] = 1;
		for (int i = 1; i <= n; i++)
		for (int j = 0; j <= n; j++)
		for (int k = 0; k <= n; k++) {
			if (i & 1) {
				for (auto x : dp[i - 1][j][k]) {
					pair <int, int> tmp = x.first; tmp.first = n + 1;
					update(dp[i][0][k][tmp], x.second);
					if (i != x.first.first) {
						tmp = x.first;
						if (i - m >= i - 2 * k + 1) chkmin(tmp.second, i - 2 * j + m);
						if (tmp.second >= i) update(dp[i][j + 1][k][tmp], x.second);
					}
				}
			} else {
				for (auto x : dp[i - 1][j][k]) {
					pair <int, int> tmp = x.first; tmp.second = n + 1;
					update(dp[i][j][0][tmp], x.second);
					if (i != x.first.second) {
						tmp = x.first;
						if (i - m >= i - 2 * j + 1) chkmin(tmp.first, i - 2 * k + m);
						if (tmp.first >= i) update(dp[i][j][k + 1][tmp], x.second);
					}
				}
			}
		}
		int ans = 0;
		for (int i = 0; i <= n; i++)
		for (int j = 0; j <= n; j++) {
			for (auto x : dp[n][i][j])
				update(ans, x.second);
		}
		writeln(ans);
	}
	return 0;
}

Measured memory_bytes: 228352
#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;

int main() {
    uint64_t N, Y;
    cin >> N >> Y;
    for (int i = 0; i <= N; i++) {
        for (int j = 0; j <= N - i; j++) {
            int64_t t = (Y / 1000) - (i * 10 + j * 5);
            if (i + j + t == N) {
                printf("%lld %d %d\n", i, j, t);
                return 0;
            }
        }
    }
    puts("-1 -1 -1");
    return 0;
}

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

//#include <atcoder/all>

using namespace std;
// using namespace atcoder;
using ll = long long;

int main() {
  int n;
  int ba = 0, _a = 0, b_ = 0;
  int in = 0;
  cin >> n;

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

    for (int i = 0; i + 1 < (int)s.size(); i++) {
      if (s[i] == 'A' && s[i + 1] == 'B') in++;
    }

    if (s.front() == 'B' && s.back() == 'A') {
      ba++;
    } else {
      if (s.front() == 'B') {
        b_++;
      }
      if (s.back() == 'A') {
        _a++;
      }
    }
  }

  if (_a == 0 && b_ == 0) {
    cout << in + max(ba - 1, 0) << endl;
  } else {
    cout << in + ba + min(_a, b_) << endl;
  }
}

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

using namespace std;

struct chan {
  int s, t, c;
  chan(int s, int t, int c) : s(s), t(t), c(c) {}
};

auto operator<(const chan &l, const chan &r) {
  if (l.c != r.c)
    return l.c < r.c;
  else
    return l.s < r.s;
}

int tim[200001];

int main() {
  int n, m;
  cin >> n >> m;
  vector<chan> v;
  for (int i = 0; i < n; ++i) {
    int s, t, c;
    cin >> s >> t >> c;
    v.push_back(chan(s * 2, t * 2, c));
  }
  sort(v.begin(), v.end());
  v[0].s--;
  for (int i = 0; i < n; ++i) {
    if (i)
      if (v[i].c != v[i - 1].c || v[i].s != v[i - 1].t) {
        v[i].s--;
      }
    tim[v[i].s]++;
    tim[v[i].t]--;
  }
  int ans = 0;
  for (int i = 0; i <= 200000; ++i) {
    if (i)
      tim[i] += tim[i - 1];
    ans = max(ans, tim[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 2292
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int k;
  scanf("%d", &k);
  long r[100001] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
  int id = 0;
  for (int i=9; i<k; i++) {
    if (r[id] % 10 == 0) {
      r[i] = r[id] * 10;
      r[i+1] = r[i] + 1;
    } else if (r[id] % 10 == 9) {
      r[i] = r[id] * 10 + 8;
      r[i+1] = r[i] + 1;
    } else {
      r[i] = r[id] * 10 + r[id]%10 - 1;
      r[i+1] = r[i] + 1;
      i++;
      r[i+1] = r[i] + 1;
    }
    i++;
    id++;
  }
  printf("%ld\n", r[k-1]);
  return 0;
}


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

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

    cin>>n>>k;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    int ans=(n+k-3)/(k-1);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i, s, n) for(int i=s; i<n; i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

int main() {
  int N;
  cin >> N;
  vector<int> X(N);
  rep(i, N) cin >> X[i];

  int hp = 100 * 100 * 100 + 10000;
  rep(p, 101)
  {
    int tmp = 0;
    rep(i, N) {
      tmp += (X[i] - p) * (X[i] - p);
    }

    hp = min(hp, tmp);
  }

  cout << hp << endl;

  return 0;
}


Measured memory_bytes: 256
# coding: utf-8

import sys
import math
import collections
import itertools
from inspect import currentframe
INF = 10 ** 10
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def MI() : return map(int, input().split())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def chkprint(*args) : names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}; print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

K = I()

N = 6
a = [100,101,102,103,104,105]
m = [1000000 for i in range(N)]

# initialize
dp = [0 if i==0 else -1 for i in range(K + 1)]

# DP
for i in range(N):
    dp_tmp = []
    for j in range(K + 1):
        if (dp[j] >= 0):
            dp_next = m[i]
        elif ((j < a[i]) or (dp_tmp[j-a[i]] <= 0)):
            dp_next = -1
        else:
            dp_next = dp_tmp[j-a[i]] - 1
        dp_tmp.append(dp_next)
    dp = dp_tmp

if dp[-1] >= 0:
    print(1)
else:
    print(0)



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

int main()
{
    string S;
    cin >> S;
    int N = S.size();
    int s0 = 0, s1 = 0;
    for (int i = 0; i < N; i++)
    {
        if (S[i] == '0')
            s0++;
        else
            s1++;
    }
    //    cout << "s0=" << s0 << endl;
    //    cout << "s1=" << s1 << endl;
    int ans = min(s0, s1) * 2;
    cout << ans << endl;
}

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

const int nm = 2e5;
int n, ok, ng, mid;
long long ans = 0;
int b[nm], c[nm], d[nm * 2], bc[nm * 2];

int main() {
	cin >> n;
	for (int i = 0, a; i < n; i++) {
		cin >> a;
		b[i] = i + a;
		c[i] = i - a;
		d[i * 2] = i + a;
		d[i * 2 + 1] = i - a;
	}

	sort(d, d + n * 2);

	for (int i = 0; i < n; i++) {
		ok = 0, ng = n * 2;
		while (ng - ok > 1) {
			mid = (ok + ng) / 2;
			if (d[mid] <= b[i])
				ok = mid;
			else
				ng = mid;
		}
		b[i] = ok;
		ok = 0, ng = n * 2;
		while (ng - ok > 1) {
			mid = (ok + ng) / 2;
			if (d[mid] <= c[i])
				ok = mid;
			else
				ng = mid;
		}
		c[i] = ok;
	}

	for (int i = 0; i < n; i++) {
		ans += bc[c[i]];
		bc[b[i]]++;
	}

	cout << ans << endl;

}


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

int main(void)
{
	int i;
	int b[3]={1, 2, 3};
	int a[3];
	scanf("%d%d", &a[0], &a[1]);
	rep(i,3){
		if(b[i] != a[0] && b[i] != a[1]){
			printf("%d", b[i]);
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';

int N;
ll pow2[200001], C[200000], res, t, c;

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> C[i];
	}
	sort(C, C + N, greater<>());
	pow2[0] = 1;
	for (ll i = 1; i <= N; i++) {
		pow2[i] = pow2[i - 1] * 2 % mod;
	}
	for (int i = 0; i < N; i++)	{
		t %= mod;
		res += (t + pow2[i])*C[i] % mod*pow2[N - i - 1];
		res %= mod;
		t *= 2;
		t += pow2[i];
		t %= mod;
	}
	res *= pow2[N];
	res %= mod;
	cout << res << endl;
}

Measured memory_bytes: 3328
/** omgursocute **/
#include <bits/stdc++.h>

using namespace std;
typedef int64_t ll;
typedef uint64_t ull;
typedef long double ld;

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

	int a, b;
	cin >> a >> b;
	cout << (a^b);

	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << " ms.\n";
}

// g++ o .cpp -O2 -std=c++11 -D cute -Wall -Wno-unused-result



Measured memory_bytes: 256
K,N = map(int,input().split())
data = list(map(int,input().split()))
diff = 0
for i in range(N-1):
    diff = max(diff,data[i+1]-data[i])
diff2 = (K-data[N-1])+data[0]
diff = max(diff,diff2)
print(K-diff)

Measured memory_bytes: 26444
n, k = map(int, input().split())
s = input()

# 100101 => [1,2,1,1,1]
# 011000 => [0,1,2,3,0]
human = []

is_handstood = False
cnt = 0

for ch in s:
    if ch == "0" and not is_handstood:
    	human.append(cnt)
    	is_handstood = True
    	cnt = 1
    elif ch == "1" and is_handstood:
    	human.append(cnt)
    	is_handstood = False
    	cnt = 1
    else:
        cnt += 1
human.append(cnt)
if is_handstood:
    human.append(0)

total_human = [0 for i in range(len(human))]
total_human[0] = human[0]
for i in range(1, len(human)):
    total_human[i] = total_human[i - 1] + human[i]

if len(human) <= 2 * k + 1:
    max_human = n
else:
    max_human = total_human[k * 2]
    for i in range(k * 2 + 2, len(total_human), 2):
        if total_human[i] - total_human[i - k * 2 - 1] > max_human:
        	max_human = total_human[i] - total_human[i - k * 2 - 1]

print(max_human)

Measured memory_bytes: 7932
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
	ll r=1;
	a=a%m;
	while(b>0)
	{
		if(b&1)
		    r=(r*a)%m;
		b>>1;
		a=(a*a)%m;
	}
	return r%m;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	string s; cin>>s;
	ll l = 0;
	ll t; cin>>t;
	string ff = "",ss = "";
	while(t--)
    {
        ll x; cin>>x;
        if(x==1)l = 1 -l;
        else
        {
            ll y;cin>>y;
            string c; cin>>c;
            if(y==1)
            {
                if(l==0)
                {
                    ff = c+ff;
                }
                else ss = ss +c;
            }
            else
            {
                if(l==0)ss= ss+c;
                else ff = c+ff;
            }
        }
    }
    if(l==0)cout<<ff<<s<<ss<<endl;
    else
    {
        reverse(ff.begin(),ff.end());
        reverse(ss.begin(),ss.end());
        reverse(s.begin(),s.end());
        cout<<ss;
        cout<<s<<ff<<endl;
    }
    return 0;
}


Measured memory_bytes: 1132
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define LOWER(s)    transform(ALL((s)),(s).begin(),TL<char>)
# define UPPER(s)    transform(ALL((s)),(s).begin(),TU<char>)
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(LL i=(a);i<(b);i++)
# define RFOR(i,a,b) for(LL i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)


int n;
int main() {
	cin >> n;
	if (n == 3) {
		cout << "2 5 63" << endl;
	}
	else if (n == 4) {
		cout << "2 5 20 63" << endl;
	}
	else {
		cout << "2 3 4 9 ";
		n -= 4;
		int pos = 6;
		int num = 15;
		while (num + 6 <= 30000 && n >= 2) {
			n -= 2;
			cout << num << " " << num + 6;
			if (num > 0) {
				cout << " ";
			}
			num += 12;
		}
		while (n > 3) {
			n -= 3;
			cout << pos << " " << pos + 2 << " " << pos + 4 << " ";
			pos += 6;
		}
		if (n == 0) {
			cout << endl;
		}
		else if (n == 1) {
			cout << pos << endl;
		}
		else if (n == 2) {
			cout << pos + 2 << " " << pos + 4 << endl;
		}
		else if (n == 3) {
			cout << pos << " " << pos + 2 << " " << pos + 4 << endl;
		}
	}
}

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

#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll=long long;


int main() {
  string S;
  int Q;
  cin >> S;
  cin >> Q;
  bool rev = false;
  rep(i,Q){
    int t;cin >> t;
    if(t==1){
      rev = !rev;
    }else{
      int f;
      char c;
      cin >> f >> c;

      if(!rev && f==1){
        S.insert(S.begin(),c);
      }
      if(!rev && f==2){
        S.insert(S.end(),c);
      }
      if(rev && f==1){
        S.insert(S.end(),c);
      }
      if(rev && f==2){
        S.insert(S.begin(),c);
      }
    }
  }
  if(!rev){cout << S;return 0;}

  else reverse(ALL(S));
  cout << S;
}

Measured memory_bytes: 900
#include<iostream>
using namespace std;
int Min(int a,int b,int c){
  if(b<a){
    if(c<b) return c;
    else return b;
  }
  else{
    if(c<a) return c;
    else return a;
  }
}
int main(){
  int n,a,b;
  cin >> n >> a >> b;
  int x=0,y=0,z=0;
  for(int i=0;i<n;i++){
    int c;
    cin >> c;
    if(c<=a) x++;
    if(a+1<=c&&c<=b) y++;
    if(b+1<=c) z++;
  }
  cout << Min(x,y,z) << "\n";
  
  
  return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
P = list(map(int,input().split()))
C = list(map(int,input().split()))
if max(C) < 0:
    print(max(C))
else:
    maxAll = 0
    isCovered = [False] * n
    index = 0
    while index < n:
        if isCovered[index]:
            index += 1
            continue
        else:
            cycleCValue = []
            newIndex = index
            while newIndex != index or not cycleCValue:
                isCovered[newIndex] = True
                cycleCValue.append(C[P[newIndex] - 1])
                newIndex = P[newIndex] - 1
            maxValue = 0
            cycleCPartialSum = [0]
            for elem in cycleCValue:
                cycleCPartialSum.append(cycleCPartialSum[-1] + elem)
            for i in range(len(cycleCValue)): # number of elements to sum
                if i > k:
                    continue
                for j in range(len(cycleCValue)): # starting element
                    if i + j <= len(cycleCValue):
                        curSum = cycleCPartialSum[i + j] - cycleCPartialSum[j]
                    else:
                        curSum = cycleCPartialSum[(i + j) % len(cycleCValue)] + cycleCPartialSum[-1] - cycleCPartialSum[j]
                    if cycleCPartialSum[-1] > 0:
                        curSum += ((k - i) // len(cycleCValue)) * cycleCPartialSum[-1]
                    if curSum > maxValue:
                        maxValue = curSum
            if maxAll < maxValue:
                maxAll = maxValue
            index += 1
    print(maxAll)
            
                    

Measured memory_bytes: 69308
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;
const int IINF = 1e9;
const ll INF = 1e18;
const int MOD = 1e9 + 7;

#define dump(x) cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl

template <typename T>
void dumpvec(vector<T> vec) {
  for (T cnt : vec) {
    cout << cnt << ", ";
  }
  cout << endl;
}

void chmin(ll &a, ll b) {
  if (a > b) {
    a = b;
  }
}
void chmax(ll &a, ll b) {
  if (a < b) {
    a = b;
  }
}

vector<string> split(string s, string delimiter) {
  int first = 0;
  int last = s.find_first_of(delimiter);
  vector<string> result;

  while (first < s.size()) {
    string sub = s.substr(first, last - first);
    result.push_back(sub);
    first = last + 1;
    last = s.find_first_of(delimiter, first);

    if (last == string::npos) {
      last = s.size();
    }
  }

  return result;
}

string join(vector<string> strings, string delimiter) {
  string result = "";
  for (int i = 0; i < strings.size(); i++) {
    if (result != "") result += delimiter;
    result += strings[i];
  }
  return result;
}

int main() {
  string w;
  cin >> w;
  bitset<26> freq;
  for (int i = 0; i < w.length(); i++) {
    freq.flip(w[i] - 'a');
  }
  cout << (freq.count() == 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

int A, B, T;

int main()
{
  scanf( "%d%d%d", &A, &B, &T );

  printf( "%d\n", (T/A)*B );

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> A(3 * n);
    for(int i = 0; i < 3 * n; i++) cin >> A[i];
    vector<ll> sumL(3 * n, 0), sumR(3 * n, 0);
    priority_queue<ll, vector<ll>, greater<ll>> L;
    for(int i = 0; i < n; i++)
    {
        L.push(A[i]);
        sumL[i] = (i - 1 < 0 ? 0 : sumL[i - 1]) + A[i];
    }
    for(int k = n; k < 2 * n; k++)
    {
        if(A[k] > L.top())
        {
            sumL[k] = sumL[k - 1] + A[k] - L.top();
            L.pop();
            L.push(A[k]);
        }
        else sumL[k] = sumL[k - 1];
    }
    priority_queue<ll> R;
    for(int i = 3 * n - 1; i >= 2 * n; i--)
    {
        R.push(A[i]);
        sumR[i] = (i + 1 >= 3 * n ? 0 : sumR[i + 1]) + A[i];
    }
    for(int k = 2 * n - 1; k >= n; k--)
    {
        if(A[k] < R.top())
        {
            sumR[k] = sumR[k + 1] + A[k] - R.top();
            R.pop();
            R.push(A[k]);
        }
        else sumR[k] = sumR[k + 1];
    }
    ll ans = -1LL<<60;
    for(int k = n - 1; k < 2 * n; k++)
    {
        ans = max(ans, sumL[k] - sumR[k + 1]);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 9588
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
struct node{char op;int x,y,z;};
int now=199999,p[63],a[31],b[31],tmp;
int New(){return now--;}
vector<node>ans;
int Add(int x,int y){
    int p=New();ans.pb(node{'+',x,y,p});
    return p;
}
void Shift(int x,int y){
    for(int i=0;i<y;i++)
        ans.pb(node{'+',x,x,x});
}
int cmp(int x,int y){
    int p=New();ans.pb(node{'<',x,y,p});
    return p;
}
int main(){
    // freopen("data.txt","w",stdout);
    p[0]=cmp(2,Add(0,1));
    ans.pb(node{'+',0,p[0],0});
    ans.pb(node{'+',1,p[0],1});
    for(int i=1;i<31;i++)p[i]=Add(p[i-1],p[i-1]);
    tmp=New();
    for(int i=30;~i;i--){
        a[i]=cmp(Add(tmp,p[i]),0);
        int q=cmp(Add(tmp,p[i]),0);
        Shift(q,i);ans.pb(node{'+',tmp,q,tmp});
    }
    tmp=New();
    for(int i=30;~i;i--){
        b[i]=cmp(Add(tmp,p[i]),1);
        int q=cmp(Add(tmp,p[i]),1);
        Shift(q,i);ans.pb(node{'+',tmp,q,tmp});
    }
    for(int i=60;~i;i--){
        ans.pb(node{'+',2,2,2});
        for(int j=0;j<=i;j++){
            int k=i-j;
            if(j<=30&&k<=30)
                ans.pb(node{'+',2,cmp(p[0],Add(a[j],b[k])),2});
        }
    }
    printf("%d\n",ans.size());
    for(int i=0;i<ans.size();i++)
        printf("%c %d %d %d\n",ans[i].op,ans[i].x,ans[i].y,ans[i].z);
    return 0;
}


Measured memory_bytes: 3908
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
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; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  double th = ((h * 30.0 + 0.5 * m) * PI) / 180.0, tm = m * 6.0 *PI / 180.0;
  double hx = a * cos(th), hy = a * sin(th);
  double mx = b * cos(tm), my = b * sin(tm);
  double x = hx - mx, y = hy - my;
  double ans = sqrt(x * x + y * y);
  cout << setprecision(10) << ans << endl;
}

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

using namespace std;

int main() {

    string arr[3] = {"Sunny", "Cloudy", "Rainy"};
    string s;
    cin >> s;
    for (int i = 0; i < 3; ++i) {
        if (s == arr[i] && i != 2) {
            cout << arr[i + 1];
            return 0;
        }
        else if (s == arr[i] && i == 2) {
            cout << arr[0];
            return 0;
        }
    }
}


Measured memory_bytes: 256
s = input()
ans = 753*2

for i in range(len(s)-2):
    sanko = list(map(int,(s[i:i+3])))
    kazu = sanko[0]*100 + sanko[1]*10 + sanko[2]

    if abs(kazu-753) < ans:
        ans = abs(kazu-753)

print(ans)


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

#define rep(X,N) for(int X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define MODN 1000000007
#define MODN2 998244353
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

int main(){

    int n;
    cin >> n;

    vector<int> a(n + 1);
    
    rep(i, n + 1){
        cin >> a[i];
    }

    ll tmpma = a[n];
    ll tmpmi = a[n];

    vector<ll> ma(n + 1);
    vector<ll> mi(n + 1);

    ma[n] = tmpma;
    mi[n] = tmpmi;

    for(int i = n - 1; i >= 0; i--){
        tmpmi = (tmpmi + 1) / 2;
        tmpma = tmpma;

        tmpmi += a[i];
        tmpma += a[i];

        ma[i] = tmpma;
        mi[i] = tmpmi;
    }

    if(tmpmi <= 1 && 1 <= tmpma){

        ll ans = 0;
        ll tmp = 1;

        rep(i, n){
            ans += tmp;
            tmp = tmp - a[i];
            tmp = min(tmp * 2, ma[i + 1]);
        }

        ans += tmp;
        cout << ans << endl;


    }else{
        cout << -1 << endl;
    }
    return 0;
}


Measured memory_bytes: 5108
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,m,MOD=1000000007;
	cin>>n>>m;
	vi in(n);
	rep(i,n)cin>>in[i];
	sort(all(in),[](int a,int b){return a>b;});
	vvi dp(n+1,vi(m+1));
	dp[0][0]=1;
	rep(i,n){
		vvi ndp(n+1,vi(m+1));
		rep(j,n+1)rep(k,m+1){
			if(k+in[i]<=m)(ndp[j][k+in[i]]+=dp[j][k])%=MOD;
			(ndp[i+1][k]+=dp[j][k])%=MOD;
		}
		dp=ndp;
	}
	int out=0;
	rep(i,m+1)out+=dp[0][i];
	rep(i,n)rep(j,m+1)if(j+in[i]>m)(out+=dp[i+1][j])%=MOD;
	cout<<out<<endl;
}

Measured memory_bytes: 18536
#include <iostream>
#include <vector>
#include <algorithm>
#include <tuple>
#include <string>
#include <set>
#include <map>
using namespace std;
using ll = long long;



int main() {
	int n, x;
	cin >> n >> x;
	vector<int> l(n);
	for (int i = 0; i < n; i++) cin >> l[i];
	int sum = 0, ans = 1;
	for (int i = 0; i < n; i++) {
		sum += l[i];
		if (sum <= x) ans++;
	}
	cout << ans << endl;

	return 0;
}

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


int findSumOfDigits(int n){
  int sum = 0;
  while (n>0){
    sum += n%10;
    n/=10;
  }
  return sum;
}
int main(){
  int n,a,b;
  cin >> n >> a >> b;
  int total= 0 ;

  for(int i=1;i<=n;i++){
    int SumOfDigits = findSumOfDigits(i);
    if(SumOfDigits>=a &&SumOfDigits<=b)total+=i;
  }
  cout<<total<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

long long attack(long long h){
  if(h<=1){
    return 1;
  } else {
    return attack(h/2)*2+1;
  }
}

int main(){
  long long h;
  long long count;
  scanf("%lld",&h);
  
  count=attack(h);
  
  printf("%lld",count);
}


Measured memory_bytes: 128
n = int (input())
h = list(map(int,input().split()))
count_list = []
count=0
for i in range(n):
   if i == n-1:
      break
   if h[i] >= h[i+1]:
      if count !=0:
         count +=1
      else:
         count = 1
   else:
      count = 0
   count_list.append(count)
if not count_list:
   count_list.append(0)
print(max(count_list))

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

int main() {
  int n;
  cin >> n;
  float sum = 0;
  float a;
  rep(i,n){
    cin >> a;
    sum += 1/a;
  } 
  printf("%.10f", 1 / sum);

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>


void print_sharp_dot(int h, int w)
{
	int i,j;

	for (i = 0; i < h; i++) {
		if (i == 0 || i == (h-1)) {
			for (j = 0; j < w; j++)
				printf("#");
		} else {
			for (j = 0; j < w; j++) {
				if (j == 0)
					printf("#");
				else if (j != (w-1))
					printf(".");
				else if (j == (w-1)) {
					printf("#");
				}
			}
		}

		printf("\n");
	}
}

int main()
{
	int h,w;

	while (true) {
		scanf("%d %d", &h, &w);

		if (h == 0 && w == 0)
			break;

		print_sharp_dot(h, w);

		printf("\n");
	}

	return 0;
}


Measured memory_bytes: 2604
#include<bits/stdc++.h>
#define int int64_t
using namespace std;

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

	int n;
	cin >> n;
	int a[n+2] = {0};
	for(int i = 1; i <= n; i++) cin >> a[i];
	int dp[n+1][n+1];
	memset(dp , 0 , sizeof(dp));
	for(int i = 1; i <= n; i++) dp[i][i] = a[i];
	if(n % 2 == 0) for(int i = 0; i <= n; i++) dp[i][i] = -dp[i][i];
	for(int l = 2; l <= n; l++) {
		for(int i = 1; i <= n-l+1; i++) {
			if(n & 1) {
				if(l & 1) dp[i][i+l-1] = max(dp[i+1][i+l-1]+a[i] , dp[i][i+l-2]+a[i+l-1]);
				else dp[i][i+l-1] = min(dp[i+1][i+l-1]-a[i] , dp[i][i+l-2]-a[i+l-1]);
			}
			else {
				if(l & 1) dp[i][i+l-1] = min(dp[i+1][i+l-1]-a[i] , dp[i][i+l-2]-a[i+l-1]);
				else dp[i][i+l-1] = max(dp[i+1][i+l-1]+a[i] , dp[i][i+l-2]+a[i+l-1]);
			}
		}
	}
	cout << dp[1][n] << "\n";

    return 0;
}


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

void CountingSort(const vector<int> &A, vector<int> &B, int k)
{
    int n = A.size();
	vector<int> C;
	C.resize(k+1);
	for(int i = 0; i <= k; i++){
		C[i] = 0;
	}
	/* C[i] ??? i ???????????°????¨?????????? */
	for(int j = 0; j < n; j++){
		C[A[j]]++;
	}
	/* C[i] ??? i ??\????????°???????????°????¨??????????*/
	for(int i = 1; i <= k; i++){
		C[i] = C[i] + C[i-1];
	}
	
	for(int j = n-1; j >= 0; j--){
		B[C[A[j]]] = A[j];
		C[A[j]]--;
	}	
}
int main()
{
	int n;
	int k = 10000;
	cin >> n;
	vector<int> A;
	vector<int> B;
	A.resize(n);
	B.resize(n+1);
	for(int i = 0; i < n; i++){
		cin >> A[i];
	}
	CountingSort(A, B, k);
	for(int i = 1; i < n; i++){
		cout << B[i] << ' ';
	}
	cout << B.back() << endl;
	return 0;
}

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





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long int
#define ULL unsigned long int
#define MOD (long int)10e9 + 7
#define LD long double

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

    vector<int> h(n);
    for(int i = 0; i < n; ++i) 
    {
        cin >> h[i];
    }

    vector<bool> flag(n,true);

    for(int i = 0; i < m; ++i)
    {
        int a,b;
        cin >> a >> b;

        if(h[a - 1] <= h[b - 1]) flag[a - 1] = false;
        if(h[a - 1] >= h[b - 1]) flag[b - 1] = false;
    }

    int ans = 0;

    for(int i = 0; i < n; ++i)
    {
        cerr << (flag[i] ? i + 1 : -1) << endl;
        ans += flag[i];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3792
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T>
struct Edge {
	int to;
	T cost;
	Edge() {}
	Edge(int to, T cost) : to(to), cost(cost) {}
	bool operator>(const Edge &r) const { return this->cost > r.cost; }
};

template<class T>
vector<T> Dijkstra(const vector<vector<Edge<T>>> &edges, const int st) {

	const int V = (int)edges.size();
	const T inf = numeric_limits<T>::max() / 2;
	vector<T> cost(V, inf);
	cost[st] = 0;

	priority_queue<Edge<T>, vector<Edge<T>>, greater<Edge<T>>> pq;
	pq.emplace(st, cost[st]);

	while (!pq.empty()) {

		Edge<T> now(pq.top().to, pq.top().cost);
		pq.pop();

		if (cost[now.to] < now.cost) continue;
		for (const Edge<T> &e : edges[now.to]) {
			T tmp_cost = now.cost + e.cost;
			if (cost[e.to] > tmp_cost) {
				cost[e.to] = tmp_cost;
				pq.emplace(e.to, cost[e.to]);
			}
		}
	}

	return cost; // min cost to vertex idx from st
}

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

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;
	int t, a;
	cin >> t >> a;
	t--, a--;

	vector<vector<Edge<int>>> edges(N);
	for (int i = 0; i < N - 1; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		edges[u].emplace_back(v, 1);
		edges[v].emplace_back(u, 1);
	}

	auto d_t = Dijkstra(edges, t);
	auto d_a = Dijkstra(edges, a);

	DMP(d_t, d_a);

	int max_d = 0;
  for(int i=0; i<N; i++) if(d_t[i] < d_a[i]) chmax(max_d, d_a[i] - 1);

	cout << max_d << "\n";

	return 0;
}


Measured memory_bytes: 7436
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int n, h;
    cin >> n >> h;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());
    int ans = (h + a[0] - 1) / a[0];
    int sum = 0;
    for (int i = 0; i < n; i++) {
        sum += b[i];
        int rest = max(0, h - sum);
        ans = min(ans, i + 1 + (rest + a[0] - 1) / a[0]);
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000009
#define EPS 1E-9

double x;

int main()
{
  while(cin >> x) cout << ceil((x * x + 98) / 98.0) << endl;

  return 0;
}

Measured memory_bytes: 1280
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

N = int(input())

A = []
for i in range(N):
    A.append(-int(input()))

B = copy.deepcopy(A)
heapq.heapify(B)

for i in range(N):
    b = heapq.heappop(B)
    if b == A[i]:
        c = b
        b = heapq.heappop(B)
        heapq.heappush(B,c)
    heapq.heappush(B,b)
    print(-b)



Measured memory_bytes: 102888
n = input()
p = list(map(int,input().split()))

ps = sorted(p)

d_p = []
d_ps = []
for i,q in enumerate(p):
  if q != ps[i]:
    d_p.append(q)
    d_ps.append(ps[i])
if len(d_p) > 2:
  print('NO')
elif len(d_p) == 2:
  d_p.sort()
  if d_p == d_ps:
    print('YES')
  else:
    print('NO')
else:
  print('YES')

Measured memory_bytes: 9100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;

int main(){
    ll i,j;
    ll n,m;
    cin>>n>>m;
    vector<ll> c(n,0);
    for(i=0;i<m;i++){
        ll a,b;
        cin>>a>>b;
        a--; b--;
        c[a]++;
        c[b]++;
    }
    for(i=0;i<n;i++){
        if(c[i]%2) {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;


    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 bool arr[10000+5];
 
 bool is_prime(int x)
 {
   if(x==1) return false;
   else if(x==2) return true;
   else 
   {
     for(int i=2;i<=sqrt(x);i++)
     {
       if(x%i==0) return false;        
     }  
     return true;   
   }    
 }
 
 void init()
 {
   for(int i=1;i<=10000;i++)
   {
     if(is_prime(i)) arr[i]=true;
     else arr[i]=false;        
   }     
 }
 
 int main()
 {
   int N;
   while(cin>>N)
   {
     init();
     int count=0;
     for(int i=1;i<=(N/2);i++)
     {
       if(arr[i]&&arr[N-i+1])
       {
         //cout<<i<<" "<<N-i+1<<endl;
         count++;
       }           
     }
     if(N%2==0) cout<<(2*count)<<endl;
     else 
     {
       if(arr[N/2+1]) count=2*count+1;
       else count*=2;
       cout<<count<<endl;     
     }
   }
   //while(1);
   return 0;
 }

 

Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int n,S;
    while(cin>>n>>S, n|S) {
        vector<int> in(n);
        for(int i=0; i<n; ++i) cin>>in[i];
        sort(in.begin(), in.end());

        int ans = 0;
        for(int i=0; i<n; ++i) {
            int idx = n - (upper_bound(in.begin(),in.end(),S-in[i]) - in.begin());
            ans += idx;
            if(in[i]+in[i] > S) ans--;
        }
        cout<<ans/2<<endl;
    }
}

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

int main(void)
{
    int n, x;
    cin >> n >> x;
    vector<int> l(n);
    for (int i = 0; i < n; i++) {
        cin >> l[i];
    }
    int count = 1;
    int d = 0;
    for (int i = 0;; i++) {
        if (count > n) break;
        d = d + l[i];
        if (d > x) break;
        count++;
    }
    cout << count << endl;

    return 0;
}



Measured memory_bytes: 256
s = list(input())
t = list(input())
ans = []
if len(s)-len(t) == 0:
  an = 0
  for j in range(len(t)):
      if s[j] == t[j]:
        an += 1
  print(len(t)-an)
else:
  for i in range(len(s)-len(t)):
    ans.append(0)
    for j in range(len(t)):
      if s[i+j] == t[j]:
        ans[i] += 1
  print(len(t) - max(ans))

Measured memory_bytes: 65788
#include<stdio.h>
int main()
{
    int i,j,k,l,temp,n,sum;
    while(scanf("%d",&n)!=EOF){
            temp=0;
    for(i=0;i<=9;i++){
        for(j=0;j<=9;j++){
            for(k=0;k<=9;k++){
                for(l=0;l<=9;l++){
                    sum=i+j+k+l;
                    if(sum==n){
                            temp++;
                        }

                    }
                }
            }
        }
    printf("%d\n",temp);
    }
    return 0;

}



Measured memory_bytes: 1732
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>

using namespace std;
int N,M;
vector<pair<int,int>> v;

bool comp(pair<int,int> p1,pair<int,int> p2){
    return p1.second < p2.second;
}

int main(){
    cin >> N >> M;
    v = vector<pair<int,int>>(M);
    for(int i=0;i<M;i++){
        int a,b;
        cin >> a >> b;
        v[i] = make_pair(a,b);
    }
    sort(v.begin(),v.end(),comp);
    int rm = -1;
    int count = 0;
    for(int i=0;i<M;i++){
        //cout << v[i].first << " " << v[i].second << endl;
        if(v[i].first <= rm) continue;
        else{
            rm = v[i].second -1;
            //cout << rm << endl;
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, a, count=0;
  cin >> n;
  for(int i=0;i<n;i++) {
    cin >> a;
    if((i+1) % 2 == 1 && a % 2 == 1) {
      count++;
    }
  }
  cout << count << '\n';
}

Measured memory_bytes: 3620
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdlib>
#include <stdio.h>


using namespace std;

int N, M, K;

int check(int nn, int mm, int kk){
  return ((M*nn + N*mm - 2*mm*nn)==kk)? 0 : -1 ;
}

int main(int argc, char *argv[]){


  cin >> N >> M >> K;
  for(int i = 0; i <= N; i++){
    for(int j = 0; j <= M; j++){
      if(check(i, j, K) == 0){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;

  return 0;
}



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

int main()
{
    int a,b,c;cin>>a>>b>>c;
    if(a<b && b<c)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}




Measured memory_bytes: 3096
x,y,a,b,c=map(int,input().split())
G=[[0]*2 for i in range(a+b+c)]
A=sorted(list(map(int,input().split())),reverse=True)
B=sorted(list(map(int,input().split())),reverse=True)
C=sorted(list(map(int,input().split())),reverse=True)
for i in range(a):
  G[i][0]=A[i]
  G[i][1]=0
for i in range(b):
  G[i+a][0]=B[i]
  G[i+a][1]=1
for i in range(c):
  G[i+a+b][0]=C[i]
  G[i+a+b][1]=2
GG=sorted(G,reverse=True)
cc=0
ca=0
cb=0
i=-1
ans=0
f=0
ff=0
while ca<x and cb<y and cc<x+y:
  i=i+1
  ans=ans+GG[i][0]
  if GG[i][1]==0:
    ca=ca+1
    cc=cc+1
    if ca==x:
      f=1
  elif GG[i][1]==1:
    cb=cb+1
    cc=cc+1
    if cb==y:
      f=2
  else:
    cc=cc+1
  if cc==x+y:
    ff=1
if ff==1:
  print(ans)
  exit()
if f==1:
  ans=0
  for i in range(x):
    ans=ans+A[i]
  GGG=sorted(G[a:a+b+c],reverse=True)
  for i in range(y):
    ans=ans+GGG[i][0]
  print(ans)
elif f==2:
  ans=0
  for i in range(y):
    ans=ans+B[i]
  GGG=sorted(G[0:a]+G[a+b:a+b+c],reverse=True)
  for i in range(x):
    ans=ans+GGG[i][0]
  print(ans)

Measured memory_bytes: 123004
/*
	Templates start.
	Powered by c++11.
	Author : Alex_Wei.
*/

#include <bits/stdc++.h>
using namespace std;

// IO templates.

char buf[1<<21],*p1=buf,*p2=buf,obuf[1<<23],*O=obuf;
#ifdef __WIN64
	#define gc getchar()
#else
	#define gc (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
#endif
#define pc(x) (*O++=x)
#define flush() fwrite(obuf,O-obuf,1,stdout)

inline int read(){
	int x=0,sign=0; char s=getchar();
	while(!isdigit(s))sign|=s=='-',s=getchar();
	while(isdigit(s))x=(x<<1)+(x<<3)+(s-'0'),s=getchar();
	return sign?-x:x;
}
void print(int x) {if(x>9)print(x/10); pc(x%10+'0');}

#define ll long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define sor(x) sort(all(x))
#define rev(x) reverse(all(x))
#define mem(x,v) memset(x,v,sizeof(x))

/*
	Templates end.
	Please give me more points.
*/

const int N=1e5+5;

ll ans,x,y,a,b,c,p[N],q[N],r[N],prep[N],preq[N],prer[N];

int count(int v){
	int pos=lower_bound(q+1,q+b+1,v)-q-1;
	int pos2=lower_bound(r+1,r+c+1,v)-r-1;
	return b+c-pos-pos2;
}

int main(){
	cin>>x>>y>>a>>b>>c;
	for(int i=1;i<=a;i++)cin>>p[i];
	for(int i=1;i<=b;i++)cin>>q[i];
	for(int i=1;i<=c;i++)cin>>r[i];
	sort(p+1,p+a+1),sort(q+1,q+b+1),sort(r+1,r+c+1);
	for(int i=1;i<=a;i++)prep[i]=prep[i-1]+p[i];
	for(int i=1;i<=b;i++)preq[i]=preq[i-1]+q[i];
	for(int i=1;i<=c;i++)prer[i]=prer[i-1]+r[i];
	
	for(int i=0;i<=x;i++){
		ll l=0,rr=2e9,ned=x+y-i;
		if(x-i>c)continue;
		int pp=lower_bound(r+1,r+c+1,q[b-y+1])-r-1;
		if(y+c-pp<ned){
			ans=max(ans,prep[a]+preq[b]+prer[c]-prep[a-i]-preq[b-y]-prer[c-(x-i)]);
			continue;
		}
		while(l<rr){
			int m=(l+rr>>1)+1;
			if(count(m)>=ned)l=m;
			else rr=m-1;
		}
		int pos=lower_bound(q+1,q+b+1,l)-q-1;
		int pos2=lower_bound(r+1,r+c+1,l)-r-1;
		ans=max(ans,prep[a]+preq[b]+prer[c]-prep[a-i]-preq[pos]-prer[pos2]-(count(l)-ned)*l);
	}
	cout<<ans<<endl;
	
	return 0; 
}

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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
#define Dev 1000000007

//cout << (c)?"Yay!":":(" << endl;

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n)
    {
        cin >> v[i];
    }
    SORT_INV(v);
    long long int ans = v[0];
    v.erase(v.begin());
    rep(i, n - 2)
    {
        ans += v[i / 2 ];
       // cout << ans << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  double N,K,ans=0,dice;
  cin >> N >> K;
  vector<double> sum(N+1,0);
  for(int i=1;i<=N;i++) {
    cin >> dice;
    sum.at(i)=(dice+1)/2+sum.at(i-1);
    if(K<=i) ans=max(ans,sum.at(i)-sum.at(i-K));
  }
  cout << fixed << setprecision(10); 
  cout << ans << endl;
}

Measured memory_bytes: 1792