akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define ls id << 1
#define rs id << 1 | 1
#define mem(array, value, size, type) memset(array, value, ((size) + 5) * sizeof(type))
#define memarray(array, value) memset(array, value, sizeof(array))
#define pb(x) push_back(x)
#define st(x) (1LL << (x))
#define pii pair<int, int>
#define mp(a, b) make_pair((a), (b))
#define Flush fflush(stdout)
using namespace std;
const int N = 500050;
const int inf = 0x3f3f3f3f;
const ll mod = 1E9 + 7;
clock_t TIME_START, TIME_END;
void program_end()
{
#ifdef ONLINE
    printf("\nTime used: %.6lf(s)\n", ((double)TIME_END - TIME_START) / CLOCKS_PER_SEC);
    system("pause");
#endif
}
ll dp[N];
int n;
ll siz[N];
vector<int> e[N];
inline ll mi(ll a, ll b)
{
    ll ret = 1;
    a %= mod;
    while (b)
    {
        if (b & 1)
            ret *= a, ret %= mod;
        a *= a, a %= mod;
        b >>= 1;
    }
    return ret;
}
void dfs1(int u, int fa)
{
    siz[u] = 1;
    for (auto v : e[u])
    {
        if (v == fa)
            continue;
        dfs1(v, u);
        siz[u] += siz[v];
    }
}
void dfs2(int u, int fa)
{
    for (auto v : e[u])
    {
        if (v == fa)
            continue;
        dp[v] = dp[u] * (n - siz[v]) % mod * mi(siz[v], mod - 2) % mod;
        dfs2(v, u);
    }
}

void solve()
{
    scanf("%d", &n);
    ll fac = 1;
    for (int i = 1; i <= n; ++i)
        fac *= i, fac %= mod;
    for (int i = 1; i < n; ++i)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        e[x].push_back(y);
        e[y].push_back(x);
    }
    dfs1(1, 0);
    dp[1] = 1;
    for (int i = 1; i <= n; ++i)
        dp[1] *= siz[i], dp[1] %= mod;
    dfs2(1, 0);
    for (int i = 1; i <= n; ++i)
    {
        ll ans = fac * mi(dp[i], mod - 2) % mod;
        printf("%lld\n", ans);
    }
}

int main()
{
    TIME_START = clock();
    int Test = 1;
    // cin >> Test;
    while (Test--)
        solve();
    TIME_END = clock();
    program_end();
    return 0;
}

Measured memory_bytes: 27636
#include<stdio.h>
#include<vector>
#include<iostream>
#include<map>
#include<tuple>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

std::vector<ll> extended_gcd(ll a, ll b){ //ax+by=zとなる(x,y,z)
    ll s=0;
    ll old_s=1;
    ll t=1;
    ll old_t=0;
    ll r=b;
    ll old_r=a;
    while(r){
        long q =old_r / r;
        std::swap(s, old_s); s-=q*old_s;
        std::swap(t, old_t); t-=q*old_t;
        std::swap(r, old_r); r-=q*old_r;
    }
    //cout << old_r << " " << old_s << " " << old_t << endl;
    std::vector<ll> ans = {old_r, old_s, old_t};
    return ans;
}

int main(){
    ll a,b;
    cin >> a >> b;
    auto ans = extended_gcd(a,b);
    cout << ans[1] << " " << ans[2] << endl;
}


Measured memory_bytes: 3096
// reference: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut 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")
    };
}

use std::cmp::Ordering;
use std::collections::BinaryHeap;

#[derive(Eq, PartialEq, Clone, Debug)]
pub struct Rev<T>(pub T);

impl<T: PartialOrd> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Rev<T>) -> Option<Ordering> {
        other.0.partial_cmp(&self.0)
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Rev<T>) -> Ordering {
        other.0.cmp(&self.0)
    }
}

fn main() {
    input! {
        s: chars
    }

    let word: Vec<Vec<char>> = vec!["dream", "dreamer", "erase", "eraser"]
        .into_iter()
        .map(|x| x.chars().collect())
        .collect();

    let mut dp = vec![false; s.len()];
    for b in 0..s.len() {
        for w in &word {
            let e = std::cmp::min(b + w.len(), s.len());
            if (b == 0 || dp[b - 1]) && &s[b..e] == &w[..] {
                dp[e - 1] = true;
            }
        }
    }

    println!("{}", if dp[s.len() - 1] { "YES" } else { "NO" });
}


Measured memory_bytes: 4352
import collections

N = int(input())
S = list(input())

lst = [0] * 26
for i in range(N):
    lst[ord(S[i]) - 97] += 1

for i in range(len(lst)):
    if i == 0:
        pass
    else:
        lst[i] += lst[i] * sum(lst[:i])

ans = sum(lst)
    
print(ans % (10**9 + 7))


