akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define ALL(x) (x).begin(), (x).end()

typedef long long int lld;
typedef pair<int, int> pii;

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

    int n = 0;
    cin >> n;

    vector<int> v(n);
    for (int i = 0; i < n; i++)
        cin >> v[i];
    
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int x = 0;
        cin >> x;
        ans += x;
    }

    for (int i = 1; i <= n - 1; i++) {
        int x = 0;
        cin >> x;

        auto it = find(ALL(v), i);
        if (it + 1 != v.end() && *(it + 1) == i + 1)
            ans += x;
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 384
s = input()
d = ['dream', 'dreamer', 'erase', 'eraser']
s = s[::-1]
for i in range(len(d)):
    d[i]= d[i][::-1]
while s != '':
    for j in range(len(d)):
        if s[0:len(d[j])] == d[j]:
            s = s[len(d[j]):]
            break
    else:
        print('NO')
        break
else:
    print('YES')

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

int main(){
    int x;
    cin>>x;
    int a=x;
    int i,j,k,s=0,s1=0;
    for(i=1;i<=x;i++){
    	if(x%i==0)s++;
    }
    if(s>2){
   		pass:
   		x++;
   		s1=0;
   	    for(j=1;j<=x;j++){
   		    if(x%j==0)s1++;
   		}
    	if(s1>2)goto pass;
	    else{
	    	cout<<x;
	    	return 0;
		}
	}
	cout<<a;
	return 0;
}

Measured memory_bytes: 256
// 5/14
// 過去問ガリガリ
#include <bits/stdc++.h>
#include <string>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main() {
    int a, b;
    cin >> a >> b;

    string A, B;
    rep(i, b) {
        // A.push_back(;
        A += to_string(a);
    }
    rep(i, a) {
        // B.push_back((char)b);
        B += to_string(b);
    }

    if (A <= B) cout << A << endl;
    else cout << B << endl;
}


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

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int M, T, P, R;

	public static void main(String[] args) {
		while (true) {
			M = sc.nextInt();
			T = sc.nextInt();
			P = sc.nextInt();
			R = sc.nextInt();
			if (M == 0) break;
			Team[] teams = new Team[T];
			for (int i = 0; i < T; ++i) {
				teams[i] = new Team(i + 1);
			}
			for (int i = 0; i < R; ++i) {
				int m = sc.nextInt();
				int t = sc.nextInt();
				int p = sc.nextInt();
				int j = sc.nextInt();
				Team team = teams[t - 1];
				if (j == 0) {
					team.ac++;
					team.pena += m + team.submit[p - 1] * 20;
				} else {
					team.submit[p - 1]++;
				}
			}
			Arrays.sort(teams);
			for (int i = 0; i < T - 1; ++i) {
				System.out.print(teams[i].idx);
				System.out.print(teams[i].equiv(teams[i + 1]) ? '=' : ',');
			}
			System.out.println(teams[T - 1].idx);
		}
	}

	static class Team implements Comparable<Team> {
		int[] submit = new int[10];
		int ac, pena, idx;

		Team(int i) {
			idx = i;
		}

		public int compareTo(Team o) {
			if (this.ac != o.ac) {
				return o.ac - this.ac;
			}
			if (this.pena != o.pena) {
				return this.pena - o.pena;
			}
			return o.idx - this.idx;
		}

		boolean equiv(Team o) {
			return this.ac == o.ac && this.pena == o.pena;
		}
	}

}

Measured memory_bytes: 60720
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

