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

using namespace std;

int main(void) {
  string s;
  int alpa[26] = {0};
  while(getline(cin, s)){
    for(int i = 0 ; i < s.size() ; i ++){
      if (0 <= s[i] - 'a' && s[i] - 'z' <= 0){
        alpa[s[i] - 'a'] ++;
      }
      if (0 <= s[i] - 'A' && s[i] - 'Z' <= 0){
        alpa[s[i] - 'A'] ++;
      }
    }
  }
  for(int i = 0 ; i < 26 ; i ++){
    cout<<char('a' + i)<<" : "<<alpa[i]<<endl;
  }
}


Measured memory_bytes: 3212
fun main(args: Array<String>) {
    val N = nextInt()
    val AB = Array<Pair<Int, Int>>(N, {
        val (a, b) = listOfInt()
        Pair(a, b)
    }).toList().sortedBy { (it.second.toLong() shl 32) + it.first.toLong() }
    var ans = true
    var t = 0
    repeat(N) {
        t += AB[it].first
        if (t > AB[it].second) ans = false
    }
    println("${if (ans) "Yes" else "No"}")
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }


Measured memory_bytes: 83884
/*** 𝕒𝕜𝕤𝕙𝕒𝕪𝕜𝕦𝕞𝕒𝕣𝟡𝟡 ***/

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD=1e9+7;
const long double PI = acos(-1);
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=1e4;
 
typedef long long ll;
typedef long double ld;

void test_case()
{
    ll a,b,n,i,j;
    cin>>a>>b>>n;
    ll st=1,ed=n;
    ll res= floor(a*n*1.0/b)-a*floor(1.0*n/b);
    while(st<ed)
    {
        ll mid=(st+ed)>>1;
        ll z= floor(a*mid*1.0/b)-a*floor(mid*1.0/b);
        if(z>res)
        {
            res=z;
            st=mid;
        }
        else
            ed=mid-1;
    }
    cout<<res<<'\n';

}

int32_t main()
{
    IOS();
    
    int tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include<map>
#include<queue>

using namespace std;

int a[8];
int dist[4] = { 1,-1,4,-4 };
map<string, int> dp;

void bfs()
{
	queue<string> q;
	string cur;
	dp["01234567"] = 0;
	q.push("01234567");
	while (!q.empty())
	{
		cur = q.front();
		q.pop();
		int p = (int)cur.find("0");
		for (int i = 0; i < 4; i++)
		{
			int np = p + dist[i];
			if (np >= 0 && np < 8 && (p != 3 || dist[i] != 1) && (p != 4 || dist[i] != -1))
			{
				string next;
				next = cur;
				next[p] = cur[np];
				next[np] = cur[p];
				if (dp.find(next) == dp.end())
				{
					dp[next] = dp[cur] + 1;
					q.push(next);
				}
			}
		}
	}
}

int main()
{
	bfs();
	while (cin >> a[0])
	{
		for (int i = 1; i < 8; i++)
			cin >> a[i];
		string s;
		for (int i = 0; i < 8; i++)
			s += a[i] + '0';
		cout << dp[s] << endl;
	}
}





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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


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: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  vector<int> c(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  for (int i = 0; i < n; i++) cin >> c[i];
  vector<P> sa(n);
  for (int i = 0; i < n; i++) {
    sa[i].first = v[i] - c[i];
    sa[i].second = i;
  }
  sort(all(sa));
  reverse(all(sa));
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    if (sa[i].first < 0) break;
    ans += sa[i].first;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    int R, G; cin >> R >> G;
    cout << G+G-R << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell1 1e9+7
#define hell2 1e9+9
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define ll long long
#define ld long double 
#define no_of_digits(n) floor(log10(n)) + 1
#define see(x) cout << (#x) << " is " << (x) << endl
#define INF 1e9

using namespace std;

ll mult(ll a,ll b, ll p=hell1){   return ((a%p)*(b%p))%p; }
ll multbig(ll a,ll b,ll mod=hell1){   if(a==0 or b==0) return 0;if(a==1 or b==1) return (a*b)%mod;ll cur=multbig(a,b/2,mod);cur=(2*cur)%mod;if(b%2) cur=(cur+a)%mod;return cur;
}
ll add(ll a, ll b, ll p=hell1){ if(a>=p) a%=p; if(b>=p) b%=p; if(a+b>p) return (a + b)%p; else return a+b;}
ll sub(ll a, ll b, ll p=hell1){return (a%p - b%p + p)%p;}
ll fpow(ll n, ll k, ll p = hell1) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = hell1) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = hell1){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}
int isPowerof2(ll x) { return (x && !(x & x-1)); } 
ll log2(ll x) { ll res = 0; while (x >>= 1) res++; return res; } 

// max({a, b, c, d})

vector<ll>adj[200005];
ll update[200005];
ll ans[200005];

void dfs(ll s, ll cur_sum, ll parent)
{
    ans[s] = update[s] + cur_sum;
    for(auto u : adj[s])
    {
        if(u == parent) continue;
        dfs(u, update[s]+cur_sum, s);
    }
}

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

    cout << max({a+b, a-b, a*b}) << "\n";    
}




Measured memory_bytes: 6016
import sys
 
readline = sys.stdin.buffer.readline
 
N,A,B = map(int, readline().split())
 
div,mod =divmod(N, A+B)
 
if div < 1:
  if N > A:
    print(A)
  else:
    print(N)