Measured memory_bytes: 4340
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>0;--i)
#define yesno(flg) if(flg){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define Vi vector<int>
#define Vl vector<long long>
#define pb(a) push_back(a)
using namespace std;

typedef long long ll;
const int inf=1000000000;
const int np=1000000007;
struct edge{
	int myc,to,c,cost;
};
struct pos{
	int to,cost,color;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

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

	cout<<d/l+d%l<<endl;
	return 0;
}



Measured memory_bytes: 3128
#include <iostream>

using namespace std;

int main(){
  int cnt=1, n,a;
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> a;
    if(a==cnt)cnt++;
  }
  cout << (cnt==1 ? -1 : n-cnt+1) << endl;
  return 0;
}

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

using lint = long long;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    lint x;
    cin >> x;
    cout << (x/500) * 1000 + ((x%500)/5) * 5 << '\n';
}

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

int main(){
	int n, i, b, ans=0;
	cin>>n;
	map<int, int> a;
	for(i=0; i<n; i++){
		cin>>b;
		a[b]++;
		if(a[b]%2) ans++;
		else ans--;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4864
k,n = map(int, input().split())
a_list = [int(x) for x in input().split()]

max = 0
for i in range(len(a_list)):
    if i == len(a_list)-1:
        length = (k-a_list[i])+a_list[0]
    else:
        length = a_list[i+1] - a_list[i]
    if length > max:
        max = length
print(k-max)

Measured memory_bytes: 26444
#include<stdio.h>
#include<math.h>

int main(void)
{
  int a, b, c;
  int i = 0;
  double l;
  
  scanf("%d %d %d", &a, &b, &c);
  
  while(!(a == b && b == c)) {
    if(a == b && c < a) {
      c += 2;
    }
    else if(b == c && a < b) {
      a += 2;
    }
    else if (c == a && b < c) {
      b += 2;
    }
    else {
      l = fmax(a, fmax(b, c));
      if(l == a) {
        b++;
        c++;
      }
      else if(l == b) {
        c++;
        a++;
      }
      else {
        a++;
        b++;
      }
    }
    
    i++;
  }
  
  printf("%d\n", i);
  
  return 0;
}

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

using namespace std;

typedef long long int ll;

int main()
{
    string s, n;
    cin >> s;
    ll m = -1, num;
    for (ll i = 0; i < s.size() - 2; i++)
    {
        n = s.substr(i, 3);
        stringstream g(n);
        g >> num;
        if (abs(num - 753) >= 0)
        {
            if (m == -1)
            {
                m = abs(num - 753);
            }
            else
            {
                m = min(m, abs(num - 753));
            }
        }
    }
    cout << m;

    return 0;
}


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

using namespace std;
using ll=long long;

const int N=1e5+10;

bool up(int arr[], int n){
    for(int i=0; i<n; i++)
        if(arr[i]%2==0)
            if(!(arr[i]%3==0||arr[i]%5==0)) return 0;
    return 1;
}

int main(){
    int n;
    cin>>n;
    int arr[n];
    for(int &i:arr) cin>>i;
    if(up(arr, n)) cout<<"APPROVED";
    else cout<<"DENIED";

}
















Measured memory_bytes: 256
import sys 
stdin = sys.stdin
ns = lambda : stdin.readline().rstrip()

s = ns()
t = ns()
s_cnt = []
t_cnt = []
for alp in "abcdefghijklmnopqrstuvwxyz":
  s_cnt.append(s.count(alp))
  t_cnt.append(t.count(alp))
s_cnt.sort()
t_cnt.sort()
if s_cnt == t_cnt:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3632
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>
#include <sstream>
#include <iterator>

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

int lefts[200005][22];

int main()
{
    int n;
    scanf("%d", &n);

    vector<int> arr(n);

    for (int i = 0; i < n; i++)
        scanf("%d", &arr[i]);

    memset(lefts, -1, sizeof(lefts));

    int prev[21];

    memset(prev, -1, sizeof(prev));

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < 20; j++)
        {
            if ((arr[i] & (1 << j)) == 0)
                continue;

            lefts[i][j] = prev[j];
            prev[j] = i;
        }
    }

    i64 ans = 0;

    int maxi = -1;

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < 20; j++)
            maxi = max(maxi, lefts[i][j]);

        ans += i - maxi;
    }

    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 18176
# A - Restaurant

# 1食800円、15食食べるごとに200円もらえる
# 合計N食食べた場合、もらった金額を差し引いた総支払額はいくらか？

pay_count = int(input())

