akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main(){

    input!{
        n: usize,
        x: [i32;n],
    }

    let mut p = 0;
    let mut hp = 0;
    let mut min_hp = 100*((100 as i32).pow(2));
    for i in 1..101{
        for &j in &x{
            hp += (j-p).pow(2);
        }
        
        min_hp = std::cmp::min(hp, min_hp);
        p += 1;
        hp = 0;
    }

    println!("{}", min_hp);

}

Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <queue>
#define ll long long
#define space putchar(' ')
#define endl putchar('\n')
#define debug puts("------------------------")
#define F(i,x,n) for(int i=x;i<=n;++i)
#define F_(i,x,n) for(int i=x;i>=n;--i)
using namespace std;
inline void read(ll &a) {a=0;int c=getchar(),b=1; while(c>'9'||c<'0') {if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();a*=b; }
inline int  Rem() {int a=0,c=getchar(),b=1; while(c>'9'||c<'0') {if(c=='-')b=-1;c=getchar();} while(c>='0'&&c<='9') a=(a<<3)+(a<<1)+c-48,c=getchar();return a*=b; }
inline void write(int x) {if(x>9)write(x/10);putchar('0'+x%10);}
inline void W(int x) {if(x<0){putchar('-'),x=-x;}write(x);}
/**/
const int N = 105;
ll n, a[N], b[N], ans;
/**/
int main()
{
	// freopen("test.in","r",stdin);
	// freopen("test.out","w",stdout);
	read(n);
	for(int i=1;i<n;i++) read(b[i]);
	a[1]=b[1];
	for(int i=1;i<n;i++)
	{
		if(i==n-1) a[i+1]=b[n-1];
		else a[i+1]=min(b[i],b[i+1]);
	}
	for(int i=1;i<=n;i++) ans+=a[i];
	cout<<ans;
}

Measured memory_bytes: 384
/*
    Bismillahir Rahmanir Raheem
    Think Twice Code Once
    author : reaziii
*/
#include<bits/stdc++.h>
#define sc(x)        scanf("%lld",&x)
#define pcase(x)     printf("Case %d: ",x++)
#define pn           printf("\n")
#define fri(f)       for(int i=0;i<f;i++)
#define frj(f)       for(int j=0;j<f;j++)
#define reset(x,e)   memset(x,e,sizeof(x))
#define all(x)       x.begin(),x.end()
#define input        freopen("input.txt","r",stdin);
#define output       freopen("output.txt","w",stdout)
#define infi         INT_MAX
#define m_v          3000000
#define pii          pair<int,int>
#define pch          pair<char,char>
#define pll          pair<ll,ll>
#define mgraph       map<int,set<int> >
#define mp           make_pair
#define pb           push_back
#define clr(x)       memset(x,0,sizeof(x))
#define frx(x,y)     for(int x=0;x<y;x++)
#define deb(x)       cout<<x
#define ideb(i,x)    cout<<i<<" "<<x
#define F            first
#define S            second
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
bool checkbitt(ll num,int pos);
ll setbitt(ll num,ll pos);
ll resetbitt(ll num,int pos);
 //.................___Start from here___.................//
//.................._____________________................//
 
 
int setbitcount(ll n){
    int ans = 0;
    for(int i=0;i<32;i++){
        ans+=(n>>i)&1;
    }

    return ans;
}
void solve(){
    int n;
    cin>>n;
    int mask = 1<<n;
    mask--;
 
    int a[n+1],x[n+1][n+1],y[n+1][n+1];
 
    for(int u = 1 ; u <= n ; u++ ){
        cin>>a[u];
        for(int v = 1;v<=a[u];v++){
            cin>>x[u][v]>>y[u][v];
        }
    }
 
    int ans = 0;
 
    for(int i=1;i<=mask;i++){
        bool f =true;
 
        for(int j=1;j<=n;j++){
            if(checkbitt(i,j-1)){
                for(int k=1;k<=a[j];k++){
                    if(y[j][k]^checkbitt(i,(x[j][k]-1))) f = false;
                }
            }
        }
 
        if(f) ans = max(ans,setbitcount(i));
    }
 
    cout<<ans<<endl;
 
}
 
 
int main(){
    int n;
  	cin>>n;
    if(n%2==0)cout<<n<<endl;
    else cout<<n*2<<endl;
}
 
 
 
 
 
 
bool checkbitt(ll num,int pos){
    return (num>>pos) & 1;
}
 
ll setbitt(ll num,ll pos){
    return (1<<pos) | num;
}
 
ll resetbitt(ll num,int pos){
    if(!checkbitt(num,pos)) {
        return num;
    }
    else{
        return (1<<pos)^num;
    }
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
bool dp[100005][105];
int arr[105];

string solve(int n,int k){


	int dp[k+1]={0};
	dp[0]=1;

	//0 means first wins
	//1 means second wins
	
	for(int i=1;i<=k;i++){
		bool all = true;
		
		for(int j=0;j<n;j++){
			int move = arr[j];
			if(move>i)
				continue;

			if(dp[i-move]==1){
				all=false;
				break;
			}
		}
		if(all)
			dp[i]=1;
	}

	return dp[k]?"Second":"First";
}


int main(){



   ios_base::sync_with_stdio(false);
        cin.tie(NULL);

       int n,k;
       cin>>n>>k;
       for(int i=0;i<n;i++)
       	cin>>arr[i];

       cout<<solve(n,k)<<endl;


}

Measured memory_bytes: 4060
#include<iostream>
 
using namespace std;
 
int main(){
  static bool cmp[1000000]={true};
  static int npr[1000000];
  for(int i=2;i<1000000;i++){
    if(!cmp[i]){
      for(int j=2;j*i<1000000;j++){
    cmp[i*j]=true;
      }
    }
    npr[i]=npr[i-1]+!cmp[i];
  }
  int n;
  while(cin>>n){
    cout<<npr[n]<<endl;
  }
  return 0;
}


Measured memory_bytes: 6044
#include <iostream>

using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;

    int x, y, z;
    x = a + b;
    y = a - b;
    z = a * b;
    
    
    int max = x;
    if( max < y ) {
        max = y;
    }
    if( max < z ) {
        max = z;
    }
    
    // 出力
    cout << max <<  endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1LL << 60;
constexpr int INF = 1000000007;
const int mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll dp[110][100050];
int main(){
  int N,W;
  cin >> N >> W;
  memset(dp,0,sizeof(dp));
  vector<pair<int,int>> P(N);
  for(int i=0; i<N; i++){
    int w,v;
    cin >> w >> v;
    P[i] = make_pair(w,v);
  }
  for(int i=0; i<N; i++){
    for(int j=0; j<=W; j++){
      if(P[i].first > j){
        dp[i+1][j] = dp[i][j];
      }else{
        dp[i+1][j] = max(dp[i][j],dp[i][j-P[i].first]+P[i].second);
      }
    }
  }
  cout << dp[N][W] << endl;
  return 0;
}


Measured memory_bytes: 86272
def is_ss(s):
    l = len(s)
    return l % 2 == 0 and s[:l//2] == s[l//2:]


def main():
    s = input()[:-1]
    while not is_ss(s):
        s = s[:-1]
    print(len(s))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <cstdio>
#include <string>
#include <vector>
#include <random>
#include <chrono>
#include <utility>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <sstream>
#include <assert.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(bool x) {cerr << (x ? "true" : "false");}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}

template<typename T, typename V> void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";} void _print() {cerr << "]\n";}
template <typename T, typename... V>void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifdef HOME
#warning CHECK int:ll::INT_MAX:LLONG_MAX
#define maxn 20
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define maxn 2000006
#define gcd __gcd
#define debug(x...)
#endif

#define ff first
#define endl '\n'
#define ss second
#define inf 0x3f3f3f3f
#define MOD 1000000007
#define PI 3.14159265358979323846264338327950L
#define f(i,x,n) for(int i=x;i<=n;i++)
#define fr(i,x,n) for(int i=x;i>=n;i--)
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

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


int main() {

	int n; cin >> n;
	map<int, int> freq;
	vector<int> a(n); for (int i = 0; i <= n - 1; i++) cin >> a[i], freq[a[i]]++;

	if (freq.size() == 1) {
		cout << n / 2;
		return 0;
	}

	map<int, int> odd, eve;
	for (int i = 0; i <= n - 1; i += 2) {
		eve[a[i]]++;
	}

	for (int i = 1; i <= n - 1; i += 2) {
		odd[a[i]]++;
	}
	int max_odd = 0, max_odd_ele = -1, max_odd2 = 0, max_eve = 0, max_eve_ele = 0, max_eve2 = 0;

	for (auto i : odd) {
		// max_odd = max(max_odd, i.ss);
		if (max_odd2 < i.ss) {
			max_odd2 = i.ss;
			if (max_odd < max_odd2) {
				swap(max_odd, max_odd2);
				max_odd_ele = i.ff;
			}
		}
		// tot_odd += i.ss;
	}

	for (auto i : eve) {
		// max_eve = max(max_eve, i.ss);
		if (max_eve2 < i.ss) {
			max_eve2 = i.ss;
			if (max_eve < max_eve2) {
				swap(max_eve, max_eve2);
				max_eve_ele = i.ff;
			}
		}
		// tot_eve += i.ss;
	}
	if (max_odd_ele == max_eve_ele) {
		cout << min(n - max_odd - max_eve2, n - max_odd2 - max_eve);
	}
	else cout << n - max_odd - max_eve;

	return 0;
}

Measured memory_bytes: 13004
package main

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

const (
	maxN = 110
)

var F [maxN][5][2]int
var P [maxN][11]int

func main() {
	fsc := NewFastScanner()
	N := fsc.NextInt()
	for i := 0; i < N; i++ {
		for j := 0; j < 5; j++ {
			for k := 0; k < 2; k++ {
				F[i][j][k] = fsc.NextInt()
			}
		}
	}
	for i := 0; i < N; i++ {
		for j := 0; j < 11; j++ {
			P[i][j] = fsc.NextInt()
		}
	}
	result := -10000000000
	for bit := 1; bit < (1 << 10); bit++ {
		open := make([]int, 0)
		for i := 0; i < 10; i++ {
			if ((bit >> uint(i)) & 1) == 1 {
				open = append(open, 1)
			} else {
				open = append(open, 0)
			}
		}
		sum := 0
		for i := 0; i < N; i++ {
			cnt := 0
			for j := 0; j < 5; j++ {
				for k := 0; k < 2; k++ {
					if F[i][j][k] == 1 && open[2*j+k] == 1 {
						cnt++
					}
				}
			}
			sum += P[i][cnt]
		}
		result = IntMax(result, sum)
	}
	fmt.Println(result)
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

//Max,Min
func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func IntMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

//Gcd
func IntGcd(a, b int) int {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return IntGcd(b, a%b)
}
func Int64Gcd(a, b int64) int64 {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return Int64Gcd(b, a%b)
}

func IntAbs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}

func Int64Abs(a int64) int64 {
	if a < 0 {
		a *= -1
	}
	return a
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
typedef vector<P> vec;
 
double eps=1e-7;
bool eq(double a,double b){return (b-a<eps&&a-b<eps);}
double dot(P a,P b){return real(b*conj(a));}
double cross(P a,P b){return imag(b*conj(a));}
P project(P a,P b,P c){b-=a;c-=a;return a+b*real(c/b);}
P reflect(P a,P b,P c){b-=a;c-=a;return a+conj(c/b)*b;}
int ccw(P a,P b,P c){
  b-=a,c-=a,a=c*conj(b);
  if(a.imag()>eps)return 1;//ccw
  if(a.imag()<-eps)return -1;//cw
  if(a.real()<-eps)return 2;//ob
  if(abs(b)+eps<abs(c))return -2;//of
  return 0;//os
}
 
//segment ab , point c
double dist(P a,P b,P c){
  if(dot(b-a,c-a)<0)return abs(c-a);
  if(dot(a-b,c-b)<0)return abs(c-b);
  return abs(cross(b-a,c-a))/abs(b-a);
}
 
bool isintersect(P a,P b,P c,P d){
  return ((ccw(a,b,c)*ccw(a,b,d)<=0)&&(ccw(c,d,a)*ccw(c,d,b)<=0));
}
 
//segment ab , segment cd
P intersect(P a,P b,P c,P d){
  a-=d;b-=d;c-=d;
  return d+a+(b-a)*imag(a/c)/imag(a/c-b/c);
}
 
double dist(P a,P b,P c,P d){
  if(isintersect(a,b,c,d))return 0;
  double ab=min(dist(a,b,c),dist(a,b,d));
  double cd=min(dist(c,d,a),dist(c,d,b));
  return min(ab,cd);
}
 
double calcArea(vec &t){
  double res=0;
  int n=t.size();
  for(int i=0;i<n;i++)res+=cross(t[i],t[(i+1==n?0:i+1)]);
  return abs(res/2.0);
}
 
int main(){
  int T;
  cin>>T;
  vec t;
  double x,y;
  while(T--){
    cin>>x>>y;
    t.push_back(P(x,y));
  }
  printf("%.1f\n",calcArea(t));
  return 0;
}

Measured memory_bytes: 3212
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#define INF 1e9
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
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; }
using namespace std;
string S;

signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> S;
  int max = 0;
  int len = S.length();


  for(int i = 0; i < len ; i++ ){
    int tmp = 0;
    if(S[i] != 'A' && S[i] != 'T' && S[i] != 'G' && S[i] != 'C'){
      continue;
    }
    else{
      tmp++;
      for(auto j = i+1; j < len; j++){
        if(S[j] != 'A' && S[j] != 'T' && S[j] != 'G' && S[j] != 'C'){
          break;
        }
        tmp++;
      }
    }
    chmax(max,tmp);
  }
  cout << max << endl;

  return 0;
}


Measured memory_bytes: 888
def main():
    N = int(input())
    A = list(map(int,input().split()))
    B = list(map(int,input().split()))
    C = list(map(int,input().split()))

    happiness = 0
    for i in range(N-1):
        happiness += B[A[i]-1]
        if A[i+1] - A[i] == 1:
            happiness += C[A[i]-1]

    print(happiness+B[A[-1]-1])

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<cstdio>
int abs(int x){
    return x<0?-x:x;
}
const int N=105;
int n;
int a[N];
int sum;
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;++i)scanf("%d",&a[i]),sum+=a[i];
    int mn=0x3f3f3f3f,mnn;
    for(int i=0;i<n;++i){
        a[i]*=n;
        if(abs(sum-a[i])<mn){
            mn=abs(sum-a[i]);
            mnn=i;
        }
    }
    printf("%d\n",mnn);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