else:
  if mod > A:
    print(A*div + A)
  else:
    print(A*div + mod)

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

#define rep(i, n) for(int i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

ll powmod(ll x, ll n) { // like pow(x, n)
  ll r = 1;
  while (n) {
    if (n & 1) {
      r = r * x % MOD;
    }
    x = x * x % MOD;
    n >>= 1;
  }
  return r;
}

int main(int argc, char** argv) {
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i, N) {
    cin >> A[i];
  }
  map<P, set<int>> mp; // (num, id) => cnt.

  rep(i, N) {
    for (int k = 2; k * k <= A[i]; ++k) {
      int j = 0; // id for same numbers.
      while ((A[i] % k) == 0) {
        P p(k, j);
        mp[p].insert(i); // insert the id of A.
        A[i] /= k;
        ++j;
      }
    }
    if (A[i] > 1) {
      P p(A[i], 0);
      mp[p].insert(i); // insert the id of A.
    }
  }

  int ans = 1;
  vector<int> candidates(N, 1);  // candidates[i] .. the take by i.
  for (auto x : mp) {
    P p = x.first;
    if (x.second.size() == N) {
      ans *= p.first;
    }
    if (x.second.size() == N-1) {
      rep(i, N) {
        if (x.second.find(i) == x.second.end()) { // i is not included
          candidates[i] *= p.first;
        }
      }
    }
  }
  int m = 1;
  rep(i, N) {
    m = max(m, candidates[i]);
  }
  cout << ans * m << endl;
}


Measured memory_bytes: 90112
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <utility>
using namespace std;

void swap_(int *a, int *b){
  int x = a[0];
  a[0] = b[0];
  b[0] = x;
}

void swap_(long int *a, long int *b){
  int x = a[0];
  a[0] = b[0];
  b[0] = x;
}

void quick_a(long int *s, int m, int *b){
  int i, j, k=1, p=1;
  int a = s[0];
  for(; k<m; k++){ // m=1だとスルー
    if(a < s[k]){
      a = s[k];
      p = k;
      break;
    }else if(a > s[k]){
      p = k-1;
      break;
    }else if(k+1==m){ // s[0]=s[1]=...=s[m-1]
      break;
    }
  }
  if(k<m-1){
    i = p;
    j = m-1;
    do{
      while(s[i]< a && i!=j){
        i++;
      }
      if(i==j)    {break; }
      while(s[j]>=a && i!=j){
        j--;
      }
      if(i==j)    {break; }
      if(s[i]>s[j]){
        swap_(&s[i], &s[j]);
        swap_(&b[i], &b[j]);
      }
    }while(i+1!=j);
    quick_a(&s[0],   j,  &b[0]);
    quick_a(&s[j], m-j,  &b[j]);
  }else if(p==k-1 && s[0]>s[k]){
    swap_(&s[0], &s[k]);
    swap_(&b[0], &b[k]);
  }
}

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

  long int a[n];
  int b[n];

  for(i=0; i<n; i++){
    cin >> a[i] >> b[i];
  }

  quick_a(a, n, b);
  int hon = 0;
  long int en;
  for(i=0; i<n; i++){
    hon += b[i];
    if(hon>=m){
      en = 0; hon = 0;
      for(j=0; j<i; j++){
        en += a[j]*b[j];
        hon += b[j];
      }
      if(i!=0)  cout << en+a[i]*(m-hon);
      else      cout << a[0]*m;
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>

int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a<b){
    printf("a < b\n");
  }else if(a==b){
    printf("a == b\n");
  }else{
    printf("a > b\n");
  }
  return 0;
}



Measured memory_bytes: 2140
N,X=map(int,input().split())
a,p=[1],[1]
for i in range(N):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)
def f(n,x):
    if n==0:
      return 0 if x<=0 else 1
    elif x<=1+a[n-1]:
      return f(n-1,x-1)
    else:
      return p[n-1]+1+f(n-1,x-2-a[n-1])
