akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

void print_vec(vector<int>& a){
  for(int i=0; i<a.size()-1; i++){
    cout << a[i] << " ";
  }
  cout << a[a.size()-1] << "\n";
}



int main(){
  int N;
  vector<int> array;
  cin >> N;
  for(int i=0; i<N; i++){
    int tmp;
    cin >> tmp;
    array.push_back(tmp);
  }

  for(int i=1; i<N; i++){
    print_vec(array);
    int tgt = array[i];
    int j = i-1;
    while(j>=0 && array[j] > tgt){
      array[j+1] = array[j];
      j--;
    }
    array[j+1] = tgt;

  }
  print_vec(array);
  

}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<bool> vb;

const int mod = 1000000007;
struct mint {
  ll x;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a) {
    if((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint &operator-=(const mint a) {
    if((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint &operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const {
    if(!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if(t & 1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint &operator/=(const mint a) { return (*this) *= a.inv(); }
  mint operator/(const mint a) const {
    mint res(*this);
    return res /= a;
  }
};
struct combination {
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1) {
    assert(n < mod);
    fact[0] = 1;
    for(int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for(int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if(k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

int main() {
  int n, k;
  cin >> n >> k;
  vi a(n);
  rep(i, n) cin >> a[i];
  sort(all(a), greater<int>());
  mint ans = 0;
  combination comb(n - 1);
  rep(ri, 2) {
    rep(i, n) {
      mint sum = comb(n - 1 - i, k - 1) * a[i];
      if(ri == 1) sum = -sum;
      ans += sum;
    }
    reverse(all(a));
  }
  printf("%d\n", ans);
}

Measured memory_bytes: 2176
fn main() {
    let buf = io::read_string();
    let mut sc = io::Scanner::new(&buf);
    let s: String = sc.read();
    let k: usize = sc.read();

    for (i, c) in s.chars().enumerate() {
        if i == k - 1 || c != '1' {
            println!("{}", c);
            break;
        }
    }
}

#[allow(dead_code)]
mod io {
    use std;
    use std::io::Read;
    use std::str::{FromStr, SplitWhitespace};
    pub struct Scanner<'a> {
        pub iter: SplitWhitespace<'a>,
    }
    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }
        pub fn read<T: FromStr>(&mut self) -> T {
            self.iter
                .next()
                .unwrap()
                .parse()
                .ok()
                .expect("parsing failed")
        }
        pub fn read_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.read()).collect()
        }
    }
    pub fn read_string() -> String {
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }
}


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

constexpr ll INF = ll(1e+18) + 1;

ll dist(ll a, ll b, ll c, ll d) {
    return abs(a-c) + abs(b-d);
}

int main() {
    int N, T;
    int bt = 0, t;
    ll sum = 0;

    cin >> N >> T;

    rep (i, N) {
        cin >> t;

        sum += (ll)min(T, t-bt);
        bt = t;
    }

    cout << sum+T << endl;
}


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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  string S; cin >> S;
  int del = 0;
  int s = 0, t = 0;
  for(int i=0;i<SZ(S);++i){
	if(S[i] == 'T'){
	  if(s){
		del += 2;
		--s;
	  }
	  else
		++t;
	}
	else{
	  ++s;
	}
  }
  cout << SZ(S) - del << endl;

  return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define test() int t;cin>>t;loop(test,1,t+1)
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define nl cout<<"\n"
#define sp cout<<" "
#define F first
#define S second
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<pii>
#define vll vector<pll>
#define MOD 1000000007
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

unordered_map<long long, int, custom_hash> safe_map;

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

int main() 
{
    fastio();

    ll n,a,b;
    cin>>n>>a>>b;

    ll diff = abs( a-b );

    if( diff%2 == 0 )
        cout<<diff/2;
    else
    {
        if( a > b ) swap(a,b);
        ll a1 = a + (b-a-1)/2;
        ll a2 = (n-b+1) + (b-a-1)/2;
        cout<<min(a1,a2);
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

#define INF int(1e9)

int dp[100005][3];

int main() {
  int N; cin >> N;
  vector<int> a(N), b(N), c(N);
  
  for (int i = 0; i < N; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  
  for (int i = 0; i < N; i++) {
    dp[i+1][0] = max(dp[i][1] + a[i], dp[i][2] + a[i]);
    dp[i+1][1] = max(dp[i][0] + b[i], dp[i][2] + b[i]);
    dp[i+1][2] = max(dp[i][0] + c[i], dp[i][1] + c[i]);
  }
  
  int res = max(dp[N][0], dp[N][1]);
  res = max(res, dp[N][2]);
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;

int main(){
  int n,m;
    while(1){
  cin >> n >> m;
  if(n == 0)return 0;
  int kakaku[n];
  for(int i=0; i<n; i++) cin >> kakaku[i];
  int buffer=0;
  for(int i=0; i<(n-1); i++){
    for(int j=(i+1); j<n; j++){
      if(kakaku[i]+kakaku[j] <= m && kakaku[i] + kakaku[j] > buffer) buffer = kakaku[i]+kakaku[j];
    }
  }
  if(buffer == 0){cout << "NONE" << endl;
  }else{
    cout << buffer << endl;
  }
  }
  return 0;
}


Measured memory_bytes: 3016
#include<stdio.h>
int main(void)
{
	int n,i,j,p=0;
	scanf("%d",&n);
	for(i=1;i<=9;i++){
		for(j=1;j<=9;j++){
			if(n==i*j&&p==0){
				printf("Yes\n");
				p=1;
			}
			if(i==9&&j==9&&p==0){
				printf("No\n");
			}
		}
	}
	return 0;
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define umap unordered_map<int, int>
#define F first
#define S second
#define pii pair<int, int>
#define endl "\n"
using namespace std;

int dp[3002][3002];
int main(){

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

	// int t; cin >> t; while(t--)
	{
		string s, t;
		cin >> s >> t;

		for(int i = 0; i < 3001; i++) {
			dp[i][0] = dp[0][i] = 0;
		}

		int i = 0; int j = 0;

		for(int i = 1; i <= s.size(); i++) {

			for(int j = 1; j <= t.size(); j++) {

				if(s[i - 1] == t[j - 1]) {
					dp[i][j] = 1 + dp[i - 1][j - 1];

				}
				else{
					dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
				}
			}
		}
		i = s.size();
		j = t.size();
		string res;
		while(i > 0 and j > 0) {

			if(s[i - 1] == t[j - 1]) {
				res += s[i - 1];
				// cout << s[i - 1];
				i--;
				j--;

			}
			else{
				if(dp[i - 1][j] > dp[i][j - 1]) i--;
				else j--;
			}
		}
		reverse(res.begin(), res.end() );
		cout << res << endl;

	}

	return 0;
}

Measured memory_bytes: 35456
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -std=c++11 */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    int x1,y1,x2,y2;
    while (cin >> x1 >> y1 >> x2 >> y2) {
        int dx = x2-x1;
        int dy = y2-y1;
        int x = x2, y = y2;
        FOR(_,0,2) {
            swap(dx,dy);
            dx = -dx;
            x += dx; y += dy;
            printf("%d %d ",x,y);
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <set>
using namespace std;


int main(void){
	int n, m, a, b;

	while (true){
		scanf("%d%d", &n, &m);
		if (n == 0 && m == 0){ break; }

		vector<int> friends[10020];
		set<int> comeon;
		comeon.insert(1);

		// テ・ツ?・テ・ツ環崚」ツつ津・ツ渉療」ツ?妥・ツ渉姪」ツつ?
		for (int i = 0; i < m; i++){
			scanf("%d%d", &a, &b);
			friends[a].push_back(b);
			friends[b].push_back(a);
		}

		// テ・ツ渉凝ゥツ?氾」ツつ津・ツ堕シテ」ツ?カ
		for (int i = 0; i < friends[1].size(); i++){
			comeon.insert(friends[1][i]);
			// テ・ツ渉凝ゥツ?氾」ツ?ョテ・ツ渉凝ゥツ?氾」ツつ津・ツ堕シテ」ツ?カ
			for (int j = 0; j < friends[friends[1][i]].size(); j++){
				comeon.insert(friends[friends[1][i]][j]);
			}
		}

		// テ、ツコツコテヲツ閉ーテ」ツつ津・ツ?コテ・ツ環?
		printf("%d\n", comeon.size() - 1);
	}

	return 0;
}

Measured memory_bytes: 1436
#include <bits/stdc++.h>
using namespace std;
	
int main(){
	long n,i,j,w,q,a,b,ans,sum;
	string s,t;
	cin >> s >> t;
	vector<vector<long>> dp(s.size()+1,vector<long>(t.size()+1,0));
	
	for(i=0; i<s.size(); i++){
		for(j=0; j<t.size(); j++){
			if(s[i]==t[j]){
				dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j]+1);
				
			}
			dp[i+1][j+1]=max(dp[i+1][j+1],dp[i+1][j]);
			dp[i+1][j+1]=max(dp[i+1][j+1],dp[i][j+1]);
		}
	}
	/*
	for(i=0; i<=s.size(); i++){
		for(j=0; j<=t.size(); j++){
			cout << dp[i][j];
		}
		cout << endl;
	}
	*/
	string cur="";
	i=s.size(); j=t.size();
	while(i>0 && j>0){
		if(dp[i][j]==dp[i-1][j]){
			i--;
		}else if(dp[i][j]==dp[i][j-1]){
			j--;
		}else{
			cur=s[i-1]+cur;
			i--; j--;
		}
	}
	cout << cur << endl;
	return 0;
}

Measured memory_bytes: 70784
s = input()

str_list = ["dream","dreamer","erase","eraser"]

def checklast(s):
    # print(s)
    for word in str_list:
        if s[-len(word):] == word:
            return s[:-len(word)]
    else:
            return None
    
for i in range(100000):
    if s is None:
        print("NO")
        break
    if len(s) == 0:
        print("YES")
        break
    s = checklast(s)





Measured memory_bytes: 9088
#include "bits/stdc++.h"
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
using namespace std;




int main(){
string n;
string j="CODEFESTIVAL2016";
ll ans=0;
cin>>n;
for(ll i=0;i<n.size();i++){
  if(n[i]!=j[i])
  ans++;
}
cout<<ans<<endl;

}


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

int main(){
    int r;
    cin >> r;
    if(r<1200){
        cout << "ABC" << endl;
    }else if(r<2800){
        cout << "ARC" << endl;
    }else{
        cout << "AGC" << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

#ifndef ONLINE_JUDGE
#define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
#else
#define dbg(x)
#endif

#define X first
#define Y second
ll dp[55][55][2555];

int main(){
    std::ios_base::sync_with_stdio(false);
    dp[0][0][0] = 1;
    int n; cin >> n;
    int A; cin >> A;
    vi arr(n);
    for (int i = 0; i < n; i++) cin >> arr[i];
    for (int id = 1; id <= n; id++){
        for (int i = 0; i < 55; i++){
            for (int j = 0; j < 2555; j++){
                if (dp[id - 1][i][j]){
                    dp[id][i][j] += dp[id-1][i][j];
                    dp[id][i + 1][j + arr[id-1]] += dp[id-1][i][j];
                }
            }
        }
    }
    ll res = 0;
    for (int i = 1; i <= n; i++){
        res += dp[n][i][i * A];
    }
    cout << res << endl;

    return 0;
}

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

using namespace std;

int main()
{

   int a,b,c;
   cin>>a>>b>>c;
   int y=(a*c)-b;
   for(int i=0;i<10;i++)
   {
       cout<<y<<endl;;
       y=(a*y)-b;
   }

    return 0;
}

Measured memory_bytes: 256
import sys
try:
    while True:
        n = int(input())
        
        res = 0
        
        for i in range(10):
            for j in range(10):
                for k in range(10):
                    for m in range(10):
                        if i + j + k + m == n:
                            res += 1
        
        print(res)
except Exception:
    sys.exit()


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

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

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

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

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

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


/*

（１）定石その１
まずは図を書け
順列内の数を頂点、swap 出来る関係を辺として図を書いてみる

（２）定石その２
問題文を, 既存問題に帰着できる形へ, 言い換えよ

-> 連結部分は, 連結の範囲の中の任意の場所に, 移動可能だとわかる

-> グルーピングが鍵になる
-> 順列内の数と元の場所が, 同じ連結部分に属するかを調べたい.
-> Union-Findを使うとよい

*/

int main() {
    int n, m;
    cin >> n >> m;
    
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    
    UnionFind tree(n);
    
    //つながりを調べる
    rep(i, m){
        int a, b;
        cin >> a >> b;
        
        a--, b--;
        tree.unite(a, b);
    }
    
    //同じ木に属する点の個数を数え上げると良い
    //同じ木に属するならば, 条件より,２頂点の間に全単射を構成できるから.
    int ans = 0;
    
    rep(i, n){
        if (tree.same(i, p[i]-1)) ans++;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
# python 3.4.3
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# library
# -------------------------------------------------------------



# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,M = map(int,input().split())
KS = [list(map(int,input().split())) for _ in range(M)]
P = list(map(int,input().split()))

ans = 0

i = 0
while i < 2**N:
    bit = bin(i)[2:].zfill(N)
    check = True
    for j in range(M):
        swlist = KS[j][1:]
        cnt = 0
        for sw in swlist:
            if bit[sw-1] == "1":
                cnt += 1
        if cnt%2 != P[j]:
            check = False
            break
    if check:
        ans += 1
    i += 1

print(ans)

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

using namespace std;

int main()
{
    //freopen("in.txt", "r", stdin);
    int k, a, b;
    cin >> k >> a >> b ;
    bool found = false;
    for(int i=a; i<=b; i++){
        if(i%k == 0) found = true;
    }
    if(found) cout << "OK" << endl;
    else cout << "NG" << endl;
}


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


int main() {
  int N;
  cin>>N;
  
  vector<double> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  
  sort(vec.begin(),vec.end());
  for(int i=0;i<N-1;i++){
    vec.at(i+1)=(vec.at(i)+vec.at(i+1))/2;
  }
  cout << fixed << setprecision(7) <<vec.at(N-1)<< endl;
  
 
  
}


Measured memory_bytes: 256
from collections import defaultdict
from queue import Queue
H, W = map(int, input().split())
m = [input() for i in range(H)]
G = defaultdict(list)
l = []
for i in range(H):
    for j in range(W):
        v = i*W + j+1
        if m[i][j] != '.':
            continue
        l.append(v)
        if i + 1 < H and m[i+1][j] == '.':
            G[v].append((i+1)*W + j+1)
        if 0 <= i - 1 and m[i-1][j] == '.':
            G[v].append((i-1)*W + j+1)
        if j + 1 < W and m[i][j+1] == '.':
            G[v].append(i*W + j+2)
        if 0 <= j - 1 and m[i][j-1] == '.':
            G[v].append(i*W + j)

def bfs(v):
    visited = defaultdict(bool)
    q = Queue()
    visited[v] = 1
    dist = [-1] * (H*W)
    dist[v-1] = 0
    q.put(v)
    while not q.empty():
        v = q.get()
        for c in G[v]:
            if not c in visited:
                visited[c] = 1
                dist[c-1] = dist[v-1] + 1
                q.put(c)
    return dist

ans = 0
for v in l:
    ans = max(ans, max(bfs(v)))
print(ans)



Measured memory_bytes: 4080
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        String s = scan.next();
        switch(s){
            case "Sunny":
                System.out.println("Cloudy");
                break;
            case "Cloudy":
                System.out.println("Rainy");
                break;
            case "Rainy":
                System.out.println("Sunny");
                break;
        }
    }
}

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

int main(){
	int count,d,l;
	cin>>d>>l;
	while(1){
		if(d==0) break;
		if(d>=l){
			d-=l;
		}else{
			d-=1;
		}
		count++;
	}
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 3120
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce, lru_cache
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def MAP1()  : return map(lambda x:int(x)-1,input().split())
def LIST()  : return list(MAP())
def LIST1() : return list(MAP1())

d, t, s = MAP()
if t >= d/s:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 10244
n,m=map(int, input().split())
def is_prime(N):
    is_prime=[True]*(N+1)
    is_prime[0:2]=False,False
    for i in range(int(N**0.5)+1):
        if is_prime[i]==False:
            continue
        for j in range(i*2,N+1,i):
            is_prime[j]=False
    return is_prime
def primes(N):
    prime=is_prime(N)
    return [i for i in range(N+1) if prime[i]]
def prime_factorization(n):
    ps=primes(int(n**0.5))
    r=[]
    for i,p in enumerate(ps):
        num=0
        while(True):
            x,y=divmod(n,p)
            if y!=0:
                break
            n=x
            num+=1
        if num>0:
            r.append((p,num))
    if n>1:
        r.append((n,1))
    return r
mod=10**9+7
def add(a,b):
    return (a+b)%mod
def sub(a,b):
    return (a-b)%mod
def mul(a,b):
    return ((a%mod)*(b%mod))%mod
def pow(x,y):
    if y==0:
        return 1
    elif y==1:
        return x%mod
    elif y%2==0:
        return pow(x,y//2)**2 % mod
    else:
        return pow(x,y//2)**2 * x % mod
def div(a,b):
    return mul(a,pow(b,mod-2))
def fac(n):
    a=1
    for i in range(2,n+1):
        a=mul(a,i)
    return a

f=prime_factorization(m)
ans=1
for p in f:
    ans=mul(ans,fac(p[1]+n-1))
    ans=div(ans,fac(p[1]))
    ans=div(ans,fac(n-1))
print(ans)


Measured memory_bytes: 3316
g=gets,k=(0..1e5).map{[]};$<.map{|l|a,b=l.split.map &:to_i;k[a]<<b;k[b]<<a};q=g[j=k[i=1][0]]=1,j;q[S,0]=g[R]=R while S=[0,i+=1].find{|c|R=k[q[-c/i]].find{|x|!g[x]}};p i,*q

Measured memory_bytes: 16508
#include <string>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <unordered_map>
#include <iostream>
using namespace std;


class CharClass{
public:
  char classify(string s){
    char retC = 'a';
    char c = s[0];
    if((c>='A')&&(c<='Z')){
      retC = 'A';
    }
    return retC;
  }
};

int main(int argc, const char*argv[]){
  CharClass cc;
  string sLn;
  getline(cin,sLn);
  char retC = cc.classify(sLn);
  cout<<retC<<endl;
  return 0;
}


Measured memory_bytes: 3632
// https://atcoder.jp/contests/dp/tasks/dp_c

package main

import "fmt"

func main() {
	var n int

	/* input */
	fmt.Scan(&n)

	a := make([]int, n)
	b := make([]int, n)
	c := make([]int, n)

	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
		fmt.Scan(&b[i])
		fmt.Scan(&c[i])
	}

	// dp[i][j] = i+1日目で最後にjを選んだときの最大幸福度
	dp := make([][3]int, n)

	// 1日目の幸福度は初期値として入れる(入力から決まる)
	dp[0][0] = a[0]
	dp[0][1] = b[0]
	dp[0][2] = c[0]

	// 2日目以降は前の最大幸福度から計算する
	for i := 1; i < n; i++ {
		dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + a[i]
		dp[i][1] = max(dp[i-1][0], dp[i-1][2]) + b[i]
		dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + c[i]
	}

	// 最大値の候補はA,B,Cそれぞれを経由した場合で3通り
	// なのでmaxをとる
	ans := max(max(dp[n-1][0], dp[n-1][1]), dp[n-1][2])

	fmt.Println(ans)
}

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


Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
 
int main() {
  int n;
  cin >> n;
  vector<int> l(n);
  for (int i = 0; i < n; i++) cin >> l.at(i);
  sort(l.begin(), l.end());
  ll sum = 0;
  for (int i = 0; i < n - 1; i++) sum += l.at(i);
  if (l.at(n - 1) < sum) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
def main():
    import sys
    input = sys.stdin.readline
    n,m=L()
    dic={}
    a=[]
    for i in range(n):
        ai,bi=L()
        if ai not in dic:
            dic[ai]=0
        dic[ai]+=bi
        a.append(ai)
    a=list(set(a))
    a.sort()
    ans=0
    drink=0
    tmp=0
    while drink<m:
        tmp=a.pop(0)
        for i in range(dic[tmp]):
            drink+=1
            ans+=tmp
            if drink>=m:
                break
    print(ans)
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 27904
import java.util.Scanner;

public class Main {

    private void solve() {
        Scanner sc = new Scanner(System.in);
        int W = sc.nextInt();
        int H = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();

        double ans1 = (double) W * H / 2;
        System.out.print(ans1 + " ");

        if ((W % 2 == 0) && (x == W / 2) && (H % 2 == 0) && (y == H / 2)) {
            System.out.print(1);
        }
        else {
            System.out.print(0);
        }
    }

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

}


Measured memory_bytes: 23764
from collections import Counter
n=int(input())
d=list(map(int,input().split()))
m=int(input())
t=list(map(int,input().split()))

d_c=Counter(d)
t_c=Counter(t)
for i in t_c.keys():
    if t_c[i]>d_c[i]:
        print('NO')
        exit()
print('YES')

Measured memory_bytes: 57048
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

int main() {
    int n; cin >> n;
    string s; cin >> s;
    if (n % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }
    for (int i = 0; i < (n / 2); i++) {
        if (s[i] != s[(n / 2) + i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


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

int main(){
    int a;
    cin >> a;
    string s[a];
    int t[a];
    for(int i = 0;i < a; i++){
        cin >> s[i];
        cin >> t[i];
    }
    string x;
    cin >> x;
    int i;
    for(i = 0; i < a; i++){
        if(x == s[i]){
            break;
        }
    }
    int time = 0;
    for(i += 1;i < a; i++){
        time += t[i];
    }
    cout << time << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int f(int A[], int n, int k, int q) {
    int V = 0, i = 0;
    while (i < n) {
        if (A[i] <= V) {
            V -= A[i++];
        } else {
            if (k-- == 0) {
                break;
            }
            V = q;
        }
    }
    return i;
}
int main() {
    int A[100010], n, k;
    scanf("%d %d", &n, &k);
    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }
    int left = 0, right = 10000 * n, mid;
    while (left + 1 != right) {
        mid = (left + right) / 2;
        if (f(A, n, k, mid) < n) {
            left = mid;
        } else {
            right = mid;
        }
    }
    printf("%d\n", right);
    return 0;
}



Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
typedef long long int lint;
using namespace std;

int main() {
    int m, k;
    cin >> m >> k;
    if (k > (1 << m) - 1) {
        cout << -1 << endl;
        return 0;
    }
    if (m == 1) {
        if (k == 0) {
            cout << "0 0 1 1 " << endl;
        } else {
            cout << -1 << endl;
        }
    } else {
        vector<int> ans(1 << (m + 1));
        for (int i = 0; i < (1 << m); i++) {
            ans[i] = i;
            ans[(1 << (m + 1)) - 2 - i] = i;
        }
        ans[(1 << m) - 1] = k;
        ans[(1 << (m + 1)) - 1] = k;
        ans[k] = (1 << m) - 1;
        ans[(1 << (m + 1)) - 2 - k] = (1 << m) - 1;
        for (int i = 0; i < (1 << (m + 1)); i++) {
            cout << ans[i] << " ";
        }
        cout << endl;
    }
}

Measured memory_bytes: 2816
s = gets.chomp.gsub("BC", "D")
blocks = s.split(/[BC]/)

swaps = blocks.inject(0) do |sum, block|
  right_d = 0
  (block.size-1).downto(0) do |i|
    if block[i] == "D"
      right_d += 1
      next
    end
    if block[i] == "A"
      sum += right_d
    end
  end
  sum
end

p swaps


Measured memory_bytes: 12796
#include<stdio.h>
int main() {
	int n, i;
	int a;
	int max = 0, min = 1000000000;
	scanf("%d\n", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &a);
		if (a > max) max = a;
		if (a< min) min = a;
	}
	printf("%d\n", max - min);
	return 0;
}

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

int main() {
  int n,k;
  cin >> n >> k;
  vector<long>data(n);
  long ans = 1000000000+7;
  for(int i = 0;i < n;i++){
    cin >> data[i];
  }
  sort(data.begin(),data.end());
  for(int i = 0;i < n-k+1;i++){
    long s = data[i+k-1]-data[i];
    if(s < ans) ans = s;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
N = int(input())
h_list = list(map(int, input().split()))

ans = "Yes"

for i in range(N-1, 0, -1):
  if h_list[i-1] == h_list[i] + 1:
    h_list[i-1] -= 1
  elif h_list[i-1] <= h_list[i]:
    pass
  else:
    ans = "No"
      
print(ans)

Measured memory_bytes: 14396
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException, Exception{
		BufferedReader st = new BufferedReader(new InputStreamReader(System.in));
		int n = getInt(st);
		int[] a = getIntArry(st);
		int[] b = getIntArry(st);
		int[] c = getIntArry(st);
		int ans = 0;
		int preNo = 0;
		for (int i = 0; i < n; i++) {
			ans = ans + b[a[i]-1];
			if (preNo == 0) {
				preNo = a[i];
			} else if(preNo == a[i]-1) {
				ans = ans + c[a[i]-2];
			}
			preNo = a[i];
			/*
			if (i == n-1 && a[i]-2 >= 0) {
				ans = ans + c[a[i]-2];
				anser(c[a[i]-2]);
			}
			*/
		}
		anser(ans);
	}

	private static int getInt(BufferedReader st) throws Exception, IOException {
		int num = Integer.parseInt(st.readLine());
		return num;
	}

	private static int[] getIntArry(BufferedReader st) throws Exception, IOException {
		String line = st.readLine();
		String[] strData = line.split(" ");
		int[] intData = new int[strData.length];
		for (int i = 0; i < strData.length; i++) {
			intData[i] = Integer.parseInt(strData[i]);
		}
		return intData;
	}

	private static void anser(int num) {
		System.out.println(num);
	}


}

Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, i;
  
  i = 0;
  
  cin >> A >> B;
  
  for (int k = A; k <= B; k++) {
    if((k -(k % 10000))/10000 == (k % 10) && ((k % 10000) - (k % 1000))/1000 == ((k % 100) - (k % 10))/10 ) {
      i++;
    }
  }
  cout << i << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

ll modnum = 1000000007;

//繰り返し二乗法
ll RepeatSquaring(ll a, ll n, ll p) {
  if (n == 0) return 1;
  if (n == 1) return a % modnum;
  if (n % 2 == 1) return (a * RepeatSquaring(a, n - 1, modnum)) % p;
  ll t = RepeatSquaring(a, n / 2, modnum);
  return (t * t) % modnum;
}

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  
  ll tmp;
  ll ans = 1;

  ans = RepeatSquaring(2, n, modnum);
  
  ll cmb_a=1, cmb_b=1;
  ll bunbo_a=1, bunbo_b=1;

  for(ll i = 1; i <= a; i++) {
    cmb_a = ((cmb_a * (n-i+1) % modnum) * RepeatSquaring(i, modnum-2, modnum)) % modnum;
  }
  for(ll i = 1; i <= b; i++) {
    cmb_b = ((cmb_b * (n-i+1) % modnum) * RepeatSquaring(i, modnum-2, modnum)) % modnum;
  }

  ll  sub =  (cmb_a + cmb_b + 1) % modnum;
  ans = (ans - sub) % modnum;
  while(ans < 0) {
    ans = ans + modnum;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>

#define ll long long
#define test(t) ll int t; cin>>t; while(t--)
#define F(i,L,R) for(ll int i=L;i<R;i++)
#define F2(i,L,R) for(ll int i=L;i>=R;i--)
#define get1(a) ll int a; cin>>a;
#define get2(a,b) ll int a,b; cin>>a>>b;
#define get3(a,b,c) ll int a,b,c; cin>>a>>b>>c;
#define pb push_back
#define mp make_pair
#define MAX 1000000001
using namespace std;



int main()
{ 
 

 ios_base::sync_with_stdio(0);


 string s;
 cin>>s;

 if(s[2]==s[3] && s[4]==s[5])
 {
    cout<<"Yes\n";
 }
 else
 {
    cout<<"No\n";
 }

  return 0;
 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 7;
const int mod = 1e9 + 7;
ll qpow(ll a,ll b){
	ll s = 1;
	a %= mod;
	while(b){
		if(b & 1) s = (s % mod) * (a % mod) % mod;
        b /= 2;
        a = (a % mod) * (a % mod) % mod;
	}
	s %= mod;
	return s;
}
ll inv(ll x){
	return qpow(x,mod-2);
}
ll c(ll n,ll m){
	if(m > n)return 0;
    ll up = 1, down = 1;
    for(int i = n - m + 1; i <= n; i++) up = up * i % mod;
    for(int i = 1; i <= m; i++)down = down * i % mod;
    return up * inv(down) % mod;
}
ll Lucas(ll n, ll m)
{
    if(m == 0)return 1;
    return c(n % mod, m % mod) * Lucas(n / mod, m / mod) % mod;
}
int main(){
	ll n,a,b;
	scanf("%lld%lld%lld",&n,&a,&b);
	ll ans = qpow(2,n) - 1;
	ll t1 = Lucas(n,a);
	ans -= t1;
	ans = (ans + mod) % mod;
	ll t2 = Lucas(n,b);
	ans -= t2;
	ans = (ans + mod) % mod;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Long[] A = new Long[n];
        Long sum = 0L;
        for(int i=0;i<n;i++){
            A[i] = sc.nextLong();
            if(i==0)continue;
            if(A[i-1]>A[i]){
                sum += A[i-1] - A[i];
                A[i] = A[i-1];
            }
        }
        System.out.println(sum);
    }
}

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

#define ll long long int
#define vi vector<int> 

int main() {
	int n;
	 cin >> n;
	 vi v(n);
	 for(int i=0;i<n;i++)cin >> v[i];;
	 int min = v[0];
	 int c=0;
	 for(int i=0;i<n;i++){
	     if(min > v[i]){
	       c++,min=v[i];
	     }
	     
	 }
	 cout << c+1;
	return 0;
}


Measured memory_bytes: 1024
local ior = io.read
local n = ior("*n")
local t = {}
local minus = 0
for i = 1, n do
  local a = ior("*n")
  if(a < 0) then minus = minus + 1 end
  t[i] = a
end
table.sort(t)
local ma = math.abs
if(minus % 2 == 0) then
  local sum = 0
  for i = 1, n do
    sum = sum + ma(t[i])
  end
  print(sum)
else
  local sum = 0
  for i = 1, minus - 1 do
    sum = sum + ma(t[i])
  end
  if(minus < n) then
    sum = sum + ma(t[minus + 1] + t[minus])
  else
    sum = sum + t[minus]
  end
  for i = minus + 2, n do
    sum = sum + t[i]
  end
  print(sum)
end


Measured memory_bytes: 2424
#include<bits/stdc++.h>
#include<sstream>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define loop(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revloop(i,a,b) for(i=(int)a;i>=(int)b;i--)
#define stloop(it,v) for(it=v.begin();it!=v.end();++it)
#define ii pair<int,int>
#define MP make_pair
#define pb push_back
#define ll long long int
#define PI acos(-1.0)
#define f first
#define se second
#define rs resize
int main()
{  std::ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   ll w,a,b,l2,r2,l1,r1;
   cin>>w>>a>>b;
   l1=a;
   r1=a+w;
   l2=b;
   r2=b+w;
   if(l2>=r1)
    cout<<l2-r1;
   else
   {
    if(l1>=r2)
     cout<<l1-r2;
    else
     cout<<0;
   }
   return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n)         for(int i=0; i<(n); i++)
#define P pair<int, int>
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"

//----------------------------------------------------

int main(){
    int d; cin >> d;
    string s = "Christmas";
    int tmp = 25 - d;
    for(int i = 0; i < tmp; i++){
        s += " Eve";
    }
    cout << s << endl;
}

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

using namespace std;

#define ll long long

#define PI 3.141592653589793
#define deg_to_rad(deg) (((deg)/360.0)*2.0*M_PI)
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)

int main() {
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double at = 360.0/720.0*(60.0*h+m);
    double bt = 360.0/60.0*m;
    // cout << at << "," << bt << endl;
    double theta = min(abs(bt-at), 360.0-abs(bt-at));
    // cout << theta << endl;
    cout << fixed << setprecision(17) << sqrt(a*a+b*b-2*a*b*cos(deg_to_rad(theta))) << endl;
    return 0;
}

Measured memory_bytes: 4224
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <stdio.h>
#include <numeric>
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	//freopen("input.txt", "rt", stdin);
	//freopen("out.txt", "wt", stdout);
	int a, b;
	cin >> a >> b;
	cout << max(a + b, max(a - b, a * b)) << endl;


	/*int n, m, k;
	cin >> n >> m >> k;
	vector <tuple<int, int, int>> edges(m);
	for (int i = 0; i < m; ++i) {
		int x, y, w;
		cin >> x >> y >> w;
		if (x > y) swap(x, y);
		edges[i] = make_tuple(w, x, y);
	}
	sort(edges.begin(), edges.end());
	vector <tuple<int, int, int>> paths;
	int curmin = get<0>(edges[0]);
	int ind = 0;
	int cnt = 0;
	while (get<0>(edges[ind]) == curmin && cnt < k) {
		paths.push_back(edges[ind]);
		++ind;
		++cnt;
	}
	while (cnt < k) {
		curmin = get<0>(edges[ind]);
		bool added = false;
		for (int i = 0; i < paths.size(); ++i)
			for (int j = i + 1; j < paths.size(); ++j) {
				int xi = get<1>(paths[i]);
			}

	}*/
	/*int n, m;
	cin >> n >> m;
	vector<vector<int>> graph(n);
	vector<int> powers(n);
	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		graph[a].push_back(b);
		graph[b].push_back(a);
		++powers[a];
		++powers[b];
	}
	vector<pair<int, int>> sorted(n);
	for (int i = 0; i < n; ++i) {
		sorted[i].first = powers[i];
		sorted[i].second = i;
	}
	sort(sorted.begin(), sorted.end());
	if (m % 2) {
		cout << -1 << endl;
		return 0;
	}*/
	//cout << get<0>(paths[k - 1]);
	return 0;
}


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

using namespace std;
typedef long long ll;

#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(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

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

    sort(all(a));
    reverse(all(a));

    int ans = 0;
    rep(i, n)
    {
        if (i % 2 == 0)
        {

            ans += a[i];
        }
        else
        {
            ans -= a[i];
        }
    }

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


Measured memory_bytes: 3616
AC = input()
correct = AC[0] == 'A' and AC.count('A') == 1 and AC[-1] != 'C' and AC[:2].count('C') == 0 and AC[2:-1].count('C') == 1 and AC.replace('A', 'a').replace('C', 'c') == AC.lower()
print('AC' if correct else 'WA')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

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

__attribute__ ((constructor))
void fastio() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(10);
}

//高速な素因数分解(abc 177-e)
//前処理O(N*logN), クエリO(Q*log(x_i))
template<typename T>
vector<T> smallest_prime_factors(T n) {
  vector<T> spf(n + 1);
  for (int 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) {
      // iを持つ整数かつまだ素数が決まっていないなら
        if (spf[j] == j) {
          spf[j] = i;
        }
      }
    }
  }
  return spf;
}

template<typename T>
vector<T> factolization(T x, vector<T> &spf) {
  vector<T> ret;
  while (x != 1) {
    ret.push_back(spf[x]);
      x /= spf[x];
  }
  sort(ret.begin(), ret.end());
  return ret;
}

int main(){
  int n;
  cin >> n;
  auto spf = smallest_prime_factors(1010);
  int ans = 1;
  FOR(i,1,n+1){
    map<int,int> mii;
    for(auto u : factolization(i,spf)){
      mii[u]++;
    }
    bool ok = 1;
    int pre = mii.begin()->second % 2;
    for(auto u : mii){
      if(u.second == 1 || pre != u.second%2){
        ok = 0;
      }
    }
    if(ok)
      ans = i;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
import java.util.*;
public class Main {
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);
	String s = scan.next();
	String m = "";
	for(int i=0;i<13;i++){
	    if(i==4)
		m+=" ";
	    else if(i<4)
		m+=String.valueOf(s.charAt(i));
	    else
		m+=String.valueOf(s.charAt(i-1));
	}
	System.out.println(m);
    }
}


Measured memory_bytes: 8916
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include <cassert>
    #include <cmath>
    #include<cstdint>

    #define INF 1e7
    #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++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<int,int>;

    int main(){
        int n,x;cin>>n>>x;
        auto l = vec(int,n);
        int sum = 0;
        int res = 1;
        rep(i,n){
            cin>>l[i];
            sum += l[i];
            if(sum>x)break;
            res++;
        }
        cout<<res;
    }
    


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Apolloliu
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;

void get() {

}

typedef long long ll;
const ll MOD=1e17;           /*******MOD***********超过long long 一点不要紧*****/
const ll d = 5e15;
ll mul(ll a, ll b, ll c){
	ll e = 0;
	for( ; b; b>>=1){
		if( b & 1 ) e = ( e + a ) % MOD;
		a = ( a + a ) % MOD;
	}
	return e;
}
ll mod_pow(ll x, ll y){
	ll res=1;
	for( ; y; y >>= 1){
		if( y & 1 ) res = mul( res, x, MOD);
		x = mul( x, x, MOD );
	}
	return res;
}

class CToInfinity {
public:
	void solve(std::istream& in, std::ostream& out) {
		string s;
		ll k;
		in >> s;
		in >> k;
		int n = s.size();
		ll sum = 0;
		for (int i = 1; i <= 8; ++i) {
			cerr << i << " " << mod_pow(i, d) << '\n';
		}
		for (int i = 0; i < n; ++i) {
			int t = s[i] - '0';
			if(t == 1)k --;
			if(!k || t > 1){out << s[i] << '\n';
				return;
			}
		}
	}
};


int main() {
	CToInfinity solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <cmath>
#define LL long long

using namespace std;

LL n,a,b,c,d;
bool check(LL l1,LL r1,LL l2,LL r2){
	if(r1<l2||l1>r2)return false;
	return true;
}
int main(){
	scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
	if(n&1){
		LL dt=abs(a-b);
		LL dx=d-c;
		n--;n/=2;
		for(LL mid=0;mid<=n*(c+d);mid+=(c+d)){
			LL l=mid-dx*n,r=mid+dx*n;
			if(dt>=l&&dt<=r){
				printf("YES");
				return 0;
			}
		}
		printf("NO");
		return 0;
	}
	else {
		LL dt=abs(a-b);
		LL dx=d-c;
		n/=2;n--;
		for(LL mid=0;mid<=n*(c+d);mid+=(c+d)){
			LL l=mid-dx*n,r=mid+dx*n;
			if(check(l,r,c+dt,d+dt)||check(l,r,c-dt,d-dt)){
				printf("YES");
				return 0;
			}
		}
		printf("NO");
		return 0;
	}
}

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

int main(){
  char c;
  cin >> c;
  if(c=='a' || c=='i' || c=='u' || c=='e' || c=='o'){
    cout << "vowel" <<endl;
  }
  else{
    cout << "consonant" << endl;
  }
}

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

int INF = 999;

int main(){
  int N;
  cin>>N;
  string S[N];
  for(int i=0;i<N;i++){
    cin>>S[i];
  }

  int d[N][N];
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(S[i][j]=='1') d[i][j]=1;
      else d[i][j]=INF;
    }
  }
  for(int i=0;i<N;i++) d[i][i]=0;

  // ワーシャルフロイドによる各頂点間の最短距離を求める
  for(int k=0; k<N; k++){
     for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
          d[i][j]=min(d[i][j], d[i][k]+d[k][j]);
      }
    }
  }

// Vi内に辺がある場合
// 例えばsample2ではd13=1,d12+d23=2
// ここでd12=1であるから頂点2,3は同一集合内にあるにもかかわらずd23=1
// つまり同一集合内に辺が存在することになる
// これは「すべての辺が頂点集合の頂点同士を結ぶ」ことに反する
  for(int k=0; k<N; k++){
     for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
          if((d[i][k]+d[k][j]-d[i][j])%2==1){
            cout<<-1<<endl;
            return 0;
          }
      }
    }
  }


// グラフの直径（各頂点間の最短距離の最大値)を求める
  int ans=0;
  for(int i=0; i<N-1; i++){
    for(int j=i+1; j<N; j++){
      ans=max(ans, d[i][j]);
    }
  }
  //直径の辺の本数＋１が集合の数
cout<<ans+1<<endl;
}


Measured memory_bytes: 512
A, B, C = map(int,input().split())
li = [A,B,C]
count = 0
while li[0]!=li[1] or li[0]!=li[2] or li[1]!=li[2]:
    li.sort(reverse=True)
    if li[2]+2 < li[0]:
        count += 1
        li[2] += 2

    elif li[2]+1 <= li[0] and li[1]+1 <= li[0]:
        count += 1
        li[1] += 1
        li[2] += 1

    else:
        count += 1
        li[2] += 2

print(count)

Measured memory_bytes: 3064
import math


def dot(ux, uy, vx, vy):
    return ux*vx + uy*vy


def cross(ux, uy, vx, vy):
    return ux*vy - uy*vx


def dist_to_segment(x, y, ax, ay, bx, by):
    if dot(x - ax, y - ay, bx - ax, by - ay) < 0:
        return math.hypot(x - ax, y - ay)
    if dot(x - bx, y - by, ax - bx, ay - by) < 0:
        return math.hypot(x - bx, y - by)
    c = abs(cross(bx - ax, by - ay, x - ax, y - ay))
    return c / math.hypot(bx - ax, by - ay)


q = int(input())

for _ in range(q):
    x0, y0, x1, y1, x2, y2, x3, y3 = map(int, input().split())

    c1 = cross(x1 - x0, y1 - y0, x2 - x0, y2 - y0)
    c2 = cross(x1 - x0, y1 - y0, x3 - x0, y3 - y0)
    c3 = cross(x3 - x2, y3 - y2, x0 - x2, y0 - y2)
    c4 = cross(x3 - x2, y3 - y2, x1 - x2, y1 - y2)

    if c1*c2 < 0 and c3*c4 < 0:
        d = 0.0
    else:
        d = dist_to_segment(x2, y2, x0, y0, x1, y1)
        d = min(d, dist_to_segment(x3, y3, x0, y0, x1, y1))
        d = min(d, dist_to_segment(x0, y0, x2, y2, x3, y3))
        d = min(d, dist_to_segment(x1, y1, x2, y2, x3, y3))

    print('{:.10f}'.format(d))



Measured memory_bytes: 5704
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()

const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b;
    cin>>a>>b;
    if(a<=9&&b<=9){
        cout << a * b << endl;
    }
    else{
        cout << -1 << endl;
    }
}

Measured memory_bytes: 256