void yes(){
	printf("Yes\n");
	exit(0);
}

int main(){
	int a, b, c; scanf("%d%d%d", &a, &b, &c);
	if(a==b && b!=c) yes();
	if(b==c && c!=a) yes();
	if(c==a && a!=b) yes();
	printf("No\n");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef pair<int,int> P;
int d[200001]={0},r[200001]={0},k;
vector<int> G[200001];
map<P,int> A;
int bfs(int s){
    queue<int> que;
    que.push(s);
    r[s]=1;
    while (!que.empty()) {
        int v=que.front();
        que.pop();
        int z=1;
        for(int nv:G[v]) {
            if(r[nv]) continue; 
            r[nv]++;
            if(z==d[v]) z++;
            d[nv]=z;
            A[P(min(v,nv),max(v,nv))]=z;
            z++;
            que.push(nv);
        }
    }
}
int main(){
    int n,a,b,num[200001]={0},X[200001][2];
    cin>>n;
    rep(i,n-1) cin>>a>>b,X[i][0]=min(a,b),X[i][1]=max(a,b),G[a].push_back(b),G[b].push_back(a),num[a]++,num[b]++;
    sort(num,num+200000,greater<int>());
    k=num[0];
    bfs(1);
    cout<<k<<endl;
    rep(i,n-1) cout<<A[P(X[i][0],X[i][1])]<<endl;
}

Measured memory_bytes: 17664
import math

A, B, H, M = map(int, input().split())

x = ((M * 1/2) + (H * 30)) - (M * 6)

R = math.radians(x)
COS = math.cos(R)
re = (A**2) + (B**2) - 2 * (A * B) * COS

print(re**0.5)

Measured memory_bytes: 9512
#include <iostream>
#include <cstdio>
#include <vector>
#include <math.h>

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define vsort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())