print(f(N,X))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
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; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	int n, k; string s;
	cin >> n >> k >> s;
	VE<P<int>> info;
	info.push_back(make_pair(1, 0));
	rep(i, n) {
		if (info[info.size() - 1].first == s[i] - '0') info[info.size() - 1].second++;
		else info.push_back(make_pair(s[i] - '0', 1));
	}
	rep1(i, info.size() - 1) info[i].second += info[i - 1].second;
	int ans = 0;
	for (int i = 0; i < info.size(); i += 2) {
		int Pos = i + 2 * k;
		chmin(Pos, (int)info.size() - 1);
		int prev = i == 0 ? 0 : info[i - 1].second;
		chmax(ans, info[Pos].second - prev);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4292
import java.util.*;

public class Main{
	public static void main(String[] args){
		//new Main().printHelloWorld();
		//System.out.println(new Main().ITP1_1_B(Integer.parseInt(new Scanner(System.in).next())));
		//new Main().ITP1_1_C();
		//new Main().ITP1_1_D();
		//new Main().ITP1_2_A();
		new Main().ITP1_2_B();
	}

	public void printHelloWorld(){
		System.out.println("Hello World");
	}

	public int ITP1_1_B(int x){
		return x*x*x;
	}

	public void ITP1_1_C(){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		System.out.println(a*b + " " + 2*(a+b));
	}

	public void ITP1_1_D(){
		int seconds = new Scanner(System.in).nextInt();
		System.out.println(seconds/3600 + ":" + (seconds%3600)/60 + ":" + (seconds%3600)%60);
	}

	public void ITP1_2_A(){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		System.out.println((a==b)?"a == b":(a > b)?"a > b":"a < b");
	}

	public void ITP1_2_B(){
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		System.out.println((a < b && b < c)?"Yes":"No");
	}
}

Measured memory_bytes: 26344
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(const T a, const T b){return a>=0 ? a/b : (a+1)/b-1;}
template<class T> T div_ceil(const T a, const T b){return a>=0 ? (a-1)/b+1 : a/b;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int main(){
    int n, l, r;
    while(scanf("%d%d%d", &n, &l, &r) && n){
        int a[n];
        rep(i, n) scanf("%d", &a[i]);
        int ans = 0;
        auto check = [&](int x){
            rep(i, n)if(x%a[i] == 0) return (i+1)%2;
            return 1-n%2;
        };
        For(x, l, r+1) ans += check(x);
        printf("%d\n", ans);
    }
}


Measured memory_bytes: 3148
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
M = list(map(int, input().split()))
res = ["no"] * Q

for i in range(2 ** N):
    s = 0
    for n in range(N):
        if (i >> n) & 1 == 1:
            s += A[n]
    else:
        if s in M:
            indexes = [j for j, x in enumerate(M) if x == s]
            for index in indexes:
                res[index] = "yes"

print("\n".join(res))


Measured memory_bytes: 5604
import sys
# sys.setrecursionlimit(10**7)  # ネスト回数制限（いる？）

# 入力値を扱いやすい形で格納していく

# input=sys.stdin.buffer.readline  # input の高速化（今回は外す）

N, M, S = map(int,input().split())  # 頂点数／辺数／初期所持金(state)
S=min(S,2500)  # 高々 2500 あれば良い（全都市を回るのに払いきれる回数）

INF=10**18
dp = [[INF]*2501 for _ in range(N)]
way=[[]for _ in range(N)]

for _ in range(M):
    u,v,a,b=map(int,input().split())
    way[u-1].append((v-1,a,b))
    way[v-1].append((u-1,a,b))

# 両替比率と時間
# CD = [list(map(int,input().split())) for _ in range(N)]  # list化する意味は？
CD = [tuple(map(int,input().split())) for _ in range(N)]

from heapq import heappush,heappop

# q は 時間／都市名／所持金　の順番 <- 時間をキーに heapq を使うため

q=[(0,0,S)]  # スタート状態

while q:
    t, u, s = heappop(q)  # 最も到着時間の短い都市 u を選択
    for nxt, a, b in way[u]:  # u からたどり着ける都市 nxt に対して
        if s >= a:  # 交通費がある場合

            if dp[nxt][s-a] > t + b:  # 到着時間を検討
                dp[nxt][s-a] = t + b  # 早いので書き換え
                heappush(q,(t + b, nxt, s-a))  #  キューに次の都市候補として登録しておく
                # 同じ都市 & 同じ金額 が複数個登録されないか？ 計算回数は
                # 更新された = 周囲の都市（点）にたどり着く値を更新する必要があるかもしれないから
                # 検討対象になる

        # この時点では、u にいて、所持金 s でたどり着けないとしてはまだ更新されていない
                
    c, d = CD[u]
    nc = min(2500, c + s)  # 所持金を増やす
    nt= t + d  # 時間も掛かる

    if nt < dp[u][nc]:  # 交換後の金額と時間を見て、更新する（無限大だけが更新になる？）
        dp[u][nc] = nt
        heappush(q, (nt, u, nc))  # 同じ都市（点）だが、違う状態が登録されている

for i in range(1,N):
    print(min(dp[i]))

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

int		main(void)
{
	int r, g, b;

	cin >> r >> g >> b;
	int num = r * 100 + g * 10 + b;

	if (num % 4 == 0)
		cout << "YES";
	else
		cout << "NO";
	cout << endl;
}


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


int main() {
string S;
cin>>S;
int N=S.size();
string s1=S.substr(0,(N-1)/2);
string s2=S.substr((N+3)/2-1,(N-1)/2);
string t=S,t1=s1,t2=s2;
reverse(S.begin(),S.end());
reverse(s1.begin(),s1.end());
reverse(s2.begin(),s2.end());
//cout<<s2<<endl;
//cout<<t2<<endl;
if(t==S&&t1==s1&&t2==s2) cout<<"Yes"<<endl;
else cout<<"No"<<endl;

}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

	    int N=gi();
	    int H=gi();
	    int[] A=new int[N];
	    int[] B=new int[N];

	    int max=0;
	    for (int i=0; i<N;i++) {
	    	A[i]=gi();
	    	B[i]=gi();
	    	max=Math.max(A[i], max);
	    }

	    Arrays.parallelSort(B);

	    long ans=0;
	    int ind=N-1;
	    while(H>0) {
	    	if(ind<0 || max>=B[ind]) {
	    		if(H%max!=0)ans++;
	    		ans+=Math.floorDiv(H, max);
	    		break;
	    	} else {
	    		H-=B[ind];
	    		ind--;
	    		ans++;
	    	}
	    }

        System.out.println(ans);
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 61544
import sys
input = sys.stdin.readline

n = int(input())
a = list(map(int, input().split()))
q = int(input())

dict = {}

for i in range(1, 10**5+1):
    dict[i] = 0
for i in a:
    dict[i] += 1

s = sum(a)

for i in range(q):
    b, c = map(int, input().split())
    s += (c-b)*dict[b]
    dict[c] += dict[b]
    dict[b] = 0
    print(s)

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

int main(int argc, char **argv)
{
	char a[3];
	char b[3];
	int c;
	scanf("%s %s",a,b);
	c = strcmp(a,b);
	if(c==0){
		printf("H\n");
	}
	else{
		printf("D\n");
	}
	return 0;
}

Measured memory_bytes: 128
a=int(input())
b=list(input().split( ))
c=list(map(int, b))
count = 0

for  j  in range(a-2):
    d = []
    d.append(c[j])
    d.append(c[j+1])
    d.append(c[j+2])
    d.sort()
    if d[1]==c[j+1]:
          count += 1

print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
long long m=1e9+7;
long long fact[1000001];

long long modRecursive(long long a,long long b,long long c)
{
	if(b == 0) return 1;
	if(b%2 ==0) return modRecursive((a*a)%c,b/2,c);
	else return ((a%c)*(modRecursive((a*a)%c,b/2,c)))%c;
}

int main()
{
    fact[1]=1; fact[0]=1;
    for(long long i=2; i<=1000000; i++)
        fact[i]=(fact[i-1]*i)%m;
    long long x,y,a,b,d=0;
    cin>>x>>y; a=max(x,y); b=min(x,y);
    x=a; y=b;
    long long ans=1;
    for(int i=1; i<=x/2; i++)
    {
        long long twos=i,ones=x-2*i;
        if(2*ones+twos==y)
        {
            d=1;
            long long total=ones+twos;
            ans=(ans*fact[total])%m;
            ans=(ans*modRecursive(fact[twos],m-2,m))%m;
            ans=(ans*modRecursive(fact[total-twos],m-2,m))%m;
        }
    }
    if(d==0) ans=0;
    cout<<ans%m<<endl;
    return 0;
}


Measured memory_bytes: 8064
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq

def modinv(a,p):
    b,u,v = p,1,0
    while b:
        t = a//b
        a -= t*b
        a,b = b,a
        u -=t*v
        u,v = v,u
    u %=p
    return u
n,p = ma()
s = input();s=s[::-1]

if p==2:
    ans=0
    for i in range(n):
        if int(s[i])%2==0:
            ans+=n-i
    print(ans)
    exit()
if p==5:
    ans=0
    for i in range(n):
        if int(s[i])%5==0:
            ans+=n-i
    print(ans)
    exit()

iv10 = modinv(10,p)
ls = [0]*n
for i in range(n):
    a = int(s[i])
    ls[i]=(ls[i-1]+a*pow(10,i,p))%p
co = collections.Counter(ls)
ans=co[0]
tmp=0
for i in range(0,n-1):
    a = int(s[i])
    co[ls[i]%p]-=1
    tmp = (tmp +a)*iv10%p
    r = tmp*pow(10,i+1,p)%p
    ans +=co[r]
print(ans)


Measured memory_bytes: 70828
#pragma GCC optimize ("O2")
#pragma GCC diagnostic ignored "-Wunused-variable"
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-label"
#pragma GCC diagnostic ignored "-Wsign-compare"

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

#define trav(a, A) for (auto & a : A)
#define f first
#define s second

typedef long long ll;

const ll MOD = 1e+9+7;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const ll MAXN = 1e+5+7;
#define MAXN 10000009
ll sievesize, numDiffPF[MAXN];
bitset<MAXN> bs;
vector<ll> primes;

void sieve(ll n) {
	sievesize = n + 1;
	bs.set();
	bs[0] = bs[1] = 0;
	for (ll i = 2; i <= sievesize; i++) {
		if (bs[i]) {
			for (ll j = i * i; j <= (ll)sievesize; j += i) bs[j] = 0;
			primes.push_back(i);
		}
	}
}
ll numDiv(ll N) {
	ll i = 0, p = primes[i], ans = 1;
	while (p * p <= N) {
		ll power = 0;
		while (N % p == 0) { N /= p; power++; }
		ans *= (power + 1);
		p = primes[++i];
	}
	if (N != 1) ans *= 2;
	return ans;
}

int main ()
{
	ios_base::sync_with_stdio (0);
	cin.tie (0);
	ll tc = 1; //cin >> tc;
	sieve(1e4);
    while (tc--)
	{
		ll i, j, n;
		cin >> n;
        int ans = 0;
        vector<int> v(n), table(1e6+1, 0);
        for (int i = 0; i < n; ++i){
            cin >> v[i];
            table[v[i]]++;
        }
        set<int> seen;
        sort(v.begin(), v.end());
        for (int i = 0; i < n; ++i){
            if (table[v[i]] > 1) continue;
            int flag = 0;
            int N = v[i];
            for (j = 1; j*j <= N; ++j){
                if (v[i] % j == 0){
                    if ((table[j] and j != v[i]) or (v[i]/j != v[i] and table[v[i]/j])){
                        flag = 1;
                        break;
                    }
                }
            }
            ans += !flag;
        }
        cout << ans << '\n';
	}

	return 0;
}




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

int c[3][3];
void input()
{
    for (int i = 0; i < 3; ++i){
        for (int j = 0; j < 3; ++j){
            cin >> c[i][j];
        }
    }
}

void solve()
{
    if ((c[1][0] - c[0][0] != c[1][1] - c[0][1]) || (c[1][2] - c[0][2] != c[1][1] - c[0][1])){
        cout << "No" << endl;
        return;
    }
    if ((c[1][0] - c[2][0] != c[1][1] - c[2][1]) || (c[1][2] - c[2][2] != c[1][1] - c[2][1])){
        cout << "No" << endl;
        return;
    }
    cout << "Yes" << endl;
    return;
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

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

int main()
{
	int n;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	 } 
	 sort(a,a+n);
	 if(a[n/2]==a[n/2-1])
	 {
	 	cout<<"0"<<endl;
	 	return 0;
	 }
	 else{
	 	cout<<a[n/2]-a[n/2-1]<<endl;
	 	return 0;
	 }
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        A[i] -= i + 1;
    }
    sort(A.begin(), A.end());

    long long res = 0;
    for (int i = 0; i < N; i++)
        res += abs(A[i] - A[N / 2]);

    cout << res << endl;
    return 0;
}

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

using namespace std;

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

  unordered_map<long long, long long> cnt;

  for(long long i = 0; i < N; i++) {
    long long a;
    cin >> a;
    cnt[a] += 1;
  }

  vector<long long> v;

  for(auto p: cnt) {
    if(p.second >= 4) {
      v.push_back(p.first);
    }
    if(p.second >= 2) {
      v.push_back(p.first);
    }
  }

  if(v.size() < 2) {
    cout << 0 << endl;
    return 0;
  }

  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());

  cout << v[0] * v[1] << endl;
}


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

