akhauriyash/Code-Regression huggingface dataset:
n = input()
s = input()

black_point = 0
turn_to_white = 0
turn_to_black = s.count(".")
min_turn = turn_to_black
previous_s = s[0]

for i, current_s in enumerate(s[1:]):
	if previous_s == "#":
		turn_to_white += 1
	else:
		turn_to_black -= 1
	min_turn = min(turn_to_white + turn_to_black, min_turn)
	previous_s = current_s

if s[-1] == "#":
	turn_to_white += 1
else:
	turn_to_black -= 1
min_turn = min(turn_to_white + turn_to_black, min_turn)

print(min_turn)

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

int n, h[100000],cur;

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &h[i]);
    }
    n;
    cur = h[n-1];
    for (int i = n - 2; i > -1; i--)
    {
        if (h[i] > cur)
        {
            if (h[i] - cur > 1)
            {
                printf("No");
                return 0;
            }
            cur = h[i]-1;
        }else{
        cur = h[i];
        }
    }
    printf("Yes");
}

Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int M=1e6+5;
int a[M];
int main(){
	int n;
	long long ans=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		if(a[i]>=a[i-1]) continue;
		int id=a[i-1]-a[i];
		a[i]+=id;
		ans+=id;
	}
	printf("%lld",ans);
	return 0;
} 

Measured memory_bytes: 2504
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
    int n, i, x[200005],y[200005];
    scanf("%d",&n);
    for(i=1;i<=n;i++)
        {scanf("%d",&x[i]);y[i]=x[i];}
    sort(y+1,y+n+1);
    for(i=1;i<=n;i++)
    {
        if(x[i]<y[n/2]) printf("%d\n",y[n/2+1]);
        else if(x[i]>y[n/2]) printf("%d\n",y[n/2]);
        else printf("%d\n",y[n/2+1]);
    }
}


Measured memory_bytes: 3712
#include<stdio.h>
#include<unistd.h>
#include<stdlib.h>
#include<stdint.h>
#include<stdbool.h>

int ceil_pow2(int n){
	int res = 0;
	while(1U<<res < (unsigned int)n)res++;
	return res;
}

typedef int32_t Int;
inline Int max(Int a, Int b){return a>b?a:b;}
inline Int segtree_op(Int a, Int b){return max(a, b);}
const Int segtree_e = INT32_MIN;

Int* segtree(int n){
	int lg = ceil_pow2(n);
	Int* res = (Int*)malloc(sizeof(Int) * (1<<lg) * 2);
	for(int i=0; i<=(1<<lg)*2; i++)res[i] = segtree_e;
	return res;
}
void update(Int arr[], int k){arr[k] = segtree_op(arr[k*2], arr[2*k+1]);}
void set(Int arr[], int n, int p, Int x){
	int lg = ceil_pow2(n);
	p += 1<<lg;
	arr[p] = x;
	for(int i=1; i<=lg; i++)update(arr, p>>i);
}
Int get(Int arr[], int n, int p){
	return arr[p +(1<<ceil_pow2(n))];
}
Int prod(Int arr[], int n, int l, int r){
	Int sml = segtree_e, smr = segtree_e;
	int lg = ceil_pow2(n);
	l += 1<<lg;
	r += 1<<lg;
	while(l < r){
		if(l & 1) sml = segtree_op(sml, arr[l++]);
		if(r & 1) smr = segtree_op(arr[--r], smr);
		l >>= 1;
		r >>= 1;
	}
	return segtree_op(sml, smr);
}
Int all_prod(Int arr[]){return arr[1];}
int max_right(Int arr[], int n, int l, bool (*f)(Int)){
	if(l == n) return n;
	int lg = ceil_pow2(n);
	int size = 1<<lg;
	l += size;
	Int sm = segtree_e;
	do{
		while(l % 2 == 0) l >>= 1;
		if(!f(segtree_op(sm, arr[l]))){
			while(l < size){
				l = 2*l;
				if(f(segtree_op(sm, arr[l]))){
					sm = segtree_op(sm, arr[l]);
					l++;
				}
			}
			return l - size;
		}
		sm = segtree_op(sm, arr[l]);
		l++;
	}while((l & -l) != l);
	return n;
}
int min_right(Int arr[], int n, int r, bool (*f)(Int)){
	if(r == 0) return 0;
	int lg = ceil_pow2(n);
	int size = 1<<lg;
	r += size;
	Int sm = segtree_e;
	do{
		r--;
		while(r>1 && r&1) r >>= 1;
		if(!f(segtree_op(arr[r], sm))){
			while(r < size){
				r = 2*r + 1;
				if(f(segtree_op(arr[r], sm))){
					sm = segtree_op(arr[r], sm);
					r--;
				}
			}
			return r + 1 - size;
		}
		sm = segtree_op(arr[r], sm);
	}while((r & -r) != r);
	return 0;
}

//fast(?) Input
#define buf_sz 1<<24
char buf[buf_sz];
unsigned int nextint(){
	static int idx = 0;
	if(idx == 0)read(0, buf, buf_sz);
	unsigned int res = 0;
	while(idx<buf_sz && buf[idx]<'0' || '9'<buf[idx])idx++;
	while(idx<buf_sz && '0'<=buf[idx] && buf[idx]<='9'){
		res *= 10;
		res += buf[idx++] - '0';
	}if(idx>=buf_sz)exit(1);
	return res;
}