print(pay_count * 800 - ((pay_count // 15) * 200))


Measured memory_bytes: 9008
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  string s;
  int k;
  cin >> s >> k;
  set<string> se;
  rep(i,s.size()) {
    string t="";
    REP(j,i,s.size()) {
      t+=s[j];
      se.in(t);
      if(se.size()>k) {
        iter(se) it=se.end();
        it--;
        se.erase(it);
      }
    }
  }
  iter(se) it=se.end();
  it--;
  pr(*it);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, s, e) for (ll (i) = (s); (i) < (e); ++(i))
#define per(i, s, e) for (ll (i) = (s); (i) >= (e); --(i))
#define all(x) x.begin(),x.end()
 
int main() {
    ll N, K, R, S, P;
    string T;
    cin >> N >> K >> R >> S >> P >> T;
    vector<string> V(K);
    rep(i, 0, N) {
        V[i % K] += T[i];
    }
    ll ans = 0;
    rep(i, 0, K) {
        vector<char> DP(V[i].size() + 1, 'n');
        rep(j, 0, V[i].size()){
            if (V[i][j] != DP[j]) {
                if (V[i][j] == 'r') ans += P;
                if (V[i][j] == 's') ans += R;
                if (V[i][j] == 'p') ans += S;
                DP[j+1] = V[i][j];
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
deque <long long> a;
void push(int &d,long long  &x){
    if(d==0){
        a.push_front(x);
    }
    else{
        a.push_back(x);
    }
}
void access(int &p){
    cout<<a[p]<<endl;
}

int main(){
    int n,q,d,p;
    long long x;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>q;
        if(q==0){
            cin>>d>>x;
            push(d,x);
        }
        else if(q==1){
            cin>>p;
            access(p);
        }
        else{
            cin>>d;
            if(d==0){
                a.pop_front();
                
            }
            else{
                a.pop_back();
                
            }
        }
    }
    return 0;
}


Measured memory_bytes: 6200
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF =ll(1e18) +5;

int main() {
    ll N;
    cin >> N;
    vector<pair<ll,ll>> X;
    for(int i=0;i<N;i++){
        ll a,b;
        cin >> a >>b;
        X.emplace_back(a,b);
    }
    sort(X.begin(),X.end());
    map<pair<ll,ll>,ll> mp;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            ll dx = X[j].first - X[i].first;
            ll dy = X[j].second -X[i].second;
            mp[make_pair(dx,dy)]++;
        }
    }
    ll ans = 0;
    for(auto itr = mp.begin();itr!=mp.end();++itr){
        ans = max(ans,(itr->second));
    }
    cout << N-ans << endl;


    return 0;
}

Measured memory_bytes: 384
#require 'prime'
#require 'openssl'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+).to_i end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n=gi
s=n.times.map{gs}
puts s.uniq.size

Measured memory_bytes: 35360
#include <iostream>
#include <vector>


using namespace std;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if ((A < C && C < B) || (A > C && C > B)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}


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

int sm(ll x){
	int an = 0;
	while (x)an += x % 10, x /= 10;
	return an;
}

int gr(ll x){
	int lst = 0, l = 0;
	while (x){
		lst = x % 10;
		++l;
		x /= 10;
	}
	return lst - 1 + (l - 1) * 9;
}

int main(){
	ll x;
	scanf("%lld", &x);
	int an = max(sm(x), gr(x));
	printf("%d\n", an);
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
from math import sqrt
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    tmp=INF
    for i in range(1,10**6+1):
        if N%i==0:
            tmp=min(tmp,i+N//i)
    print(tmp-2)
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 39024
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        n: usize,
        y: usize,
    }

    for i in 0..(n + 1) {
        for j in 0..(n - i + 1) {
            let k = n - i - j;
            let s = 10000 * i + 5000 * j + 1000 * k;
            if s == y {
                println!("{} {} {}", i, j, k);
                return;
            }
        }
    }
    println!("{} {} {}", -1, -1, -1);
}


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

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		char[] S = sc.next().toCharArray();
		int N = S.length;
		int[] next = new int[N];
		int[] prev = new int[N];
		int[] start = new int[26];
		int[] end = new int[26];
		Arrays.fill(next, -1);
		Arrays.fill(prev, -1);
		Arrays.fill(start, -1);
		Arrays.fill(end, -1);
		for (int i = 0; i < N; ++i) {
			int ch = S[i] - 'a';
			if (end[ch] == -1) {
				start[ch] = i;
			} else {
				next[end[ch]] = i;
			}
			prev[i] = end[ch];
			end[ch] = i;
		}
		BIT bit = new BIT(N);
		long ans = 0;
		for (int i = 0; i < N / 2; ++i) {
			long min = 1 << 28;
			int mi = -1;
			for (int j = 0; j < 26; ++j) {
				if (start[j] == -1) continue;
				if (start[j] == end[j]) {
					System.out.println(-1);
					return;
				}
				long count = start[j] - bit.sum(1, start[j] + 1);
				count += (N - end[j] - 1) - bit.sum(end[j] + 1, N);
				if (count < min) {
					min = count;
					mi = j;
				}
			}
			if (mi == -1) {
				System.out.println(-1);
				return;
			}
			ans += min;
			bit.add(start[mi] + 1, 1);
			bit.add(end[mi] + 1, 1);
			if (next[start[mi]] == end[mi]) {
				next[start[mi]] = -1;
				prev[end[mi]] = -1;
				start[mi] = end[mi] = -1;
			} else {
				prev[next[start[mi]]] = -1;
				start[mi] = next[start[mi]];
				next[prev[end[mi]]] = -1;
				end[mi] = prev[end[mi]];
			}
		}
		System.out.println(ans);
	}

	static class BIT {
		long[] v;

		BIT(int size) {
			int len = 1;
			while (len < size) {
				len *= 2;
			}
			this.v = new long[len + 1];
		}

		long cumulativeSum(int index) {
			long ret = 0;
			while (index > 0) {
				ret += v[index];
				index &= index - 1;
			}
			return ret;
		}

		// inclusive, 1-indexed
		long sum(int l, int r) {
			long ret = cumulativeSum(r) - cumulativeSum(l - 1);
			return ret;
		}

		void add(int index, long val) {
			while (index < v.length) {
				v[index] += val;
				index += (index & -index);
			}
		}

		void set(int index, long val) {
			long old = sum(index, index);
			add(index, val - old);
		}
	}

}

Measured memory_bytes: 42580
s = list(input())
t = list(input())
def judge(l1,l2): # l1 (= l2
    for e in l1:
        if e not in l2:
            return False
            break
        elif e  == l1[-1]:
            return True
if len(s) < len(t) and judge(s,t):
    print("Yes")
else:
    s_ord = [ord(e) for e in s]
    t_ord = [ord(e) for e in t]
    s_ord.sort()
    t_ord.sort()
    t_ord.reverse()
    for i in range(min(len(t_ord),len(s_ord))):
        if t_ord[i] > s_ord[i]:
            print("Yes")
            break
        elif i == min(len(t_ord),len(s_ord)) - 1:
            print("No")

Measured memory_bytes: 3064
// darksta5's template v2.0

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

int par1[200050], par2[200050];

int find1(int i) {
  int x = i;
  while (x != par1[x]) {
    x = par1[x];
  }

  return par1[i] = x;
}

int find2(int i) {
  int x = i;
  while (x != par2[x]) {
    x = par2[x];
  }

  return par2[i] = x;
}

void uni1(int i, int j) {
  int x = find1(i), y = find1(j);
  if (x != y) {
    par1[y] = x;
  }
}

void uni2(int i, int j) {
  int x = find2(i), y = find2(j);
  if (x != y) {
    par2[y] = x;
  }
}

ll make_key(int x, int y) {
  return (ll)x*200050LL+(ll)y;
}

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

  int n, r1, r2;
  cin >> n >> r1 >> r2;
  for (int i = 0; i < n; i++) {
    par1[i] = i;
    par2[i] = i;
  }

  for (int i = 0; i < r1; i++) {
    int x, y;
    cin >> x >> y;
    uni1(x-1, y-1);
  }

  for (int i = 0; i < r2; i++) {
    int x, y;
    cin >> x >> y;
    uni2(x-1, y-1);
  }

  unordered_map<ll, int> cnt;
  for (int i = 0; i < n; i++) {
    ll key = make_key(find1(i), find2(i));
    cnt[key]++;
  }

  for (int i = 0; i < n; i++) {
    ll key = make_key(find1(i), find2(i));
    if (i < n-1) {
      cout << cnt[key] << " ";
    } else {
      cout << cnt[key] << endl;
    }
  }
}

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