using namespace std;

#ifdef LOCAL
  #include "debug.h"
#else
  #define debug(...) 42
#endif

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  map<char, int> cnt;
  for (char c : s) {
    cnt[c] += 1;
  }
  if (cnt['W'] == 0 or cnt['R'] == 0) {
    cout << 0 << '\n';
    return 0;
  }
  int op = 0;
  for (int i = 0; i < cnt['R']; i++) {
    op += s[i] != 'R';
  }
  cout << op << '\n';
}


Measured memory_bytes: 3740
#ifdef Rahul
# include "RAHUL.h"
#else
# include <bits/stdc++.h>
  using namespace std;
# define error(...) 42;
#endif
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
#define Lu(...) [&] (auto &&u) { return __VA_ARGS__; }
#define Luv(...) [&] (auto &&u, auto &&v) { return __VA_ARGS__; }
const int MOD = (int) 1e9 + 7;
const i64 INF = (i64) 1e18 + 42;

int main() {
  cin.tie(nullptr) -> sync_with_stdio(false);
  
  int tt; cin >> tt;
  while (tt--) {
    int n; cin >> n;
    multiset<pair<int, int>> a, b;
    vector<int> k(n), l(n), r(n);
    for (int i = 0; i < n; ++i) {
      cin >> k[i] >> l[i] >> r[i];
      if (l[i] > r[i]) {
        a.insert({l[i] - r[i], i});
      } else {
        b.insert({r[i] - l[i], i});
      }
    }
    vector<int> at(n, -1);
    set<int> lids, rids;
    for (int i = 0; i < n; ++i) {
      (i < SZ(a) ? lids : rids).insert(i);
    }
    error(k, l, r);
    error(lids, rids, at);
    error(a);
    error(b);
    vector<int> spare;
    while (!a.empty() or !b.empty()) {
      auto av = a.empty() ? pair{-1, -1} : *prev(a.end());
      auto bv = b.empty() ? pair{-1, -1} : *prev(b.end());
      error(a, b, av, bv);
      if (av > bv) {
        a.erase(prev(a.end()));
        auto it = lids.lower_bound(k[av.second]);
        if (it == lids.begin()) {
          spare.push_back(av.second);
          continue;
        }
        --it;
        at[*it] = av.second;
        lids.erase(it);
      } else {
        b.erase(prev(b.end()));
        auto it = rids.lower_bound(k[bv.second]);
        if (it == rids.end()) {
          spare.push_back(bv.second);
          continue;
        }
        at[*it] = bv.second;
        rids.erase(it);
      }
    }
    i64 ans = 0;
    error(at);
    error(spare);
    for (int i = 0; i < n; ++i) {
      if (at[i] == -1) {
        at[i] = spare.back();
        spare.pop_back();
      }
      int j = at[i];
      if (i < k[j]) ans += l[j];
      else ans += r[j];
    }
    cout << ans << '\n';
  }
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

vl weights = {1,2,4,7,12,20,29,38,52,73};

ll max_hamilton(vvl adj) {
	ll n = sz(adj), res = 0;
	vl p(n);
	iota(all(p),0);
	do {
		ll cur = 0;
		FOR(i,1,n) cur += adj[ p[i] ][ p[i-1] ]; 
		res = max(res,cur);
	} while (next_permutation(all(p)));
	return res;
}

bool check(vvl adj) {
	ll n = sz(adj);
	vl p(n);
	iota(all(p),0);
	set<ll> s;
	do {
		ll cur = 0;
		if (p[0] > p[n-1]) continue;
		FOR(i,1,n) cur += adj[ p[i] ][ p[i-1] ];
		if (s.count(cur)) return false;
		s.insert(cur);
	} while (next_permutation(all(p)));
	return true;
}

vvl solve(ll n) {
	if (n == 2) return {{0,1},{1,0}};
	n--;
	vvl res = solve(n);
	
	ll hmax = max_hamilton(res) + (n==2);
	
	res.pb(vl(n+1));
	FOR(i,0,n) res[i].resize(n+1);
	
	FOR(i,0,n) res[i][n] = res[n][i] = weights[i] * hmax;
	return res;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;
	vvl res = solve(n);
	FOR(i,0,n) FOR(j,0,n) cout << res[i][j] << " \n"[j+1==n];
	cout << endl;
	cerr << max_hamilton(res) << endl;
	assert(check(res));
}



Measured memory_bytes: 85376
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
#include <string.h>
#define ll long long
using namespace std;


int main() {
    int a, b;
    cin >> a;
    
    b=a/2+a%2;
    
    cout << b << endl;
    
    return 0;
}

Measured memory_bytes: 256
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout
	cnt := 0

	if os.Getenv("MASPY") == "ますピ" {
		fp, _ = os.Open(os.Getenv("BEET_THE_HARMONY_OF_PERFECT"))
		cnt = 2
	}
	if os.Getenv("MASPYPY") == "ますピッピ" {
		wfp, _ = os.Create(os.Getenv("NGTKANA_IS_GENIUS10"))
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)
	solve(scanner, writer)
	for i := 0; i < cnt; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}

	writer.Flush()
}