int N, Q, T, X, Y;
bool f(Int x){return x < Y;}
int main(){
	N = nextint(); Q = nextint();
	Int *d = segtree(N);
	for(int i=0; i<N; i++) set(d, N, i, nextint());
	while(Q--){
		T = nextint(); X = nextint()-1; Y = nextint();
		if(T == 1)set(d, N, X, Y);
		else if(T == 2)printf("%d\n", prod(d, N, X, Y));
		else printf("%d\n", 1 + max_right(d, N, X, f));
	}
	return 0;
}

Measured memory_bytes: 8896
#include <stdio.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
	int n, i, j, k, t;
	scanf("%d", &n);
	vector< vector<int> > numbers;
	vector<int> scores;
	vector<int> tmp;

	for(i = 0;i < n;++i){
		tmp.clear();
		for(j = 0;j < 3;++j){
			scanf("%d", &t);
			tmp.push_back(t);
		}
		numbers.push_back(tmp);

		scores.push_back(0);
	}

	for(i = 0;i < 3;++i){
		for(j = 0;j < n;++j){
			t = numbers[j][i];
			for(k = 0;k < n;++k) if(numbers[k][i] == t && k != j) t = 0;
			scores[j] += t;
		}
	}

	for(i = 0;i < n;++i) printf("%d\n", scores[i]);

	return 0;
}

Measured memory_bytes: 2812
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>

int main() {
    int n, m;
    std::cin >> n >> m;
    std::vector<std::pair<int, int>> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i].first >> a[i].second;
    }

    // かかる日数の短い順に並べる
    std::sort(a.begin(), a.end());

    int ans = 0, pos = 0;
    std::priority_queue<int> que;
    for (int i = 0; i <= m; i++) {
        while (pos < n && a[pos].first <= i) {
            que.push(a[pos].second);
            pos++;
        }

        if (!que.empty()) {
            ans += que.top();
            que.pop();
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 1660
import sys
import re

DBG_FLAG = 0

def p_dbg(str):
    if(DBG_FLAG == 1):
        sys.stdout.flush()
        print str

S=raw_input()

array=[]

p_dbg(S)

# regular expression
#   AKIHABARA
# ->*KIH*B*RA
# ->[A]?KIH[A]?B[A]?R[A]?
pattern = r"^[A]?KIH[A]?B[A]?R[A]?$"

if re.match(pattern, S):
    print "YES"
else:
    print "NO"


Measured memory_bytes: 2692
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define pii pair<int, int> 
#define mod 998244353
ll power(ll a,ll b){
    ll res=1;
    while(b>0){
        if(b%2!=0) res=(res*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res;
}
ll ncr(ll n,ll k){
    if(k==0||k==n) return 1ll;
    if(k>n-k) k=n-k;
    ll pro=1;
    for(ll i=0;i<k;i++){
        pro=(pro*(n-i))%mod;
        pro/=(i+1);
    }
    return (pro%mod);
}
vector<int> prime;
void seive(){
    vector<bool > isprime(2001,true);
    for(int i=2;i*i<=2000;i++){
        if(isprime[i]){
            for(int j=i*i;j<=2000;j+=i){
                isprime[j]=false;
            }
        }
    }
    for(int i=2;i<=2000;i++){
        if(isprime[i]) prime.push_back(i);
    }
}

int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string str;
    cin>>str;
    int len=str.size();
    for(int i=1;i<=len;i++){
        if(i%2==0 && (str[i-1]=='L' || str[i-1]=='U' || str[i-1]=='D')) continue;
        else if(i%2!=0 && (str[i-1]=='R' || str[i-1]=='U' || str[i-1]=='D')) continue;
        else {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define debug(x) cerr << #x << " = " << x << "\n";
#define debug_v(x) cerr << #x << " ="; for(auto it : x) {cerr << " [" <<  it << "]";} cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
const double PI = acos(-1);
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 2e18;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cout << fixed << setprecision(20);
	int a;
	string s;
	cin >> a >> s;
	cout << (a >= 3200 ? s : "red") << '\n';
	return 0;
	
}


Measured memory_bytes: 892
#include <iostream>
#include <string>

template <class X>
X cinas() {
  X in;
  std::cin >> in;
  return in;
}

int main() {
  std::string text;
  while (std::cin >> text) {
    if (text == "-") break;

    int m = cinas<int>();
    int total = 0;
    for (int i = 0; i < m; i++) {
      total += cinas<int>();
    }

    int movedPos = total % text.length();
    for (int i = movedPos; i < movedPos + text.length(); i++) {
      std::cout << text[i % text.length()];
    }
    std::cout << std::endl;
  }
  return 0;
}



Measured memory_bytes: 3128
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    
    // 定義：整数の個数を「 N 」、整数を「 num 」、素数でない個数を「 count 」と置く
    int N, num, count = 0;
    cin >> N;
    
    for(int i = 0; i < N; i++){
        cin >> num;
        for(int j = 2; j <= sqrt((double)num); j++){
            
            // 判定：合成数か判定している（素数でない場合のこと）
            if(num % j == 0){
                count++;
                break;
            }
        }
    }
    
    // 計算：整数の個数 － 素数でない個数 ＝ 素数の個数
    cout << N - count << endl;
}





/**********************************************************************

※オススメ (URL) https://qiita.com/srtk86/items/874639e361917e5016d4

*********************************************************************/





Measured memory_bytes: 3100
N, K=map(int, input().split())

import sys
sys.setrecursionlimit(100000)
nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

for i in range(1,K+1):
    if i>N-K+1:
        print(0)
        continue
    print(cmb(K-1, i-1)*cmb(N-K+1, i)%(10**9+7))

Measured memory_bytes: 166104
#include<cstdio>
#include<cctype>
#include<cstring>
#define max(a,b) (a>b?a:b)
#define reg register
typedef long long ll;
template<typename T>inline T read(){
    reg T x=0;reg short f=1;reg char c=getchar();
    for(;!isdigit(c);f=c=='-'?-1:1,c=getchar());
    for(;isdigit(c);x=x*10+(c^48),c=getchar());
    return x*f;
}
inline void swap(ll& a,ll& b){a^=b;b^=a;a^=b;}
int main(){
	reg ll n=read<ll>(),x=read<ll>(),ans=n,a=max(x,n-x),b=n-a;
	while(b)ans+=((((a/b)<<1)-!(a%b))*b),a%=b,swap(a,b);
	printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) throws IOException{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String input = br.readLine();
		StringTokenizer st = new StringTokenizer(input, " ");
		long[] a = new long[n];
		long min = 1000000;
		long max = -1000000;
		long sum = 0;

		for(int i = 0; i < n; i++){
			a[i] = Long.parseLong(st.nextToken());
			min = Math.min(min, a[i]);
			max = Math.max(max, a[i]);
			sum += a[i];
		}

		System.out.println(min + " " + max + " " + sum);

	}
}

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

signed main()
{
   int H,W; cin>>H>>W;
   vector<vector<int> > a(H,vector<int>(W));
   for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
         cin>>a[i][j];
      }
   }
   
   int sum=0;
   for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
         int k=(i+1)*(j+1)*(H-i)*(W-j);
         sum+=k*a[i][j];
      }
   }
   cout<<sum<<endl;
}