const int MOD = 1000000007;
const int INF = INT_MAX;


int main(){

    string s;
    cin >> s;

    int cnt = 0;
    for (int i=2; i < s.size()-1; i++){
        if (s[i] == 'C') cnt++;
    }

    int flag = 1;
    for (int i=1; i < s.size(); i++){
        if (('a' <= s[i] && s[i] <= 'z') || s[i] == 'C') ;
        else flag = 0;
    }

    if (s[0] == 'A' && cnt == 1 && flag == 1) cout << "AC" << endl;
    else cout << "WA" << endl;

}





//              g++ -std=c++1z

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
#define vec2(a,y,x) vector<vector<int>> a(y,vector<int>(x,0))
#define vec1(a,n) vector<int> a(n);rep(i,n)cin>>a[i]
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};

int main(){
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int h,w,x,y,nx,ny;
  cin>>h>>w;
  vector<vector<char>> a(h,vector<char>(w));
  rep(i,h)rep(j,w) cin>>a[i][j];
  if(h*w==2){cout<<1<<endl;return 0;}
  int ans=1;
  rep(i,h)rep(j,w){//strart:(i,j)
     if(a[i][j]=='#') continue;
    queue<P> q;
    vec2(seen,h,w);
    q.push(P(i,j));
    while(q.size()){
    	x=q.front().second;y=q.front().first;
      q.pop();
      rep(k,4){
        nx=x+dx[k];ny=y+dy[k];
      	if(nx<0 || ny<0 || nx>=w || ny>=h || a[ny][nx]=='#' ||seen[ny][nx]>0) continue;
        seen[ny][nx]=seen[y][x]+1;
        q.push(P(ny,nx));
      }
    }
    rep(k,h)rep(l,w) ans =max(ans,seen[k][l]);
  }
  cout<<ans<<endl;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> ball(N,0);
    vector<int> vec(N);
    rep(i,N){
        cin >> vec[i];
    }
    int ans = 0;
    for (int i = N - 1; i >= 0; i--){
        int num = N / (i + 1);
        int count = 0;
        for (int j = 1; j <= num; j++){
            count += ball[(i + 1) * j - 1];
        }
        if ((count % 2) != vec[i]){
            ball[i]++;
            ans++;
        }
    }
    cout << ans << endl;
    rep(i,N){
        if (ball[i] == 1) cout << i + 1 << " ";
    }
    if (ans >= 1){
        cout << endl;
    }
}