func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	s := getNextString(scanner)
	n := len(s)
	aa := make([]int, n+1)
	bb := make([]int, n+1)
	cc := make([]int, n+1)
	qq := make([]int, n+1)
	for i := 0; i < n; i++ {
		switch s[i] {
		case 'A':
			aa[i+1]++
		case 'B':
			bb[i+1]++
		case 'C':
			cc[i+1]++
		case '?':
			qq[i+1]++
		}
	}
	for i := 0; i < n; i++ {
		aa[i+1] += aa[i]
		bb[i+1] += bb[i]
		cc[i+1] += cc[i]
		qq[i+1] += qq[i]
	}

	ss := make([]int64, n)
	ss[0] = 1
	for i := 1; i < n; i++ {
		ss[i] = mod(ss[i-1] * 3)
	}
	var ans int64
	for i := 0; i < n; i++ {
		if s[i] != 'B' && s[i] != '?' {
			continue
		}
		// A*C
		ans = mod(ans + mod(int64(before(i, aa))*int64(after(i, cc)))*ss[before(i, qq)+after(i, qq)])
		// A*?
		if after(i, qq)-1 >= 0 {
			ans = mod(ans + mod(int64(before(i, aa))*int64(after(i, qq)))*ss[before(i, qq)+after(i, qq)-1])
		}
		// ?*C
		if before(i, qq)-1 >= 0 {
			ans = mod(ans + mod(int64(before(i, qq))*int64(after(i, cc)))*ss[before(i, qq)+after(i, qq)-1])
		}
		// ?*?
		if before(i, qq)-1 >= 0 && after(i, qq)-1 >= 0 {
			ans = mod(ans + mod(int64(before(i, qq))*int64(after(i, qq)))*ss[before(i, qq)+after(i, qq)-2])
		}
	}
	fmt.Fprintln(writer, ans)
}