Measured memory_bytes: 4748
N = int(input())
y = input()
W = [y]
cnt = False
for i in range(1,N):
  x = input()
  if x in W:
    cnt = True
  elif x[0]!=y[-1]:
    cnt = True
  W.append(x)
  y = x
print("Yes" if cnt==False else "No")


Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String[] nmarray = reader.readLine().split(" ");
        int n = Integer.parseInt(nmarray[0]);
        int m = Integer.parseInt(nmarray[1]);
        int[] a = new int[n];
        String[] arr = reader.readLine().split(" ");
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(arr[i]);
        }
        Arrays.sort(a);
        BC[] bc = new BC[m];
        for (int j = 0; j < m; j++) {
            String[] bcarray = reader.readLine().split(" ");
            bc[j] = new BC(Integer.parseInt(bcarray[0]), Integer.parseInt(bcarray[1]));
        }
        Arrays.sort(bc);
        int index = 0;
        label: for (int j = 0; j < m; j++) {
            while (0 < bc[j].b && index < n) {
                if (a[index] < bc[j].c) {
                    a[index] = bc[j].c;
                    index++;
                    bc[j].b--;
                } else {
                    break label;
                }
            }
        }
        long sum = 0L;
        for (int i = 0; i < n; i++) {
            sum += a[i];
        }
        System.out.println(sum);
    }

    private static class BC implements Comparable<BC> {
        int b;
        int c;
        private BC(int b, int c) {
            this.b = b;
            this.c = c;
        }
        public int compareTo(BC o) {
            return this.c < o.c ? 1 : this.c == o.c ? 0 : -1;
        }
    }
}