using namespace std;

int main(){
    int A,B;
    cin >> A >> B;
    vector<int>a(3);
    a[0]=A+B;
    a[1]=A-B;
    a[2]=A*B;
    sort(a.begin(),a.end());
    cout << a[2] << endl;
    return 0;
}



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

int main(){
  int n;
  int num;
  int sum = 0;
  int ABC;
  while(cin >> n){
    if(n == 0)
      break;
    for(int i = 0; i < n*(n-1)/2; i++)
      {
	cin >> num;
	sum += num;
	//cout << num << sum << endl;
      }
    //cout << "n" <<  n<< endl;
    
    ABC = sum/(n-1);
    cout << ABC <<endl;
    sum = 0;
  }
  return 0;
}
    
    

Measured memory_bytes: 3064
N,K = map(int,input().split())
P = list(map(int,input().split()))
B = [0]
def f(p):
    return p*(1+p)//2/p
for i in range(N):
    B.append(B[i]+f(P[i]))
ans = 0
for i in range(K,N+1):
    ans = max(ans,B[i]-B[i-K])
print(ans)

Measured memory_bytes: 25060
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
const long long MOD = 998244353;
const long long inf = 1e18;
 
using namespace std;
 
ll MAXN=100001;
ll spf[100001]; 
 
ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result;  
} 
 
