akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define PI acos(-1)
#define EPS 1e-12
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define bitCount __builtin_popcount
#define forn(i, n) for(i = 0; i < (ll)n; i++)
#define for1(i, n) for(i = 1; i <= (ll)n; i++)
#define forv(i, v) for(i = 0; i < v.size(); i++)
#define forab(i, a, b) for(i = a; i <= (ll)b; i++)
#define Sort(v) sort(v.begin(), v.end())
#define bend(v) v.begin(), v.end()
#define sz(v) v.size()
#define trace(x) cout<<"x = "<<x<<"\n"
#define trace2(x, y) cout<<"x = "<<x<<" y = "<<y<<"\n"
#define trace3(x, y, z) cout<<"x = "<<x<<" y = "<<y<<" z = "<<z<<"\n"
#define trace4(w, x, y, z) cout<<"w = "<<w<<" x = "<<x<<" y = "<<y<<" z = "<<z<<"\n"
#define ln "\n"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef set<int>::iterator sit;
typedef set<ll>::iterator sllt;
typedef set<char>::iterator sct;
typedef map<int, int>::iterator mit;
typedef vector<int>::iterator vit;
typedef multiset<int>::iterator msit;
const int maxn = 1e5+5;
const ll mod = 1e9+7;
const int alphabet = 26;
const int inf = INT_MAX;
const ll linf = 1e18+9;
namespace util{
	inline ll cnm(char ch){ return (ch-'0'); }
	inline ll cap(char ch){ return (ch-'a'); }
	inline void instr(string& s, ll& n){ cin>>s;    n = s.length(); }
	inline void instr(string& s){ cin>>s; }
	template<typename T> T gcd(T a, T b){ if(a==0) return b; return gcd(b%a, a); }
	template<typename T> bool min(T a, T b, T c){
		return  std::min(a, std::min(b, c));
	}
}
using namespace util;


void solve(int tc)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	ll i, j, k, m, n;
	vector<int> a(5);
	int ans = -1;
	for(i = 0; i < 5; i++) {
		cin>>a[i];
		if(a[i] == 0) ans = i+1;
	}

	cout<<ans;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	int t = 1;
	int i = 1;
	// cin>>t;
	while(i <= t){
		solve(i);
		i++;
	}

	return 0;
}



Measured memory_bytes: 3588
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int INF=0x3f3f3f3f;

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

    if(s.size()<=k)
        cout<<s<<endl;
    else
    {
        for(int i=0;i<k;i++)
            cout<<s[i];
        cout<<"..."<<endl;
    }

    return 0;
}




Measured memory_bytes: 3636
h, w, n = map(int, input().split())
sr, sc = map(int, input().split())
S = input()
T = input()
win = 0

SR = sr
SC = sc
sr = SR
sc = SC
for i in range(n):
    if S[i] == "L":
        sc -= 1
    if sc <= 0:
        break
    if T[i] == "R" and sc < w:
        sc += 1
if sc <= 0:
    win = 1


sr = SR
sc = SC
for i in range(n):
    if S[i] == "R":
        sc += 1
    if sc > w:
        break
    if T[i] == "L" and sc > 1:
        sc -= 1
if sc > w:
    win = 1


sr = SR
sc = SC
for i in range(n):
    if S[i] == "D":
        sr += 1
    if sr > h:
        break
    if T[i] == "U" and sr > 1:
        sr -= 1
if sr > h:
    win = 1


sr = SR
sc = SC
for i in range(n):
    if S[i] == "U":
        sr -= 1
    if sr <= 0:
        break
    if T[i] == "D" and sr < h:
        sr += 1
if sr <= 0:
    win = 1

if win:
    print("NO")