Measured memory_bytes: 48408
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main(void){
    int N,R;
    cin >> N >> R;
    int ans;
    if(N<10) {
        ans=R+100*(10-N);
    }
    else{
        ans=R;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3592
//#include <atcoder/modint>
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
typedef long long ll;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPR(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(x) ll(x.size()) 
using P = pair<int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 2e9;
const ll LINF = (1LL<<60);

template <typename T>
struct PrimeFact {
  vector<T> spf;
  PrimeFact(T N) { init(N); }
  void init(T N) { // 前処理。spf を求める
    spf.assign(N + 1, 0);
    for (T i = 0; i <= N; i++) spf[i] = i;
    for (T i = 2; i * i <= N; i++) {
      if (spf[i] == i) {
        for (T j = i * i; j <= N; j += i) {
          if (spf[j] == j) spf[j] = i;      
        }
      }
    }
  }
  map<T, T> get(T n) { // nの素因数分解を求める
    map<T, T> mp;
    while (n != 1) {
      mp[spf[n]]++;
      n /= spf[n];
    }
    return mp;
  }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n; cin >> n;

  PrimeFact<int> pf(n);
  ll ans = 0;
  FOR(c,1,n){
    auto p = pf.get(n-c);
    ll tmp = 1;
    for(auto [num, cnt]: p) tmp *= (cnt+1);
    ans += tmp;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7108
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

ll mod = 1e9 + 7;

//zaki_UnionFind
class UnionFind
{
    std::vector<int> data;

  public:
    UnionFind(int size) : data(size, -1) {}
    bool unite(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x != y)
        {
            if (data[y] < data[x])
                std::swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    bool find(int x, int y)
    {
        return root(x) == root(y);
    }
    int root(int x)
    {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x)
    {
        return -data[root(x)];
    }
};

struct edge{
  	ll from, to, cost;
};

bool comp(const edge& e1, const edge& e2){
  	return e1.cost < e2.cost;
}

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

  	ll n, m;
  	cin >> n >> m;
  	ll a, b, c;
  	vector<edge> es;
  	REP(i, m){
    	cin >> a >> b >> c;
    	es.push_back((edge){a, b, c});
  	}
  	sort(es.begin(), es.end(), comp);
  	ll res = 0;
  	UnionFind uf(n);
  	for(auto e : es){
    	if(!uf.find(e.from, e.to)){
      		uf.unite(e.from, e.to);
      		res += e.cost;
    	}
  	}
  	cout << res << endl;
  	return 0;
}



Measured memory_bytes: 6020
// E - Coins Respawn

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 9223372036854775807;
const int MAX_V = 2500;
const int MAX_E = 5000;

struct Edge {
	int from;
	int to;
	ll cost;
};

Edge edges[MAX_E];
ll min_d[MAX_V]; // 最短距離
int V, E;

void bellman_ford(int s) {
  bool negative_cycle = false;

	for (int i=0; i<V; i++) {
		min_d[i] = INF;
	}

	min_d[s] = 0;

	int update_cnt = 0;
	while (true) {
		bool update = false;
		for (int i=0; i<E; i++) {
			Edge e = edges[i];
			if (min_d[e.from] == INF) continue;
			if (min_d[e.to] > min_d[e.from] + e.cost) {
				min_d[e.to] = min_d[e.from] + e.cost;
				update = true;
			}
		}

		if (!update) break;
		else update_cnt++;

		if (update_cnt >= V) {
			negative_cycle = true;
			break;
		}
	}

	if (!negative_cycle) return;

	// set negative cycle to -INF
	update_cnt = 0;
	while (true) {
		bool update = false;
		for (int i=0; i<E; i++) {
			Edge e = edges[i];
			if (min_d[e.from] == INF || min_d[e.to] == -INF) continue;
			if (min_d[e.from] == -INF || min_d[e.to] > min_d[e.from] + e.cost) {
				min_d[e.to] = -INF;
				update = true;
			}
		}

		if (!update) break;
		else update_cnt++;
	}
}

int main() {
	int N, M, P;
	cin >> N >> M >> P;
	V = N;
	E = M;

	int A, B, C;
	for (int i=0; i<M; i++) {
		cin >> A >> B >> C;
		A--;
		B--;

		edges[i] = {A, B, -C+P};
	}

	bellman_ford(0);

	ll ans;
	if (min_d[N-1] == -INF) {
		ans = -1;
	} else {
		ans = max(0LL, -min_d[N-1]);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>

typedef long long ll;

using namespace std;

namespace Solver {

    int N;
    inline void Read() {
        cin >> N;
    }

    inline void Work() {
        vector<ll> vll;
        for (ll i = 1; i < 2000000000; i *= 3) vll.push_back(i);
        cout << lower_bound(vll.begin(), vll.end(), N) - vll.begin() << endl;
    }

    inline void Solve() {
        Read();
        Work();
    }
}

int main() {
    Solver::Solve();
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
	int H, W; cin >> H >> W;
	vector<vector<string>> a(H, vector<string>(W));
	vector<int> mark_h, mark_w;
	for (int i = 0; i < H; ++i) {
		string tmp; cin >> tmp;
		for (int j = 0; j < W; ++j) {
			a[i][j] = tmp[j];
		}
	}
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			if (a[i][j] == "#")  {
				mark_h.push_back(i);
				break;
			}
		}
	}
	for (int i = 0; i < W; ++i) {
		for (auto j : mark_h) {
			if (a[j][i] == "#")  {
				mark_w.push_back(i);
				break;
			}
		}
	}
	for (auto h : mark_h) {
		for (auto w : mark_w) {
			cout << a[h][w];
		}
		cout << endl;
	}
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 3928
n = int(input())
[t,a] = list(map(int,input().split()))
h = list(map(int,input().split()))
ans = 0
point=1000

for i in range(n):
	if point > abs( t-0.006*h[i] -a):
		point =abs( t-0.006*h[i] -a)
		ans = i+1
	
print(ans) 

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

int main()
{
	int res = 0, len;
	string W, T;
	cin >> W;
	len = W.size();
	for (int i = 0; i < len; i++) {
		if (W[i] >= 'A' && W[i] <= 'Z') {
			W[i] += 'a' - 'A';
		}
	}
	while (cin >> T, T != "END_OF_TEXT") {
		if (len == T.size()) {
			bool flag = true;
			for (int i = 0; i < len; i++) {
				if (T[i] >= 'A' && T[i] <= 'Z') {
					T[i] += 'a' - 'A';
				}
			}
			if (W == T) {
				res++;
			}
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int a,b,h;
	cin >> a>> b>> h;
    cout << (a+b)*h/2 << endl;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
#include<iomanip>

using namespace std;

int n, l, t;
vector <int> finish;

int main()
{
	cin >> n >> l >> t;
	int one = 0;
	for (int i = 0; i < n; i++)
	{
		int a, d;
		cin >> a >> d;
		if (d == 1)
		{
			finish.push_back((a + t) % l);
			if (t >= l - a) 
			{
				one += (t - (l - a)) / l + 1;
			}
		}
		else 
		{
			finish.push_back(((a - t) % l + l) % l);	
			if (t > a) 
			{
				one -= (t - a - 1) / l + 1;
			}
		}
	}
	one = ((one % n) + n) % n;
	sort(finish.begin(), finish.end());
	for (int i = one; i < n; i++)
	{
		cout << finish[i] << endl;
	}
	for (int i = 0; i < one; i++)
	{
		cout << finish[i] << endl;
	}
}


 

Measured memory_bytes: 1656
N = int(input())
A = list(map(int, input().split()))
 
INF = 10**9
dp = [0] + [INF]*N
 
for i in range(1,N):
    if i == 1:
        dp[1] = abs(A[1]-A[0])
    else:
        dp[i] = min(dp[i-1]+abs(A[i]-A[i-1]), dp[i-2]+abs(A[i]-A[i-2]))
 
print(dp[N-1])

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

typedef long long LL;
typedef pair<int, LL> II;

const int MAXN = (int) 2e5 + 10;
int n, m, a[MAXN], c[MAXN];

#define mid ((l + r) >> 1)
struct SegmentTree {
	II S[MAXN * 5];
	int L[MAXN * 5];
	II Merge(II a, II b) {
		if (a.first == b.first) return II(a.first, a.second + b.second);
		return min(a, b);
	}
	void Build(int k, int l, int r) {
		if (l == r) {
			S[k] = II(0, 1);
			L[k] = 0;
			return;
		}
		Build(k << 1 | 0, l, mid);
		Build(k << 1 | 1, mid + 1, r);
		S[k] = Merge(S[k << 1], S[k << 1 | 1]);
		L[k] = 0;
	}
	void Propagate(int k) {
		int v = L[k]; L[k] = 0;
		S[k << 1 | 0].first += v; L[k << 1 | 0] += v;
		S[k << 1 | 1].first += v; L[k << 1 | 1] += v;
	}
	void Update(int k, int l, int r, int i, int j, int v) {
		if (l > j || r < i) return;
		if (i <= l && r <= j) {
			S[k].first += v;
			L[k] += v;
			return;
		}
		Propagate(k);
		Update(k << 1 | 0, l, mid, i, j, v);
		Update(k << 1 | 1, mid + 1, r, i, j, v);
		S[k] = Merge(S[k << 1], S[k << 1 | 1]);
	}
	int Query() {
		if (S[1].first == 0) return S[1].second;
		return 0;
	}
} ST;
#undef mid

int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; ++i) {
		int x; scanf("%d", &x);
		c[x]++;
		a[i] = x;
	}

	ST.Build(1, 1, n);
	for (int i = 1; i <= n; ++i)
		if (c[i] > 0) ST.Update(1, 1, n, max(1, i - c[i] + 1), i, 1);
	
	while (m--) {
		int i, x; scanf("%d%d", &i, &x);
		if (a[i] - c[a[i]] + 1 > 0)
			ST.Update(1, 1, n, a[i] - c[a[i]] + 1, a[i] - c[a[i]] + 1, -1);
		c[a[i]]--; a[i] = x;
		c[a[i]]++;
		if (a[i] - c[a[i]] + 1 > 0)
			ST.Update(1, 1, n, a[i] - c[a[i]] + 1, a[i] - c[a[i]] + 1, 1);
		printf("%d\n", ST.Query());
	}
	return 0;
}

Measured memory_bytes: 22656
n = int(input())
res = 0
a = 0
b = 0
ab = 0
for i in range(n):
    s = input()
    res +=  s.count('AB')
    if s[0] == 'B':
        if s[-1] == 'A':
            ab += 1
        else:
            b += 1
    elif s[-1] == 'A':
        a += 1
if a == 0 and b == 0:
    res += max(0,ab-1)

elif a < b:
    res += a
    res += ab
else:
    res += b
    res += ab
print(res)

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

int main()
{
	int n;
	cin>>n;
	map<string,int>mp;
	
	while(n--)
	{
		string s;
		cin>>s;
		mp[s]++;
	}
	
 
		cout<<"AC x "<<mp["AC"]<<endl;
		cout<<"WA x "<<mp["WA"]<<endl;
		cout<<"TLE x "<<mp["TLE"]<<endl;
		cout<<"RE x "<<mp["RE"]<<endl;
	    
}

Measured memory_bytes: 3644
//Date : 01 - 07 - 18  //Author:Rishabh Paul

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

int main() {
	int n;
	cin >> n;
	if(n % 2 == 0)	printf("%d" ,n);
	else printf("%d" ,n*2);
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
  int a, b;
  cin >> a >> b;
  cout << (a + b) % 24 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	char a;
	cin >> a;
	if(a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u'){
		puts("vowel");
	}else puts("consonant");
 	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int MAXN=1000005;
const int mod=998244353;
int mu[MAXN],pr[MAXN],plen,is[MAXN],S[MAXN];
void ad(int &x,int y){x+=y;if(x>=mod)x-=mod;}
vector<int> vec[MAXN];
void getmu()
{
	mu[1]=1;
	for(int i=2;i<MAXN;i++)
	{
		if(!is[i])mu[i]=mod-1,pr[++plen]=i;
		for(int j=1;i*pr[j]<MAXN&&j<=plen;j++)
		{
			is[i*pr[j]]=1;
			if(!(i%pr[j])){mu[i*pr[j]]=0;break;}
			mu[i*pr[j]]=mod-mu[i];
		}
	}
	for(int i=1;i<MAXN;i++)for(int j=1;i*j<MAXN;j++)
		ad(S[i*j],1LL*i*mu[j]%mod*j%mod*j%mod),vec[i*j].push_back(i);
}
int n,a1[MAXN],a2[MAXN];
int main()
{
	getmu();
	n=read();for(int i=1;i<=n;i++)
	{
		int x=read();
		for(int j=0;j<vec[x].size();j++)
		{
			int u=vec[x][j];
			ad(a1[u],1LL*a2[u]*(x/u)%mod);ad(a2[u],x/u);
		}
	}int ans=0;
	for(int i=1;i<MAXN;i++)ad(ans,1LL*S[i]*a1[i]%mod);
	pr2(ans);
	return 0;
}


Measured memory_bytes: 138240
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vll a(n), b(n);
    rep(i, n){
        cin >> a[i] >> b[i];
    }
    ll ans = 0;
    for(ll i = n-1; i >= 0; i--){
        if((ans + a[i]) % b[i]) ans += b[i] - (ans + a[i]) % b[i];
        dump(ans, a[i]);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
using ull = unsigned long long;
using ll = long long;

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

	ll a = 7 % k;
	ll b = 7;
	if (a == 0)
	{
		cout << 1 << endl;
		return 0;
	}
	if (k % 2 == 0 || k % 5 == 0)
	{
		cout << -1 << endl;
		return 0;
	}
	for (int n = 2;; n++)
	{
		b = (b * 10) % k;
		a = (a + b) % k;
		if (a == 0)
		{
			cout << n << endl;
			break;
		}
	}
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<math.h>
	int main()
{
	double r, area, circumference;
	scanf("%lf", &r);
	area = r * r * M_PI;
	circumference = 2 * r * M_PI;
	printf("%.6f %.6f\n", area, circumference);
	return 0;
}

Measured memory_bytes: 652
x1, y1, x2, y2 = gets.split.map(&:to_f)
vx = x2 - x1
vy = y2 - y1
rv = Math.sqrt(vx*vx+vy*vy)
#normarize
vx /= rv
vy /= rv
q = gets.to_i
q.times{
  x, y = gets.split.map(&:to_f)
  rp1x = (x-x1)*vx+(y-y1)*vy
  tx = rp1x*vx + x1
  ty = rp1x*vy + y1
  puts "%.12f %.12f" % [x + (tx-x)*2, y + (ty-y)*2]
}

Measured memory_bytes: 8848
n, k = map(int, input().split())
a = list(map(int, input().split()))
MOD = 10**9 + 7

cnt = [0] * 2001
for i in range(n):
    cnt[a[i]] += 1

ruiseki = [0] * (2000 + 1 + 1)
for i in range(2000 + 1):
    ruiseki[i+1] = ruiseki[i] + cnt[i]

ans = 0
for i in range(n):
    num = a[i]
    ans += (ruiseki[num] * (k - 1) * k) // 2
    ans %= MOD
    for j in range(i, n):
        if a[i] > a[j]:
            ans += k
    ans %= MOD
print(ans)

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


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e16+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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 (b<a) { a=b; return true; } return false; }

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

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

    ll d,g;
    cin>>d>>g;
    Vec p(d);
    Vec c(d);
    g /= 100;
    rep(i,d){
        cin>>p[i]>>c[i];
        c[i] /= 100;
    }

    ll b = 1LL<<d;

    ll ans=INF;
    rep(i,b){
        ll cnt = 0;
        ll score = 0;
        rep(j,d){
            if(i & 1LL<<j){
                score += p[j]*(j+1);
                score += c[j];
                cnt += p[j];
            }
        }

        per(j,d-1){
            if(i & 1LL<<j){
                continue;
            }
            ll x = 0;
            while(p[j]>x){
                if(score>=g){
                    chmin(ans,cnt);
                    break;
                }
                x++;
                score += j+1;
                cnt ++;
            }
        }

        if(score>=g){
            chmin(ans,cnt);
            continue;
        }
    }

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


Measured memory_bytes: 256
#ifdef ConanYu
#include "E:\yuzining\code\local.hpp"
#else
#pragma GCC optimize("-O3")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(...) do { } while(false)
void Main();
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie();
  Main();
  return 0;
}
#endif

void Main() {
  int n, m; cin >> n >> m;
  vector<int> v(n);
  int tot = 0;
  for(int &x: v) {
    cin >> x;
    tot += x;
  }
  int cnt = 0;
  for(int &x: v) {
    if(x * 4 * m >= tot) {
      cnt++;
    }
  }
  cout << (cnt >= m ? "Yes\n" : "No\n");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5+5 , M = 998244353, OO = 0x3f3f3f3f;
typedef long long ll;
ll n, h;
ll a[N], b[N];
int main()
{
    cin >> n >> h;
    for(int i=0; i<n; ++i) cin >> a[i] >> b[i];
    ll mx = a[0];
    for(int i=1; i<n; ++i) mx=max(mx, a[i]);
    sort(b, b+n);
    ll u = 0;
    ll sum = 0;
    bool f = 1;
    for(int i=n-1; i>=0; --i)
    {
        if(b[i] > mx)
        {
            u++;
            sum+=b[i];
            if(sum >= h)
            {
                f=0;
                break;
            }
        }
        else break;
    }
    if(!f)
    {
        cout << u << endl;
        return 0;
    }
    ll rem = h - sum;
    ll d = (rem+mx-1)/mx;
    cout << (d+u) << endl;
    return 0;
}


Measured memory_bytes: 1792
using System;
using System.Linq;

class Program
{
	static void Main(string[] args)
    {
    	var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var k = input[0];
        var s = input[1];
      	var count = 0;	
      
        for(var i = 0; i <= k; i++)
        {
        	for(var j = 0; j <= k; j++)
            {
                if (s - (i + j) <= k && s - (i + j) >=0) { count++; }
            }
        }
        Console.WriteLine(count);
    }
}


Measured memory_bytes: 11348
class UnionFind():
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        if self.par[x] != x:
            self.par[x] = self.find(self.par[x])
        return self.par[x]

    def unite(self, x, y):
        xroot = self.find(x)
        yroot = self.find(y)

        if xroot == yroot:
            # already same
            return

        if self.size[xroot] < self.size[yroot]:
            # merge to yroot
            self.par[xroot] = yroot
            self.size[yroot] = self.size[xroot] + self.size[yroot]
        else:
            # merge to xroot
            self.par[yroot] = xroot
            self.size[xroot] = self.size[xroot] + self.size[yroot]

    def same(self, x, y):
        return self.find(x) == self.find(y)


def read_input():
    n, m, k = map(int, input().split())

    friend_edge = []
    for _ in range(m):
        friend_edge.append(tuple(map(int, input().split())))

    block_edge = []
    for _ in range(k):
        block_edge.append(tuple(map(int, input().split())))

    return n, friend_edge, block_edge


def submit():
    n, friend_edge, block_edge = read_input()

    # 友達関係をUF
    uf = UnionFind(n)
    for a, b in friend_edge:
        uf.unite(a - 1, b - 1)

    # blockか、friend関係にある要素を整理
    # blockかつ、おなじufに含まれるもののみをのこす　
    remove_dict = {i : 0 for i in range(n)}
    for c, d in block_edge:
        if uf.same(c - 1, d - 1):
            remove_dict[c - 1] += 1
            remove_dict[d - 1] += 1
        
    # friend関係を整理
    for a, b in friend_edge:
        remove_dict[a - 1] += 1
        remove_dict[b - 1] += 1

    # result
    result = []
    for i in range(n):
        target_size = uf.size[uf.find(i)]
        result.append(target_size - remove_dict[i] - 1)

    print(" ".join(map(str, result)))


if __name__ == "__main__":
    submit()

Measured memory_bytes: 51896
import java.util.*;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int n = Integer.parseInt(scanner.next());
        int k = Integer.parseInt(scanner.next());
        double[] p = new double[n];
        for (int i = 0; i < n; i++) {
            int a = Integer.parseInt(scanner.next());
            p[i] = a * (a + 1) / 2.0 / a;
        }

        double[] cSum = new double[n + 1];
        for (int i = 0; i < n; i++) {
            cSum[i + 1] = cSum[i] + p[i];
        }

        double max = 0;
        for (int i = 0; i + k <= n; i++) {
            max = Math.max(max, cSum[i + k] - cSum[i]);
        }

        System.out.printf("%.8f\n", max);
    }
}



Measured memory_bytes: 62484
import java.util.Scanner;

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

		long h = sc.nextLong();
		long ans = 0, i = 0;
		while (h >= 1) {
			ans += Math.pow(2, i);
			h /= 2;
			i++;
		}
		System.out.println(ans);
	}
}

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

using namespace std;

using ll = long long;

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)

typedef pair<int, int> P;

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

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

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

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string s;
	cin >> s;
	
	bool ac = true;
	int cnt = 0;
	REP(i, s.length()) {
		if (i == 0) {
			if (s[i] != 'A') ac = false;
		}
		if (2 <= i && i <= s.length() - 2) {
			if (s[i] == 'C') {
				cnt++;
			} else {
				if (s[i] - 'a' >= 26) {
					ac = false;
				}
			}
		}
//		if (i == 1 || i == s.length() - 1) {
//			if (s[i] - 'A' <= 25) {
//				ac = false;
//			}
//		}
		if (s[i] != 'A' && s[i] != 'C') {
			if (s[i] - 'A' <= 25) {
				ac = false;
			}
		}
	}
	
	if (cnt != 1) ac = false;
	
	if (ac) cout << "AC" << endl;
	else cout << "WA" << endl;

//	cout << 'a' - 'A' << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int K,X; cin >> K >> X;
    int L = X - (K-1);
    int R = X + (K-1);
    for (int i=L;i<=R;i++){
        cout << i;
        if (i<R) cout << " ";
        else cout << endl;
    }     
    return 0;
}

Measured memory_bytes: 256
h, w = gets.split.map(&:to_i)
c = []
h.times{|i| c << gets.split('') }
c << []
h.times do |y|
  w.times do |x|
    if c[y][x] == "#" && c[y-1][x] != '#' && c[y+1][x] != '#' && c[y][x-1] != '#' && c[y][x+1] != '#'
      puts "No"
      exit
    end
  end
end
puts 'Yes'


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

using namespace std;

typedef long long ll;
typedef pair<int,int> p;


int main()
{
  int h, w;
  cin >> h >> w;
  vector<string> v(h, ".");
  for (int i = 0; i < h; i++){
    cin >> v[i];
  }
  int dx[4] = {-1, 0, 1, 0};
  int dy[4] = {0, -1, 0, 1};

  for (int i = 0; i < h; i++){
    for (int j = 0; j < w; j++){
      if (v[i][j] == '#') {
        int count = 0;
        for (int k = 0; k < 4; k++){
          // cout << count << endl;
          if (i + dy[k] < 0 || j + dx[k] < 0 || i + dy[k] >= h || j + dx[k] >= w) {
            count++;
            if (count == 4) {
              cout << "No" << endl;
              return 0;
            }
            continue;
          }
          if (v[i + dy[k]][j + dx[k]] == '.') {
            count++;
            if (count == 4) {
              cout << "No" << endl;
              return 0;
            }
          }
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

//nの約数を返す関数.sortされてない.
vector<long long int> divisors(long long int n){
	vector<long long int> res;
	for (long long int i = 1; i * i <= n;i++){
		if (n % i == 0){
			res.push_back(i);
			if(i * i != n){
				res.push_back(n / i);
			}
		}
	}
	return res;
}

int main()
{
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i += 2)
	{
		vector<ll> d = divisors(i);
		if (d.size()==8)
			ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)

#define sim template<class n
sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
sim> auto operator << (ostream &p, n y) ->
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define I(x) #x " =", (x), " "
#define A(a, i) #a "[" #i " =", i, "] =", a[i], " "

int value(int x)
  {
  debug(x);
  FOR(i, 1, 100)
    {
    debug(x, i);
    if(x >= i)
      {
      x-=i;
      }
    else return i-1;
    }
  assert(false);
  }
int main()
  {
  ios_base::sync_with_stdio(0); 
  LL n;
  cin >> n;
  map<LL, int> M;
  for(LL i = 2; i * i <= n; i++)
    {
    while(n % i == 0)
      {
      n /= i;
      M[i]++;
      }
    }
  if(n > 1)M[n]++;

  int res = 0;
  for(auto i: M)
    res += value(i.s);
  cout << res << endl;
  }


Measured memory_bytes: 3660
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <queue>
#include <math.h>
#include <bitset>
#define INF 100000000000
#define ll long long
using namespace std;

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(ll N) : par(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

int main(){
    ll n,q; cin>>n>>q;
    UnionFind tree(n);
    
    for(ll i=0; i<q; i++){
        ll a,b,c; cin>>a>>b>>c;
        if(a==0) tree.unite(b,c);
        if(a==1){
            if(tree.same(b,c)) cout<<"1"<<endl;
            else cout<<"0"<<endl;
        }
    }
}

Measured memory_bytes: 4824
#include <climits>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
using namespace std;

struct edge {
	int to, cost;
	edge(int t, int c):to(t), cost(c){}
};

typedef pair<int, int> P;
vector<vector<edge> > es;

int dijkstra(int s, int t) {
	priority_queue<P, vector<P>, greater<P> > que;
	vector<int> dist(es.size(), INT_MAX);
	que.push(P(0, s));
	dist[s] = 0;
	
	while(!que.empty()) {
		P p = que.top();
		que.pop();
		int v = p.second;
		if(dist[v] < p.first)
			continue;

		if(v == t)
			return dist[t];

		for(int i = 0; i < es[v].size(); ++i) {
			edge& e = es[v][i];
			if(dist[e.to] > dist[v] + e.cost) {
				dist[e.to] = dist[v] + e.cost;
				que.push(P(dist[e.to], e.to));
			}
		}
	}

	return -1;
}

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

	for(int n, k; cin >> n >> k, n;) {
		es.clear();
		es.resize(n);
		for(int i = 0; i < k; ++i) {
			int q;
			cin >> q;

			if(!q) {
				int from, to;
				cin >> from >> to;
				--from; --to;
				cout << dijkstra(from, to) << endl;
			}
			else {
				int u, v, cost;
				cin >> u >> v >> cost;
				--u; --v;
				es[u].push_back(edge(v, cost));
				es[v].push_back(edge(u, cost));
			}
		}
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1244