akhauriyash/Code-Regression huggingface dataset:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
 
def main():
    s = input()
    x = ord(s)
    if (ord('A') <= x) and (x <= ord('Z')):
        print('A')
    else:
        print('a')
if __name__ == '__main__':
    main()


Measured memory_bytes: 61620
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int A, B;
    cin >> A >> B;
    cout << A*B << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int AC_num = 0, WA_num = 0, TLE_num = 0, RE_num = 0;
  for(int i = 0; i < N; i++) {
    string S;
    cin >> S;
    if(S == "AC") AC_num++;
    else if(S == "WA") WA_num++;
    else if(S == "TLE") TLE_num++;
    else RE_num++;
  }
  cout << "AC" << " " << "x" << " " << AC_num << endl;
  cout << "WA" << " " << "x" << " " << WA_num << endl;
  cout << "TLE" << " " << "x" << " " << TLE_num << endl;
  cout << "RE" << " " << "x" << " " << RE_num << endl;
}

Measured memory_bytes: 3628
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize, k: usize,
        teles: [Usize1; n],
    }

    let mut visited = vec![false; n];
    let mut before_pattern = Vec::new();
    let mut enter_pattern = Vec::new();
    let mut next = 0;

    for _ in 0..n {
        if visited[next] {
            break;
        }
        visited[next] = true;
        before_pattern.push(next);
        next = teles[next];
    }
    let mut visited = vec![false; n];
    for _ in 0..n {
        if visited[next] {
            break;
        }
        visited[next] = true;
        enter_pattern.push(next);
        next = teles[next];
    }

    if before_pattern.len() >= k+1 {
        println!("{}", before_pattern[k] + 1);
        return;
    }

    let k = k - before_pattern.len();
    let k = k % enter_pattern.len();
    println!("{}", enter_pattern[k] + 1);

    dbg!(before_pattern);
    dbg!(enter_pattern);
}


Measured memory_bytes: 8480
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main()
{
	int n;
	cin >> n;
	
	vector<vector<int>> ki(n);
	rep(i,n-1)
	{
		int a,b;
		cin >> a >> b;
		a--;b--;
		ki[a].push_back(b);
		ki[b].push_back(a);
	}
	vector<int> w(n,-1),b(n,-1);
	queue<int> Q;
	Q.push(0);
	int d = 0;
	b[0]=0;
	while(!Q.empty())
	{
		int now = Q.front();
		//cout<<now<<endl
		Q.pop();
		rep(i,ki[now].size())
		{
			if(b[ki[now][i]]==-1)
			{
				Q.push(ki[now][i]);
				b[ki[now][i]]=b[now]+1;
			}
		}
	}
	Q.push(n-1);
	w[n-1]=0;
	while(!Q.empty())
	{
		int now = Q.front();
		//cout<<now<<endl
		Q.pop();
		rep(i,ki[now].size())
		{
			if(w[ki[now][i]]==-1)
			{
				Q.push(ki[now][i]);
				w[ki[now][i]]=w[now]+1;
			}
		}
	}
	int s=0,f=0;
	rep(i,n)
	{
		if(w[i]<b[i])f++;
		else s++;
	}
	if(f<s)cout<<"Fennec"<<endl;
	else cout<<"Snuke"<<endl;

	return 0;
}

Measured memory_bytes: 6528
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

long long int PRIME = 1000000007;