else:
    print("YES")


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/
template<typename T_n>
std::map<T_n, int> prime_factor(T_n n) {
    std::map<T_n, int> ret;
    for(T_n i = 2; i*i <= n; i++){
        while(n % i == 0){
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return ret;
}

/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int n; cin >> n;
    cout << n << ':';
    auto p = prime_factor(n);
    for(auto pp : p) rep(i,pp.second) cout << ' ' << pp.first;
    cout << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 3220
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int x, y; readV(x, y);
  writeln(x+y/2);
}


Measured memory_bytes: 256
N, M = map(int, input().split())


if not (abs(N - M) == 0 or abs(N - M) == 1):
    print(0)
    exit()
elif abs(N - M) == 0:
    tmp = 2
else:
    tmp = 1

for i in range(1,N+1):
    tmp = (tmp * i) % 1000000007

for i in range(1, M+1):
    tmp = (tmp * i) % 1000000007

print(tmp)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
const int MOD = 998244353;
struct Mint {
	int val;
	Mint() { val = 0; }
	Mint(const ll& x) {
		val = (-MOD <= x && x < MOD) ? x : x % MOD;
		if (val < 0) val += MOD;
	}
	template <typename U>
	explicit operator U() const { return (U)val; }
	friend bool operator==(const Mint& a, const Mint& b) { return a.val == b.val; }
	friend bool operator!=(const Mint& a, const Mint& b) { return !(a == b); }
	friend bool operator<(const Mint& a, const Mint& b) { return a.val < b.val; }
	Mint& operator+=(const Mint& m) { if ((val += m.val) >= MOD) val -= MOD; return *this; }
	Mint& operator-=(const Mint& m) { if ((val -= m.val) < 0) val += MOD; return *this; }
	Mint& operator*=(const Mint& m) { val = (ll)val * m.val % MOD; return *this; }
	friend Mint modex(Mint a, ll p) {
		assert(p >= 0);
		Mint ans = 1;
		for (; p; p >>= 1, a *= a) if (p & 1) ans *= a;
		return ans;
	}
	Mint& operator/=(const Mint& m) { return *this *= modex(m, MOD - 2); }
	Mint& operator++() { return *this += 1; }
	Mint& operator--() { return *this -= 1; }
	Mint operator++(int) { Mint result(*this); *this += 1; return result; }
	Mint operator--(int) { Mint result(*this); *this -= 1; return result; }
	Mint operator-() const { return Mint(-val); }
	friend Mint operator+(Mint a, const Mint& b) { return a += b; }
	friend Mint operator-(Mint a, const Mint& b) { return a -= b; }
	friend Mint operator*(Mint a, const Mint& b) { return a *= b; }
	friend Mint operator/(Mint a, const Mint& b) { return a /= b; }
	friend ostream& operator<<(ostream& os, const Mint& x) { return os << x.val; }
};
Mint F[3005][3005], G[3005][3005];
int main() {
	int A, B, C, D;
	scanf("%d%d%d%d", &A, &B, &C, &D);
	G[A][B] = 1;
	for (int r = A; r <= C; ++r) {
		for (int c = B; c <= D; ++c) {
			if (r > A) F[r][c] = c * (F[r - 1][c] + G[r - 1][c]);
			if (c > B) G[r][c] = r * G[r][c - 1] + F[r][c - 1];
		}
	}
	printf("%d\n", (F[C][D] + G[C][D]).val);
}


Measured memory_bytes: 74324
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int N;
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  int count = 0;
  int i = 1;
  while (count < N) {
    i = a.at(i-1);
    count++;
    if (i == 2) {
      cout << count << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}
    

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

using namespace std;

const double eps = 1e-8;
#define eq(a, b) (fabs((a)-(b)) < eps)
#define lt(a, b) (((a)-(b)) < -eps)

struct node {
  string self;
  double sim;
  set<int> sub;
  int li, ri;
  node(){}
  node(string self, double sim, int li, int ri):self(self), sim(sim), li(li), ri(ri){}
};

string s;
int idx;
map<string, int> mp;
vector<node> vec;
int sz;

int insert(string tree, int li, int ri) {
  if(!mp.count(tree)) {
    node new_node(tree, 0.0, li, ri);
    if(li != -1) {
      set<int> A = vec[li].sub;
      set<int> B = vec[ri].sub;
      if(A.size() < B.size()) swap(A, B);
      int cnt = 0;
      for(int b : B) {
	cnt += A.count(b);
	A.insert(b);
      }
      new_node.sub = A;
      new_node.sim = (double)cnt/A.size();
    }
    mp[tree] = sz++;
    new_node.sub.insert(mp[tree]);
    vec.push_back(new_node);
  }
  return mp[tree];
}

int cmp(int i, int j) {
  node x = vec[i];
  node y = vec[j];
  if(!eq(x.sim, y.sim)) {
    if(lt(x.sim, y.sim)) return 1;
    else return -1;
  }
  if(x.li == -1) return 0;
  int res = cmp(x.li, y.li);
  if(res == 0) res = cmp(x.ri, y.ri);
  return res;
}

int solve() {
  int ch = s[idx++];
  if(ch == 'x') return insert("x", -1, -1);
  int li = solve(); idx++;
  int ri = solve(); idx++;
  //if(vec[li].sim > vec[ri].sim) swap(li, ri);
  if(cmp(li, ri) == -1) swap(li, ri);
  node lch = vec[li];
  node rch = vec[ri];
  string self = "(" + lch.self + " " + rch.self + ")";
  return insert(self, li, ri);
}


string output(int i, bool izryt) {
  //cout << i << endl;
  if(vec[i].self == "x") return "x";
  node v = vec[i];
  //if((cmp(v.li, v.ri)==-1)^izryt) swap(v.li, v.ri);
  if(izryt) swap(v.li, v.ri);
  return "(" + output(v.li, false) + " " + output(v.ri, true) + ")";
}

int main() {
  cout<<fixed<<setprecision(12);
  while(getline(cin, s), s != "0") {
    mp.clear();
    vec.clear();
    sz = 0;
    idx = 0;
    int ans = solve();
    cout << output(ans, false) << endl;
  }
  return 0;
}



Measured memory_bytes: 3320
//
//  main.cpp
//  Chokudai_Contest_004
//
//  Created by tolemy on 2019/08/31.
//  Copyright © 2019 tolemy. All rights reserved.
//

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

using namespace std;

typedef pair<int, int> job;

#define rep(i, start, end) for (int i = (int)(start); i < (int)(end); i++)

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

    int n, k, q;
    cin >> n >> k >> q;

    int *b = new int[n + 1]();
    rep(i, 0, q)
    {
        int a = 0;
        cin >> a;

        b[a]++;
    }

    rep(i, 1, n + 1)
    {
        if (b[i] - q > -k)
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 1024
n,m = map(int,input().split())
lst = [list(map(int,input().split())) for _ in range(m)]
lst.sort(key=lambda x:x[1])
res = []
for i in range(m):
    a,b = lst[i][0], lst[i][1]
    flg = False
    if i==0:
        res.append(b-1)
    else:
        for r in res:
            if a<=r<=b:
                flg=True
        if not flg:
            res.append(b-1)
print(len(res))

Measured memory_bytes: 64984
#include <bits/stdc++.h>
#define LL long long

const int N = 3e3 + 5;
const int mod = 998244353;

int n, s;
int a[N];
LL f[N][N][3];

int main() {
    scanf("%d %d", &n, &s);
    for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
    f[0][0][0] = 1;
    for(int i = 1; i <= n; ++i) {
        for(int j = 0; j <= s; ++j) {
            f[i][j][0] = (f[i][j][0] + f[i - 1][j][0]) % mod;
            f[i][j][1] = (f[i][j][1] + f[i - 1][j][0] + f[i - 1][j][1]) % mod;
            f[i][j][2] = (f[i][j][2] + f[i - 1][j][0] + f[i - 1][j][1] + f[i - 1][j][2]) % mod;
            if(j + a[i] <= s) {
                f[i][ j + a[i] ][1] = (f[i][ j + a[i] ][1] + f[i - 1][j][0] + f[i - 1][j][1]) % mod;
                f[i][ j + a[i] ][2] = (f[i][ j + a[i] ][2] + f[i - 1][j][0] + f[i - 1][j][1]) % mod;
            }
        }
    }
    printf("%lld", f[n][s][2]);
    return 0;
}


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

long long GCD(long long a, long long b) 
{ 
    if(b==0) 
        return a; 
    return GCD(b, a%b);  
      
}

long long LCM(long long a, long long b)
{
    long long gcd=GCD(a,b);
     return (a*b)/gcd;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    
    long long i, j, k, n=3, m, t, x, y, z, s=0, c=0, l;
    string a;
    while(n--)
    {
        cin >> a;
        cout << a[s];
        s++;
    }
    cout << endl;
}


Measured memory_bytes: 3652
#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>;

const int MX = 100005;

int main() {
  int n;
  cin >> n;
  vector<ll> cnt(MX);
  rep(i,n) {
    int a;
    cin >> a;
    cnt[a]++;
  }
  ll tot = 0;
  rep(i,MX) tot += i*cnt[i];

  int q;
  cin >> q;
  rep(i,q) {
    int b, c;
    cin >> b >> c;
    tot -= b*cnt[b];
    tot -= c*cnt[c];
    cnt[c] += cnt[b]; cnt[b] = 0;
    tot += b*cnt[b];
    tot += c*cnt[c];
    cout << tot << endl;
  }
  return 0;
}

Measured memory_bytes: 4048
#include <stdio.h>

int main(){
   long n,a,b,ans,t;
 
   scanf("%ld %ld %ld",&n,&a,&b);
   ans=(n/(a+b))*a;
   t=n%(a+b);
   if (t>a) printf("%ld\n",ans+a);
   else     printf("%ld\n",ans+t);
   return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int MOD = 1e9 + 7;

inline int solve(pii a, pii b){
	return abs(a.first - b.first) + abs(a.second - b.second);
}

int main(){
	int H, W, D, Q;
	cin >> H >> W >> D;
	vector<pii> pos(H*W);
	for (int i = 0; i < H; ++i){
		for (int j = 0; j < W; ++j){
			int A;
			cin >> A;
			A--;
			pos[A] = make_pair(i, j);
		}
	}

	vector<ll> dist(H*W);
	for (int i = 0; i < H*W; ++i)
		if (i - D >= 0)
			dist[i] = dist[i - D] + solve(pos[i], pos[i - D]);

	cin >> Q;
	for (int i = 0; i < Q; ++i){
		int l, r;
		cin >> l >> r;
		l--, r--;
		cout << dist[r] - dist[l] << '\n';
	}

	return 0;
}

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

class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n =scanner.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            int x = scanner.nextInt();
            a[i] = (int)(Math.log(x & -x)/Math.log(2));
        }
        System.out.println(Arrays.stream(a).min().getAsInt());
    }
}


Measured memory_bytes: 26836
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
using namespace std;

typedef long long LL;
const int MaxN = 1e5 + 6;
char s[105];
LL k;
LL qwr(LL x, LL y){
	LL res = 1;
	while(y){
		if(y & 1) res *= x;
		x *= x;
		y >>= 1;
	}
	return res;
}

int main(){
	cin>>s+1;
	cin>>k;
	int pos = 1;
	int n = strlen(s+1);
	for(int i = 1; i <= n; i++){
		if(s[i] != '1'){ 
			pos = i;
			break;
		}
	}
	if(k < pos) cout<<'1'<<endl;
	else cout<<s[pos]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
main()
{
    int n,i,j,k,m,l=0;
    scanf("%d%d%d",&i,&j,&k);
    n=i-j;
    m=k-n;
    if(m<0)
        printf("0");
    else
        printf("%d\n",m);
}


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

#define mod 200003
#define G 2
#define MAXN 8000010
#define PI 3.1415926535897932384

struct cp
{
	double real,imag;
	cp(){}
	cp(double a,double b):real(a),imag(b){}
	cp operator+(cp &c){return cp(real+c.real,imag+c.imag);}
	cp operator-(cp &c){return cp(real-c.real,imag-c.imag);}
	cp operator*(cp &c){return cp(real*c.real-imag*c.imag,real*c.imag+imag*c.real);}
	cp operator/(int x){return cp(real/x,imag/x);}
};

int n,m,l=1,tt,rev[MAXN],ln[MAXN],now=1,tmp[MAXN];
long long ans;
cp a[MAXN];

void init(int x)
{
	while(l<=x)l<<=1,++tt;
	for(int i=0;i<l;++i)rev[i]=(rev[i>>1]>>1)|((i&1)<<(tt-1));
}

void fft(cp *a,int dft)
{
	for(int i=0;i<l;++i)if(i<rev[i])swap(a[i],a[rev[i]]);
	for(int mid=1;mid<l;mid<<=1)
	{
		cp w(cos(PI/mid),dft*sin(PI/mid));
		for(int r=mid<<1,i=0;i<l;i+=r)
		{
			cp nw(1,0);
			for(int j=0;j<mid;++j)
			{
				cp x=a[i+j],y=nw*a[i+mid+j];
				a[i+j]=x+y;
				a[i+mid+j]=x-y;
				nw=nw*w;
			}
		}
	}
	if(dft==-1)for(int i=0;i<l;++i)a[i]=a[i]/l;
}

void calc()
{
	int now=1;
	for(int i=1;i<mod;++i)
	{
		now=(long long)now*G%mod;
		ln[now]=i;
	}
}

int main()
{
	calc();
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		int x;
		scanf("%d",&x);
		if(x==0)continue;
		a[ln[x]].real+=1;
		++tmp[2*ln[x]];
	}
	init(2*mod);
	fft(a,1);
	for(int i=0;i<l;++i)a[i]=a[i]*a[i];
	fft(a,-1);
	for(int i=0;i<l;++i)
	{
		ans+=now*((long long)(a[i].real-tmp[i]+.5))/2;
		now=(long long)now*G%mod;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 16724
N = int(input())
block_list = [int(x) for x in input().split()]

# print(N, block_list)

check_num = 1
K = 0
for i in range(N):
    if block_list[i] == check_num:
        K += 1
        check_num += 1

if K == 0:
    print(-1)    
else:
    print(len(block_list) - K)

Measured memory_bytes: 25768
import java.util.*;

class Main{
    Scanner sc = new Scanner(System.in);
    
    Main(){
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if ( H == 0 && W == 0 ) break;
            for ( int h = 0; h < H; h++){
                if ( h % 2 == 0){
                    for ( int w = 0; w < W; w++){
                        if ( w % 2 == 0 ){
                            System.out.print("#");
                        }else{
                            System.out.print(".");
                        }
                    }
                }else{
                    for ( int w = 0; w < W; w++){
                        if ( w % 2 == 0 ){
                            System.out.print(".");
                        }else{
                            System.out.print("#");
                        }
                    }
                }
                System.out.print("\n");
            }
            System.out.print("\n");
        }
    }
    public static void main(String[] args){
        new Main();
    }
}
                    


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

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

	vector<int> ans(l,0);
	for(int i=0;i<l;i++)
	{
		if(s[i]!='.')continue;
		int left=0,right=0;
		int tmp=0;
		for(int j=i-1;j>=0;j--)
		{
			if(s[j]=='.') {
				tmp = 0;
				break;
			}
			if(s[j]=='B')tmp++;
			if(s[j]=='W')
			{
				left=tmp;
				break;
			}
		}
		tmp = 0;
		for(int j=i+1;j<l;j++)
		{
			if(s[j]=='.'){
				tmp=0;
				break;
			}
			if(s[j]=='B')tmp++;
			if(s[j]=='W')
			{
				right=tmp;
				break;
			}
		}
		ans[i] = left + right;
		bool lflag=false,rflag=false;
		for(int j=i-1;j>=0;j--)
		{
			if(s[j]=='.') {
				lflag=false;
				break;
			}
			if(s[j]=='B'){
				lflag=true;
				break;
			}
			if(s[j]=='W')
			{
				continue;
			}
		}
		for(int j=i+1;j<l;j++)
		{
			if(s[j]=='.') {
				rflag=false;
				break;
			}
			if(s[j]=='B') {
				rflag=true;
				break;
			}
			if(s[j]=='W')
			{
				continue;
			}
		}
		if(lflag and rflag) ans[i] = 0;
		//cerr << lflag << " " << rflag << endl;
		//cerr << i << " "  << left << " " << right << " " << ans[i] << endl;
	}
	
	sort(ans.begin(), ans.end());
	cout << ans[l-1] << endl;
}


Measured memory_bytes: 3200
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

int sum[100009]; // sum[i] : 難易度がi以下の問題の総数

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

	int N; cin >> N;
	for (int i = 0; i < N; i++) {
		int tmp; cin >> tmp;
		sum[tmp]++;
	}

	for (int i = 1; i < 100009; i++) sum[i] += sum[i - 1];

	int ans = 0;

	for (int i = 1; i <= 100000; i++) {
		int cnt1 = sum[i - 1]; // 難易度がi未満
		int cnt2 = sum[100000] - sum[i - 1]; // 難易度がi以上
		if (cnt1 == cnt2) ans++; 
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
typedef long long ll;
int main(){
    string C[2];
    cin >> C[0] >> C[1];
    bool ans = true;
    REP(i,3) if(C[0][i] != C[1][2-i]) ans = false;
    if(ans) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    int buka[n] = {0};
    for (int i=1; i<n; i++) {
        int a;
        cin >> a;
        buka[a-1]++;
    }
    for (int i=0; i<n; i++) {
        cout << buka[i] << endl;
    }
}

Measured memory_bytes: 4408
#include <stdio.h>

int main(void)
{
	int n_conv, n_data;
	char conv[100][2], data, iscomp;
	register char *p;
	register int i;
	for (;;) {
		scanf("%d%*c", &n_conv);
		if (!n_conv)
			return 0;
		for (p = conv; p < conv[n_conv]; p++)
			scanf("%c %c%*c", p++, p);
		scanf("%d%*c", &n_data);
		for (i = 0; i < n_data; iscomp = 0, i++) {
			scanf("%c%*c", &data);
			for (p = conv; p < conv[n_conv]; p += 2) {
				if (data == *p) {
					putchar(*(p + 1));
					iscomp = 1;
					break;
				}
			}
			if (!iscomp)
				putchar(data);
		}
		puts("");
	}
}

Measured memory_bytes: 588
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <cstring>
#include <cmath>
#include <queue>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)

#define debug(x) cerr<<#x<<": "<<x<<endl;

#define fi first
#define se second

#define vi vector<int>
#define pb push_back
#define mp make_pair

#define pcnt __builtin_popcount

typedef long long ll;

const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int dx[6] = {1,-1,1,0,-1,0};
const int dy[6] = {1,-1,0,1,0,-1};

int main(){
    int a,b;
    while(cin >> a >> b,a){
        int bfs[200][200];
        int ban[200][200];
        rep(i,200)rep(j,200)ban[i][j]=bfs[i][j]=0;
        rep(i,b){
            int x,y;
            cin >> x >> y;
            x+=100;
            y+=100;
            ban[y][x]=1;
        }
        int sx,sy;
        cin >> sx >> sy;
        sx+=100;
        sy+=100;
        queue<int> qy;
        queue<int> qx;
        qx.push(sx);
        qy.push(sy);
        bfs[sy][sx] = a+1;
        while(qx.size()){
            int y = qy.front();
            int x = qx.front();
            qx.pop();qy.pop();
            if(bfs[y][x] == 1) break;
            rep(i,6){
                int nx = x+dx[i];
                int ny = y+dy[i];
                if(!bfs[ny][nx]&&!ban[ny][nx]){
                    bfs[ny][nx] = bfs[y][x]-1;
                    qx.push(nx);
                    qy.push(ny);
                }
            }
        }
        int ret = 0;
        rep(i,200)rep(j,200)if(bfs[i][j])ret++;
        cout << ret << endl;
    }
}



Measured memory_bytes: 3376
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

main() {
    int64_t x, y;
    cin >> x >> y;

    int64_t ans = 0;
    for (auto r : {x, y}) {
        switch (r) {
            case 1:
                ans += 300000;
                break;
            case 2:
                ans += 200000;
                break;
            case 3:
                ans += 100000;
                break;
        }
    }

    if (x == y && x == 1) {
        ans += 400000;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma once

#ifndef call_from_test
#include <bits/stdc++.h>
using namespace std;
#endif
/*
 * @see https://snuke.hatenablog.com/entry/2017/07/18/101026
 */
//BEGIN CUT HERE
// longest prefix suffix matching of [0, i)
vector<int> morris_pratt(const string &s){
  int n=s.size();
  vector<int> mp(n+1,-1);
  for(int i=0,j=-1;i<n;i++){
    while(~j&&s[i]!=s[j]) j=mp[j];
    mp[i+1]=++j;
  }
  return mp;
}
// smallest d s.t. s[x] == s[x + d] for all x
vector<int> minimum_period(const string &s){
  auto mp=morris_pratt(s);
  for(int i=1;i<(int)mp.size();i++) mp[i]=i-mp[i];
  return mp;
}
//END CUT HERE
#ifndef call_from_test

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
// test minimum_period
signed ARC060_F(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  string w;
  cin>>w;

  int n=w.size();
  if(w==string(n,w[0])){
    cout<<n<<endl<<1<<endl;
    return 0;
  }

  auto kmp=minimum_period(w);
  if(n%kmp[n]!=0||n==kmp[n]){
    cout<<1<<endl<<1<<endl;
    return 0;
  }

  string w_rev=w;
  reverse(w_rev.begin(),w_rev.end());
  auto kmp_rev=minimum_period(w_rev);

  int cnt=0;
  for(int i=1;i<n;i++){
    int j=n-i;
    if(i%kmp[i]==0&&i>kmp[i]) continue;
    if(j%kmp_rev[j]==0&&j>kmp_rev[j]) continue;
    cnt++;
  }
  cout<<2<<endl<<cnt<<endl;
  return 0;
}
/*
  verified on 2020/08/20
  https://atcoder.jp/contests/arc060/tasks/arc060_d
*/

signed main(){
  ARC060_F();
  return 0;
}
#endif


Measured memory_bytes: 8108
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> e(m);
    for (int i = 0; i < n; i++) {
        int k; cin >> k;
        for (int j = 0; j < k; j++) {
            int a;
            cin >> a;
            e[a-1]++;
        }
    }
    int ans = 0;
    rep(i, m) {
        if (e[i] == n) ans++;
    }
    cout << ans << endl;
} 

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i = n;i >= 0;--i)
#define FOR(i,m,n) for(int i = m, i##_len=(n);i <i##_len; ++i)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

int main(void)
{
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i,n) cin >> a[i];
    vector<int> b(n);
    REP(i,n) cin >> b[i];
    vector<int> c(n - 1);
    REP(i,n - 1) cin >> c[i];

    int sum = 0;
    int pre = 0;
    REP(i,n){
        sum += b[a[i] - 1];
        if(pre == a[i] - 1){
            sum += c[a[i] - 2];
        }
        pre = a[i];
    }
    
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
N=int(input())
c=0;
while N-26**c>=0:
  N-=26**c
  c+=1

d=[0]*(c-1)

i=0
for i in range(c):
  d.insert(c-1,N%26)
  N=(N-d[i])//26
  i+=1
#print(d)
e=[]
s=''
for i in range(2*c-1):
  e.append(chr(97+d[i]))
  s+=e[i]
print(s[c-1:2*c-1])
#1000000000000001
#zzzzzz
#321272416

Measured memory_bytes: 9196
/*
AIZU ONLINE A0062
What is the Bottommost?
*/

#include <stdio.h>

/**Assay of 9Cr last digits**/
int lastdigit_9Cr[10] = { 1,9,6,4,6,
                          6,4,6,9,1 };

main()
{           char buf[11];
            int i;
            int sum;


  while(EOF != scanf("%s",buf))
    { sum = 0;
      for(i=0;i<10;i++)
      sum += (buf[i] - '0')*lastdigit_9Cr[i];

      printf("%d\n",sum % 10);
    }

  return(0);
}

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {

    string s1, s2, s3;
    int a, b;
    cin >> s1 >> s2;
    cin >> a >> b;
    cin >> s3;

    if (s3 == s1) a--;
    else b--;

    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair<long long ,long long> ii; 	
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin >> s;
	ll ans = 0;
	for (int z=0;z<s.size();z++){
		if (s[z] != s[s.size()-z-1]) ans++;
	}
	cout << ans/2 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 200005
#define int long long
#define pb push_back
#define x first
#define y second
#define all(v) v.begin(),v.end()
#define coffee prince
#define sz(a) (int)a.size()
using namespace std;

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string a,b;
    cin>>a>>b;
    if(b.length()<a.length()){
        cout<<"No";
        return 0;
    }
    for(int i=0;i<a.length();i++){
        if(a[i]!=b[i]){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
        return 0;
}


Measured memory_bytes: 3652
#include <cstdio>
#include <vector>

int n, m;
std::vector<std::vector<int> > G;
int dp[100000];

int longest(int x){
  if(dp[x]) return dp[x];
  int r = 0;
  for(int y: G[x]){
    r = std::max(r, 1 + longest(y));
  }
  return dp[x] = r;
}

int main(){
  scanf("%d%d", &n, &m);
  G.resize(n);
  for(int i = 0; i < m; i++){
    int a, b;
    scanf("%d%d", &a, &b);
    G[b-1].push_back(a-1);
  }

  int ans = 0;
  for(int i = 0; i < n; i++) ans = std::max(ans, longest(i));

  printf("%d\n", ans);

  return 0;
}


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

int main(){
  int X, Y;
  cin >> X >> Y;
  int a[13] = {0,1,3,1,2,1,2,1,1,2,1,2,1};
  cout << (a[X]==a[Y]? "Yes":"No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string lcs(string s, string t) {
        int m=s.size();
        int n=t.size();
        //if(m==0||n==0) return 0;
        vector<vector<int>>dp(m+1,vector<int>(n+1,0));
        for(int i=1;i<=m;i++){
            for(int j=1;j<=n;j++){
                if(s[i-1]==t[j-1]) dp[i][j]=1+dp[i-1][j-1];
                else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
             // cout<<dp[i][j]<<" ";
            }
            // cout<<endl;
        }
        string ans="";
        int i=m;
        int j=n;
         while(1){
        if(i<1||j<1) break;
        
             
        if(s[i-1]==t[j-1]&&(dp[i][j]==dp[i-1][j-1]+1)){ans=s[i-1]+ans;i--;j--; }
             else {
                 if(dp[i][j]==dp[i-1][j]) {
                     i--;
                 }
                 else j--;
                 
             }
        
        
    }
        
        return ans;
    }
 
int main(){
  
  string s,t;
  cin>>s>>t;
  cout<<lcs(s,t);
  
  
}

Measured memory_bytes: 35584
#include<stdio.h>
#include<string.h>
#include<ctype.h>
#define MAX 1000

int main(){
char W[11];
char T[MAX];
int i;
int cnt;
cnt=0;

scanf("%s",W);
for(i=0;i<strlen(W);i++)W[i]=(char)toupper(W[i]);

while(1){
 scanf("%s",T);
 if(strcmp(T,"END_OF_TEXT")==0)break;
 for(i=0;i<strlen(T);i++)T[i]=(char)toupper(T[i]);
 if(strcmp(W,T)==0)cnt++;

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


Measured memory_bytes: 2016
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val K, A, B = sc.nextLong()
    // 普通に増やすと K 枚まで増やせる
    // B - A > 2 の場合, 普通に叩いて増やすより効率的
    // K max ((K / 2) * (B - A) + K % 2)
    // 注意するのは 最初に A 枚まで増やす必要がある.
    // K - (A + 1)

    println((K + 1) max (((K - A + 1L) / 2L) * (B - A) + (K - A + 1L) % 2L + A))
  }

}


Measured memory_bytes: 25416
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

int main(void) {
    int N, i;
    cin >> N >> i;

    cout << N - i + 1 << endl;

    return 0;
}


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

using ll = long long;

#define vl vector<long long>
using pll = pair<long long, long long>;
#define __ << '\n'
#define _ << ' '
#define all(x) (x).begin(), (x).end()

void error()
{
    cout << "-1";
    exit(0);
}

#define flush fflush(stdout)

bool check(ll i, vector<bitset<64>>& a)
{
    ll c_1 = 0;
    ll c_0 = 0;

    for (auto e : a)
    {
        if (e[i] == 1)
            c_1++;
        else
            c_0++;
    }

    if (c_1 < c_0)
        return true;
    else
        return false;
}

template<typename T>
int BS(vector<T> &mas, T val)
{
    int l, r;
    l = 0;
    r = mas.size() - 1;
    while (r - l > 1)
    {
        int mid = l + (r - l) / 2;
        if (mas[mid] < val)
        {
            l = mid;
        } else
            r = mid;
    }
    if (mas[r] == val)
        return r;
    if (mas[l] == val)
        return l;
    return -1;
}

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

    vector<ll> d;
    ll n, m;
    cin >> n>> m;

    if(n >= m)
    {
        cout << 0;
        return 0;
    }

    vector<ll> a(m);
    for(int i = 0; i < m; ++i){
        cin >> a[i];
    }

    sort(all(a));

    for(int i = 1; i < m; i++)
    {
        d.push_back(a[i] - a[i - 1]);
    }

    sort(all(d));

    ll sum = 0;
    for(ll i = 0; i <n - 1; ++i)
    {
        sum += d[d.size() - 1 - i] - 1;
    }
    
    cout << a[a.size() - 1] - a[0] + 1 - n - sum;


    return 0;
}

Measured memory_bytes: 2168
import math

while 1:

    # input the students number
    n = input()
    if n == 0:
        break
    # input the points
    s = map(float, raw_input().split())
    # get the average of points
    ave = 0
    for i in s:
        ave += i
    ave = ave / len(s)
    # get the standard deviation
    alpha = 0
    for i in s:
        alpha += (i - ave)*(i - ave)
    alpha = math.sqrt( alpha/len(s) )
    # print
    print alpha

Measured memory_bytes: 6432
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n, C;
int s[100100], t[100100], c[100100];

int sum[100100];

int solve() {
    vector<P> vec[31];
    for (int i = 0; i < n; i++) {
        vec[c[i]].push_back(P(s[i],t[i]));
    }
    for (int i = 1; i <= C; i++) {
        sort(ALL(vec[i]));
        int l = (int)vec[i].size();
        for (int j = 0; j < l; j++) {
            sum[vec[i][j].first]++;
            if (j < l-1 && vec[i][j].second == vec[i][j+1].first) {
                sum[vec[i][j].second]--;
            } else {
                sum[vec[i][j].second+1]--;
            }
        }
    }
    int res = 0;
    for (int i = 1; i < 100100; i++) {
        sum[i] += sum[i-1];
        res = max(res, sum[i]);
    }
    return res;
}

void input() {
    cin >> n >> C;
    for (int i = 0; i < n; i++) cin >> s[i] >> t[i] >> c[i];
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 3072
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int A,B;R(A,B);
    if(A>=13)W(B);
    else if(A>=6)W(B/2);
    else W(0);
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
int main(){
    int a[50],i,j,k,n,temp;
    scanf("%d",&n);
    scanf("%d",&k);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++){
        for(j=0;j<n-1;j++){
            if(a[j]>a[j+1]){
                temp=a[j];
                a[j]=a[j+1];
                a[j+1]=temp;
            }
        }
    }
    temp=0;
    for(i=n-k;i<n;i++){
        temp+=a[i];
    }
    printf("%d\n",temp);

    return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize(4)
#include <bits/stdc++.h>
#define rint register int
typedef long long ll;
using namespace std;
const int N=300+2;
const int inf=0x3f3f3f3f;
 
int n;
int c[N][N];
int v[N][N];
int fan[N];
int f[N];
int vv[N];
int ans=inf;

struct edge
{
    int u,v;
}vec[N*N],ggg[N*4];
int vn,gn;         //模拟vector 否则需要多次调用clear函数清空，直接用vector也可

int getf(int x)
{
    return x==f[x]?x:f[x]=getf(f[x]);
}
 
int main()
{
 
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    while(cin>>n&&n)
    {
        ans=inf;
        for(rint i=1;i<=n;++i)
            for(rint j=i+1;j<=n;++j)
            {
                cin>>v[i][j];
                if(v[i][j]<0) c[i][j]=c[j][i]=1,v[i][j]=v[j][i]=-v[i][j];
                else c[j][i]=c[i][j]=0,v[j][i]=v[i][j];
            }

        for(rint i=1;i<=n;++i)
        {
            for(rint j=1;j<=n;++j)
            {
                if(i==j) fan[i]=1;			//反转叶子节点
                else if(c[i][j]) fan[j]=1;	//反转其他节点使与叶子节点连边都为黑色
                else fan[j]=0;
            }
            //vec.clear();
            vn=0;
            for(rint j=1;j<=n;++j)
                for(rint k=1;k<=n;++k)
                    if(j<k&&((c[j][k]^fan[j]^fan[k])==0)) {	//在邻接表a中存边
                        vec[++vn].u=j;
                        vec[vn].v=k;
                        //vec.push_back({j, k, v[j][k]});
                    }
 
            if(vn<=2*(n-1)&&abs(vn-(n-1))%2==(n-1)%2)		//若不满足此条件必然不会得到树
            for(rint j=1;j<=n;++j)
            {
                if(i==j) continue;
                for(rint k=1;k<=n;++k) vv[k]=0;
                gn=0;//ggg.clear();
                for(rint k=1;k<=vn;++k)
                {
                    if(vec[k].u!=j&&vec[k].v!=j)			//在邻接表b中存边
                    {
                        ggg[++gn]=vec[k]; //ggg.push_back(it);
                    }
                    else
                    {
                        if(vec[k].u==j) vv[vec[k].v]=1;		//标记与j相连的边
                        else vv[vec[k].u]=1;
                    }
                }
 
                for(rint k=1;k<=n;++k)
                {
                    if(!vv[k]&&k!=j)						//将未相连的边存入邻接表b
                    {
                        ggg[++gn].u=j;
                        ggg[gn].v=k;
                    }
                }
                if(gn==n-1)			//judge
                {
                    for(rint k=1;k<=n;++k) f[k]=k;
                    int sum=0;
                    for(rint k=1;k<=gn;++k)
                    {
                        int x=getf(ggg[k].u);
                        int y=getf(ggg[k].v);
                        if(x==y) {sum=ans;break;}	//有环，不可更新答案。直接break会将ans更新成sum
                        else
                        {
                            f[x]=y;
                            sum+=v[ggg[k].u][ggg[k].v];
                            if(sum>=ans) break;
                        }
                    }
                    ans=min(ans,sum);
                }
            }
        }
        if(ans==inf) cout<<-1<<'\n';
        else cout<<ans<<'\n';
    }
    return 0;
}


Measured memory_bytes: 4124
#include <stdio.h>
int main()
{
	int x=1;
	int i=1;
	while(x!=0)
	{
		scanf("%d",&x);
		if(x==0)
		{
			break;
		}
		printf("Case %d: %d\n",i,x);
		i=i+1;
	}
	return 0;
}


Measured memory_bytes: 2028
#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
    scanf("%d",&n);
    for(register int i=0;i<=25;i++) for(register int j=0;j<=15;j++) if(4*i+7*j==n){
        printf("Yes");return 0;
    }
    printf("No");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std; 
int main(){
    string k;
    int d;
    cin>>k>>d;
    //dp[i][j][k] represents how many numbers with i digits have
    //their sum of digits modulo d equal to j and whether the 
    //bound on the ith digit is tight or not, if it's not tight
    //the current digit can take numbers from 0 to 9 else it 
    //can digits only from 0 to k[i]
    int dp[k.size()+1][d][2];  
    memset(dp,0,(k.size()+1)*d*sizeof(dp[0][0]));
    dp[0][0][0] = 1;
    dp[0][0][1] = 0;
    for(int i=1;i<=k.size();i++){
        for(int j=0;j<d;j++){
            for(int m=0;m<2;m++){
                for(int l=0;l<=9;l++){
                    if(l>(k[i-1]-'0')&&!m)break;
                    dp[i][(j+l)%d][m||(l<(k[i-1]-'0'))]=(dp[i][(j+l)%d][m||(l<(k[i-1]-'0'))]+dp[i-1][j][m])%mod;
                    
                }
            }
        }
    }
    int ans = (dp[k.size()][0][0]+dp[k.size()][0][1]-1+mod)%mod;
    cout<<ans<<"\n";
    return 0;
}

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

#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define vvi vector<vi>
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )

const int INF = 1e9;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;


int main() {

    ll n;
    cin >> n;
    ll menor = n - 1;

    for ( int i = 2; (ll) i * i <= n; i++ ) {
        // if ( i >= MAX ) cout << "PQ VEI\n" << i * i << endl;
        if ( n % i == 0 ) {
            menor = min(menor, i - 1 + (n / i) - 1);
        }
    }

    cout << menor << endl;

    return 0;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>p(n); for(auto&&i:p)cin>>i;
	int ans=0;
	for(int i=2;i<n;++i){
		int&l=p.at(i-2),&m=p.at(i-1),&r=p.at(i);
		if(m!=max({l,m,r})&&m!=min({l,m,r}))++ans;
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
static int MIN = 100001;
class Point {
public:
	int a;
	int lenth;
	Point(int a, int b) :a(a), lenth(b) {};
};
struct cmp
{
	bool operator() (Point a, Point b) {
		return a.lenth > b.lenth;
	}
};
vector<Point>v[100001];
priority_queue<Point,vector<Point>,cmp>p;
int visited[100001];
int n;
int m;
long long all = 0;
void dfs(int root) {
		visited[root] = 1;
		for (int i = 0; i < v[root].size(); i++) {
			int key = v[root][i].a;
			if (!visited[key]) {
				p.push(v[root][i]);
			}
		}
		while (!p.empty()) {
			int key = p.top().a;
			int len = p.top().lenth;
			p.pop();
			if (visited[key]) continue;
			visited[key] = 1;
			all += len;
			for (int i = 0; i < v[key].size(); i++) {
				int key_2 = v[key][i].a;
				if (!visited[key_2]) {
					p.push(v[key][i]);
				}
			}
		}
}
void solve() {
	dfs(0);
	cout << all << endl;
}
int main(void) {
	cin >> n>>m;
	int a, b, c;
	for (int i = 0; i < m; i++) {
		cin >> a >> b >> c;
		v[a].push_back(Point(b, c));
		v[b].push_back(Point(a, c));
	}
	solve();
}


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

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

    int ans = 0, cnt = 0, N = S.size();
    for (int i = 0; i < N; i++) {
        if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
            cnt++;
        } else {
            ans = max(ans, cnt);
            cnt = 0;
        }
    }
    ans = max(ans, cnt);

    cout << ans << endl;
}

Measured memory_bytes: 256