func before(i int, aa []int) int {
	return aa[i]
}
func after(i int, aa []int) int {
	return aa[len(aa)-1] - aa[i+1]
}
func mod(x int64) int64 {
	m := int64(1e9 + 7)
	return (x%m + m) % m
}


Measured memory_bytes: 4864
//int a = s - '0'; 文字から数字
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
//同じ作業繰り返す系の問題：収束先を見つける
//過半数：N/2.0で判定
//優先度付きキュー
//priority_queue<
//ll,
//vector<ll>
//> q;
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
#define PI 3.14159265358979323846264338327950L
using namespace std;

//割るやつ
const ll MOD = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

//a,bの最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1));
}

//Nのd桁目の数
ll dignum(ll N, ll d) {
	ll x = pow(10, d);
	N %= x;
	ll y = pow(10, d - 1);
	N /= y;
	return N;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

ll RS(ll N, ll P, ll M) {
	if (P == 0) return 1;
	if (P % 2 == 0) {
		ll t = RS(N, P / 2, M);
		return t * t % M;
	}
	return N * RS(N, P - 1, M);
}

vector<int> IntegerToVector(int bit, int N) {
    vector<int> S;
    for (int i = 0; i < N; ++i) {
        if (bit & (1 << i)) {
            S.push_back(i);
        }
    }
    return S;
}

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

	sort(ALL(a));
	ll ans = 1e12;
	for(int n = a[0]; n <= a[N-1]; n++){
		ll sum = 0;
		for(int i = 0; i <= N-1; i++){
			sum += (a[i] - n)*(a[i] - n);
		}
		if(ans >= sum) ans = sum;
	}

	cout << ans << endl;
}	

Measured memory_bytes: 10964
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<queue>
#include<list>
#include<stack>
#include<deque>
#include <sstream>
#include <string.h>
#include<fstream>

typedef long long ll ;
// random in each run --> srand(time(NULL));