Measured memory_bytes: 2432
#line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = (ll)n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = (ll)r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U> inline void cmax(T& a, U b) { if (a < b) a = b; }
template<class T, class U> inline void cmin(T& a, U b) { if (a > b) a = b; }
constexpr char el = '\n';
template<class T, class U> ostream &operator<<(ostream &os, const pair<T, U>& p) { os << p.first << " " << p.second; return os; }
template<class T, class U> istream &operator>>(istream &is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<class T> ostream &operator<<(ostream &os, const vector< T > &v) { rep(i, v.size()) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }
template<class T> istream &operator>>(istream &is, vector< T > &v) { for(T &in : v) is >> in; return is; }
struct IoSetup {
  IoSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); }
} io_setup;
#line 3 "../../library/debug.hpp"

// https://codeforces.com/blog/entry/68809
void debug_print(int x) {cerr << x;}
void debug_print(long x) {cerr << x;}
void debug_print(long long x) {cerr << x;}
void debug_print(unsigned x) {cerr << x;}
void debug_print(unsigned long x) {cerr << x;}
void debug_print(unsigned long long x) {cerr << x;}
void debug_print(float x) {cerr << x;}
void debug_print(double x) {cerr << x;}
void debug_print(long double x) {cerr << x;}
void debug_print(char x) {cerr << '\'' << x << '\'';}
void debug_print(const char *x) {cerr << '\"' << x << '\"';}
void debug_print(const string &x) {cerr << '\"' << x << '\"';}
void debug_print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V> void debug_print(const pair<T, V> &x) {cerr << '{'; debug_print(x.first); cerr << ','; debug_print(x.second); cerr << '}';}
template<typename T> void debug_print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), debug_print(i); cerr << "}";}

void debug_print_() {cerr << "]\n";}
template <typename T, typename... V>
void debug_print_(T t, V... v) {debug_print(t); if (sizeof...(v)) cerr << ", "; debug_print_(v...);}