bool isPrime(int x)
{
    if(x%2==0)
        return 0;
    for(int i=3;i<=sqrt(x);i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
 

 
void solve()
{
	int N ;
	cin>>N ;
	int H[N] ;
	rep(i  ,N) cin>>H[i] ;
	int mx = 0 ; 
	int i = 0 ;
	while(i<N ){
		int temp = H[i] ; 
		int c = 0 ;
		while(i<N && temp>=H[i]){
			c++ ; 
			temp = H[i]  ;
			i++;
		}
		mx = max(mx , c-1) ;
	}
	cout<<mx<<endl;
}
 
int main() {
    // #ifndef ONLINE_JUDGE
    //     // for getting input from input.txt
    //     freopen("input.txt", "r", stdin);
    //     // for writing output to output.txt
    //     freopen("output.txt", "w", stdout);
    // #endif
    
    // ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1;
    // cin>>t;
    while(t--)
    {
        solve();
    } 
    // cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
bool test = 0;
int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
#define MAX (int)1e6 + 5

ll T;
int N;
ll s[MAX], t[MAX];

signed main(void) {
	int i, j, k, l;
	cin >> T >> N;
	rep(i, N) {
		cin >> s[i] >> t[i];
	}
	t[N] = (ll)1e18;
	int begin;
	int end = 0;
	ll sum = 0;
	ll ans = 0;
	rep(begin, N) {
		while (t[end] - s[begin] <= T) {
			sum += t[end] - s[end];
			end++;
		}
		//dump(s[end]);
		//dump(t[end]);
		ll tmp = sum;
		//dump(tmp);
		if (end != N) {
			if (s[begin] + T - s[end] > 0) {
				tmp += s[begin] + T - s[end];
			}
		}
		//dump(tmp);
		if (tmp > ans) {
			//dump(begin);
			ans = tmp;
		}
		if (begin < end) {
			sum -= t[begin] - s[begin];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4664
#include <stdio.h>
#include <ctype.h>

int main()
{
  char input_st;
  int i;
  int counter[26];
  for(i = 0 ; i <= 26 ; i++)
    counter[i] = 0;

  while(scanf("%c", &input_st) != EOF)
  {
    if(isupper(input_st))
    {
      i = input_st - 'A';
      counter[i]++;
    }
    else if(islower(input_st))
    {
      i = input_st - 'a';
      counter[i]++;
    }
  }

  for(i = 0 ; i < 26 ; i++)
    printf("%c : %d\n", 'a' + i, counter[i]);
}



Measured memory_bytes: 2056
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;
using pii = pair<int, int>;

const int MAX_V = 300;
const int INF = 1000000000;

struct edge{int to, cap, rev;};
vector<edge> graph[MAX_V];
vector<bool> used;

void add_edge(int from, int to, int cap)
{
    graph[from].push_back(edge{to, cap, (int)graph[to].size()});
    graph[to].push_back(edge{from, 0, (int)graph[from].size() - 1});
}

int dfs(int v, int t, int f)
{
    if (v == t) return f;
    used[v] = true;

    rep(i, 0, graph[v].size())
    {
        edge &next = graph[v][i];
        if (used[next.to] or next.cap <= 0) continue;

        int now_f = dfs(next.to, t, min(f, next.cap));
        if (now_f > 0)
        {
            // cout << next.to << ' ' << v << ' ' << now_f << endl;;
            next.cap -= now_f;
            graph[next.to][next.rev].cap += now_f;
            return now_f;
        }
    }
    return 0;
}

int max_flow(int s, int t)
{
    int flow = 0;
    while (true)
    {
        used = vector<bool>(t + 1, false);
        // cout << "**********" << endl;
        int f = dfs(s, t, INF);
        if (f == 0) break;
        else flow += f;
    }
    return flow;
}

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

    vector<pii> reds, blues;
    rep(i, 0, n)
    {
        int a, b;
        cin >> a >> b;
        reds.emplace_back(a, b);
    }
    rep(i, 0, n)
    {
        int c, d;
        cin >> c >> d;
        blues.emplace_back(c, d);
    }

    rep(i, 0, n)
    {
        add_edge(2 * n, i, 1);
        add_edge(n + i, 2 * n + 1, 1);
    }

    rep(i, 0, n)
    {
        rep(j, 0, n)
        {
            int a, b, c, d;
            tie(a, b) = reds[i];
            tie(c, d) = blues[j];

            if (a < c and b < d)
            {
                add_edge(i, n + j, 1);
                // cout << i << ' ' << n + j << endl;
            }
        }
    }
    int ans = max_flow(2 * n, 2 * n + 1);
    cout << ans << endl;

    return 0;
}

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

using namespace std;

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

	vector <int> v(n);

	for (int i = 0; i < n; i++)
		cin >> v[i];
	long long min_1 = 0;
	for (int i = 0; i < n - 1; i++)
		min_1 += (v[i+1] - v[i]);
		
	long long min_2 = 0;
	for (int i = n - 1; i > 0; i--)
		min_2 += (v[i] - v[i-1]);
		
	long long pos_min = 0, may = 0;
	for (int i = 0; i < n - 1; i++)
		if (v[i+1] - v[i] > may)
			may = v[i+1] - v[i], pos_min = i;
	long long res = 0;
	for (int i = pos_min; i >= 0; i--)
	{
		if (i == 0)
			res += (v[i] + k - v[n - 1]);
		else
			res += (v[i] - v[i-1]);
	}
	for (int i = pos_min + 1; i < n - 1; i++)
		res += (v[i+1] - v[i]);
	cout << min(res, min(min_1, min_2)) ;
	// 0 5 15
	//  5 10
	
	// 100 
	// 3	70	75	90	93		= 10 + 3 + 15 + 5 = 33
	// 67   5  15   3

	
	// 20   15 		5
	//  21 4
	// 0 5 15 20
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N; cin >> N;
    if(N%2 == 0){
        cout << N*(N-2)/2 << endl;
        rep1(i, N){
            Rep1(j, i+1, N){
                if(i+j == N+1) continue;
                cout << i << " " << j << endl;
            }
        }
    }else{
        cout << N-1 + (N-1)*(N-3)/2 << endl;
        rep1(i, N-1){
            cout << N << " " << i << endl;
        }
        rep1(i, N-1){
            Rep1(j, i+1, N-1){
                if(i+j == N) continue;
                cout << i << " " << j << endl;
            }
        }
    }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define pb push_back

#define N 300005

char s[N];

const int mod = 998244353;

int fac[N] = {1, 1}, rfac[N] = {1, 1}, inv[N] = {0, 1};

typedef pair <int, int> pii;

vector <pii> vec;

int n;
int chv[300], ans;
int p[3][3];
int gg[3];

void update_p(int c, int d) {
//	cerr << "update_p " << "(" << c << ", " << gg[c] << ") and (" << d << ", " << gg[d] << ")" << endl;
    if (gg[c] >= gg[d]) {
        if ((c+1)%3 == d) p[c][d] += gg[d];
        else p[d][c] += gg[d];
        ans = 1ll * ans * fac[gg[d]] % mod;
        gg[c] -= gg[d]; gg[d] = 0;
    }
    else {
        if ((c+1)%3 == d) p[c][d] += gg[c];
        else p[d][c] += gg[c];
        ans = 1ll * ans * fac[gg[d]] % mod * rfac[gg[d]-gg[c]] % mod;
        gg[d] -= gg[c]; gg[c] = 0;
    }
    return;
}

void print_state() {
    puts("----------------------------------");
    for (int i = 0; i < 3; i ++) printf("gg[%d] - %d\n", i, gg[i]);
    for (int i = 0; i < 3; i ++) printf("number of pairs (%d, %d) - %d\n", i, (i+1)%3, p[i][(i+1)%3]);
    printf("now answer is %d\n", ans);
    puts("----------------------------------");
}

void update(int c, int g) {
//	printf("Update %d %d\n", c, g);
    int &pp = p[(c+1)%3][(c+2)%3];
    while (pp && g) {
        ans = 1ll * ans * pp % mod;
        pp --;
        g --;
    }
    if (g) {
        gg[c] += g;
        if (gg[(c+1)%3]) {
            update_p(c, (c+1)%3);
        }
        else if (gg[(c+2)%3]) {
            update_p(c, (c+2)%3);
        }
        else {
        }
    }
}

int main() {
    chv['R'] = 0, chv['G'] = 1, chv['B'] = 2;
    for (int i = 2; i < N; i ++) {
        fac[i] = 1ll * fac[i-1] * i % mod;
        inv[i] = 1ll * (mod/i) * (mod - inv[mod%i]) % mod;
        rfac[i] = 1ll * rfac[i-1] * inv[i] % mod;
    }
    scanf("%d", &n);
    scanf("%s", s+1);
    int len = 3 * n;
    for (int i = 1, j; i <= len; i = j) {
        for (j = i; s[j] == s[i] && j <= len; j ++) ;
        vec.pb(pii(chv[s[i]], j-i));
    }
    ans = 1;
    memset(p, 0, sizeof p);
    for (int i = 0; i < vec.size(); i ++) {
        update(vec[i].x, vec[i].y);
    }
    ans = 1ll * ans * fac[n] % mod;
    printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 10096
import math
import itertools
N=int(input())
C=[tuple(map(int,input().split())) for _ in range(N)]
e=10**-10

def dist(p1,p2):
    return math.sqrt((p1[0]-p2[0])**2 + (p1[1]-p2[1])**2)

def dist2(p1,p2):
    return ((p1[0]-p2[0])**2 + (p1[1]-p2[1])**2)

def mid(p1,p2):
    return ((p1[0]+p2[0])/2, (p1[1]+p2[1])/2)

def angle(p1,p2):
    return math.atan2(p2[1]-p1[1], p2[0]-p1[0])

def angle2(c1,c2,r):
    d = dist(c1,c2)
    return math.acos((d/2/r))

def cross(c1,c2,r):
    if dist2(c1,c2) > (2*r)**2:
        return set()
    a = angle(c1,c2)
    t = angle2(c1,c2,r)
    return set([
        (
            c1[0]+r*math.cos(a+t),
            c1[1]+r*math.sin(a+t)
        ),
        (
            c1[0]+r*math.cos(a-t),
            c1[1]+r*math.sin(a-t)
        )
    ])

def judge(r):
    P=set()
    for c1,c2 in itertools.product(C,C):
        if c1==c2:
            continue
        P |= cross(c1,c2,r)
    for p in P:
        for c in C:
            if dist2(p,c)>(r**2+e):
                break
        else:
            return True
    return False

def solve():
    under=0
    ok=800
    while ok-under>10**-6:
        m=(ok+under)/2
        if judge(m):
            ok=m
        else:
            under=m
    return ok

print(solve())


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

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

	reverse(s.begin(), s.end());

	string d[4] = { "dream","dreamer","erase","eraser" };

	for (int i = 0; i < 4; i++) {
		reverse(d[i].begin(), d[i].end());
	};

	int t = 1;

	
	for (int i = 0; i < s.size(); ) {
		int t2 = 0;
		for (int j = 0; j < 4; j++) {
			if (s.substr(i, d[j].size()) == d[j]) {
				t2 = 1;
				i += d[j].size();
			}
		}
		
		if (!t2) {
			t = 0;
			break;
		}
	}

	if (t) cout << "YES" << endl;
	else cout << "NO" << endl;


	return 0;
}

Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }
//V,P(大文字)使用不可

const ll INF=1e18;

vector<ll> divisor(ll n){
    vector<ll> res;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            res.push_back(i);
            if(i!=n/i) res.push_back(n/i);
        }
    }
    return res;
}

signed main(){
    ll n;
    cin>>n;
    //vector<ll> a=divisor(n);
    ll ans=0;
    if(n>2) ans=n-1;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            if(i<=n/i-2) ans+=n/i-1;
            if(i!=n/i){
                ll t=n/i;
                if(t<=n/t-2) ans+=n/t-1;
            }
        }
    }
    cout<<ans<<endl;
}

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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define BIT(bit,a,n) for (int bit = a;bit < (1<<n);bit++) // {0, 1, ..., n-1} の部分集合の全探索 // n番目のフラグが立っている状態は (1<<n)

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20

