akhauriyash/Code-Regression huggingface dataset:
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let mut a: Vec<Card> = Vec::with_capacity(n);
    for _i in 0..n {
        a.push(
            Card {
                suit: iterator.next().unwrap().chars().next().unwrap(),
                number: iterator.next().unwrap().parse().unwrap(),
            }
        )
    }

    let mut b = a.clone();

    quick_sort(&mut a, 0, n as isize - 1);

    b.sort_by_key(|c| c.number);

    let mut is_stable = true;
    for i in 0..n {
        if a[i].suit != b[i].suit {
            is_stable = false;
            break;
        }
    }

    let mut ans = if is_stable {
        String::from("Stable\n")
    } else {
        String::from("Not stable\n")
    };

    for i in 0..n {
        let card = &a[i];
        ans += &format!("{} {}\n", card.suit, card.number);
    }

    return ans.trim().to_string();
}

fn quick_sort(a: &mut Vec<Card>, p: isize, r: isize) {
    if p < r {
        let q = partition(a, p as usize, r as usize);
        quick_sort(a, p, q as isize - 1);
        quick_sort(a, q as isize + 1, r);
    }
}

fn partition(a: &mut Vec<Card>, p: usize, r: usize) -> usize {
    let x = a[r].number;
    let mut i: isize = p as isize - 1;
    for j in p..r {
        if a[j].number <= x {
            i += 1;
            a.swap(i as usize, j)
        }
    }
    a.swap(i as usize + 1, r);
    i as usize + 1
}

#[derive(Clone)]
struct Card {
    suit: char,
    number: usize,
}



Measured memory_bytes: 13192
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  string s;
  cin >> s;
  int len = sz(s);
  rep(i,len-1) {
    if(i < len-1) {
      if(s[i] == s[i+2]) {
        cout << i+1 << " " <<  i+3 << endl;
        return 0;
      }
    }
    if(s[i] == s[i+1]) {
      cout << i+1 << " " << i+2 << endl;
      return 0;
    }
  }
  cout << -1 << " " << -1 <<  endl;
  return 0;
}

Measured memory_bytes: 512
import sys
sys.setrecursionlimit(10 ** 6)


def input():
    return sys.stdin.readline()[:-1]


def main():
    def dfs(now, prev=-1):
        for next in edge[now]:
            if next == prev:
                continue
            score[next] += score[now]
            dfs(next, now)

    N, Q = map(int, input().split())
    edge = [[] for _ in range(N+1)]
    for _ in range(N-1):
        u, v = map(int, input().split())
        edge[u].append(v)
        edge[v].append(u)
    p = []
    x = []
    score = [0] * (N+1)
    for _ in range(Q):
        p, x = map(int, input().split())
        score[p] += x
    dfs(1)
    print(*score[1:])


if __name__ == "__main__":
    main()


Measured memory_bytes: 268428
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