#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define IN(n) scanf("%d" , &n )
#define debug(x) cout<<#x<<" = { "<<x<<" }\n"
void fo (){fflush(stdout);}
using namespace std;
int N , W ;
int a[101][2];
ll dp[101][100001];
int main ()
{
  scanf ("%d%d" , &N , &W );
  for (int i =1; i <= N ;i++)
  {
    int w , v ;
    scanf ("%d%d" , &w , &v );
    a[i][0] = w;
    a[i][1] = v;
  }
  for (int i = 1 ; i <= 1e5 ;i++)dp[0][i] = 1e12 ;
  for (int i = 1 ; i <= N ;i++)
  {
    for (int j = 1 ; j <= 1e5 ; j++)
    {
      dp[i][j] = min (dp[i-1][j] , (j >= a[i][1] ? dp[i-1][j-a[i][1]] + a[i][0] : (ll)1e12 ));
    }
  }
  int ans =0 ;
  for (int i = 1; i <= 1e5 ;i++)if (dp[N][i] <= W )ans = i ;
  printf ("%d\n" , ans );
  return 0;
}


Measured memory_bytes: 79104
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict

H,W,K=map(int, sys.stdin.readline().split())
S=[ sys.stdin.readline().strip() for _ in range(H) ]

ans=float("inf")
for bit in range(2**H):
    cnt=0
    group_num=0
    GROUP={}
    for i,s in enumerate(S):
        if i==0:
            GROUP[i]=group_num
        else:
            if bit>>i-1&1==1:
                cnt+=1      #境目のカウントに+1
                group_num+=1
            GROUP[i]=group_num

    ok=None
    VALUE=defaultdict(lambda: 0)
    w=0
    break_flag=False
    for w in range(W):
        if break_flag:  #breakフラグがTrueならループを止める
            break
        for h in range(H):
            VALUE[GROUP[h]]+=int(S[h][w])
        #現在の集計でKを超えている値がないかをチェック
        for v in VALUE.values():
            if v<=K:
                pass
            else:
                if ok is None:      #okに値がない場合は、このパターンは成り立たない
                    cnt=float("inf")    #不可能なパターンなのでカウントに無限大を代入
                    break_flag=True     #breakフラグにTrueを代入
                    break
                else:      #以前の列でok番号に値が入っていた、つまり成り立つ列があった場合
                    cnt+=1      #境目のカウントに+1
                    VALUE=defaultdict(lambda: 0)    #NGの場合は値を初期化して入れなおし
                    for h in range(H):
                        VALUE[GROUP[h]]+=int(S[h][w])
                    break
        else:
            ok=w    #値が全てK以下だった場合はok変数に列番号を記録
    ans=min(ans,cnt)
       
print ans

Measured memory_bytes: 33900
def d_five_five_everywhere(N):
    def prime_table(n):
        # nまでの素数のリスト
        table = [True for _ in range(n + 1)]
        i = 2
        while i**2 <= n:
            if table[i]:
                j = i + i
                while j <= n:
                    table[j] = False
                    j += i
            i += 1
        ret = [i for i in range(n + 1) if table[i] and i >= 2]
        return ret
    prime = prime_table(55555)  # 55555以下の素数を得る
    prime_match = []  # 素数のうち5で割った余りが1の素数のリスト(長さN)
    series_length = 0
    for p in prime:
        if p % 5 == 1:
            prime_match.append(p)
            series_length += 1
        if series_length == N:
            break
    ans = ' '.join(map(str, prime_match))
    return ans

N = int(input())
print(d_five_five_everywhere(N))

Measured memory_bytes: 3736
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>

using namespace std;

long long h,zr;

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

cin >> h;
long long v = h;

long long q = 1;

while (h>1){
	zr += q;
	long long a = h/2;
	q *= 2;
	h /= 2;
	if (a == 1)
		zr+= q;
}
				
if (v == 1)
	cout << 1;
else				
	cout << zr;

return 0;
}



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

#define N 10000

int d[ N ][ 721 ];

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  int i, j;

  for ( ; ; )
  {
    int pcn, stdn;
    int r, q;

    scanf ( "%d%d", &pcn, &stdn );
    if ( !( pcn | stdn ) ) break ;

    memset ( d, 0, sizeof ( d ) );
    scanf ( "%d", &r );
    while ( r-- )
    {
      int t, pc, std, s;

      scanf ( "%d%d%d%d", &t, &pc, &std, &s );
      d[ std - 1 ][ t - 540 ] += ( s ? 1 : -1 );
    }
    for ( i = 0; i < stdn; ++i )
    {
      int su = 0;
      int st = 0;

      for ( j = 0; j <= 720; ++j )
      {
        su += !!( st );
        st += d[ i ][ j ];
        d[ i ][ j ] = su;
      }
    }

    scanf ( "%d", &q );
    while ( q-- )
    {
      int ts, te, std;

      scanf ( "%d%d%d", &ts, &te, &std );
      printf ( "%d\n", d[ std - 1 ][ te - 540 ] - d[ std - 1 ][ ts - 540 ] );
    }
  }

  return ( 0 );
}

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

int mid(int a,int b,int c){
  return a+b+c-max(max(a,b),c)-min(min(a,b),c);
}

int main(){
  int a;
  cin >> a;
  cout << 3 * a * a << endl;
}
  
    

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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

ll z = 0;
ll n;
ll a[200000], b[200000];
ll allcnt[36], cnt[36];
vector<ll> hoge[36];