typedef long long ll;
using namespace std;

ll n,y;
int price[] = {10000,5000,1000};
int main() {
    scanf("%lld%lld",&n,&y);
    for(ll i = 0; i < n+1; i++){
        for(ll j = 0; j < n+1; j++){
            if(i+j > n) break;
            ll k = n-(i+j);
            if(price[0]*i+price[1]*j+price[2]*k == y){
                printf("%lld %lld %lld\n",i,j,k);
                return 0;
            }
        }
    }
    printf("-1 -1 -1\n");
    return 0;
}

Measured memory_bytes: 256
import itertools
N=int(input())
S=input()
ans=0
L=dict()
R=dict()
for seq in itertools.product([0,1],repeat=N):
    T0=""
    T1=""
    T2=""
    T3=""
    for i in range(N):
        if seq[i]==0:
            T0+=S[i]
            T2+=S[-i-1]
        else:
            T1+=S[i]
            T3+=S[-i-1]
    a0=len(T0)
    a1=len(T1)
    a2=len(T2)
    a3=len(T3)
    L[(T0,T1)]=L.get((T0,T1),0)+1
    R[(T2,T3)]=R.get((T2,T3),0)+1
for tup in L:
    ans+=L[tup]*R.get(tup,0)
print(ans)


Measured memory_bytes: 174204
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#define Read_Fast    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define PI acos(-1)
#define all(a) a.begin(),a.end()
#define f first
#define s second
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mp make_pair
#define f0(i,n) for(i=0;i<n;i++)
#define f1(i,n) for(i=1;i<n;i++)
#define f1n(i,n) for(i=1;i<=n;i++)
#define szf sizeof()
#define sz size()
#define ln length()
using namespace std;
using ll=long long;
const int N=2e5+5;
//ll cum[N+4];
int main()
{
    string str;
    int n;
    cin>>n>>str;
    int len=str.size();
    if(n>=len)
    {
        cout<<str<<endl;
    }
    else{
        for(int i=0;i<n;i++)
        {
            cout<<str[i];
        }
        cout<<"..."<<endl;
    }
    return 0;
}