mat G(100010, vec(0));
vector<bool> used(100010, false);
ll dfs(ll v){
    used[v] = true;
    ll res = 0;
    for(ll to : G[v]){
        if(!used[to]){
            res = res ^ (dfs(to) + 1);
        }
    }
    return res;
}
int main(){
    cin>>N;
    rep(i,N-1){
        cin>>A>>B;
        --A, --B;
        G[A].push_back(B);
        G[B].push_back(A);
    }
    ll ans = dfs(0);
    cout<<(ans == 0 ? "Bob" : "Alice")<<endl;
    //cout<<ans<<endl;
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL)
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp> 
//using namespace __gnu_pbds; 
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define trace(x)  cerr << #x << ": " << x << endl;
typedef long long ll;
typedef long double ld;
//const ll MOD = 1e9+7;
void __print(ll x) {cerr << x;}
void __print(ld x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
int main()
{
	fast;
	string s,t;cin>>s>>t;
	ll n=t.size();ll mini=1e17;
	for(ll i=0;i<s.size();i++)
	{
		if(i+n>s.size())break;
		ll ans=0;
		string s1=s.substr(i,n);
		for(ll j=0;j<n;j++)
		{
			if(s1[j]!=t[j])ans++;
		}
		mini=min(mini,ans);
	}
	cout<<mini;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl '\n'
#define rep(i,n) for(int i=0;i<n;i++) 
#define all(v) v.begin(),v.end()
#define F first
#define S second 
const ll MOD=1e9+7;
template<typename ForwardIterator,typename T>
ForwardIterator first_less_than(ForwardIterator first,ForwardIterator last,T val)
{
	auto it=lower_bound(first,last,val);
	return (it==first?first:it);
}

void solve()
{
	string s,t;
	cin>>s>>t;
	ll minres=LLONG_MAX;
	ll n=s.length();
	for(int i=0;i<n;i++)
	{
		if(n-i>=t.length())
		{
			string val=s.substr(i,t.length());
			//cout<<val<<endl;
			ll count=0;
			for(int i=0;i<t.length();i++)
			{
				if(t[i]!=val[i])
				{
					count++;
				}
			}
			minres=min(minres,count);
		}
	}
	cout<<minres<<endl;
}

int main()
{
	ios_base::sync_with_stdio(false); 
  	 cin.tie(NULL);  
	int tt;
	tt=1;
	while(tt--)
	{
		solve();
	}
}


Measured memory_bytes: 3624
def solve():
    s = input()
    num = 1
    for w in s:
        if num %2 == 0:
            if w == 'L' or w == 'U' or w == 'D':
                num+=1
            else:
                print('No')
                return
        else:
            if w == 'R' or w == 'U' or w == 'D':
                num+=1
            else:
                print('No')
                return
    print('Yes')


if __name__ == "__main__":
    solve()

Measured memory_bytes: 3060
#include <cstdio>
#include <iostream>

using namespace std;
int main(){
    int r, D, x2000;
    cin >> r >> D >> x2000;
    int x = x2000;
    for(int i = 0; i < 10; i++){
        x = r*x - D;
        cout << x << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

pair<int,int> sum(string& s,int& i);
pair<int,int> mul(string& s,int& i);
pair<int,int> bracket(string& s,int& i);

bool isdigit(char c){
    return c=='?';
}

pair<int,int> sum(string& s,int& i){
    pair<int,int> ret=mul(s,i);
    while(s[i]=='|'){
        char op=s[i];
        i++;
        pair<int,int> res=mul(s,i);
        pair<int,int> nr;
        nr.first=ret.first+res.first;
        nr.second=min(ret.second,res.second+min(ret.first,ret.second));
        ret=nr;
    }
    return ret;
}
pair<int,int> mul(string&s,int& i){
    pair<int,int> ret=bracket(s,i);
    while(s[i]=='&'){
        char op=s[i];
        i++;
        pair<int,int> res=bracket(s,i);
        pair<int,int> nr;
        nr.first=min(ret.first,res.first+min(ret.first,ret.second));
        nr.second=ret.second+res.second;
       ret=nr;
    }
    return ret;
}

pair<int,int> bracket(string& s,int& i){
    if(isdigit(s[i])){
        ++i;
        return {1,1};
    }
    i++;
    pair<int,int> ret=sum(s,i);
    i++;
    return ret;
}


int main(){
    string s;
    cin>>s;
    int i=0;
    auto res = sum(s,i);
    cout<<res.first<<" "<<res.second<<endl;
    return 0;
}


Measured memory_bytes: 3332
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;




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

	
	vector< pair<ll,P> > v;
	FOR(h,1,151){
		FOR(w,1,151){
			if(w>h)
			v.push_back({h*h+w*w,{h,w}});
		}
	}
	SORT(v);

	ll h,w,i;
	while(1){
		cin >> h >> w;
		if(h+w==0)break;
		pair<ll,P> x;
		x .first = h*h+w*w;
		x.second = {h,w};
		i = POSL(v,x);
		i++;
		P ans = v[i].second;
		cout << ans.first << " " << ans.second << endl;
	}
}



Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long int ll;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

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

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

int main() {
  double n, m;
  cin >> n >> m;
  vector<double> v(n);
  double sum = 0;
  rep (i, n) {
    cin >> v[i];
    sum += v[i];
  }

  sort(v.rbegin(), v.rend());
  // P(sum);
  sum = sum / (4 * m);
  // P(sum);
  int count = 0;
  rep (i, m) {
    if (v[i] < sum) break;
    // P(v[i]);
    count++;
  }
  if (count >= m) Yes;
  else No;
  return 0;
}

Measured memory_bytes: 256
import java.math.*;
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

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

    void run() {

        int n = sc.nextInt();

        int[] arr = new int[4];

        for (int i=0; i<n; i++) {
            String s = sc.next();
            if (s.equals("AC")) {
                arr[0]++;
            } else if (s.equals("WA")) {
                arr[1]++;
            } else if (s.equals("TLE")) {
                arr[2]++;
            } else if (s.equals("RE")) {
                arr[3]++;
            }
        }

        System.out.println("AC x " + arr[0]);
        System.out.println("WA x " + arr[1]);
        System.out.println("TLE x " + arr[2]);
        System.out.println("RE x " + arr[3]);

    }


}



Measured memory_bytes: 58312
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define MAX INT_MAX
#define MIN INT_MIN
#define ss second
#define ff first
//const int mod = 1e9+7;
vector<int> v[100003];
int dp[100003];
int indeg[100003];
void dfs(int curr){
	for(int i:v[curr]){
		dp[i] = max(dp[i], dp[curr]+1);
		--indeg[i];
		if(indeg[i] == 0)
			dfs(i);
	}
	return;
}


int32_t main(){
	int n, m;
	cin >> n >> m;
	//vector<vector<int> > v(m, vector<int>(2));
		for(int i = 0; i < m; ++i){
		int x, y;
		cin >> x >> y;
		v[x].pb(y);
		++indeg[y];
	}
	for(int i = 1; i <= n; i++){
		v[0].pb(i);
		++indeg[i];
	}
	int ans = 0;
	dfs(0);
	for(int i = 0; i <= n; i++){
		//cout << "i-> " << i << " || " << dp[i] << endl;
		ans = max(ans, dp[i]);
	}
	cout << ans-1 << endl;
	return 0;
}


Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    long long n, cnt = 0;
    cin >> n;
    for (int i = 1; i < n + 1; i++) {
        if (i % 5 != 0 && i % 3 != 0) cnt += i;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3580
import sys
import math
from collections import defaultdict, deque, Counter
from copy import deepcopy
from bisect import bisect, bisect_right, bisect_left
from heapq import heapify, heappop, heappush
    
input = sys.stdin.readline
def RD(): return input().rstrip()
def F(): return float(input().rstrip())
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float,input().split()))
def Init(H, W, num): return [[num for i in range(W)] for j in range(H)]


    
    
def main():
    N, M = MI()
    mylist = [[] for i in range(N)]
    for i in range(M):
        a, b = MI()
        mylist[a-1].append(b-1)
        mylist[b-1].append(a-1)
    
    dic = defaultdict(int)
    
    visit = [True]*N
    index = 0

    for i in range(N):
        dq = deque()
        if visit[i]:
            dq.append(i)
            while dq:
                temp = dq.popleft()
                for j in mylist[temp]:
                    if visit[j]:
                        dic[index]+=1
                        visit[j] = False
                        dq.append(j)
            index+=1
                
        
        
        
    #グループ数
    all_group_num = sorted(dic.values())
    res = 0
    all_num = N
    min_num = 0
    
    if sum(all_group_num) < N:
        all_group_num = [1]*(N-sum(all_group_num))+all_group_num
    group = len(all_group_num)

    while True:
        index = bisect_right(all_group_num, min_num)
        all_num -= (group-index)*(all_group_num[index]-min_num)
        res+= all_group_num[index]-min_num
        
        min_num = all_group_num[index]
        
        if all_num == 0:
            break
        
    print(res)

    
    
    
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 102796
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, m) = (v[0], v[1]);
    if (n as i64 - m as i64).abs() > 1 {
        println!("0");
        return;
    }
    let big_int = 1000_000_000 + 7;
    let mut ans = 1;
    if n == m {
        ans += 1;
    }
    for i in 1..n + 1 {
        ans *= i;
        ans %= big_int;
    }
    for i in 1..m + 1 {
        ans *= i;
        ans %= big_int;
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <string.h>

int main(){
	int n,i,j,k,len,flag;
	char str[1028],tmp[8] = "Hoshino";

	scanf("%d",&n);
	getchar();

	for(i = 0;i < n;i++){
		gets(str);
		len = strlen(str);
		j = 0;
		while(j <= len){
			if(str[j] == 'H'){
				flag = 1;
				for(k = 0;k < 7;k++){
					if(str[j+k] != tmp[k]){
						flag = 0;
					}
				}
				if(flag){
					str[j+7-1] = 'a';
				}
			}
			j++;
		}
		printf("%s\n",str);
	}

	return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	ll ans = 0;
	ll n, k;
	cin >> n >> k;
	rep(i, n){
		if(i == 0)ans = k;
		else ans *= k-1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
# ABC 121 B
import numpy as np
N,M,C = list(map(int, input().split()))
B_list = np.array(list(map(int, input().split())))

cnt = 0
for _ in range(N):
    A_list = np.array(list(map(int, input().split())))
    if sum(A_list * B_list) > -C:
        cnt += 1
print(cnt)

Measured memory_bytes: 14044
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		solve(s);
		s.close();
	}

	public static void solve(Scanner s) {
		int n = s.nextInt();
		int[] a = new int[n];

		for (int i = 0; i < n; i++) {
			a[i] = s.nextInt();
		}

		int count = 0;

		for (int i = 0; i < n; i++) {
			int j = a[i];
			if (i == a[j - 1] - 1) {
				count++;
			}
		}

		System.out.println(count / 2);
	}
}

Measured memory_bytes: 32240
#include<cstdio>
#include<algorithm>
int main()
{
	int *a = new int[3];
	for (int i = 0; i < 3; i++)scanf("%d", a + i);
	std::sort(a, a + 3);
	for (int i = 0; i < 2; i++)printf("%d ", a[i]);
	printf("%d\n", a[2]);
	delete[]a;
}


Measured memory_bytes: 2832
N,M = map(int,input().split())
key_list = []
for i in range(M):
  a,b = map(int,input().split())
  bin_int = 0
  c = list(map(int,input().split()))
  for C in c:
    bin_int += 2 ** (C - 1)
  key_list.append([a, bin_int])

n1 = 2 ** N
dp = [[120001 for i in range(n1)] for j in range(M + 1)]
dp[0][0] = 0

for i in range(M):
  dp_i = dp[i]
  dp_i1 = dp[i + 1]
  key = key_list[i]

  for j in range(n1):
    dp_key = dp_i[j]
    dp_i1[j] = min(dp_key, dp_i1[j])
    dp_i1[j | key[1]] = min(dp_key + key[0], dp_i1[j | key[1]])
  # print(dp)
ans = dp[M - 1][n1 - 1]
if ans == 120001:
  print(-1)
else:
  print(dp[M - 1][n1 - 1])

Measured memory_bytes: 80472
N,M=map(int,input().split())
A=[list(map(int,input().split())) for i in range(N)]
A.sort()

num=0
pay=0
for a,b in A:
	if num+b>=M:
		pay+=(M-num)*a
		break
	else:
		pay+=a*b
		num+=b

print(pay)

Measured memory_bytes: 27760
#include<iostream>
#include<cstdio>
#include<complex>
#include<cmath>
using namespace std;
typedef complex<double> xy_t;
int main()
{
  xy_t P[110];
  int N = 0;
  double x,y;
  while(~scanf("%lf,%lf",&x,&y)){
    P[N++] = xy_t(x,y);
  }
  double sum = 0.0;
  for(int i = 0; i + 2 < N; ++i){
    xy_t a = P[0],b = P[i + 1],c = P[i + 2]; 
      sum += (conj(b - a) * (c - a)).imag();
  }
  sum /= 2;
  printf("%.6f\n",abs(sum));
  return 0;
}

Measured memory_bytes: 1244
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<queue>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX 110000

vector<int> G[MAX];
int d[MAX], d2[MAX], con[MAX],con2[MAX];
int N, M, s, t, x, y;

void bfs(int ss, int d[]){
	fill(d,d+N+1,INF);
	queue<int> Q;
	
	d[ss] = 0;
	Q.push(ss);
	
	while(!Q.empty()){
		int f = Q.front(); Q.pop();//cout<<f<<endl;
		// if(f == t) break;
		for(int y : G[f]){
			if(d[y] == INF){
				d[y] = d[f]+1;
				Q.push(y);
			}
		}
	}
}

int solve(){
	int re = 0;
	bfs(s,d);bfs(t,d2);
	for(int i = 1; i <= N; i++){
		if(d[i] != INF)con[d[i]]++;
		if(d2[i] != INF)con2[d2[i]]++;
	}//cout<<" test test "<<endl;
	for(int i = 0; i <= d[t]-2; i++){
		// cout<<i<<" "<<con[i]<<" "<<con2[i]<<endl;
		re += con[i]*con2[d[t]-i-2];
	}
	return re;
}

signed main(){
	cout<<fixed<<setprecision(7);
	
	cin>>N>>M>>s>>t;
	
	

	rep(i,M){
		cin>>x>>y;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	
	cout<<solve()<<endl;
	
	return 0;
}


Measured memory_bytes: 12244
N, M = map(int, input().split())
*P, = map(int, input().split())
*p, = range(N)
def root(x):
    if x == p[x]:
        return x
    y = p[x] = root(p[x])
    return y
def unite(x, y):
    px = root(x); py = root(y)
    if px == py:
        return 0
    if px < py:
        p[py] = px
    else:
        p[px] = py
    return 1

for i in range(M):
    x, y = map(int, input().split())
    x -= 1; y -= 1
    unite(x, y)

pp = [set() for i in range(N)]
qq = [set() for i in range(N)]
for i in range(N):
    r = root(i)
    pp[r].add(i)
    qq[r].add(P[i]-1)

ans = 0
for i in range(N):
    ans += len(pp[i] & qq[i])
print(ans)


Measured memory_bytes: 114924
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin>> n;
  vector<vector<int> > v;
  v = vector<vector<int> >(n, vector<int>(n,0));
  for(int i=0; i<n; ++i){
    int tmp;
    cin >> tmp;
    cin >> tmp;
    for ( int j=0; j<tmp; ++j){
      int to;
      cin >> to;
      v[i][to-1] = 1;
    }
  }
  for(int i=0; i<n; ++i){
    for(int j=0; j<n; ++j){
      cout << v[i][j];
      if( j != n-1) cout << ' ';
    }
    cout << endl;
  }
  return 0;
}
  


Measured memory_bytes: 3156
#include <stdio.h>

int S[500000];
int S2[500000];
int cou = 0;

void merge(int[],int,int);


int main(){

  int i,j,n; 


  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d",&S2[i]);
  }
  
  merge(S2,0,n-1);
  
  for(i = 0; i < n; i++){
    printf("%d",S2[i]);
    if(i != n - 1)printf(" ");
  }
  printf("\n");
  printf("%d\n",cou);
  return 0;
}