int main() {
    cin >> n;
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n) {
        for (ll j = 0; j <= 35; j++) {
            allcnt[j] += ((b[i]&(1LL<<j)) != 0);
            hoge[j].push_back(b[i]%(1LL<<(j+1)));
        }
    }
    rep(j,36) sort(hoge[j].begin(), hoge[j].end());
    
    ll ans = 0;
    rep(i,n) {
        ll now = 0;
        rep(j,36) cnt[j] = allcnt[j];
        for (ll j = 0; j <= 35; j++) {
            if ((a[i]&(1LL<<j)) == 0) {
                now += (1LL<<j)*(cnt[j]%2);
            } else {
                now += (1LL<<j)*((n-cnt[j])%2);
            }
            ll up = n-(lower_bound(hoge[j].begin(), hoge[j].end(), ((1LL<<(j+1))-a[i]%(1LL<<(j+1))))-hoge[j].begin());
            cnt[j+1] += up;
            cnt[j+1] %= 2;
        }
        ans ^= now;
    }
    cout << ans << endl;
}
































Measured memory_bytes: 63252
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub\
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		if(n>=1 && n<=100) {
		if(n%2 == 0) {
			System.out.println(n/2);
		}else {
			System.out.println(n/2 +1);
		}
		}

	}

}


Measured memory_bytes: 22100
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);

	HashMap<String, Integer> map;
	LinkedList<String> que;

	void run() {
		map = new HashMap<String, Integer>();
		que = new LinkedList<String>();
		int cnt = 0;
		que.add("01234567");
		map.put("01234567", cnt);
		while (!que.isEmpty()) {
			cnt++;
			int size = que.size();
			for (int i = 0; i < size; i++) {
				String now = que.poll();
				int zero = 0;
				for (int j = 0; j < 8; j++) {
					if (now.charAt(j) == '0') {
						zero = j;
					}
				}
				if (zero != 0 && zero != 4) {
					char[] next = now.toCharArray();
					char t = next[zero - 1];
					next[zero] = t;
					next[zero - 1] = '0';
					setParam(next, cnt);
				}
				if (zero != 3 && zero != 7) {
					char[] next = now.toCharArray();
					char t = next[zero + 1];
					next[zero] = t;
					next[zero + 1] = '0';
					setParam(next, cnt);
				}
				char[] next = now.toCharArray();
				char t = next[(zero + 4) % 8];
				next[zero] = t;
				next[(zero + 4) % 8] = '0';
				setParam(next, cnt);
			}
		}
		while (sc.hasNext()) {
			String key = "";
			for (int i = 0; i < 8; i++) {
				key += sc.nextInt();
			}
			System.out.println(map.get(key));
		}
	}

	void setParam(char[] next, int cnt) {
		String nextS = String.valueOf(next);
		if (!map.containsKey(nextS)) {
			map.put(nextS, cnt);
			que.add(nextS);
		}
	}

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

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

#define ll long long int

int vals [100005];
ll memo[100005];
int N;

ll costo(){
	memo[0]= 0;
	memo[1]= abs(vals[1]-vals[0]);
	for(int i = 2; i<N;i++)
		memo[i] = min(abs(vals[i-1]-vals[i])+memo[i-1], 
					  abs(vals[i-2]-vals[i])+memo[i-2]);
	return memo[N-1];
}

int main() {
	cin>>N;
	for(int i = 0; i<N;i++)
		cin>>vals[i];
	cout<<costo()<<endl;
	return 0;
}

Measured memory_bytes: 4668
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
#include <queue>
#include <functional>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m?-n:n;}
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

using V = vector<int>;
using VV = vector<V>;
struct P {int x, y;};

int main() {
	int dx[] = {4, 2}, dy[] = {2, 4};
	for (int w, h; w = in(), h = in();) {
		P s = {in() - 1, in() - 1}, g = {in() - 1, in() - 1};
		int n = in();
		VV m(h, V(w));
		while (n--) {
			int c = in(), d = in(), x = in() - 1, y = in() - 1;
			for (int i = 0; i < dy[d]; i++)
				for (int j = 0; j < dx[d]; j++)
					m[i + y][j + x] = c;
		}
		function<bool(int, int, int)> f = [&](int x, int y, int c) {
			if (x == g.x && y == g.y)
				return true;
			P d = {1, 0};
			for (int i = 0; i < 4; i++) {
				int tx = x + d.x, ty = y + d.y;
				if (tx >= 0 && ty >= 0 && tx < w && ty < h && m[ty][tx] == c) {
					m[ty][tx] = 0;
					if (f(tx, ty, c))
						return true;
				}
				swap(d.x, d.y *= -1);
			}
			return false;
		};
		int c = m[s.y][s.x];
		m[s.y][s.x] = 0;
		outl(c ? f(s.x, s.y, c) ? "OK" : "NG" : "NG");
	}
}


Measured memory_bytes: 2568
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int,int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/

int main(){
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N,K;
    cin >> N >> K;

    cout << K * (ll)(pow(K-1,N-1)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define fr(i, a, b) for (int i = a; i < b; i++)
using namespace std;
#define mod 1000000007
#define fr(i, a, b) for (int i = a; i < b; i++)
#define fast_io ios::sync_with_stdio(false);cin.tie(NULL);
string solve(vi &a,int k){
    bool dp[k + 1] = {false};
    fr(j,1,k+1){
        for(int m:a){
            if(m>j) continue;
            if(dp[j-m]==0){
                dp[j]=1;
            }
        }
    }
    return dp[k]?"First":"Second";
}
int main(){
    fast_io
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    int n,k;
    cin>>n>>k;
    vi a(n);
    fr(i,0,n){
        cin>>a[i];
    }
    cout<<solve(a,k);
}

Measured memory_bytes: 384