Measured memory_bytes: 3592
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://code-festival-2016-quala.contest.atcoder.jp/tasks/codefestival_2016_qualA_c>
問題文============================================================
 高橋君は、英小文字のみからなる文字列 s を持っています。
 高橋君は s に対して、次の操作をちょうど K 回行います。
 
 s から好きな位置の文字をひとつ選び、その文字を次のアルファベットへ変える。
 ただし、z の次のアルファベットは a であるとする。
 
 例えば、aaz の 2 文字目を選んで操作を行うと、aaz → abz となります。
 続けて、abz の 3 文字目を選んで操作を行うと、abz → aba となります。
 
 高橋君は、操作をちょうど K 回行った後の s を、辞書順でできるだけ小さくしたいと考えています。
 操作をちょうど K 回行った後の s のうち、辞書順で最小のものを求めてください。
 
 制約
 1≤|s|≤10^5 である。 ただし、|s| は s の長さを表す。
 s は英小文字のみからなる。
 1≤K≤10^9
=================================================================

解説=============================================================

================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    string s; cin >> s;
    ll K; cin >> K;
    for(auto& c:s){
        if(c == 'a') continue;
        ll t = (26 - (c - 'a'))%26;
        if(K >= t){
            c = 'a';
            K-=t;
        }
    }
    
    s[s.length()-1] = (s[s.length()-1] - 'a' + K)%26 + 'a';
    
    cout << s << endl;
	return 0;
}


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