#ifdef LOCAL
#define debug(x...) cerr << "[" << #x << "] = ["; debug_print_(x)
#else
#define debug(x...)
#endif
#line 3 "e.cpp"

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

  auto dis = [&n](ll l, ll r) {
    if (r >= l) {
      return r-l;
    } else {
      return n-(l-r);
    }
  };

  vl a(m), b(m);

  // 距離が奇数の組の個数
  ll ki = (m+1)/2;
  // 距離が偶数の組の個数
  ll gu = m/2;

  debug(ki, gu);

  ll cnt = 1;
  rep(i, ki) {
    a[i] = cnt++;
  }
  per(i, ki) {
    b[i] = cnt++;
  }
  rep(i, gu) {
    a[i+ki] = cnt++;
  }
  cnt++;
  per(i, gu) {
    b[i+ki] = cnt++;
  }

  rep(i, m) {
    debug(dis(a[i], b[i]), dis(b[i], a[i]));
    cout << a[i] << " " << b[i] << el;
  }
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int N = nextLong();
  const ll K = nextLong();

  vector<ll> P(N), C(N);
  REP(i, N) P[i] = nextLong() - 1;
  REP(i, N) C[i] = nextLong();
  ll ans = -(1LL << 61);
  REP(start, N) {

    vector<int> vis(N, 0);
    int i = start;
    ll cycle = 0;
    ll sum = 0;
    for (int age = 1; ; age++) {
      if (vis[i]) {
        cycle = age - vis[i];
        break;
      }
      vis[i] = age;
      sum += C[i];
      i = P[i];
    }
    // cout << start << " : " << cycle << " : " << sum << endl;

    ll s = max(0LL, K / cycle - 1LL);
    ll base = sum > 0 ? s * sum : 0;
    ll k = K - cycle * s;
    ll max_val = -(1LL << 61);
    ll val = 0;

    i = start;
    REP(_, k) {
      i = P[i];
      val += C[i];
      chmax(max_val, val);
    }

    chmax(ans, base + max_val);
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 3780
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>

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

using namespace std;

typedef pair<int, int> pii;
typedef unsigned long long ull;

int main(void){
    int nt = 0, nh = 0;
    for(int a, b, c; ~scanf("%d,%d,%d", &a, &b, &c);){
        if(a == b) nh ++;
        else if(a * a + b * b == c * c) nt ++;
    }
    cout << nt << endl << nh << endl;

    return 0;
}

Measured memory_bytes: 1208
#include<stdio.h>
#include<math.h>
typedef long long int ll;
int dpow(int x,int y){int tmp=x;for(int i=0;i<y-1;i++){x*=tmp;}return x;}
int main(){
    int a,n,m;

    scanf("%d %d %d",&a,&n,&m);

    int cnt=0;
    char str[100];
    int x;
    int sum=0;
    for(int i=1;i<=72;i++){
        x=dpow(i+a,n);
        if(x>m)break;
        sprintf(str,"%d",x);
        sum=0;
        for(int j=0;str[j]!='\0';j++){
            sum+=str[j]-0x30;
        }
        if(sum==i)cnt++;
    }
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 2112
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
T[] RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[][] RDA2(T = long)(size_t n, T[] fix = []) { auto r = new T[][](n); foreach (i; 0..n) { r[i] = readln.chomp.split.to!(T[]); foreach (j, e; fix) r[i][j] += e; } return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

//long mod = 10^^9 + 7;
long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto Q = RD;
	auto edges = new long[][](N);
	foreach (i; 0..N-1)
	{
		auto a = RD-1;
		auto b = RD-1;
		edges[a] ~= b;
		edges[b] ~= a;
	}
	
	auto score = new long[](N);
	foreach (i; 0..Q)
	{
		auto p = RD-1;
		auto x = RD;
		score[p] += x;
	}

	auto ans = new long[](N);
	
	void dfs(long pos, long par, long x)
	{
		x += score[pos];
		ans[pos] = x;
		foreach (to; edges[pos])
		{
			if (to == par) continue;
			dfs(to, pos, x);
		}
	}
	dfs(0, -1, 0);

	ans.map!(to!string).join(" ").writeln;
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 63740
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <cassert>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

vector<vector<int>> grid_max_square(const vector<string> &s, char wall='#', char path='.'){
  assert(s.size()!=0);
  int n = (int)s.size();
  int m = (int)s[0].size();
  //dp[i][j]:= (i, j) からの辺の最大長
  //dp[i][j] = min(dp[i+1][j], dp[i+1][j+1], dp[i][j+1]) + 1
  vector<vector<int>> dp(n, vector<int>(m, 0));
  for(int i=n-1;i>=0;i--){
    for(int j=m-1;j>=0;j--){
      if(s[i][j]==wall) continue;
      int ans = 1000000000;
      if(i+1<n) ans = min(ans, dp[i+1][j]);
      if(j+1<m) ans = min(ans, dp[i][j+1]);
      if(i+1<n&&j+1<m) ans = min(ans, dp[i+1][j+1]);
      dp[i][j] = min({ans + 1, n-i, m-j});
    }
  }
  return dp;
}

#include <stack>
//L[i]/R[i] h[i]が最小値となる最大区間(閉区間)
pair<vll, vll> histogram_max_rectangle(const vector<ll>& h){
  int n = (int)h.size();
  vector<ll> L(n), R(n);
  stack<int> st;
  for(int i=0;i<n;i++){
    while(true){
      if(st.empty()){
        L[i] = 0;
        break;
      }
      int tmp = st.top();
      if(h[tmp]>=h[i]) {
        st.pop();
        continue;
      }
      L[i] = tmp + 1;
      break;
    }
    st.push(i);
  }
  st = stack<int>();
  for(int i=n-1;i>=0;i--){
    while(true){
      if(st.empty()){
        R[i] = n-1;
        break;
      }
      int tmp = st.top();
      if(h[tmp]>=h[i]) {
        st.pop();
        continue;
      }
      R[i] = tmp - 1;
      break;
    }
    st.push(i);
  }
  return {L, R};
}

int main(){
  ll h, w;scanf("%lld %lld", &h, &w);
  vector<string> s(h);re(i, h) std::cin >> s[i];
  vll dp(2*w+1, 0);
  vector<string> S(h);
  for(int i=0;i<h;i++){
    string ret = "#";
    for(int j=0;j<w;j++){
      if(j==w-1||(i&&((s[i][j]=='#') + (s[i][j+1]=='#') + (s[i-1][j]=='#') + (s[i-1][j+1]=='#'))%2)) ret += ".#";
      else ret += "..";
    }
    ret += "#";
    S[i] = ret;
  }
  ll ans = 0;
  for(int i=0;i<h;i++){
    for(int j=1;j<2*w;j++) dp[j] = (S[i][j]=='#'?1:dp[j]+1);
    auto [L, R] = histogram_max_rectangle(dp);
    for(int j=1;j<2*w;j++) ans = max(ans, dp[j] * (R[j]-L[j]+2)/2);
  }
  std::cout << ans << '\n';
}


Measured memory_bytes: 19152
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T f=0,x=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
namespace run{
	typedef long long ll;
	const int N=2e5+9;
	int head[N],nex[N],to[N],w[N],cnt;
	inline void add(int u,int v,int c){
		nex[++cnt]=head[u];
		head[u]=cnt,to[cnt]=v,w[cnt]=c;
	}
	int siz[N],mx[N],n;ll ans;
	inline void dfs(int u,int _f){
		siz[u]=1;
		for(int i=head[u];i;i=nex[i])
			if(to[i]^_f){
				dfs(to[i],u),siz[u]+=siz[to[i]];
				mx[u]=max(mx[u],siz[to[i]]);
				ans+=2LL*min(siz[to[i]],n-siz[to[i]])*w[i];
			}
		mx[u]=max(mx[u],n-siz[u]);
	}
	int main(){
		n=read<int>();
		for(int i=1;i<n;i++){
			int u=read<int>(),v=read<int>(),c=read<int>();
			add(u,v,c),add(v,u,c);
		}
		dfs(1,0);
	//	cout<<ans<<endl;
		int rt=0,mn=1e8;
		for(int i=1;i<=n;i++)
			if(mx[i]<=n/2){rt=i;break;}
		for(int i=head[rt];i;i=nex[i])
			if(mx[to[i]]<=n/2){mn=w[i];break;}
			else mn=min(mn,w[i]);
		printf("%lld\n",ans-mn);
		return 0;
	}
}
int main(){
#ifdef my
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	return run::main();
}

Measured memory_bytes: 13780
/*
ID: barish21
LANG: C++14
TASK: test
*/

/****Author: Barish Namazov****/
#include <bits/stdc++.h>

using namespace std;

/***TEMPLATE***/
#define intt long long

#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

#define F first
#define S second
#define pb push_back

#define IO ios_base::sync_with_stdio(false);cin.tie();

const intt max4 = 10004;
const intt maxx = 100005;
const intt max6 = 1000006;
const intt max7 = 10000007;

const intt lg4 = 13;
const intt lg5 = 17;
const intt lg6 = 20;

const intt INF = 2LL * 1000000000;
/***************/

/***Additional Functions***/

intt powmod (intt a, intt b, intt mod) {
    intt res = 1;
    a %= mod;
    for (; b; b >>= 1) {
        if (b & 1)
            res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}

intt gcd (intt a, intt b) {
    while (b > 0) {
        intt t = a % b;
        a = b, b = t;
    }
    return a;
}

intt lcm (intt a, intt b) {
    return (a / gcd (a, b)) * b;
}

intt is_prime (intt n) {
    if (n <= 1 || n > 3 && (n % 2 == 0 || n % 3 == 0))
        return 0;
    for (intt i = 5, t = 2; i * i <= n; i += t, t = 6 - t)
        if (n % i == 0)
            return 0;
    return 1;
}

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

const intt init = (1 << 31) - 1;

intt n, q;
intt t[maxx << 2];

void update (intt v, intt l, intt r, intt i, intt val) {
    if (i < l || i > r)
        return;
    if (l == r) {
        t[v] += val;
        return;
    }
    intt mid = (l + r) >> 1;
    update (v << 1, l, mid, i, val);
    update (v << 1 | 1, mid + 1, r, i, val);
    t[v] = t[v << 1] + t[v << 1 | 1];
}

intt query (intt v, intt l, intt r, intt i, intt j) {
    if (j < l || i > r)
        return 0;
    if (i <= l && r <= j)
        return t[v];
    intt mid = (l + r) >> 1;
    return query (v << 1, l, mid, i, j) + query (v << 1 | 1, mid + 1, r, i, j);
}

int main() {
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    IO;
    cin >> n >> q;
    while (q --) {
        intt type, x, y;
        cin >> type >> x >> y;
        if (type == 0)
            update (1, 1, n, x, y);
        else
            cout << query (1, 1, n, x, y) << endl;
    }
    return 0;
}

Measured memory_bytes: 5284
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
const ll MAX = 1001001;
const ll MOD = 1000000007;
int main()
{
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll cw = 0;
    ll cr = 0;
    rep(i, n)
    {
        if (s[i] == 'R')
        {
            cr++;
        }
    }
    ll ans = cr;
    rep(i, n)
    {
        if (s[i] == 'W')
        {
            cw++;
        }
        else
        {
            cr--;
        }
        ans = min(ans, max(cw, cr));
    }

    cout << ans << endl;
}


Measured memory_bytes: 3736
#include<iostream>
#include<set>
#include<vector>
#include<array>
#include<algorithm>
#include<chrono>

int const INF = 1e9;

uint64_t xor64(void) {
  static uint64_t x = 88172645463325252ULL;
  x = x ^ (x << 7);
  return x = x ^ (x >> 9);
}

auto b_cl = std::chrono::system_clock::now();
inline double get_time() {
  auto e_cl = std::chrono::system_clock::now();
  double msec = std::chrono::duration_cast<std::chrono::milliseconds>(e_cl - b_cl).count();
  return msec;
}

struct state {
  int score_k;
  int type;
  int last[26];
  int score;
  std::vector<state>::iterator prev;
  bool operator< (state const& rhs) const { return score_k > rhs.score_k; } // reverse order
};

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int D; std::cin >> D;
  int c[26];
  for(auto& ci: c) std::cin >> ci;
  std::vector<std::array<int,26>> s(D);
  for(int d = 0; d < D; ++d) {
    for(auto& si: s[d]) std::cin >> si;
  }
  int const B = 740;
  int const K = 2;
  std::vector<int> t(D);
  
  std::vector<std::vector<state>> states(D+1);
  auto beam_step = [&](int d, int k) {
    auto& prev = states[d];
    auto& curr = states[d+1];
    int dd = std::min(d+k, D-1);
    for(auto it = prev.begin(); it != prev.end(); ++it) {
      for(int T = 0; T < 26; ++T) {
        curr.push_back(*it);
        state& st = curr.back();
        st.prev = it;
        st.last[T] = d;
        st.type = T;
        st.score_k = st.score + s[d][T];
        for(int cx = 0; cx < 26; ++cx) {
          st.score_k -= c[cx]*(d+dd - 2*st.last[cx])*(dd-d+1)/2;
        }
      }
    }
    std::sort(curr.begin(), curr.end());
    if(curr.size() > B) curr.resize(B);
    for(auto& st: curr) {
      st.score += s[d][st.type];
      for(int cx = 0; cx < 26; ++cx) {
        st.score -= c[cx]*(d - st.last[cx]);
      }
    }
  };
  
  auto beam_search = [&](int k) {
    states.assign(D+1, std::vector<state>());
    states[0].emplace_back();
    states[0][0].score = 0;
    states[0][0].score_k = 0;
    std::fill_n(states[0][0].last, 26, -1);
    for(int d = 0; d < D; ++d) beam_step(d, k);
    auto it = states[D].begin();
    for(int d = D-1; d >= 0; it = it->prev, --d) {
      t[d] = it->type;
    }
  };
  beam_search(K);
  for(auto ti: t) std::cout << ti+1 << "\n";
  return 0;
}


Measured memory_bytes: 881172
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int main(){
  int A, B; cin >> A >> B;

  for (int i = 0; i <= 1e5; i++){
    int Anow = i * 8 / 100;
    int Bnow = i * 10 / 100;
    if (Anow == A && Bnow == B){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <algorithm>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
using namespace std;

int n,h,deg[410],cnt,sum,gap[410],dis[410],s,t;
bool flag[410];
struct edge
{
    int v,f;
    edge *nxt,*rev;
} pool[210000],*tp=pool,*fst[410],*cur[410];

int getint()
{
    char ch;
    while (!isdigit(ch=getchar()));
    int x=ch-'0';
    for (; isdigit(ch=getchar()); x=x*10+ch-'0');
    return x;
}

void addedge(int u,int v,int f)
{
    ++deg[u],--deg[v];
    *tp=(edge){v,f,fst[u],tp+1},fst[u]=tp++;
    *tp=(edge){u,0,fst[v],tp-1},fst[v]=tp++;
}

int sap(int x,int flow)
{
    if (x==t)
        return flow;
    int sum=0,f;
    for (edge *i=cur[x]; i; i=i->nxt)
        if (i->f && dis[i->v]+1==dis[x])
        {
            f=sap(i->v,min(flow-sum,i->f));
            i->f-=f,i->rev->f+=f,cur[x]=i;
            if ((sum+=f)==flow || dis[s]==t)
                return sum;
        }
    if (!--gap[dis[x]])
        dis[s]=t;
    ++gap[++dis[x]],cur[x]=fst[x];
    return sum;
}

void dfs(int x)
{
    if (flag[x])
        return;
    flag[x]=1;
    for (edge *i=fst[x]; i; i=i->nxt)
        if (i->f)
            ++cnt,dfs(i->v);
}

bool check()
{
    repu(i,1,n)
    {
        int a=getint(),b=getint(),c=getint(),d=getint();
        int u=c?c:h+a,v=d?h+d:b;
        addedge(u,v,1);
    }
    s=h*2+1,t=s+1;
    repu(i,h+1,h*2)
        if (deg[i]>0)
            dfs(i),sum+=deg[i];
    if (cnt<n)
        return 0;
    repu(i,1,h*2)
    {
        if (deg[i]>0)
            if (i>h)
                addedge(s,i,deg[i]);
            else
                return 0;
        if (deg[i]<0)
            if (i<=h)
                addedge(i,t,-deg[i]);
            else
                return 0;
    }
    gap[0]=t;
    repu(i,1,t)
        cur[i]=fst[i];
    for (; dis[s]<t; sum-=sap(s,1<<30));
    return !sum;
}

int main()
{
    scanf("%d%d",&n,&h);
    puts(check()?"YES":"NO");
    return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head

void solve(){
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++) cin >> p[i];
    int ans = 0;
    for (int i = 1; i < n-1; i++){
        if ((p[i] > p[i-1] && p[i] < p[i+1]) || (p[i] < p[i-1] && p[i] > p[i+1])) ans++;
    }
    cout << ans << '\n';
}

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

    //int t; cin >> t; while (t--)
        solve();
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	if (n>m)
	{
		for (int i=1;i<=n;i++)
		{
			cout<<m;
		}
	}
	else
	{
		for (int i=1;i<=m;i++)
		{
			cout<<n;
		}
	}
	cout<<endl;
	return 0;
 } 

Measured memory_bytes: 256
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
String s=sc.next();
    while(s.contains("0B")||s.contains("1B")){
    s=s.replaceAll("0B","");
    s=s.replaceAll("1B","");
    }
    s=s.replaceAll("B","");
    
    System.out.println(s);            
}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define mod 1000000007
#define P pair<int,int>
using namespace std;
pair<P,int> p[100000];
P x[100000];
signed main(){
	int a,b;
	cin>>a>>b;
	f(i,b){
		cin>>p[i].F.F>>p[i].F.S;
		p[i].S=i;
		x[i].F=p[i].F.F;
	}
	sort(p,p+b);
	int z=1;
	f(i,b){
		if(i&&p[i].F.F!=p[i-1].F.F){
			z=1;
		}
		x[p[i].S].S=z;
		z++;
	}
	f(i,b){
		int c=6,d=x[i].F;
		while(d){
			d/=10;
			c--;
		}
		f(i,c) cout<<0;
		cout<<x[i].F;
		c=6;
		d=x[i].S;
		while(d){
			d/=10;
			c--;
		}
		f(i,c) cout<<0;
		cout<<x[i].S<<endl;
	}
	return 0;
}


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

using namespace std;

#define ll long long
#define up(i,j,n)	for(ll i=j;i<=n;i++)
#define down(i,j,n)	for(ll i=j;i>=n;i--)
#define cmax(a,b)	a=max(a,b)
#define cmin(a,b)	a=min(a,b)

const ll mod=1e9+7;
const ll MAXN=1e6+5;
const ll LIM=1e6;

ll fac[MAXN],N,M;

int main(){
//	freopen("input.in","r",stdin);
	scanf("%lld%lld",&N,&M);
	fac[0]=1;
	up(i,1,LIM)fac[i]=i*fac[i-1]%mod;
	ll ans=(abs(N-M)>1)?0:(fac[N]%mod*fac[M]%mod);
	if(N-M==0)(ans*=2LL)%=mod;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 8064
# -*- encoding: utf-8 -*-

x = int(input())

l = [False] * (x + 1)

l[1] = True
for i in range(2, x + 1):
    v = i * i
    while (v <= x):
        l[v] = True
        v *= i

res = x
for i in l[::-1]:
    if i is True:
        print(res)
        break
    res -= 1

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

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

			int roopCount = (s.length() -  t.length()) + 1;

			int ans = t.length();
			char[] sArr = s.toCharArray();
			char[] tArr = t.toCharArray();
			for (int i = 0; i < roopCount; i++) {
				int index = i;
				int res = 0;
				boolean isEqual = false;
				for (char tc : tArr) {
					if (tc == sArr[index++]) {
						isEqual = true;
						res++;
					}
				}
				if (isEqual) {
					ans = Math.min(ans, (t.length() - res));
				}
			}

			System.out.println(ans);
		}
	}
}

Measured memory_bytes: 35672
# -*- coding: utf-8 -*-

import sys

def parse_input(lines_as_string = None):


    lines = []
    if lines_as_string is None:
        lines.append(input())
        lines.append(input())
        lines.append(input())
        lines.append(input())
        lines.append(input())
        lines.append(input())
    else:
        lines = [e for e in lines_as_string.split("\n")][1:-1]


    a_e = [int(e) for e in lines[:5]]
    k = int(lines[5])

    return (a_e, k)


def solve(a_e, k):

    result = False
    for i in range(5):
        for j in range(i+1, 5):
            if a_e[j] - a_e[i] > k:
                result = True
                break

        if result:
            break
    if result:
        res = ':('
    else:
        res = 'Yay!'           

    return res 


def main():
    # 出力

    print("%s" % solve(*parse_input()))

if __name__ == '__main__':

    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int d[110];
int f[110];
bool seen[110]={false};
void dfs(vector<vector<int> > &G,int &t,int v){
    seen[v] = true;
    d[v] = t;
    t++;
    for(int i=0;i<G[v].size();i++){
	int nv = G[v][i];
	if(!seen[nv]){ 
	    dfs(G,t,nv);
	}
    }
    f[v] = t;
    t++;
}
int main(void){
    int n; cin >> n;
    vector<vector<int> > G(n+1);
    for(int i=0;i<n;i++){
	int a,b;cin >> a >> b;
	for(int j=0;j<b;j++){
	    int c; cin >> c;
	    G[a].push_back(c);
	}
    }
    int t = 1;
    for(int i=1;i<=n;i++){
	if(seen[i]) continue;
	dfs(G,t,i);
    }
    for(int i=1;i<=n;i++){
	cout << i << " " << d[i] << " " << f[i] << endl;
    }

    return 0;
}



Measured memory_bytes: 3164