int main(){
	
	long long int n, m;
	
	cin >> n >> m;
	
	long long int unit = 0;
	long long int pre, cur;
	
	cin >> pre;
	
	for(long long int i = 1; i < n; i++){
		cin >> cur;
		long long int diff = cur - pre;
		unit += diff * i * (n - i);
		unit %= PRIME;
		pre = cur;
	}
	
	
	long long int ans = 0;
	
	cin >> pre;
	
	for(long long int i = 1; i < m; i++){
		cin >> cur;
		long long int diff = cur - pre;
		ans += diff * i * (m - i);
		ans %= PRIME;
		pre = cur;
	}
	
	ans *= unit;
	ans %= PRIME;
	
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;
 
long long mod = 1000000007;
 
long long div(long long a, long long b, long long c){
    return b / c - (a - 1) / c;
}
 
void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
 
int main() {
    int n, a = 0, b;
    vector<int> as(10);
    for (int i = 1; i < 10; i++){
        cin >> as[i];
    }
    cin >> n;
    vector<int> bs(n + 1);
    map <int, int> cnt;
    for (int i = 0; i < n; i++){
        cin >> bs[i];
        for (int j = 1; j < 10; j++){
            if (bs[i] == as[j]){
                cnt[as[j]]++;
            }
        }
        if (cnt[as[1]] > 0 && cnt[as[2]] && cnt[as[3]]){
            cout << "Yes" << endl;
            return 0;
        }
        if (cnt[as[4]] > 0 && cnt[as[5]] && cnt[as[6]]){
            cout << "Yes" << endl;
            return 0;
        }
        if (cnt[as[7]] > 0 && cnt[as[8]] && cnt[as[9]]){
            cout << "Yes" << endl;
            return 0;
        }
        if (cnt[as[1]] > 0 && cnt[as[4]] && cnt[as[7]]){
            cout << "Yes" << endl;
            return 0;
        }
        if (cnt[as[2]] > 0 && cnt[as[5]] && cnt[as[8]]){
            cout << "Yes" << endl;
            return 0;
        }
        if (cnt[as[3]] > 0 && cnt[as[6]] && cnt[as[9]]){
            cout << "Yes" << endl;
            return 0;
        }
        if (cnt[as[1]] > 0 && cnt[as[5]] && cnt[as[9]]){
            cout << "Yes" << endl;
            return 0;
        }
        if (cnt[as[3]] > 0 && cnt[as[5]] && cnt[as[7]]){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
# coding: utf-8
import sys

S = input()
t = "keyence"

# full matching
idx = S.find(t)
if idx == 0 or idx == len(S)-7:
    print("YES")
    sys.exit()

# partial matching
for idx in range(6):
    if S.find(t[0:6-idx]) == 0 and S.endswith(t[7-idx-1:7], len(S) - 1 -idx, len(S)):
        print("YES")
        sys.exit()
        
print("NO")


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

int main()
{
	int i,temp;
	vector<int> A;
	for(i=0;i<3;i++){
		cin>>temp;
		A.push_back(temp);
	}
	sort(A.begin(),A.end());
	cout<<A.at(2)-A.at(0);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    long long a,b;
    cin>>a>>b;
    if(a*b<=0){
        cout<<"Zero"<<endl;
    }else if(a>0||(b-a)%2==1){
        cout<<"Positive"<<endl;
    }else{
        cout<<"Negative"<<endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
#define ip(arr, n) for(int i=0; i<n; i++) cin>>arr[i];
#define op(arr, n) for(int i=0; i<n; i++) cout<<arr[i]<<" ";
#define fstIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mod 1000000007
#define MAX 10005

ll s[MAX], t[MAX];
ll n, m;

void sovle(){
    vector<vector<ll> >dp(n+1, vector<ll>(m+1, 0));

    // dp[i][j] -> total no of comom seq upto ith index of s and jth index og t
    ll ans=0;

    for(int i=1; i<=n; i++){
        for(int j=1; j<=m; j++){
            // when (i-1) & (j-1)th of s and t match then
            // dp[i][j] will be total common seq upto (i, j-1)(i.e without conisdering jth element of t)
            // and (i-1, j)(i.e without conisdering ith element of s)
            // and plus 1 as ith and jth element match, so it also common seq
            if(s[i-1] == t[j-1]){
                dp[i][j] = (dp[i-1][j]%mod + dp[i][j-1]%mod +1)%mod;
            }

            // we sub dp[i-1][j-1] as it already include in both (i-1,j)&(i,j-1)
            else dp[i][j] = (dp[i-1][j]%mod +dp[i][j-1]%mod -dp[i-1][j-1]%mod +mod)%mod;
        }
    }
    cout<<(dp[n][m]+1)%mod<<endl; // add plus one for when both string are empty
}
int main(){
    cin>>n>>m;
    ip(s, n);
    ip(t, m);
    sovle();
    return 0;
}

Measured memory_bytes: 31616
fun main(args: Array<String>) {
    val (h,w)= readLine()!!.split(" ").map{it.toLong()}
    if(h%3==0L || w%3==0L){
        println(0)
        return
    }
    var diff=Math.min(h,w)

    diff = Math.min(diff, divideT(h,w))
    diff = Math.min(diff, divideT(w,h))

    println(diff)
}

fun divideT(h:Long, w:Long):Long{
    val l=w/2
    val r=(w+1)/2
    var d=Long.MAX_VALUE
    for(i in 1..h-1){
        d = Math.min( d,
                Math.max( i*w, Math.max((h-i)*l,(h-i)*r) )
                -Math.min( i*w, Math.min((h-i)*l,(h-i)*r) )
        )
    }
    return d
}

Measured memory_bytes: 37920
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int in;

in l=1e9+7,fac[200005],inv[200005],b[3005];

in mod(in x,in n)
{
	if(n==0)
	return 1;

	if(n==1)
	return (x%l);

	if(n==2)
	return ((x*x)%l);

	if(n%2)
	return ((x*mod((x*x)%l,(n-1)/2))%l);

	return (mod((x*x)%l,n/2)%l);
}

in f(in x,in y,in r,in s)
{
	if(x<r||y<s)
	return 0;

	in ret=(inv[x-r]*inv[y-s])%l;

	ret=(fac[x-r+y-s]*ret)%l;

	return ret;
}

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

	in i,j;

	fac[0]=1;

	for(i=1;i<200005;++i)
	fac[i]=(fac[i-1]*i)%l;

	inv[0]=1;

	for(i=1;i<200005;++i)
	inv[i]=mod(fac[i],l-2)%l;

	in h,w,n;
	cin>>h>>w>>n;

	pair<in,in> e[n+5];

	for(i=0;i<n;++i)
	cin>>e[i].first>>e[i].second;

	e[n].first=h;
	e[n].second=w;

	++n;

	sort(e,e+n);

	for(i=0;i<n;++i)
	{
		in x1=e[i].first,y1=e[i].second;

		b[i]=f(x1,y1,1,1);

		for(j=0;j<i;++j)
		{
			in x2=e[j].first,y2=e[j].second;

			b[i]=(b[i]-(b[j]*f(x1,y1,x2,y2))%l)%l;
		}
	}

	b[n-1]=(b[n-1]%l+l)%l;

	cout<<b[n-1];

    return 0;
}




Measured memory_bytes: 3456
#pragma region Macros
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep2(i, a, b) for(ll i = a; i <= b; ++i)
#define rep(i, n) for(i = 0; i < n; ++i)
#define rep3(i, a, b) for(ll i = a; i >= b; --i)
using namespace std;

// _________コーディングはここから！！___________

int n, m, k, i;
constexpr int N = 200010;
int a[N], b[N];
constexpr int sz = 5000000;
char reader[sz];
char *pos = reader;
int nn,now,ans;
int kk;
main() {
    reader[fread(reader, sizeof(char), sizeof(char) * sz, stdin)];
    while('0' <= *pos and *pos <= '9') n = n * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos and *pos <= '9') m = m * 10 + *pos++ - '0';
    pos++;
    while('0' <= *pos and *pos <= '9') k = k * 10 + *pos++ - '0';
    nn = n;
    pos++;
    rep(i, n) {
        while('0' <= *pos and *pos <= '9') a[i + 1] = a[i + 1] * 10 + *pos++ - '0';
        pos++;
        a[i + 1] += a[i];
        if(a[i + 1] > k) {
            nn = i;
            ++i;
            for(; i < n; ++i) {
                while('0' <= *pos and *pos <= '9') pos++;
                pos++;
            }
            break;
        }
    }
    while(*pos and *pos <= 32) pos++;
    rep(i, m) {
        while('0' <= *pos and *pos <= '9') b[i + 1] = b[i + 1] * 10 + *pos++ - '0';
        pos++;
        b[i + 1] += b[i];
        if(b[i + 1] > k) {
            m = i;
            break;
        }
    }
    now = ans = nn;
    for(i = 1; i <= m; i++) {
        kk = k - b[i];
        while(a[now] > kk) now--;
        ans = max(ans, i + now);
    }
    pos = reader;
    i = 0;
    do {
        *pos++ = ans % 10 + '0';
        ans /= 10;
        i++;
    } while(ans);
    reverse(reader, reader + i);
    fwrite(reader, sizeof(char), sizeof(char) * i, stdout);
}


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

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

const ll MOD = 1000 * 1000 *1000 + 7 ;
inline void chadd(ll &a, const ll b) { a = (a + b) % MOD;}
inline ll add(const ll a, const ll b){ return (a + b) %  MOD;}
inline void chsub(ll &a, const ll b) { a = (a - b + MOD) % MOD;}
inline ll sub(const ll a, const ll b){ return (a - b + MOD) % MOD; }
inline void chmul(ll &a, const ll b) { a = (a * b) %  MOD;}
inline ll mul(const ll a, const ll b){ return (a * b) %  MOD;}

const int MOD_TABLE_SIZE = 1000000 + 10;
ll inv[MOD_TABLE_SIZE];
ll fac[MOD_TABLE_SIZE];
ll facinv[MOD_TABLE_SIZE];

void mod_table_init() {
  inv[1] = 1;
  for(int i = 2; i < MOD_TABLE_SIZE; i++) {
    inv[i] = MOD - (MOD / i) * inv[(int)MOD % i] % MOD;
  }
  fac[0] = facinv[0] = 1;
  for(int i = 1; i < MOD_TABLE_SIZE; i++) {
    fac[i] = (fac[i-1] * (ll)i) % MOD;
    facinv[i] = (facinv[i-1] * inv[i]) % MOD;
  }
}

inline ll P(int a, int b) {
  if(a<b) return 0LL;
  return fac[a] *  facinv[a-b] % MOD;
}

inline ll C(int a, int b) {
  if(a<b) return 0LL;
  return (fac[a] * facinv[b] % MOD) * facinv[a-b] % MOD;
}

inline ll H(int a, int b) {
  return C(a+b-1,b);
}

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) { 
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  mod_table_init();
  int N, K; cin>>N>>K;
  for(int i = 1; i <= K; i++) {
    ll a = C(N-K+1, i);
    ll b = C(K-1, i-1);
    ll ans = mul(a, b);
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 23928
using System;

class Program
{
    private const int H_ANGLE = 30;
    private const int M_ANGLE = 6;
    private const double HM_ANGLE = 0.5d;

    static void Main (string[] args)
    {
        string[] inputstr = Console.ReadLine().Split(' ');
        double a,b;
        int h,m;
        //標準入力の分解
        a = double.Parse(inputstr[0]);
        b = double.Parse(inputstr[1]);
        h = int.Parse(inputstr[2]);
        m = int.Parse(inputstr[3]);

        //針の角度の計算
        //時針：時間×30度＋分×0.5度
        //分針：分×6度
        double a_angle , b_angle;
        a_angle = h * H_ANGLE;
        a_angle += m * HM_ANGLE;
        b_angle = m * M_ANGLE;

        //a-bの角度の絶対値を計算（a-b辺の角度を計算
        double c_angle = Math.Abs(a_angle - b_angle);
        double answer = 0.0d;
        //角度が180度を超えていた場合の対応
        if(c_angle > 180)
        {
            c_angle = 360 - c_angle;
        }

        answer = Math.Sqrt(Math.Pow(a,2) + Math.Pow(b,2) - (2 * a * b * Math.Cos(c_angle * Math.PI / 180)));
/*
        switch (c_angle)
        {
            case 0:
                answer = Math.Abs(a - b);
                break;
            case 180:
                answer = a + b;
                break;
                //角度が180度を超えていた場合の対応
                if(c_angle > 180)
                {
                    c_angle = 360 - c_angle;
                }

                answer = Math.Sqrt(Math.Pow(a,2) + Math.Pow(b,2) - (2 * a * b * Math.Cos(c_angle * Math.PI / 180)));
                break;
        }
        /*
        Console.WriteLine("a:{0}\nb:{1}\nh:{2}\nm:{3}\n",a,b,h,m);
        Console.WriteLine("a_angle:{0}\nb_angle:{1}\nc_angle:{2}\n",a_angle,b_angle,c_angle);
        Console.WriteLine((2 * a * b * Math.Cos(c_angle * Math.PI / 180)));
        */
        Console.WriteLine($"{answer:F20}");
    }
}

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

#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 repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9
#define MOD 1000000007

using namespace std;
typedef long long ll;

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

  int n = s.size();
  bool ans = true;

  if(s[0] != 'A') ans = false;

  int cnt = 0;
  repm(i,1,n){
    if(isupper(s[i])){
      if(i == 1 || i == n-1 || s[i] != 'C') ans = false;
      cnt++;
    }
  }

  if(cnt != 1) ans = false;

  cout << (ans ? "AC":"WA") << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int N;

	scanf("%d", &N);
	if (N >= 64)
		printf("64");
	else if (N < 64 && N >= 32)
		printf("32");
	else if (N < 32 && N >= 16)
		printf("16");
	else if (N < 16 && N >= 8)
		printf("8");
	else if (N < 8 && N >= 4)
		printf("4");
	else if (N < 4 && N >= 2)
		printf("2");
	else
		printf("1");

	



	return 0;
}

Measured memory_bytes: 256
def resolve():
    def mat_mul(a, b):
        H = len(a)
        W = len(b[0])
        K = len(a[0])

        C = [[0] * W for _ in range(H)]
        for i in range(H):
            for j in range(W):
                for k in range(K):
                    C[i][j] += a[i][k] * b[k][j]
                    C[i][j] %= MOD
        return C

    def mat_pow(a, p):
        n = len(a)
        ret = [[0] * n for _ in range(n)]
        for i in range(n):
            ret[i][i] = 1

        while p > 0:
            if p % 2 == 1:
                ret = mat_mul(ret, a)
            a = mat_mul(a, a)
            p >>= 1
        return ret

    MOD = 10 ** 9 + 7
    N, K = map(int, input().split())
    AB = [list(map(int, input().split())) for _ in range(N)]

    ret = mat_pow(AB, K)
    ans = 0
    for i in range(N):
        for j in range(N):
            ans += ret[i][j]
            ans %= MOD

    print(ans)


if __name__ == "__main__":
    resolve()


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

int main ()
{
  
  int n, m;
  
  cin >> n;
  cin >> m;
  
  if(m < n)
  {
      cout << "No" << '\n';
  }
  else
  {
      cout << "Yes" << '\n';
  }
  
  return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int N; vector<string> ans;
void dfs(string s, char max_c) {
  if(s.size() == N) {
    ans.push_back(s);
    return;
  }
  for(char i = 'a'; i <= max_c + 1; ++i) {
    dfs(s + i, max(max_c, i));
  }
}

int main() {
  cin >> N;
  dfs("", 'a' - 1);
  sort(all(ans));
  REP(i, ans.size()) cout << ans[i] << endl;
}

Measured memory_bytes: 7312
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
using P = pair<int, int>;
template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    const int MOD = 1e9+7;
    string s;
    cin>>s;
    int ans=MOD;
    rep(i,26){
        string memo=s;
        while(true){
            if(count(memo.begin(),memo.end(),(char)('a'+i))==memo.size()){
                break;
            }
            string n_memo;
            rep(j,memo.size()-1){
                if(memo[j]==('a'+i)||memo[j+1]==('a'+i))n_memo+=(char)('a'+i);
                else n_memo+=(char)('a'+i-1);
            }
            memo=n_memo;
        }
        ans=min(ans,(int)(s.size()-memo.size()));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import sys

N,K,Q = map(int,input().split())
A = (int(x) for x in sys.stdin.read().split())
 
score = [K-Q] * (N+1) 
for x in A:
    score[x] += 1
 
answer = '\n'.join('No' if x <= 0 else 'Yes' for x in score[1:])
print(answer)

Measured memory_bytes: 12624
#include <iostream>
#include <vector>
#include <algorithm>
#include <ios>
#include <iomanip>
#include <cmath>
#include <regex>
#include <bitset>
using namespace std;

int main(){
  string a, b, c;
  cin >> a >> b >> c;
  cout << a[0] << b[1] << c[2] << endl;
  return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;
using i64 = int64_t;
#define rep(i, s, n) for (i64 i = (s); i < (n); ++i)

void run() {
  int x;
  cin >> x;
  cout << ((x == 0) ? 1 : 0) << endl;
}

int main() {
  cin.tie(nullptr);
  run();
  return 0;
}


Measured memory_bytes: 3192
#include<iostream>
#include<string>
using namespace std;
int c,f;
string st;
int main()
{
	cin>>st;
	for(int i=0; i<st.size(); i++)
	{
       if(st[i]=='C')c=1;
       if(st[i]=='F'&&c==1)f=1;
	}
	if(c==1&&f==1)cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
#define repe(i,x) for (edge *i=fst[x]; i; i=i->nxt)
using namespace std;

int n,cnt[100100],stk[100100],top;
struct edge
{
    int v;
    edge *nxt;
} pool[200100],*tp=pool,*fst[100100];
bool flag[100100];

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

int main()
{
    n=getint();
    repu(i,1,n-1)
    {
        int u=getint(),v=getint();
        *tp=(edge){v,fst[u]},fst[u]=tp++;
        *tp=(edge){u,fst[v]},fst[v]=tp++;
        ++cnt[u],++cnt[v];
    }
    repu(i,1,n)
        if (cnt[i]==1)
            stk[++top]=i;
    while (top)
    {
        int u=stk[top--],v=0;
        if (flag[u])
            continue;
        if (!cnt[u])
        {
            puts("First");
            return 0;
        }
        repe(i,u)
            if (cnt[i->v]>0)
                v=i->v;
        repe(i,v)
        {
            if (i->v!=u && cnt[i->v]==1)
            {
                puts("First");
                return 0;
            }
            if ((--cnt[i->v])==1)
                stk[++top]=i->v;
        }
        cnt[u]=cnt[v]=0,flag[u]=flag[v]=1;
    }
    puts("Second");
    return 0;
}

Measured memory_bytes: 4736
#include"bits/stdc++.h"
using namespace std;
int main(){
	int ans = 0, n, cur_max = 0;
	cin >> n;
	
	for(int i = 0; i != n; ++i){

		int temp;
		cin >> temp;
		cur_max = max(cur_max, temp);

		if(temp >= cur_max)
			++ans;
	}

	cout << ans;
}
 






Measured memory_bytes: 256
def solve(n, m, a_list):
    res = n - sum(a_list)
    if res >= 0:
        return res
    else:
        return -1


def main():
    n, m = map(int, input().split())
    a_list = list(map(int, input().split()))
    res = solve(n, m, a_list)
    print(res)


def test():
    assert solve(41, 2, [5, 6]) == 30
    assert solve(10, 2, [5, 6]) == -1
    assert solve(11, 2, [5, 6]) == 0
    assert solve(314, 15, [9, 26, 5, 35, 8, 9, 79, 3, 23, 8, 46, 2, 6, 43, 3]) == 9


if __name__ == "__main__":
    test()
    main()


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
  }
  int x=1;
  for(int i=0;i<n;i++){
    if(a.at(i)==x){
      x++;
    }
  }
  if(x==1){
    cout << -1 << endl;
  }else{
    cout << n-x+1 << endl;
  }
}

Measured memory_bytes: 1024
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def rls(): return list(input())
def pli(a): return "".join(list(map(str, a)))
 
import copy
 
N = ri()
relation = [[] for _ in range(N+1)]
dist = [[0 for i in range(N+1)] for j in range(2)]
for i in range(N-1):
    a,b = rli()
    relation[a].append(b)
    relation[b].append(a)
 
def dfs_visit(u):
    start = u
    rel = copy.deepcopy(relation)
    s = []
    color = [-1 for _ in range(N+1)]
    s.append(u)
    color[u] = 0
    while(s != list()):
        u = s[-1]
        try:
            v = rel[u].pop()
        except IndexError:
            dist[0 if start == 1 else 1][s[-1]] = len(s)
            s.pop()
            color[u] = 1
            continue
        if(color[v] == -1):
            color[v] = 0
            s.append(v)
 
def dfs():
    dfs_visit(1)
    dfs_visit(N)
 
dfs()
fe = 0
sn = 0
 
for i in range(1, N+1):
    if(dist[0][i] <= dist[1][i]):
        fe += 1
    else:
        sn += 1
print("Fennec" if fe > sn else "Snuke")

Measured memory_bytes: 54980
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
//#include <unordered_map>
//#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:33554432")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble
#define rf(x) (x)=0;while(*p<48)p++;while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;
//typedef tuple <int, int, int> t3;

int IT_MAX = 1 << 18;
const ll MOD = 1000000009;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 1234567890123456789ll;
const db PI = acos(-1);
const db EPS = 1e-8;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<(n);i++)

int in[10050];

int ans[105][105];

bool dchk[105][105];
vector <pii> Va;
int main() {
	int H, W, N, i, j;
	scanf("%d %d %d", &H, &W, &N);
	for (i = 1; i <= N; i++) scanf("%d", &in[i]);

	int P[4][2] = { {0,1},{1,0},{0,-1},{-1,0} };
	int x = 1, y = 1, d = 0;
	for (i = 1; i <= H*W; i++) {
		Va.emplace_back(x, y);
		dchk[x][y] = true;
		if (i == H*W) break;

		for (;; d = (d + 1) % 4) {
			int x2 = x + P[d][0], y2 = y + P[d][1];
			if (x2 >= 1 && x2 <= H && y2 >= 1 && y2 <= W && !dchk[x2][y2]) {
				x = x2, y = y2;
				break;
			}
		}
	}
	for (i = 1, j = 0; i <= N; i++) {
		for (int k = 1; k <= in[i]; k++) {
			int x = Va[j].first, y = Va[j].second;
			ans[x][y] = i;
			j++;
		}
	}
	
	for (i = 1; i <= H; i++) {
		for (j = 1; j <= W; j++) printf("%d ", ans[i][j]);
		printf("\n");
	}
	return 0;
}

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

const int N = 2e5 + 10;

int a[N], b[N];

int main ()
{
	int n, st, sp = 1, f, fp;
	scanf("%d", &n);
	st = n / 2;
	f = fp = (n & 1) ? 1 : -1;
	scanf("%d", &a[st]);
	for(int i = 1; i < n; i++){
		scanf("%d", &a[st + sp * f]);
		if(f == fp) f = -f;
		else{
			f = -f; sp++;
		}
	}
	
	for(int i = 0; i < n; i++)
		printf("%d%c", a[i], i == n-1 ? '\n' : ' ');
	
	
	return 0;
}

Measured memory_bytes: 2944
#ifndef ONLINE_JUDGE
    #include "debug.cpp"
#endif

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

#define endl '\n'
#define int long long

void solve()
{
    int h, w, m;
    cin >> h >> w >> m;
    set< pair<int, int> > st;
    map<int, int> row, col;
    // vector<int> row(h + 1, 0), col(w + 1, 0);
    for(int i = 0; i < m; i++)
    {
        int h, w;
        cin >> h >> w;
        row[h]++;
        col[w]++;
        st.insert({h, w});
    }
    
    int ans = 0;
    // for(auto x : row)
    // {
    //     for(auto y : col)
    //     {
    //         int k = x.second + y.second;
    //         if(st.count({x.first, y.first}))
    //             k--;
    //         ans = max(ans, k);
    //     }
    // }
    // cout << ans << endl;
    int rowMax = 0;
    int rowMaxPos = -1;
    for(auto x : row)
    {
        // rowMax = max(rowMax, x.second);
        if(x.second > rowMax)
        {
            rowMax = x.second;
            rowMaxPos = x.first;
        }
    }
    int colMax = 0;
    int colMaxPos = -1;
    for(auto x : col)
    {
        // colMax = max(colMax, x.second);
        if(x.second > colMax)
        {
            colMax = x.second;
            colMaxPos = x.first;
        }
    }

    for(auto x : row)
    {
        int k = colMax + x.second;
        if(st.count({x.first, colMaxPos}))
            k--;
        ans = max(ans, k);
    }

    for(auto x : col)
    {
        int k = rowMax + x.second;
        if(st.count({rowMaxPos, x.first}))
            k--;
        ans = max(ans, k);
    }
    cout << ans << endl;
}   

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

    int t = 1;
    // cin >> t;
    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 59900
#include <iostream>

using namespace std;

int main(){
        double x[8];
        while(cin >> x[0]){
                for(int i = 1; i < 8; i++) cin >> x[i];
                if((x[0]-x[2])*(x[4]-x[6])+(x[1]-x[3])*(x[5]-x[7])) cout << "NO" << endl;
                else cout << "YES" << endl;
        }   
}

Measured memory_bytes: 0
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
	int a, b, c, d, w, x, y, z;
	scanf("%d %d %d %d %d %d %d %d", &a, &b, &c, &d, &w, &x, &y, &z);

	int t;
	t = max(a + b + c + d, w + x + y + z);

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

	return 0;
}

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

int main(){
    int n,m;
    cin >> n >> m;
    int a[n][m]={0};
    int b[m]={0};
    int x,y;
    int c=0;
    
    for (int i=0;i<n;i++){
        for (int j=0;j<m;j++){
            cin >> x;
            a[i][j]=x;
        }
    }
    for (int k=0;k<m;k++){
        cin >> y;
        b[k]=y;
    }
    for (int l=0;l<n;l++){
        for (int p=0;p<m;p++){
            c += (a[l][p])*(b[p]);
        }
        cout << c << endl;
        c=0;
    }
    return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

bool compare (const pair<long long, long long>& x, const pair<long long, long long>& y) {return x.second > y.second;}

int main() {
    int n, m;
    vector<long long> a;
    vector<pair<long long, long long> > bc;
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        long long a_;
        cin >> a_;
        a.push_back(a_);
    }
    sort(a.begin(), a.end());

    for (int i = 0; i < m; i++) {
        long long b_, c_;
        cin >> b_ >> c_;
        bc.push_back(make_pair(b_, c_));
    }
    sort(bc.begin(), bc.end(), compare);

    int ai = 0;
    int bci = 0;
    long long ans = 0;
    while (1) {
        if (bci == m || a[ai] >= bc[bci].second || ai == n) break;
        if (a[ai] < bc[bci].second && bc[bci].first > 0) {
            ans += bc[bci].second;
            ai++;
            bc[bci].first--;
        }
        else if (bc[bci].first == 0) {
            bci++;
        }
    }
    for (; ai < n; ai++) {
        ans += a[ai];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3188
function Main(input) {
  input = input.split(/\s+/);
  const a = parseInt(input[0]);
  const b = parseInt(input[1]);

  if ((a * b) % 2 == 0) {
    console.log("Even");
  } else {
    console.log("Odd");
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (int)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898

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

int main() {
    ll n, m;
    cin >> n >> m;
    if (abs(n - m) >= 2) {
        cout << 0 << endl;
    } else if (abs(n - m) == 1) {
        ll p = 1;

        repll2(i, n) {
            p *= i;
            p %= MOD;
        }

        repll2(i, m) {
            p *= i;
            p %= MOD;
        }
        cout << p << endl;
    } else {
        ll p = 2;

        repll2(i, n) {
            p *= i;
            p %= MOD;
        }

        repll2(i, m) {
            p *= i;
            p %= MOD;
        }
        cout << p << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(){
int a,b;
int x;


while(scanf("%d %d",&a,&b)!=EOF){
	int i=0;
x=a+b;
while(x>=1){
x=x/10;
i++;
	}
	
printf("%d\n",i);
}

return 0;
	}

Measured memory_bytes: 600
strs = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'  
shift = int(input())
data = []
inp = input()
for i in inp:                     #iterate over the text not some list
    data.append(strs[(strs.index(i) + shift) % 26]) 
output = ''.join(data)
print(output)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
const int MOD=1e9+7;
const int INF=1e18;


signed main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    //freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
    int n;cin>>n;
    vi v(n+1),suf(n+1);
    for(int i=1;i<=n;i++){
        cin>>v[i];
    }
    suf=v;
    for(int i=n-1;i>=1;i--){
        suf[i]+=suf[i+1];
        suf[i]%=MOD;
    }
    
    int sum=0;
    for(int i=1;i<=n;i++){
        sum+=v[i]*(i+1<=n?suf[i+1]:0)%MOD;
        sum%=MOD;
    }
    cout<<sum;
    
}

Measured memory_bytes: 6356
import java.util.Map;
import java.util.Scanner;

public class Main {

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

	    long n=gl();

	    
	  if (n%2==0) {
	    System.out.println(n);
	  } else {
		  System.out.println(2*n);
	  }
	    
        //System.out.println(Math.pow(l/3, 3));
//        if (a<b) {
//        	System.out.print(Math.max(b-a-w, 0));
//        }else {
//        	System.out.print(Math.max(a-b-w, 0));
//        }


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

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

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

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

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

using namespace std;

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

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

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

    int sum = 0;
    rep(i, N) sum += s[i];
    sort(all(s));
    if (sum % 10 != 0) {
        cout << sum << endl;
        return 0;
    }
    rep(i, N) {
        sum -= s[i];
        if (sum % 10 != 0) {
            cout << sum << endl;
            return 0;
        }
        sum += s[i];
    }
    cout << "0" << endl;
    return 0;
}


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

#define int long long
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
template<typename T, typename U> inline bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> inline bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
struct Init {
    Init() {
        cout << fixed << setprecision(20);
    };
} init;

int N, A, B, C;
int l[11];
signed main() {
    cin >> N >> A >> B >> C;
    for (int i = 0; i < N; i++) { cin >> l[i]; }
    int ans = LLONG_MAX;
    for (int i = 0; i < 1 << (N * 2); i++) {
        int cur = i;
        int a = 0, b = 0, c = 0, j = 0, m = 0;
        while (cur > 0) {
            if (cur % 4 == 1) { a += l[j], m += 10; }
            else if (cur % 4 == 2) { b += l[j], m += 10; }
            else if (cur % 4 == 3) { c += l[j], m += 10; }
            cur /= 4, j++;
        }
        if (a == 0 || b == 0 || c == 0) { continue; }
        chmin(ans, abs(A - a) + abs(B - b) + abs(C - c) + m - 30);
    }
    cout << ans << endl;
}


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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int gcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  int n;
  cin>>n;
  vector<int> v(n),a(n),b(n);
  rep(i,n) cin>>v[i]>>a[i]>>b[i];
  rep(i,n){
    if(v[i]%2!=(a[i]+b[i])%2){
      cout<<"No"<<endl;
      return 0;
    }
    if(abs(a[i])+abs(b[i])>v[i]){
      cout<<"No"<<endl;
      return 0;
    }
  }
  rep(i,n-1){
    if(abs(v[i+1]-v[i])<abs(a[i+1]-a[i])+abs(b[i+1]-b[i])){
      cout<<"No"<<endl;
      return 0;
    }
  }
  cout<<"Yes"<<endl;
  
  
  
}
///////////////////////////

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


const int limit = 50;
int n, m;
int a[limit], b[limit];
bool graph[limit][limit];
bool visited[limit];
void dfs(int v) {
visited[v] = true;
for (int v2 = 0; v2 < n; ++v2) {
if (graph[v][v2] == false) continue; if (visited[v2] == true) continue; dfs(v2);
} }
int main(void) {
 cin>>n>>m; 
 for (int i = 0; i < m; ++i) {
   cin >> a[i] >> b[i];
   a[i]--, b[i]--;
   graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
 }
 int ans =0;
 for
(int i = 0; i < m; ++i) {
graph[a[i]][b[i]] = graph[b[i]][a[i]] = false; for (int j = 0; j < n; ++j) visited[j] = false; dfs(0);
bool bridge = false;
for (int j = 0; j < n; ++j) if (visited[j] == false) bridge = true; if (bridge) ans += 1;
graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
 }
cout << ans << endl; 
return 0;
 }

Measured memory_bytes: 256
// AOJ 2417

#include <iostream>
#include <map>
#include <string>
using namespace std;

char b[] = {'a', 'i', 'u', 'e', 'o'};
char s[] = {'*', 'k', 's', 't', 'n', 'h', 'm', 'y', 'r', 'w'};

int main(void)
{
	string flick;
	cin >> flick;
	map <char, int> data;
	data['T'] = 0;
	data['L'] = 1;
	data['U'] = 2;
	data['R'] = 3;
	data['D'] = 4;
	
	for (int i = 0; i < flick.length(); i++){
		if (flick[i] == '1'){
			i++;
			cout << b[data[flick[i]]];
		}
		else if (flick[i] == '0'){
			i++;
			if (flick[i] == 'U') cout << "nn";
			if (flick[i] == 'T') cout << "wa";
			if (flick[i] == 'D') cout << "wo";
		}
		else {
			cout << s[flick[i]-'0'-1];
			i++;
			cout << b[data[flick[i]]];
		}
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 1188
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>

using namespace std;

typedef long long ll;
const ll mod = 1000000007;
const int N = 1010;
bool is_acyclic = true;

vector<int> Graph[N * N];
int visited[N * N];
int dis[N * N];

int to_vertex(int n, int a, int b) {
    if (a > b) swap(a,b);
    return a * n + b;
}

int dfs(int v) {
    visited[v] = 2;
    int len = 1;
    int res = 0;
    for (auto s : Graph[v]) {
        if (visited[s] == 2) {
            is_acyclic = false;
            return -1; 
        } else {
            if (!visited[s]) {
                int tmp = dfs(s);
                if (tmp == -1) return -1;
                else res = max(res,tmp);
            } else res = max(res,dis[s]);
        }
    }
    visited[v] = 1;
    len += res;
    dis[v] = len;
    return len;
}

int main() {
    int n;
    scanf("%d",&n);
    for (int i = 0; i < n; i++) {
        int a;
        scanf("%d",&a);
        a--;
        int prev = to_vertex(n, i, a); 
        for (int j = 0; j < n - 2; j++) {
            int b;
            scanf("%d",&b);
            b--;
            int next = to_vertex(n, i, b);
            Graph[prev].push_back(next);
            prev = next;
        }
    }
    int path = 0;
    for (int i = 0; i < n * (n - 1); i++) {
        if (!visited[i]) {
            path = max(path,dfs(i));
        }
    }
    if (!is_acyclic) printf("%d\n",-1);
    else printf("%d\n",path);
}

Measured memory_bytes: 47872
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <map>
#include <iterator>
#include <queue>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for (int i=(a-1);i>=(b);--i)
#define rrep(i,n) rrepd(i,n,0)
typedef long long ll;
typedef pair<int, int> P;


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

  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 0;
  char tmp = 'A';
  rep(i, n){
    if (s[i] != tmp) ans++;
    tmp = s[i];
  }
  cout << ans << endl;
  return 0; 
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();

    int[] h = new int[n];

    h[0] = sc.nextInt();
    int max = h[0];
    for (int i = 1; i < n; ++i) {
      h[i] = sc.nextInt();
      max = (h[i] > max) ? h[i] : max;

      if (h[i] <= max - 2) {
        System.out.println("No");
        System.exit(0);
      }
    }

    System.out.println("Yes");
  }
}

Measured memory_bytes: 50232
N,K,Q = map(int,input().split())
A = {}
for i in range(N):
  A[i+1] = 0
for i in range(Q):
  a = int(input())
  A[a] += 1
for i in range(N):
  if K - (Q - A[i+1]) > 0:
    print("Yes")
  else:
    print("No")
  

Measured memory_bytes: 15084
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
using namespace std;

void solve() {
	long long N;
	cin >> N;
	cout << (N - 1) * N / 2 << endl;
	return;
}

//////////////////////////////
//////////////////////////////

int main() {
#ifdef DEBUGTIME
	for (int time = 0; time < DEBUGTIME; time++) {
		solve();
		cout << "####################" << endl;
	}
#else
	solve();
#endif
	return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N;
	cin >> N;
	vector<ll> a(N);
	string S;
	cin >> S;
	REP(i, N) a[i] = S[i] - 'a';

	ll fi = -1;
	REP(i, N-1){
		vector<ll> tmp(26, 0);
		vector<ll> tmp2(26, 0);
		ll res = 0;
		REP(j, i+1) tmp[a[j]]++;
		for(int j=i+1;j<N;j++) if(tmp[a[j]]>0) tmp2[a[j]]++;
		REP(j, 26) if(tmp2[j]>0) res++;
		fi = max(fi, res);
	}
	cout << fi << endl;
    return 0;
}

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

int main(){
  int H, W;
  cin >> H >> W;

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

  vector<int> hs, ws;
  for(int h = 0; h < H; h++){
    bool has_black = false;
    for(int w = 0; w < W; w++){
      if(a[h][w] == '#'){
        has_black = true;
      }
    }
    if(has_black){
      hs.push_back(h);
    }
  }

  for(int w = 0; w < W; w++){
    bool has_black = false;
    for(int h = 0; h < H; h++){
      if(a[h][w] == '#'){
        has_black = true;
      }
    }
    if(has_black){
      ws.push_back(w);
    }
  }

  for(auto h: hs){
    for(auto w: ws){
      cout << a[h][w];
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
#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<ll,ll>;
using vv = vector<vector<ll>>;
template <class _t> inline bool chmax (_t& a,_t b){if(a<b){a=b;return true;}return false;}
template <class _t> inline bool chmin (_t& a,_t b){if(a>b){a=b;return true;}return false;}

const long long inf = 1ll << 60;
const long long mod = 1000000007;

int main(void){
    int n;cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    sort(a.rbegin(),a.rend());
    cout << -a[n/2] + a[n/2-1] << endl; 
    return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>

using namespace std;

int main(){
  int a[3];
  for (int i = 0; i < 3; i++){
    scanf("%d",&a[i]);
  }
  sort(a, a + 3);
  printf("%d %d %d\n",a[0],a[1],a[2]);
  return 0;
}



Measured memory_bytes: 2712
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		// 初期化
		int[] list = new int[5];
		int[] check = {9,0,8,7,6,5,4,3,2,1};
		
		Scanner sc = new Scanner(System.in);
		list[0] = sc.nextInt();
		list[1] = sc.nextInt();
		list[2] = sc.nextInt();
		list[3] = sc.nextInt();
		list[4] = sc.nextInt();

		int result=0;
		int cnt=1;
		for(int i=0;i<check.length;i++) {
			for(int j=0;j<list.length;j++) {
				int amari = list[j] % 10;
				if(amari == check[i]) {
					if(cnt!=5) {
						if(amari != 0) {
							result += list[j] + 10 - amari;
						}
						else {
							result += list[j];
						}
					}
					else {
						result += list[j];
					}
					cnt++;
				}	
			}
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 21844
package main

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

func check(w, h, x, y, r int) {
	startX := r
	startY := r
	endX := w - r
	endY := h - r
	if x >= startX && x <= endX && y >= startY && y <= endY {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	num, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(1)
	}
	return num
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	w := nextInt(scanner)
	h := nextInt(scanner)
	x := nextInt(scanner)
	y := nextInt(scanner)
	r := nextInt(scanner)
	check(w, h, x, y, r)
}



Measured memory_bytes: 1088
#include<stdio.h>
int main()
{
    int n,i,r=1;
    char s[100];
    scanf("%d%s",&n,&s);

    if(n%2)
    {
        r=0;
    }
    else{
        for(i=0;i<n/2;i++){
            r*=s[i]==s[n/2+i];
        }
    }
    printf(r?"Yes":"No");
    return 0;
}


Measured memory_bytes: 1656
#include <stdio.h>
#include <math.h>
  
int main(void)
{
  double x1,x2,x3,y1,y2,y3,r,xp,yp;
  int n,i;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3);
 
    xp=((y2-y3)*(x1*x1+y1*y1)+(y3-y1)*(x2*x2+y2*y2)+(y1-y2)*(x3*x3+y3*y3))/(2*(x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2)));
    yp=((x2-x3)*(x1*x1+y1*y1)+(x3-x1)*(x2*x2+y2*y2)+(x1-x2)*(x3*x3+y3*y3))/(2*(y1*(x2-x3)+y2*(x3-x1)+y3*(x1-x2)));
 
    r=sqrt((x1-xp)*(x1-xp)+(y1-yp)*(y1-yp));
    printf("%.3lf %.3lf %.3lf\n",xp,yp,r);
     
  }
  return 0;
}


Measured memory_bytes: 2052