#define x first
#define y second
#define y0 hi1
#define y1 hi2
#define ll long long
#define mp make_pair
#define pb push_back
#define sqr(a) (a)*(a)
#define ld long double
#define all(a) (a).begin(), (a).end()

using namespace std;

const int inf = 2000000000;
const int N = 1;

int main(){
    int n;
    cin >> n;
    n = 2 * n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a, a + n);
    reverse(a, a + n);

    int ans = 0;
    for(int i = n - 1; i >= 1; i -= 2){
        ans += min(a[i], a[i - 1]);
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    ll n,m,v,p;
    cin >> n >> m >> v >> p;
    Vi a(n);
    rp(i,n) cin >> a.at(i);
    Sort(a);
    ll lim = a.at(p-1);
    ll lowest;
    ll sum=0;
    repi(i,p,n){
        if(a.at(i)<lim-m){
            lowest=i;
            break;
        }
        sum += lim-a.at(i);
        if(i==n-1)lowest=n;
    }
    ll between=lowest-p;
    if(v<=n-between){
        print(lowest);
        return 0;
    }
    for(ll i=lowest-1; i>=p; i--){
        sum-=lim-a.at(i);
        if(m*(v-(n-(i-p+1)))<=sum+(a.at(i)+m-lim)*(i-p+1)){
            print(i+1);
            return 0;
        }
    }
    print(p);
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i,  n) for (int i  =  0; i < (int)(n); ++i)
#define REPR(i,  n) for (int i  =  n - 1; i >= 0; --i)
using namespace std;
#define int long long int
//------------ATCODER TEMPLATE-------------

signed main() {
  int K; cin >> K;
  if (K % 2 == 0) {
    cout << -1 << endl;
    return 0;
  }

  int sum = 0;
  int a = 7;
  for (int i = 0; i < 100000000; ++i) {
    sum += a;
    a = (a * 10) % K;
    sum %= K;

    if (sum % K == 0) {
      cout << i + 1 << endl;
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

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


int main(){
	int N,M,R;
	cin >> N >> M >> R;

	ll d[201][201];

	for(int i=1;i<=N;i++){
		for(int j=1;j<=N;j++){
			d[i][j] = 1000000000;
		}
	}
	int r[200];
	for(int j=0;j<R;j++){
		cin >> r[j];
	}
	for(int j=0;j<M;j++){
		int a,b,c;
		cin >> a >> b >> c;
		d[a][b] = c;
		d[b][a] = c;
	}
	for(int k=1;k<=N;k++){
		for(int i=1;i<=N;i++){
			for(int j=1;j<=N;j++){
				d[i][j] = min(d[i][j],d[i][k]+d[k][j]);
			}
		}
	}

	ll ans = 100000000000;

	vector<int> v(R);
	for(int i=0;i<R;i++) v[i] = i;
	do {
		ll tmp = 0;
		for(int j=1;j<R;j++){
			tmp += d[r[v[j-1]]][r[v[j]]];
		}
		ans = min(tmp, ans);
	} while( next_permutation(v.begin(), v.end()) );     // 次の順列を生成
	
	

	cout << ans << endl;
	

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int K;
  cin >> K;
  vector<ll> All;
  vector<ll> pre;
  vector<ll> nxt;
  for (int i = 1; i < 10; i++) { pre.push_back(i); }
  while (All.size() < K) {
    for (ll v : pre) {
      ll d = v % 10ll;
      All.push_back(v);
      for (ll i = max(0ll, d - 1); i <= min(9ll, d + 1); i++) {
        nxt.push_back(v * 10ll + i);
      }
    }
    swap(pre, nxt);
    nxt.clear();
  }
  sort(all(All));
  // dmp(All);
  cout << All[K - 1] << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();
  return 0;
}


Measured memory_bytes: 8888