#[allow(unused_imports)]
fn main() {
    use std::cmp::max;
    use std::cmp::min;

    input!{
        n: usize,
        a: usize,
        b: usize,
    }
    let mut ans = 0;
    for i in 1..n+1 {
        let mut j = i;
        let mut sum = 0;
        while j > 0 {
            sum = sum + j%10;
            j = j/10;
        }
        if a <= sum && sum <= b {
            ans = ans + i;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4476
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 1000000007;
double pi = 3.14159265358979;

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}

int main() {
  ll a;
  long double b;
  cin >> a >> b;
  long double c = a * b;
  ll g = c;
  printf("%lld\n", g);
}


Measured memory_bytes: 3728
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl
using P = pair<int, int>;

int main() {
    int d, n; cin >> d >> n;

    if(n==100){
        if(d==0) cout << 101 << endl;
        if(d==1) cout << 10100 << endl;
        if(d==2) cout << 1010000 << endl;

        return 0; 
    }

    if(d==0){
        cout << n << endl;
    }
    else if(d==1){
        cout << 100 * n << endl;
    }
    else cout << 10000 * n << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#define pai 3.1415926535


int main(void) {
	
	char S[11];
	scanf("%s", S);
	int a = atoi(S);
	int b = atoi(&S[5]);
	int c = atoi(&S[8]);


	if (a < 2019) {
		printf("Heisei");
	}
	else if (b < 4) {
		printf("Heisei");
	}
	else if (b==4&&c <= 30) {
		printf("Heisei");
	}
	else {
		printf("TBD");
	}



	return 0;
}

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

string S;
int N;

int main(void){
	cin>>S;
	N = S.size();
	if(N==2){
		int ans = abs((int)S[0]-(int)S[1]);
		cout<<ans<<endl;
		return 0;
	}
	vector<int>yak;
	for(int i = 1;i * i <= N;++i){
		if(N % i == 0){
			yak.push_back(i);
			if(i * i < N){
				yak.push_back(N / i);
			}
		}
	}
	int ans = 8;
	for(int elm : yak){
		if(elm == N)continue;
		vector<string>v;
		for(int i = 0;i < N;i += elm){
			string tmp;
			for(int j = i;j < i + elm;++j){
				tmp.push_back(S[j]);
			}
			v.push_back(tmp);
		}
		sort(v.begin(),v.end());
		bool fail = false;
		for(int j = 0;j < elm - 1;++j){
			if(v.front()[j] != v.back()[j]){
				fail = true;
				break;
			}
		}
		if(fail)continue;
		//for(auto&s:v)cerr<<s<<endl;
		int can = v.back()[elm - 1] - v.front()[elm - 1];
		ans = min(ans, can);
	}
	//cerr << ans << endl;
	int now = 0;
	int big = -1,small = 111;
	while(now < N){
		if(S[now]=='1' && now < N - 1){
			int tmp = S[now+1]-'0';
			tmp += 10;
			big = max(big,tmp);
			small = min(small,tmp);
			now += 2;
		}else{
			int tmp = S[now]-'0';
			big = max(big,tmp);
			small = min(small,tmp);
			now += 1;
		}
	}
	int can = big - small;
	ans = min(ans,can);
	cout << ans << endl;
	return 0;
}


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

int main() {
	int N;
	cin >> N;
	vector<int> A(N);
	vector<long long> B(N + 1, 0); //累積和テーブル
	int mod = 1000000007;

	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
		B[i + 1] = B[i] + A[i];
	}

	long ans = 0;

	//i について全探索する
	for (int i = 0; i < N; i++)
	{
		//累積和を使ってA[i+1] + ... + A[N] を求める
		long long sum = (B[N] - B[i + 1]) % mod;

		ans += A[i] * sum;
		ans %= mod;
	}

	cout << ans << endl;
}



Measured memory_bytes: 5604
#include "bits/stdc++.h"
using namespace std;

#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)


int main() {
	int N, T, t[200001];
	cin >> N >> T;
	REP(i, N)cin >> t[i];
	sort(t, t + N);
	int ans = 0;
	REP(i, N - 1) {
		ans += min(t[i + 1] - t[i], T);
	}
	ans += T;
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>


using namespace std;
//using namespace __gnu_pbds;


#define LL long long
#define N 100005
#define MOD 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

int main() {

ios_base::sync_with_stdio(false);
cin.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--){
        int a,b;
        cin>>a>>b;
        if(a==b)
            cout<<0;
        else if((a+b)%2==0)
            cout<<(a+b)/2;
        else
            cout<<"IMPOSSIBLE"<<'\n';
    }
return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
const long long MOD = 1000000007;
int N, M, A, B, a[1000][1000];
long long K;
long long POWER(long long a, long long b)
{
	long long r = 1;
	for (; b; b >>= 1)
	{
		if (b & 1)
			r = r * a % MOD;
		a = a * a % MOD;
	}
	return r;
}
struct matrix
{
	long long a, b, c, d;
	inline matrix operator * (const matrix &y)
	{
		return { (a * y.a + b * y.c) % MOD, (a * y.b + b * y.d) % MOD, (c * y.a + d * y.c) % MOD, (c * y.b + d * y.d) % MOD };
	}
};
int main()
{
	scanf("%d%d%lld", &N, &M, &K);
	if (K <= 1)
	{
		puts("1");
		return 0;
	}
	for (int i = 0; i < N; i++)
	{
		static char _a[1001];
		scanf("%s", _a);
		for (int j = 0; j < M; j++)
			a[i][j] = _a[j] == '#';
	}
	for (int i = 0; i < M; i++)
		if (a[0][i] && a[N - 1][i])
		{
			A = 1;
			break;
		}
	for (int i = 0; i < N; i++)
		if (a[i][0] && a[i][M - 1])
		{
			B = 1;
			break;
		}
	if (A && B)
	{
		puts("1");
		return 0;
	}
	if (!A && !B)
	{
		long long c = 0;
		for (int i = 0; i < N; i++)
			c += std::count(a[i], a[i] + M, 1);
		printf("%lld\n", POWER(c, K - 1));
		return 0;
	}
	if (A)
	{
		int D = std::max(N, M);
		for (int i = 0; i < D; i++)
			for (int j = i + 1; j < D; j++)
				std::swap(a[i][j], a[j][i]);
		std::swap(N, M);
	}
	long long Side = 0, Block = 0, Connect = 0;
	for (int i = 0; i < N; i++)
	{
		if (a[i][0] && a[i][M - 1])
			Side++;
		for (int j = 0; j < M; j++)
			if (a[i][j])
				Block++;
		for (int j = 1; j < M; j++)
			if (a[i][j - 1] && a[i][j])
				Connect++;
	}
	K = (K + MOD - 2) % (MOD - 1);
	printf("%lld\n", (POWER(Block, K % (MOD - 1)) - Connect * (POWER(Block, K % (MOD - 1)) - POWER(Side, K % (MOD - 1)) + MOD) % MOD * POWER(Block - Side, MOD - 2) % MOD + MOD) % MOD);
	return 0;
}



Measured memory_bytes: 5604
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    int c= (b/n)*n;
    if(c<=b&&c>=a)
    cout<<"OK"<<endl;
    else
    {
        cout<<"NG"<<endl;
    }
    return 0;
}


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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
using ll = long long;
using ld = long double;
using str = string;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vs = vector<str>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;

// Constant variables
const ld PI = (acos(-1));
const ll MOD = 1000000007;

// I/O Asynchronizing
struct __io_async{
    __io_async(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
};

inline bool ok(const str &s, const ll loc, const str &t) {
    int i = loc;
    REPR(j, t.length()) {
        if(i < 0) return false;
        if(s[i] == '?' || s[i] == t[j]) i--;
        else return false;
    }
    return true;
}

int main() {
    str s, t, ans = "";
    cin >> s >> t;
    REPR(i, s.length()) {
        if(ok(s, i, t)) {
            s = s.substr(0, i - t.length() + 1) + t + s.substr(i + 1);
            break;
        }
        if(i <= 0) ans = "UNRESTORABLE";
    }
    REP(i, s.length()) {
        if(s[i] == '?') s[i] = 'a';
    }

    cout << (ans != "" ? ans : s) << endl;

    return 0;
}


Measured memory_bytes: 256
def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    mod = 10 ** 9 + 7

    ans = 0
    for i in range(N):
        tmp_1 = 0
        tmp_2 = 0
        for j in range(N):
            if A[i] > A[j]:
                tmp_1 += 1
            if A[i] > A[j] and i < j:
                tmp_2 += 1

        ans += tmp_2 * K * (K+1) // 2
        ans += (tmp_1-tmp_2) * (K-1) * K // 2
        ans %= mod

    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;

#define _overload3(_1,_2,_3,_4,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a, i##_len=(b); i<i##_len; ++i)
#define _repis(i,a,b,s) for(int i=a, i##_len(b); i<i##_len; i+=s)
#define REP(...) _overload3(__VA_ARGS__,_repis,_repi,_rep,)(__VA_ARGS__)

#define REPR(i, n) for(int i = n;i >= 0;--i)

#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define yes(n) cout<<((n)?"yes":"no")<<endl
#define poss(n) cout<<((n)?"possible":"impossible")<<endl
#define Poss(n) cout<<((n)?"Possible":"Impossible")<<endl
#define POSS(n) cout<<((n)?"POSSIBLE":"IMPOSSIBLE")<<endl

int main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(a*b,c*d);
    return 0;
}

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

using namespace std;

using ll = long long;

ll n, a, b, d;
vector<ll> h;

bool Solve(ll k) {
    ll sum = 0;
    for (int i = 0; i < n; ++i) {
        if (h[i] - k * b <= 0) continue;
        sum += (h[i] - k * b + d - 1) / d;
    }
    return sum <= k;
}


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

    cin >> n >> a >> b;

    h.assign(n, 0);
    for (int i = 0; i < n; ++i) cin >> h[i];
    d= a - b;

    ll lb = -1, ub = *max_element(h.begin(), h.end());
    while (1 < ub - lb) {
        ll mid = (ub + lb) >> 1;
        if (Solve(mid)) ub = mid;
        else lb = mid;
    }

    cout << ub << endl;

    return 0;
}


Measured memory_bytes: 1024
# coding: utf-8
lst = list(map(int, input().split()))

K = lst[3]
c = 0
a = 0

for i in range(3):
    if K > 0:
        a = min(lst[i], K)
        K = K - a
        if i == 0:
            c += a * 1
        elif i == 2:
            c += a * (-1)
    else:
        break
print(c)

Measured memory_bytes: 9184
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n, m;
    cin >> n >> m;
    
    vector<vector<ll>> v(100001);
    ll x, y;
    
    for ( ll i = 0; i < n; i++ ){
        cin >> x >> y;
        v[x].push_back(y);
    }
        
    priority_queue<ll> q;
    
    ll ans = 0;
    
    for ( ll i = 1; i <= m; i++ ){
        for ( auto x: v[i] ) q.push(x);
            
        if ( !q.empty() ) {
            ans += q.top();
            q.pop();
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 5632
// ------------------------------------
// Date:2018/ 3/13
// Problem:rgb cards . c.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl

typedef long long ll;

static const int MOD = 1000000007;

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

  int r, g, b;
  cin >> r >> g >> b;

  bool ok = false;
  if ((g * 10 + b) % 4 == 0)  {
    ok = true;
  } 

  cout << (ok ? "YES" : "NO") << endl;
  
  return 0;
}



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

int main()
{
  int ans;
  string s;
  cin >> s;
  ans = s.size();

  for (int i = 0; i < 2; i++)
  {
    int count = 0;
    for (int j = 0; j < s.size(); j++)
    {
      if (j % 2 == 0 and s[j] != to_string(i)[0])
        count++;
      if (j % 2 == 1 and s[j] == to_string(i)[0])
        count++;
    }
    ans = min(ans, count);
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define VAL 100000
#define ll  long long
#define INF 10000000000000000LL
#define pll pair<long long , long long>
const int MAX=1e6+10;
const ll MOD=2019;
const int TOT_PRIMES=19;
const int MAX_A=70;
using namespace std;
vector<int>adj[MAX];
int main() 
{
	int n ,m;
	cin>>n>>m;
	cout<<n*m;

}

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

using namespace std;

#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) ((int)(x).size())
#define whole(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

const int N = int(1e5) + 2;
const int LG = 20;
const ll mod = 998244353;
const int INF = 2147483647;
const ll linf = 1e18;
const ld pi = acos(-1);
const ld EPS = 1e-10;

int a, p, ans;

void calc (){
    while (p >= 2){
        p -= 2;
        ans++;
    }
}

int main (){
    scanf ("%d %d", &a, &p);
    p += (a * 3);
    calc();
    return !printf ("%d\n", ans);
}


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

using namespace std;

using ll = long long;

int main() {
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      char x;
      cin >> x;
      if (i == j) cout << x;
    }
  }
  return 0;
}




Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int n;
    cin>>n;
    int ans = 0;
    int v=n;
    for(int i=10;i<=n;i*=10){
        if(v/i==1 && v%i==0){
            ans = 10;
            cout<<ans<<endl;
            return 0;
        }
    }
    while(v){
        ans += v%10;
        v/=10;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = int64_t;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll n;
    cin >> n;
    vector<string> vs(n);
    rep(i,n) cin >> vs.at(i);
    ll ac=0,wa=0,tle=0,re=0;
    rep(i,n){
        if(vs.at(i) == "AC") ac++;
        if(vs.at(i) == "WA") wa++;
        if(vs.at(i) == "TLE") tle++;
        if(vs.at(i) == "RE") re++;
    }
    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
}

Measured memory_bytes: 6360
#include<stdio.h>
int main()
{
    int a,b,c;
    scanf("%d",&a);
    b = a/10;
    c = a - b*10;
    
    if(b==9){
      printf("Yes\n");
      return 0;
    }else if(c==9){
      printf("Yes\n");
      return 0;
    }
    printf("No\n");
    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
struct edge{ll to,cost;};
const int inf = 1<<28;
const ll INF = 1LL<<53;
const int COMBMAX = 500005;
const ll MOD = 1e9+7;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;++i)
#define repf(i,n) for(int i=0;i<=n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define eachdo(v, e) for(const auto& e : v)
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (ll)distance(v.begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (ll)distance(v.begin(), upper_bound((v).begin(), (v).end(), e))
ll mpow(ll a, ll n,ll mod=MOD){ll res=1;while(n>0){if(n&1)res=res*a%mod;a=a*a%mod;n>>=1;}return res;}
template<class T1, class T2> ll bcount(T1 v, T2 a){return upper_index(v,a)-lower_index(v,a);} 
template<class T> bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
template<class T> void debug2(T v){rep(i,v.size()){rep(j,v[i].size())cout<<v[i][j]<<" ";cout<<endl;}}
template<class T> void rdv(T &v){rep(i,v.size())cin>>v[i];}
template<class T> void rdvv(T &v){rep(i,v.size()){rep(j,v[i].size())cin>>v[i][j];}}
// multimap
// mmap.emplace(key,value);
// auto ngw = list.equal_range("");
// for(auto e = ngw.first; it != ngw.second ; ++e)

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;

    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }

    ll find(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }

    bool merge(ll x, ll y) {
        x = find(x);
        y = find(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return find(x) == find(y);
    }

    ll size(ll x) {
        return siz[find(x)];
    }
};


int main(){
    ll N,Z,W; cin >> N >> Z >> W;
    vl a(N); rdv(a);
    if(N==1){
        cout << abs(W - a[N-1]) << endl;
    }else{
        cout << max(abs(W - a[N-1]),abs(a[N-1]-a[N-2])) << endl; 
    }
    return 0;
}

Measured memory_bytes: 256
mod = 10**9 + 7

n,k = map(int, input().split())
a = list(map(int, input().split()))

pos_cnt = sum(ai>=0 for ai in a)
neg_cnt = n-pos_cnt
if k-pos_cnt > 0 and (k-pos_cnt)%2 == 1 and (n==k or pos_cnt == 0):
    res = 1
    a.sort(reverse=True)
    for i in range(k):
        res *= a[i]
        res %= mod
    print(res)
    exit()

b = [(abs(ai), ai) for ai in a]
b.sort(reverse=True)
pos_top = []
neg_top = []
for i in range(k):
    _, ai = b[i]
    if ai >= 0:
        pos_top.append(ai)
    else:
        neg_top.append(ai)

pos_left = []
neg_left = []
for i in range(k, n):
    _, ai = b[i]
    if ai >= 0:
        pos_left.append(ai)
    else:
        neg_left.append(ai)

ans = 1
if len(neg_top)%2 == 0:
    for ai in pos_top:
        ans *= ai
        ans %= mod
    for ai in neg_top:
        ans *= ai
        ans %= mod
    print(ans)
    exit()

ans_tmp = []
if len(pos_left) > 0 and len(neg_top) > 0:
    pos_use = pos_left[0]
    neg_drop = neg_top[-1]
    pos_tmp = pos_top[:]
    pos_tmp.append(pos_use)
    neg_tmp = neg_top[:]
    neg_tmp.pop()
    res = 1
    for ai in pos_tmp:
        res *= ai
        res %= mod
    for ai in neg_tmp:
        res *= ai
        res %= mod
    ans_tmp.append([abs(pos_use/neg_drop), res])

if len(neg_left) > 0 and len(pos_top) > 0:
    neg_use = neg_left[0]
    pos_drop = pos_top[-1]
    pos_tmp = pos_top[:]
    pos_tmp.pop()
    neg_tmp = neg_top[:]
    neg_tmp.append(neg_use)
    res = 1
    for ai in pos_tmp:
        res *= ai
        res %= mod
    for ai in neg_tmp:
        res *= ai
        res %= mod
    ans_tmp.append([abs(neg_use/pos_drop), res])

ans_tmp.sort(reverse=True)
ans = ans_tmp[0][1]
print(ans)


Measured memory_bytes: 112336
###
### atcorder test program
###

### math class
class math:
    ### pi
    pi = 3.14159265358979323846264338

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

math = math()

### input sample
#i = input()
#A, B, C = [x for x in i.split()]
#templist = [int(w) for w in input().split()]
#R = float(input())
#A = [int(x) for x in input().split()]

### output sample
#print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
#print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))

while True:
    i = input()
    X, Y = [int(x) for x in i.split()]
    if X == 0:
        break
    for n in range(X):
        for m in range(Y):
            if (n + m) % 2 == 0:
                print("#", end="")
            else:    
                print(".", end="")
        print("")
    print("")



Measured memory_bytes: 7032
#include<bits/stdc++.h>
#define LL long long
#define RG register
#define R RG int
using namespace std;
vector<int>c[400];
int main(){
	R n,now=0;
	cin>>n;
	R d=(1+sqrt(1+8*n))/2;
	if(d*(d-1)!=2*n)return puts("No"),0;
	printf("Yes\n%d\n",d);
	for(R i=1;i<=d;++i){
		printf("%d",d-1);
		for(R j=1;j<i;++j)
			printf(" %d",c[j][c[j].size()-1]),c[j].pop_back();
		for(R j=i;j<d;++j)
			printf(" %d",++now),c[i].push_back(now);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 1920
#include<cstdio>
#include<cmath>
long long ans[100000];
void vis(){
	int j=0;
	for (int i=1;;i++){
		ans[j]=i*i;
		j++;
		if(i==99999)
			break;
	}
}
int main(){
	vis();
	long long int n;
	scanf ("%I64d",&n);
	for (int i=0;i<100000;i++){
		if (ans[i]>n){
			printf ("%I64d\n",ans[i-1]);
			break;
		}
		if (ans[i]==n){
			printf ("%I64d\n",n);
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 896
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10


#奇数個のリンゴがあったら先手の勝利
N = INT()
a = [INT() for _ in range(N)]

for x in a:
	if x%2:
		print("first")
		break
else:
	print("second")


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

int main(){
    int N;
    cin >> N;
    int a[N][3];
    int dp[N][3];
    for(int i=0;i<N;i++){
        for(int j=0;j<3;j++){
            cin >> a[i][j];
        }
    }
    dp[0][0] = a[0][0];
    dp[0][1] = a[0][1];
    dp[0][2] = a[0][2];
    for(int i=1;i<N;i++){
        for(int j=0;j<3;j++){
            dp[i][j] = 0;
        }
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(j == k) continue;
                dp[i+1][k] = max(dp[i+1][k], dp[i][j] + a[i+1][k]);
            }
        }
    }
    int ans = 0;
    for(int i=0;i<3;i++){
        ans = max(ans, dp[N-1][i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
//constexpr ll MOD = 998244353;
//constexpr ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
constexpr ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

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

  if (A == B && B == C)
    FINALANS("No");
  if (A != B && B != C && C != A)
    FINALANS("No");
  FINALANS("Yes");
}

Measured memory_bytes: 256
#include <stdio.h>

int suit_to_int(char c)
{
	switch (c) {
		case 'S':
			return 0;
		case 'H':
			return 1;
		case 'C':
			return 2;
		case 'D':
			return 3;
		default:
			return 9;
	}
}

char int_to_suit(int m)
{
	switch (m) {
		case 0:
			return 'S';
		case 1:
			return 'H';
		case 2:
			return 'C';
		case 3:
			return 'D';
		default:
			return 'U';
	}
}

int main(void)
{
	char c;
	int n, m;
	int card[4][13];
	scanf("%d\n", &n);
	
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 13; j++) {
			card[i][j] = 0;
		}
	}
	
	for (int i = 0; i < n; i++) {
		scanf("%c %d\n", &c, &m);
		card[suit_to_int(c)][m - 1] = 1;
	}
	
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 13; j++) {
			if (card[i][j] != 1) {
				printf("%c %d\n", int_to_suit(i), j + 1);
			}
		}
	}
}



Measured memory_bytes: 2060
package main

import (
	"fmt"
)

func walkOnMultiplicationTable(num int) int {

	l := num
	x := 1
	for i := 1; i < l; i++ {
		if num%i == 0 {
			x = i
		}
		l = num / i
	}
	return x + num/x - 2

}

func main() {
	var a int
	fmt.Scan(&a)
	fmt.Println(walkOnMultiplicationTable(a))
}


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


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

  int i=1, maxv=-1;
  while ( i <= n ) {
    if ( i*i > n ) break;
    i++;
  }

  cout << (i-1)*(i-1) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int n, m, s, c, e;
int a[10];
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 0; i <= n; i++) {
		a[i] = 10;
	}
	for (int i = 0; i < m; i++) {
		scanf("%d%d", &s, &c);
		if (s == 1 && c == 0 && n != 1)e = 1;
		if (a[s] != 10 && a[s] != c)e = 1;
		a[s] = c;
	}
	if (e)printf("-1\n");
	else {
		for (int i = 1; i <= n; i++) {
			if (a[i] == 10 && !(i == 1 && n != 1))a[i] = 0;
			if (i == 1 && a[i] == 10 && n != 1)a[i] = 1;
			printf("%d", a[i]);
		}
		printf("\n");
	}
}

Measured memory_bytes: 128
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll inf = 1e9 + 7;
const ll Mod = 998244353;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

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

  ll r = 0, g = 0, b = 0;
  for (int i = 0; i < N; i++){
    if (S[i] == 'R') r++;
    if (S[i] == 'G') g++;
    if (S[i] == 'B') b++;
  }
  ll ans = r * g * b;

  for (int i = 0; i < N; i++){
    for (int j = i + 1; j < N; j++){
      int k = 2 * j - i;
      if (k >= N) break;

      if (S[i] != S[j] && S[j] != S[k] && S[k] != S[i]) ans--;
    }
  }
  cout << ans << endl;
  

  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n;
    cin >> n;
    if (n == 1) {
        cout << "Yes" << endl;
        cout << "2" << endl;
        cout << "1 1" << endl;
        cout << "1 1" << endl;
    } else if (n == 2) {
        cout << "No" << endl;
    } else {
        for (int i = 1; i * (i - 1) <= 2 * n; ++i) {
            if (i * (i - 1) != 2 * n) continue;
            vector<deque<int>> q(i);
            int index = 0;
            cout << "Yes" << endl;
            cout << i << endl;
            REP(j,0,i) {
                cout << i - 1;
                if (j == 0) {
                    REP(k,0,i-1) {
                        cout << " " << k + 1;
                        q[j].push_back(k);
                        ++index;
                    }
                } else {
                    int cnt = 0;
                    RREP(k,0,j) {
                        if (cnt == i - 1) break;
                        if (!q[k].empty()) {
                            cout << " " << q[k][0] + 1;
                            q[k].pop_front();
                            ++cnt;
                        }
                    }
                    REP(k,cnt,i-1) {
                        cout << " " << index + 1;
                        q[j].push_back(index);
                        ++index;
                    }
                }
                cout << endl;
            }
            return;
        }
        cout << "No" << endl;
    }
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define pp pair<int,int>
#define Pi acos(-1)
#define pq priority_queue
#define mz 1000000007
 
using namespace std;
 
int x,k,q,t;
int r[100005];
int d[100005];
int lu[100005],ld[100005],ru[100005],rd[100005];
 
int main()
{
    int a,ans,nowlu,nowld,nowru,nowrd,temp=0;
    scanf("%d",&x);
    scanf("%d",&k);
    for(int i=1;i<=k;i++)
        scanf("%d",&r[i]);
    for(int i=1;i<=k;i++)
        d[i]=min(r[i]-r[i-1],x);
    lu[0]=ru[0]=x;
    ld[0]=rd[0]=0;
    r[k+1]=mz;
    for(int i=1;i<=k;i++)
    {
        if(i%2)
        {
            nowld=d[i];
            nowlu=x;
            nowrd=0;
            nowru=x-d[i];
        }
        else
        {
            nowld=0;
            nowlu=x-d[i];
            nowrd=d[i];
            nowru=x;
        }
        if(ru[i-1]<nowld || rd[i-1]>nowlu)
        {
            if(i%2)
            {
                ld[i]=x;
                lu[i]=x;
                rd[i]=0;
                ru[i]=0;
            }
            else
            {
                ld[i]=0;
                lu[i]=0;
                rd[i]=x;
                ru[i]=x;
            }
        }
        else
        {
            if(rd[i-1]<=nowld)
            {
                ld[i]=ld[i-1]+nowld-rd[i-1];
                rd[i]=nowrd;
            }
            else
            {
                ld[i]=ld[i-1];
                rd[i]=nowrd-nowld+rd[i-1];
            }
            if(ru[i-1]>=nowlu)
            {
                lu[i]=lu[i-1]+nowlu-ru[i-1];
                ru[i]=nowru;
            }
            else
            {
                lu[i]=lu[i-1];
                ru[i]=nowru-nowlu+ru[i-1];
            }
        }
    }
    scanf("%d",&q);
    while(q--)
    {
        scanf("%d%d",&t,&a);
        while(r[temp+1]<=t)
            temp++;
        if(a>=ld[temp] && a<=lu[temp])
            ans=a-ld[temp]+rd[temp];
        else
        {
            if(a<=ld[temp])
                ans=rd[temp];
            else
                ans=ru[temp];
        }
        if(temp%2)
            ans=min(x,ans+(t-r[temp]));
        else
            ans=max(0,ans-(t-r[temp]));
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 3584
#include <iostream>
using namespace std;
long long MAX_NUM=1000000007;
long long Ni(int N){
	if (N==0 || N==1){
		return 1;
	}
	long long num=1;
	for (int n=N;n>=1;n--){
		num*=n;
		num%=MAX_NUM;
	}
	return num;
}
int main(int argc, char* argv[])
{
	int N,M;
	cin>>N>>M;
	if (N>M+1 || M>N+1){
		cout<<0<<endl;
		return 0;
	}
	if (N==M){
		long long numN=Ni(N)%MAX_NUM;
		long long numM=Ni(M)%MAX_NUM;
		long long num=2*numN*numM%MAX_NUM;
		cout<<num<<endl;
		return 0;
	}
	if (N==M+1){
		long long numN=Ni(N)%MAX_NUM;
		long long numM=Ni(M)%MAX_NUM;
		long long num=numN*numM%MAX_NUM;
		cout<<num<<endl;
		return 0;
	}
	if (M==N+1){
		long long numM=Ni(M)%MAX_NUM;
		long long numN=Ni(N)%MAX_NUM;
		long long num=numM*numN%MAX_NUM;
		cout<<num<<endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
data = list(map(int,input().split()))
da = [0,0,0]
even = 0
odd = 0
max = 0
min = 50
for i in range(3):
  if max < data[i]:
    max = data[i]
  if min >= data[i]:
    min = data[i]
  if data[i]%2 == 0:
    da[i] = 1
    even += 1
  else:
    odd += 1
if even == 3 or odd == 3:
  print(((max * 3) - (data[0] + data[1] + data[2]))//2)
elif even == 2:
  for i in range(3):
    if da[i] == 1:
      if max == data[i]:
        max += 1
      data[i] += 1
  print(((max * 3) - (data[0] + data[1] + data[2]))//2 + 1)
else:
  for i in range(3):
    if da[i] == 0:
      if max == data[i]:
        max  += 1
      data[i] += 1
  print(((max * 3) - (data[0] + data[1] + data[2]))//2 + 1)

Measured memory_bytes: 3064
#ifdef BUILT_LOCAL

#include "niklib.h"

#endif

#include <iostream>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>
#include <map>
#include <cmath>
#include <set>
#include <list>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef __int128 lll;
constexpr ll mod = 1000000007;

#define bs(n) (1ull<<(ull)(n))
#define rep(i, n) for(ll (i) = 0;(i) < (n);(i)++)

ll n, m, a[100000], s[100001];

//return the number of handshakes which gains greater or equal amount of happiness
ll cnt(ll x) {
    ll c = 0;
    rep(i, n) {
        auto t = (a + n) - lower_bound(a, a + n, x - a[i]);
        c += t;
    }
    return c;
}

ll sum(ll x) {
    ll v = 0;
    rep(i, n) {
        auto t = (a + n) - lower_bound(a, a + n, x - a[i]);
        v += s[n] - s[n - t] + a[i] * t;
    }
    return v;
}

int main() {
    cin >> n >> m;
    rep(i, n) cin >> a[i];
    sort(a, a + n);
    rep(i, n) s[i + 1] = s[i] + a[i];
    ll l = 0, r = 20000000000;
    while (r - l > 1) {
        ll m2 = (l + r) / 2;
        auto t = cnt(m2);
        if (t > m) l = m2;
        else r = m2;
    }
    ll c = cnt(r);
    ll v = sum(r);
    if (c < m) v += l * (m - c);
    cout << v <<endl;
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	for (auto &u : v) os << u << el;
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

int main() {
	string S, T;
	cin >> S >> T;
	cout << (int)(S[0] == T[0]) + (int)(S[1] == T[1]) + (int)(S[2] == T[2]) << endl;
	return (0);
}

Measured memory_bytes: 256
#include <cctype>
#include <iostream>
#include <cstring>
#include <cstdio>


using namespace std; 


int main(){

	int n,k;
	
	scanf("%d%d",&n,&k);
	k = k - 1;
	char s[n];
	
	cin >> s;
	
	char lowchar = char(tolower(s[k]));
	s[k] = lowchar;
	
	cout << s << endl;
	
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int[] n = new int[5];

        n[0] = cin.nextInt();
        n[1] = cin.nextInt();
        n[2] = cin.nextInt();
        n[3] = cin.nextInt();
        n[4] = cin.nextInt();
        var k = cin.nextInt();

        for (int i = 0; i < 5; i++)
        {
            for (int j = 0; j < 5; j++)
            {
                if (n[i] - n[j] > k)
                {
                    Console.WriteLine(":(");
                    return;
                }
                if (n[j] - n[i] > k)
                {
                    Console.WriteLine(":(");
                    return;
                }
            }
        }

        Console.WriteLine("Yay!");
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }

    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <iomanip>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
typedef long long ll;
using namespace std;

int main() {
	int t[13]={1,13,12,11,10,9,8,7,6,5,4,3,2};
	int cnta=0,cntb=0;
	int a,b;
	cin>>a>>b;
	for(int i=0;i<13;i++){
		if(a==t[i]){
			cnta=i;
		}
		if(b==t[i]){
			cntb=i;
		}
	}
	if(cnta<cntb){
		cout<<"Alice"<<endl;
	}else if(cnta>cntb){
		cout<<"Bob"<<endl;
	}else{
		cout<<"Draw"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
N, u, v = map(int,input().split())
u, v = u - 1, v - 1
path = [] 
for _ in range(N):
    path.append([])
for _ in range(N - 1):
    A, B = map(int,input().split())
    A, B = A - 1, B - 1
    path[A].append(B)
    path[B].append(A)
dep = [0] * N
dep[v] = 1
leaf = []
stack2 = [v]
cnt = 2
while stack2:
    stack = stack2[0:]
    stack2 = []
    while stack:
        s = stack.pop()
        for to in path[s]:
            judge = len(path[s])
            if dep[to]:
                judge -= 1
                if judge == 0:
                    leaf.append([cnt - 1, s])
                continue
            dep[to] = cnt
            stack2.append(to)
            judge += 1 
    cnt += 1
leaf.sort(reverse=True)
depmax = [0] * N
for i in range(len(leaf)):
    depth, a = leaf[i][0], leaf[i][1] 
    depmax[a] = depth
    end = False
    for j in range(depth - 1, 0, -1):
        if end:
            break
        for b in path[a]:
            if dep[b] == j:
                if depmax[b] < depmax[a]:
                    depmax[b] = depmax[a]
                    a = b
                    break
                else:
                    end = True
                    break
dis = dep[u] - 2
leng = depmax[u]
a = u
for depth in range(dep[u] - 1, dep[u] - 1 - (dis // 2), -1):
    for to in path[a]:
        if depth == dep[to]:
            leng = depmax[to]
            a = to
print(leng - 2)

Measured memory_bytes: 70380
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
Int INF = 1e18;
double EPS = 0.00000001;
//Int mod = 1e6+3;

int main() {
    string s;
    cin >> s;
    if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) {
        dump("Bad");
    }
    else {
        dump("Good");
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <map>

int main (){
	int N;
	scanf("%d",&N);
	std::string S;
	std::cin >> S;
	if (N%2==1){
		printf("No\n");
		return 0;
	} else {
		for (int i=0; i<N/2; i++){
			if (S[i]!=S[N/2+i]){
				printf("No\n");
				return 0;
			}
		}
		printf("Yes\n");
		return 0;
	}

}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val S = readLine()!!.toCharArray()
    val Q = readLine()!!.toInt()

    val f = Array(26) { Fenwick(N + 1) }

    for (i in S.indices) {
        val c = S[i] - 'a'
        f[c].add(i + 1, 1)
    }

    for (t in 1..Q) {
        val (a, b, c) = readLine()!!.split(" ")

        if (a == "1") {
            val i = b.toInt()

            if (S[i - 1] != c[0]) {
                f[S[i - 1] - 'a'].add(i, -1)
                f[c[0] - 'a'].add(i, 1)
                S[i - 1] = c[0]
            }
        } else {
            val l = b.toInt()
            val r = c.toInt()
            var res = 0
            for (i in 0 until 26) {
                if (f[i].get(r) - f[i].get(l - 1) > 0) {
                    ++res
                }
            }

            println(res)
        }
    }
}

class Fenwick(val n: Int) {
    val bit = IntArray(n + 1) { 0 }

    fun add(i_: Int, v: Int) {
        val n = bit.size
        var i = i_ + 1
        while(i < n) {
            bit[i] += v
            i += i and -i
        }
    }

    fun get(i_: Int): Int {
        var res = 0
        var i = i_ + 1
        while(i > 0) {
            res += bit[i]
            i -= i and -i
        }

        return res
    }
}


Measured memory_bytes: 116256