void merge(int x[], int left,int right){
  
  int mid,i,j,k;
  
  if(left >= right)
    return;

  mid = (left + right)/2;
   merge(x, left,mid);
   merge(x, mid+1, right);

  for(i= left; i<= mid; i++){
    S[i] = x[i];
  }
 

  for(i= mid + 1, j = right; i <= right; i++,j--){
    S[i] = x[j];
  }

  i = left;
  j = right;

  for(k = left; k <= right; k++){
    cou++;
    if (S[i] <= S[j]){
    x[k] = S[i++];
    }
    else x[k] = S[j--];
  }

} 

Measured memory_bytes: 4508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

vector<pair<char,ll>> run_length_encoding(string s){
    vector<pair<char,ll>> res;
    ll n = s.size();
    char prev = -1;
    ll cur = 1;
    for(ll i = 0; i < n; i++) {
        if(prev == s[i]) cur++;
        else {
            if(prev != -1) res.push_back({prev, cur});
            prev = s[i];
            cur = 1;
        } 
    }
    res.push_back({prev, cur});
    return res;
}

int main(){
    string s;
    ll k;
    cin >> s >> k;
    ll n = s.size();
    auto v = run_length_encoding(s);
    if(v.size() == 1) {
        cout << k * v[0].second / 2 << endl;
        return 0;
    } 
    ll unit = 0;
    for(auto e : v) {
        unit += (e.second / 2);
    }
    auto head = (*v.begin()).second;
    auto tail = (*v.rbegin()).second;
    if((*v.begin()).first == (*v.rbegin()).first){
        cout << k * unit - (head / 2 + tail / 2 - (head + tail) / 2) * (k - 1) << endl;
    }else{
        cout << k * unit << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
import java.util.*;
class Main {
    public static void main(String[] args) {
        try(Scanner sc = new Scanner(System.in)){
            int sec = sc.nextInt();
            int min;
            int hour;
           hour = sec / 3600;
           min = (sec % 3600) / 60;
           sec= sec % 60;
           
           System.out.println(hour + ":" + min + ":" + sec);
        }
    }
}


Measured memory_bytes: 26396
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0};
int dy[8]={0,-1,0,1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n,a,b;cin>>n>>a>>b;
    if((b-a)%2==0)
        cout<<"Alice"<<endl;
    else
        cout<<"Borys"<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 256
import string
numbers = "0123456789"
alphabets = string.ascii_letters # a-z+A-Zをロード
characters = numbers + alphabets
 
def base_cvt(value, n=2):
    try:
        tmp = int(value)
    except:
        raise ValueError('Invalid value:', value)
 
    if n < 2 or n > len(characters):
        raise ValueError('Invalid n:', value)
 
    result = ''
    tmp = int(value)
    while tmp >= n:
        idx = tmp%n
        result = characters[idx] + result
        tmp = int(tmp / n)
    idx = tmp%n
    result = characters[idx] + result
    return result
  
n,k = map(int,input().split())
print(len(base_cvt(n,k)))

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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
#define N 100001
vector<int> par(N);
vector<int> ranks(N);
vector<ll> sizes(N);

void init(int n)
{
	int i;
	rep(i,n)
	{
		par[i]=i;
		ranks[i]=0;
		sizes[i]=1;
	}
}

int find(int x)
{
	if(par[x]==x)return x;
	else return par[x] = find(par[x]);
}

void unite(int x,int y)
{
	x = find(x);
	y = find(y);
	if(x==y)return;
	if(ranks[x]<ranks[y])
	{
		par[x] = y;
		sizes[y] += sizes[x];
	}
	else
	{
		par[y] = x;
		sizes[x] += sizes[y];
		if(ranks[x]==ranks[y])ranks[x]++;
	}
}

ll sizing(int x)
{
	return sizes[find(x)];
}

bool same(int x,int y)
{
	return find(x) == find(y);
}

ll c2(ll i)
{
	if(i==1) return 0;
	else return i*(i-1)/2;
}

int main()
{
	ll n,m;cin>>n>>m;
	vector<int> a(m);
	vector<int> b(m);
	int i;
	rep(i,m)cin>>a[i]>>b[i];
	vector<ll> count(m+1,0);
	init(n+1);
	for(i=m-1;i>=0;i--)
	{
		if(same(a[i],b[i]))
		{
			count[i]=count[i+1];
			continue;
		}
		ll bef=c2(sizing(a[i]))+c2(sizing(b[i]));
		unite(a[i],b[i]);
		ll aft=c2(sizing(a[i]));
		count[i]=count[i+1]+(aft-bef);
	}
	rep(i,m)count[i+1]=c2(n)-count[i+1];
	rep(i,m)cout<<count[i+1]<<endl;
}


Measured memory_bytes: 4480
import sys

readline = sys.stdin.readline

N, M = map(int, readline().split())

k, s = [], []

for i in range(M):
    line = readline().split()
    k.append(int(line[0]))
    s.append(list(map(int, line[1:])))

p = list(map(int, readline().split()))

total = 0
for bits in range(0, 2 ** N):
    flag = True
    for i in range(M):
        bsum = 0
        for b in s[i]:
            bsum += ((bits >> (b - 1)) & 1)
        flag = flag and (bsum % 2 == p[i])
    if flag:
        total += 1

print(total)
            

Measured memory_bytes: 40816
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(val)  no. of elements strictly less than val
// s.find_by_order(i)  itertor to ith element (0 indexed)
typedef vector<vector<ll>> matrix;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
int arr[305][305];
int indx[305];
int cnt[305];
void solve()
{
    ll n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
            cin>>arr[i][j];
    }
    set <int> s;
    for(int i=1;i<=m;i++)
        s.insert(i);
    ll ans=0;
    for(int i=1;i<=n;i++)
    {
        cnt[arr[i][1]]++;
        indx[i]=1;
    }
    for(int i=1;i<=m;i++)
        ans=max(ans,cnt[i]);
    while(true)
    {
        if(s.size()==1)
            break;
        int temp=0;
        int maxi=0;
        for(int i=1;i<=m;i++)
        {
            if(maxi<cnt[i])
            {
                maxi=cnt[i];
                temp=i;
            }
        }
        s.erase(temp);
        cnt[temp]=0;
        for(int i=1;i<=n;i++)
        {
            if(arr[i][indx[i]]==temp)
            {
                while(s.find(arr[i][indx[i]])==s.end())
                    indx[i]++;
                cnt[arr[i][indx[i]]]++;
            }
        }
        ll curr=0;
        for(int i=1;i<=m;i++)
            curr=max(curr,cnt[i]);
        ans=min(ans,curr);
    }
    cout<<ans<<'\n';
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 12544
def main():
    N = int(input())
    A = list(map(int, input().split()))
    d = {}
    r = 0
    for i, v in enumerate(A, start = 1):
        if -i-v in d:
            d[-i-v] += 1
        else:
            d[-i-v] = 1
        if v-i in d:
            r += d[v-i]
    return r
print(main())


Measured memory_bytes: 111572
#include "bits/stdc++.h"
 
typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
using namespace std;
int MOD = 1000000007;

signed main(){
    int a;
    string s;
    cin >> a >> s;
    int cnt = 0;
    int c = 0;
    rep(i,a){
        if(s[i] == 'R')cnt++;
        else c++;
    }
    if(cnt > c)cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0; 
}

// g++ -std=c++14 code1.cpp
// rm -r -f test;oj dl https://yahoo-procon2019-qual.contest.atcoder.jp/tasks/yahoo_procon2019_qual_d
// rm -r -f test;oj dl http://exawizards2019.contest.atcoder.jp/tasks/exawizards2019_a

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int A = int.Parse(str[0]);
		int B = int.Parse(str[1]);
		int C = int.Parse(str[2]);
		int tmp = 0;
		if(A>B){
			tmp = B;
			B = A;
			A = tmp;
		}
		if(B>C){
			tmp = C;
			C = B;
			B = tmp;
		}
		if(A>B){
			tmp = B;
			B = A;
			A = tmp;
		}
		int count = 0;
		while(B<=C-2){
			count += 1;
			B += 2;
		}
		while(A<=B-2){
			count += 1;
			A += 2;
		}
		if(A<B && B<C){
			count += 3;
		} else if(A<B){
			count += 2;
		} else if(B<C){
			count += 1;
		}
		Console.WriteLine(count);
	}
}

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

using namespace std;
using u64 = std::uint_fast64_t;

const u64 MOD = 1000000007;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  vector<bool> broken(N, false);
  for (int i = 0; i < M; i++) {
    int a;
    cin >> a;
    broken[a] = true;
  }

  vector<u64> dp(N + 1, 0);
  dp[0] = 1;
  for (int i = 0; i < N + 1; i++) {
    if (broken[i]) continue;
    if (i - 1 >= 0) dp[i] += dp[i - 1];
    if (i - 2 >= 0) dp[i] += dp[i - 2];
    dp[i] %= MOD;
  }

  cout << dp[N] << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define pp pair<ll,ll>
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=INF;
 
int main() {
    string s,t;
    cin >> s >> t;
    bool tt=true;
    if (s.size()!=t.size()-1) tt=false;
    rep(i,s.size()){
        if (s[i]!=t[i]) tt=false;
    }
    if (tt) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x,y;
  cin >> x >> y;
  bool flg = false;
  for (int i = 0; i <= x; i++){
    for (int j = 0; j <= x; j++){
      if(i*2+j*4==y&&i+j==x){
        flg = true;
      }
    }
  }
  if(flg){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
using ll = long long;
constexpr ll INF = 1LL << 60;

ll N, M, L, R, C;
vector<pair<ll, ll>> g[100010];

int main() {
  cin >> N >> M;
  for(int i = 0; i < M; ++i) {
    cin >> L >> R >> C;
    --L, --R;
    g[L].emplace_back(R, C);
  }
  for(int i = 1; i < N; ++i) 
    g[i].emplace_back(i-1, 0);

  vector<ll> dist(N, INF);
  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> pq;
  dist[0] = 0;
  pq.emplace(0, 0);
  while(pq.size()) {
    ll d = pq.top().first;
    ll v = pq.top().second;
    pq.pop();
    for(auto next : g[v]) {
      ll nv = next.first;
      ll nc = next.second;
      if(dist[nv] > d + nc) {
        dist[nv] = d + nc;
        pq.emplace(dist[nv], nv);
      }
    }
  }
  if(dist[N-1] == INF) cout << -1;
  else cout << dist[N-1];
  return 0;
}

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

using namespace std;

int n;
long long a[1111], b[1111];

int main(){
//	freopen("input.inp", "r", stdin);
	scanf("%d",&n);
	for(int i = 1; i <= n; ++i) scanf("%lld%lld",&a[i],&b[i]);
	for(int i = 2; i <= n; ++i){
		long long x = max(a[i - 1] / a[i], b[i - 1] / b[i]);
		if (x == 0) continue;
		long long c = a[i], d = b[i];
		a[i] *= x;
		b[i] *= x;
		if (a[i] < a[i - 1] || b[i] < b[i - 1])
			a[i] += c, b[i] += d;
	}
	printf("%lld",a[n] + b[n]);
	return 0;
}

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

using namespace std;

const int N = 1e4 + 2;
const int mod = 1e9 + 7;

int d, n, ans, dp[N][105], pref[N];
string s;

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

      n = s.size();
      s = ' ' + s;

      for(int i = 1; i <= n; i ++){
            pref[i] = pref[i - 1] + s[i] - '0';
      }

      dp[0][0] = 1;

      for(int i = 1; i < n; i ++){
            for(int j = 0; j <= 9; j ++){
                  if(i == 1 && !j)
                        continue;
                  for(int k = 0; k < d; k ++){
                        int to = (k + j) % d;
                        dp[i][to] = (dp[i - 1][k] + dp[i][to]) % mod;
                  }
            }
            ans = (ans + dp[i][0]) % mod;
      }

      memset(dp, 0, sizeof(dp));
      dp[0][0] = 1;

      for(int i = 1; i < n; i ++){
            for(int j = 0; j <= 9; j ++){
                  for(int k = 0; k < d; k ++){
                        int to = (k + j) % d;
                        dp[i][to] = (dp[i - 1][k] + dp[i][to]) % mod;
                  }
            }
      }

      for(int i = 1; i <= n; i ++){
            for(int j = 0; j < s[i] - '0'; j ++){
                  if(i == 1 && !j)
                        continue;
                  int sum = (pref[i - 1] + j) % d;
                  ans = (ans + dp[n - i][(d - sum + d) % d]) % mod;

            }
      }

      if(pref[n] % d == 0)
            ans = (ans + 1) % mod;

      cout << ans << endl;
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    ll l, r;
    cin>>l>>r;
    ll  si = r - l + 1;
    if(si >= 2019)
    {
        cout<<0;
    }
    else
    {
        ll ans = inf;
        ll i, j;
        FOR(i, l, r+1)
            FOR(j, i+1, r+1)
            {
                ll cur = (i%2019 * j%2019)%2019;
                ans = MIN2(ans, cur);
            }
        cout<<ans;
    }
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int solve(){
  	char c;
  	int cnt[50] = {};
  	for(int i = 0; i < 4; i++){
		cin >> c;
      	cnt[c-'A']++;
    }
  	for(int i = 0; i < 50; i++){
		if(cnt[i] != 0 && cnt[i] != 2)return 0;
    }
  	return 1;
}
 
 
int main(){
	cout << (solve() ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>  // std::greater<T>()

using namespace std;

// macro
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define DESCEND greater<int>()  // sort 降順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから

// func declaration
template <class T> void printVec(vector<T>);


int main() {
    string str;
    cin >> str;
    cout << str.at(0) << str.size() - 2 <<str.at(str.size() - 1) << endl;
    return 0;
}

// function
template <class T> void printVec(vector<T> vec) {
    // 1要素ずつ、空白・改行なしで出力
    REP(i, vec.size()) {
        cout << vec.at(i);
    }
    cout << endl;
}


Measured memory_bytes: 256
import math

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

start = 0
end = max(a)
middle = (end+start) // 2

while end - start > 1:
    count = 0
    for i in range(n):
        if a[i] > middle:
            count += math.ceil(a[i] / middle) - 1
            
    if count <= k:
        end = middle
    else:
        start = middle
        
    middle = (end+start) // 2
    
print(end)

Measured memory_bytes: 104356
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(int i=num, i##_len=(n); i<i##_len; ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define print(x) (cout << (x) << endl)
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
#define fs first
#define sc second
// 多倍長
#include <boost/rational.hpp>
#include <boost/multiprecision/cpp_int.hpp>
using boost::rational;
using boost::multiprecision::cpp_int;

const int INF = 1e9;
const ll LLINF = 1e16;
const ll MOD = 1e9+7;
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
 
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 

// 指定した文字cが文字列に何文字入ってるか
ll stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c);
}


// 割り算の切り上げ処理
template<typename T>
T rp(T a, T b) {
  return (a + b - 1) / b;
}

// 桁和
template<typename T>
T digsum(T n) {
    T res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

// 回文判定
bool kai (string s) {
    string t{s};
    reverse(begin(t), end(t));
    return s == t;
}

using pint = pair<int, int>;
using pll = pair<ll, ll>;

#define MAX 50

string printString(ll n) 
{ 
    char str[MAX];
    ll i = 0;
  
    while (n > 0) { 
        ll rem = n % 26; 
  
        if (rem == 0) { 
            str[i++] = 'z'; 
            n = (n / 26) - 1; 
        } 
        else
        { 
            str[i++] = (rem - 1) + 'a'; 
            n = n / 26; 
        } 
    } 
    str[i] = '\0'; 
  
    reverse(str, str + strlen(str));  
  
    return str; 
} 

int main(void)
{
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    ll n;
    cin >> n;
    string ans = printString(n);
    print(ans);




}




Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(void){
  int N; cin >> N;
  vector<int> A(N),B(N),C(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < N; i++) cin >> B[i];
  for (int i = 0; i < N; i++) cin >> C[i];
  sort(A.begin(),A.end()); sort(B.begin(),B.end()); sort(C.begin(),C.end());

  ll ans = 0;
  for (int i = 0; i < N; i++){
    ll A_lower = lower_bound(A.begin(),A.end(),B[i]) - A.begin();
    ll C_upper = C.end() - upper_bound(C.begin(),C.end(),B[i]);
    ans += A_lower * C_upper;
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <iomanip>

using namespace std;

int main() {
    double n, m, d;
    cin >> n >> m >> d;
    cout << setprecision(15) << (d == 0 ? (m - 1) / n : 2 * (n - d) / (n * n) * (m - 1)) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

//変数
ll N, M;
vector<int> vec(5);
ll k;

//解法
void solve() {

	ll ans = true;

	rep(i, 4) {
		rep(j, 4-i) {
			if (abs(vec[i] - vec[4-j]) > k) ans = false;
		}
	}
	cout << (ans ? "Yay!" : ":(");

	return;
}

int main() {

	//入力
	rep(i, 5) cin >> vec[i];
	cin >> k;

	solve();
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int main() {
  int a, b;
  cin >> a >> b;
  if (a == b) cout << a * 2 << endl;
  else cout << max(a, b) * 2 - 1 << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val s = sc.next()
  val t = sc.next()

  var count = 0
  for (i in 0 until 3) {
    if (s[i] == t[i]) {
      count++
    }
  }
  println(count)
}



Measured memory_bytes: 29472
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair <int, int>;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
 string T;
 cin >> T;
 int cnt_D = 0;
 int cnt_PD = 0;
 rep(i, T.size()){
   if(T[i] == '?') T[i] = 'D';
 }

 cout << T << endl;
}


Measured memory_bytes: 3720
//----------------------------------------------------------------------
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
//----------------------------------------------------------------------

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

int main(void) {
    ll n, k;
    cin >> n >> k;
    if(n > k) {
        n = n % k;
    }
    cout << min(n, k - n) << endl;
    return 0;
}

Measured memory_bytes: 384
s=input()

cur=0
peek=0
length=0
for i in range(len(s)):
    if s[i] in ("A", "C", "G", "T"):
        peek=i
        l=(peek-cur)+1
        if length < l:
            length = l
    else:
        cur=i+1
        peek=i+1

print(length)


Measured memory_bytes: 2940
l, r = map(int, input().split())
ans = 10 ** 9
for i in range(l, r + 1):
  for j in range(l, r + 1):
    if i == j:
      continue
    ans = min(ans, (i * j) % 2019)
    if ans == 0:
      print(ans)
      exit()

print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <bitset>
#include <map>
#include <math.h>
#include <utility>

using namespace std;

int main(){

    int N, ans = 0;
    cin >> N;

    vector<int> d(N);
    for (int i = 0; i < N; i++){
        cin >> d[i];
    }

    for (int i = 0; i < N; i ++){
        for (int j = i+1; j < N; j++){
            ans += d[i] * d[j];
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256