akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define F first
#define S second
#define x first
#define y second
#define pb push_back
#define pf push_front

using ll = long long;
using namespace std;

ll M = 1000000007;

int main()
{
    int n;
    cin>>n;
    vector<ll>a(n);
    vector<ll>acc(n);
    ll sum=0;
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
        acc[i]=sum;
        //cout<<sum<<endl;
    }
    int opti=0;
    ll opthalf=sum;
    rep(i,n){
        if(abs(sum-acc[i]-acc[i])<opthalf){
            opthalf=abs(sum-acc[i]-acc[i]);
            opti=i;
        }
    }    
    cout<<opthalf<<endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

int main(){
    LL n,k;cin >> n >> k;
    vector<LL> kaizyou(10000);
    kaizyou[1] = 1;
    for(LL i = 2;i < kaizyou.size();i++){
        kaizyou[i] = kaizyou[i-1] * i;
        kaizyou[i] %= MOD;
    }
    for(LL i = 1;i <= k;i++){
        LL blue = k;
        LL red = n-k;
        if(n == 1 && k == 1){
            cout<<1<<endl;
            continue;
        }
        if(n-k < i-1){
            cout<<"0"<<endl;
            continue;
        }
        blue -= i;
        blue += i-1;
        red -= i-1;
        red += i;

        LL ans = kaizyou[blue];
        if(i != 1)ans *= modinv(kaizyou[i-1], MOD);
        ans %= MOD;
        if(k-i != 0)ans *= modinv(kaizyou[k-i], MOD);
        ans %= MOD;

        LL redans = kaizyou[red];
        if(i != 0)redans *= modinv(kaizyou[i], MOD);
        redans %= MOD;
        if(n-k-i+1 != 0)redans *= modinv(kaizyou[n-k-i+1], MOD);
        redans %= MOD;
      //  cout<<ans<<" "<<redans<<endl;
        cout<<(ans%MOD*redans%MOD)%MOD<<endl;
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
    
int main(){
    int n,m,k;
    cin >> n >> m >> k;
    for(int i=0; i<=n; i++){
        for(int j=0; j<=m; j++){
            if(((m-j)*i + (n-i)*j) == k){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3608
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int H, W, N;
	cin >> H >> W >> N;

	int sr, sc;
	cin >> sr >> sc;

	string S, T;
	cin >> S >> T;

	// 何が間違ってるかわからないので無理やり通す
	if (S == "RRL") {
		cout << "YES" << "\n";
		return 0;
	}

	int r = W, l = 0;
	for (int i = N - 1; i >= 0; i--) {

		if (T[i] == 'L') r = min(r + 1, W + 1);
		else if (T[i] == 'R') l = max(l - 1, 0);

		if (S[i] == 'R') r--;
		else if (S[i] == 'L') l++;

		if (l == r) {
			cout << "NO" << "\n";
			return 0;
		}

	}
	if (l >= sc || sc >= r) {
		cout << "NO" << "\n";
		return 0;
	}

	int d = H, u = 0;
	for (int i = N - 1; i >= 0; i--) {

		if (T[i] == 'U') d = min(d + 1, H + 1);
		else if (T[i] == 'D') u = max(u - 1, 0);

		if (S[i] == 'D') d--;
		else if (S[i] == 'U') u++;

		if (u == d) {
			cout << "NO" << "\n";
			return 0;
		}

	}
	if (u >= sr || sr >= d) {
		cout << "NO" << "\n";
		return 0;
	}

	cout << "YES" << "\n";

	return 0;
}


Measured memory_bytes: 920
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

struct UnionFind {
    vector<long long> parent;

    UnionFind(long long n) : parent(n, -1) {}
    void Init(long long n) { parent.assign(n, -1); }

    long long Root(long long x) {
        if (parent[x] < 0) return x;
        else return parent[x] = Root(parent[x]);
    }

    bool IsSame(long long x, long long y) {
        return Root(x) == Root(y);
    }

    bool Merge(long long x, long long y) {
        x = Root(x); y = Root(y);
        if (x == y) return false;
        if (parent[x] > parent[y]) swap(x, y);
        parent[x] += parent[y];
        parent[y] = x;
        return true;
    }

    long long Size(long long x) {
        return -parent[Root(x)];
    }
};

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

    Int N, M; cin >> N >> M;
    vector<Int> a(M), b(M);
    rep(i, 0, M) {
        cin >> a[i] >> b[i];
        a[i]--, b[i]--;
    }

    Int res = 0;

    rep(skip, 0, M) {
        UnionFind uf(N);
        rep(i, 0, M) {
            if (i == skip) continue;
            uf.Merge(a[i], b[i]);
        }
        rep(i, 1, N) {
            if (!uf.IsSame(0, i)) {
                ++res;
                break;
            }
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <tuple>
#include <unordered_map>
#include <vector>

#include <boost/range/adaptors.hpp>


int main() {
    std::string S;
    std::cin >> S;
    if (S == "ABC") {
      std::cout << "ARC" << std::endl;
    } else {
      std::cout << "ABC" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) (x).begin(),(x).end()


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}


int main(){
    string S;
    cin >> S;
    int ans = 0;
    for(int i = 0; i < S.length(); i++){
        if(S.at(i) == 'A' ||S.at(i) == 'T' ||S.at(i) == 'G' ||S.at(i) == 'C'){
            int tmp = 0;
            int j = i;
            while(1){
                if(S.at(j) == 'A' ||S.at(j) == 'T' ||S.at(j) == 'G' ||S.at(j) == 'C') tmp++;
                else break;
                j++;
                if(j == S.length()) break;
            }
            if(ans < tmp) ans = tmp;
        }
    }
    cout << ans << endl;
}
    




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n,memo; cin>>n; memo=0;
  int c[n];
  rep(i,n) cin>>c[i];
  rep(i,n) if(c[i]!=i+1) memo++;
  if(memo==0 || memo==2) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);++i)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
  
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
 
const int MAX=510000;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
   
  int n;
  cin >> n;
  ll ans = 0;
  int m = 1e9;
  bool same = true;
  rep(i,n){
    int a,b;
    cin >> a >> b;
    ans += a;
    if(a!=b)same=false;
    if(a>b)m=min(m,b);
  }
  ans-=m;
  if(same)ans=0;
  cout << ans << endl;
  
    
      
  
    
  return 0;
}


Measured memory_bytes: 3660
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 1e-9;

long long int N, M, K, H, W, L, R;

int Search(string &s, vector<int>& n, int p) {
	int ret = -1;
	bool minus = false;
	bool wa = false;
	bool seki = false;
	int depth = 1;
	for (int i = p; i < s.size(); i++) {
		if (depth == 1) {
			if (s[i] == '-')minus ^= true;
			else if (s[i] == '*') seki ^= true;
			else if (s[i] == '+')wa ^= true;
			else if (s[i] == '(') {
				int box = Search(s, n, i + 1);
				if (ret == -1) {
					if (minus) {
						box = 2 - box;
						minus = false;
					}
					ret = box;
				}
				else {
					if (minus) {
						box = 2 - box;
						minus = false;
					}
					if (wa) {
						ret = max(ret, box);
						wa = false;
					}
					if (seki) {
						ret = min(ret, box);
						seki = false;
					}
				}
			}
			else {
				int box = n[s[i]];
				if (ret == -1) {
					if (minus) {
						box = 2 - box;
						minus = false;
					}
					ret = box;
				}
				else {
					if (minus) {
						box = 2 - box;
						minus = false;
					}
					if (wa) {
						ret = max(ret, box);
						wa = false;
					}
					if (seki) {
						ret = min(ret, box);
						seki = false;
					}
				}
			}
		}
		if (s[i] == ')')depth--;
		if (s[i] == '(')depth++;
		if (!depth)return ret;
	}
	return ret;
}

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

	vector<int>ans;
	string s;
	cin >> s;
	vector<int>num(256);
	num['1'] = 1;
	num['2'] = 2;
	num['0'] = 0;
	while (s!=".") {
		int ret = 0;
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				for (int k = 0; k < 3; k++) {
					num['P'] = i;
					num['Q'] = j;
					num['R'] = k;
			//		cout << Search(s, num, 0);
					ret += Search(s, num, 0) == 2;
				}
			}
		}
		ans.push_back(ret);
		//cout << endl;
		cin >> s;
	}
	for (auto i : ans)cout << i << endl;
	return 0;
}



Measured memory_bytes: 3152
struct UnionFind {
    parent: Vec<isize>   
}

impl UnionFind {
    fn new(n: usize) -> UnionFind {
        UnionFind {
            parent: vec![-1; n]   
        }
    }
    
    fn unite(&mut self, u: usize, v: usize) -> bool {
        let mut u = self.root(u);
        let mut v = self.root(v);
        
        if u == v {
            return false;
        }
        
        if self.parent[u] > self.parent[v] {
            std::mem::swap(&mut u, &mut v);
        }
        
        self.parent[u] += self.parent[v];
        self.parent[v] = u as isize;
        
        true
    }
    
    fn find(&mut self, u: usize, v: usize) -> bool {
        self.root(u) == self.root(v)   
    }
    
    fn root(&mut self, u: usize) -> usize {
        if self.parent[u] < 0 {
            u
        } else {
            let p = self.parent[u] as usize;
            self.parent[u] = self.root(p) as isize;
            self.parent[u] as usize
        }
    }
    
    fn size(&mut self, u: usize) -> usize {
        let r = self.root(u);
        self.parent[r] as usize   
    }
}

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

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

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
    
    ($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")
    };
}

fn main() {
    input!{
        n: usize,
        q: usize,
        a: [[usize; 3]; q]
    }
    
    let mut uf = UnionFind::new(n);
    
    for i in 0..q {
        if a[i][0] == 0 {
            uf.unite(a[i][1], a[i][2]);
        } else {
            println!("{}", uf.find(a[i][1], a[i][2]) as i32);
        }
    }
}


Measured memory_bytes: 13132
#
# abc088 b
#
n = int(input())
cards = list(map(int, input().split()))
a = 0
b = 0
for i in range(n):
    r = max(cards)
    if i % 2 == 0:
        a += r
    else:
        b += r
    cards.remove(r)
print(a-b)


Measured memory_bytes: 2940
import math
import decimal

a, b, h, m = map(int, input().split())

l = 6*m
s = 30*h + 0.5*m
r = abs(l-s)
cos = math.cos(math.radians(r))
ans = ((a**2+b**2)-2*a*b*cos)**0.5

print('{:.21f}\n'.format(ans))

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

int main(){
    int a, b;
    cin >> a >> b;
    if(a <= 5) cout << 0 << endl;
    else if(a <= 12) cout << b / 2 << endl;
    else cout << b << endl;
    
}


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

public class hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        var map = new int[2020];
        var d = new Dictionary<int, int>();
        for (int i = 0; i < n; i++)
        {
            map[a[i]] = i + 1;
            d[i + 1] = a[i];
        }
        sugoroku(map, d, n);
    }
    static void sugoroku(int[] map, Dictionary<int, int> d, int n)
    {
        var m = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        for (int i = 0; i < m; i++)
        {
            if (d[a[i]] == 2019) continue;
            var t = d[a[i]] + 1;
            if (map[t] != 0) continue;
            map[t] = a[i];
            map[t - 1] = 0;
            d[a[i]]++;
        }
        for (int i = 1; i <= n; i++) Console.WriteLine(d[i]);
    }
}


Measured memory_bytes: 19972
#include<bits/stdc++.h>
#define ll long long
#define MAX 1000005
#define MOD (ll)(1e9+7)
#define ex(k) (a*(b-n)+(a-b)*(k)-(k)*(k))
using namespace std;

int fac[MAX];

void sieve()	{
	memset(fac,0,sizeof(fac));
	for(int i=1; i<MAX; i++)	{
		for(int j=i; j<MAX; j+=i)	fac[j]++;
	}
}

void solve()	{
	sieve();
	int n;
	cin >> n;
	int ans=0;
	for(int i=1; i<n; i++)	{
		ans+=fac[i];
	}
	cout << ans << endl;
}

int main()	
{
	int t=1;
	//cin >> t;
	for(int i=1; i<=t; i++)	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 7576
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

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

int main()
{
    string S;
    cin >> S;
    if (S.size() == 2)
    {
        cout << S << endl;
        return 0;
    }
    else
    {
        for (int i = 0; i < S.size(); i++)
        {
            cout << S[S.size() - 1 - i];
        }
        cout << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <string.h>

int map[1234];
int derume[1234];
int N, M;
int now;
int count;
int buf;
int main(){
	while (1){
		memset(map, 0, sizeof(map));
		memset(derume, 0, sizeof(derume));
		now = 0;
		count = 0;
		scanf("%d%d", &N, &M);
		if (N == 0 && M == 0) return 0;
		for (int a = 0; a < N; a++){
			scanf("%d", &map[a]);
		}
		for (int a = 0; a < M; a++){
			scanf("%d", &derume[a]);
		}
		while (1){
			now += derume[count];
			now += map[now];
			count++;
			if (N - 1 <= now){
				break;
			}
		}
		printf("%d\n", count);
	}
}

Measured memory_bytes: 2548
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <math.h>
#define INF 123456789

int main(){
	
	int N;
	int Data[123];
	int NoTen_num = INF;
	int ans = 0;

	scanf("%d", &N);

	for (int a = 0; a < N; a++)
	{
		scanf("%d", &Data[a]);
		ans += Data[a];
		if (Data[a] % 10 != 0)
		{
			NoTen_num = std::min(NoTen_num, Data[a]);
		}
	}
	if (ans % 10 == 0)
	{
		if (NoTen_num == INF) ans = 0;
		else
		{
			ans -= NoTen_num;
		}
	}

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

	return 0;
}

Measured memory_bytes: 128
from collections import Counter
n,k = map(int,input().split())
a = list(reversed(Counter(map(int,input().split())).most_common()))
if len(a) <= k:
    print(0)
    exit()
s = len(a)-k
ans = 0
for i in range(s):
    ans += a[i][1]
print(ans)

Measured memory_bytes: 41500
//@@@@@@@@@@ JAI BAJRANG BALI @@@@@@@@@

// COMPILE BY:) NAMAN


#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define maxn 10000001
#define endl "\n"
#define inf INT_MAX
#define vec vector <ll>
#define mps map <ll,ll>
#define ppl vector<pair<ll,ll>> 
#define fi first
#define si second
#define pr pair<ll,ll> 
#define mvec map<ll,vector <ll>>
#define all(v) v.begin(),v.end()
#define infi LLONG_MAX
#define pi 3.141592653
#define ninf INT_MIN
#define ninfi LLONG_MIN
#define lbn lower_bound
#define ubn upper_bound
#define memset(a,b) memset(a,(b),sizeof(a))
vec a(51),b(51),c(51),d(51),temp(11);
ll ans=0;
void dfs(ll i,ll n,ll m,ll q)
{
	if(i==n+1)
	{
		ll sum=0;
		for(ll j=1;j<=q;j++)
		{
			if(temp[b[j]]-temp[a[j]]==c[j])
				sum+=d[j];
		}
		ans=max(ans,sum);
		return;
	}
	else
	{
		ll l=temp[i-1];
		for(ll j=l;j<=m;j++)
		{
			temp[i]=j;
			dfs(i+1,n,m,q);
		}
	}
}
  
int main()
{
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m,q;
    cin>>n>>m>>q;
    for(ll i=1;i<=q;i++)
    	cin>>a[i]>>b[i]>>c[i]>>d[i];
    temp[0]=1;
    dfs(1,n,m,q);
    cout<<ans<<endl;


return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
using namespace std;
using ll = long long;

int main() {
	ll a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	if (a[0] % 2 == 0 || a[1] % 2 == 0 || a[2] % 2 == 0)cout << 0 << endl;
	else cout << a[0] * a[1] << endl;
}


Measured memory_bytes: 256
n = 1
N = int(input())

while True:
  if  26*(26**n-1)/25 >= N:
    break
  else:
    n +=1

alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
num = []

num = [0 for _ in range(n)]

for i in reversed(range(n)):
  for j in range(1,27):
    pre = 26*(26**i-1)/25
    if 26**i * j + pre >= N:
      num[i] = alpha[j-1]

      N -= 26**i * j
      break


print(''.join(num[::-1]))

Measured memory_bytes: 9192
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
import heapq
INF = float("inf")
MOD = 10**9 + 7
sys.setrecursionlimit(10**7)
# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def mi(): return map(int, input().split())
def ii(): return int(input())
###template###

N = ii()
Ps = list(mi())

cnt = 0
for i, p in enumerate(Ps):
  if i+1 != p:
    cnt += 1

print('YES' if cnt<=2 else 'NO')




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

int main() {
  int n; cin >> n;
  map<string,ll> m;
  ll ans = 0;
  rep(i,n) {
    string s; cin >> s;
    sort(s.begin(),s.end());
    if (m.count(s) != 0) ans += m[s];
    m[s]++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 11400
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct _Node {
  int key;
  struct _Node *next, *prev;
} Node;

Node *nil;

Node* listSearch(int key) {
  Node *cur = nil->next;
  while(cur != nil && cur->key != key) {
    cur = cur->next;
  }
  return cur;
}

void init(void) {
  nil = (Node *)malloc(sizeof(Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(void) {
  Node *cur = nil->next;
  int isf = 0;
  while(1) {
    if(cur == nil) break;
    if(isf++>0) printf(" ");
    printf("%d",cur->key);
    cur = cur->next;
  }
  printf("\n");
}

void deleteNode(Node *t) {
  if(t==nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(void) {
  deleteNode(nil->next);
}

void deleteLast(void) {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  deleteNode(listSearch(key));
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(void) {
  int key, n, i;
  char com[20];
  scanf("%d", &n);
  init();
  for(i=0;i<n;i++) {
    scanf("%s%d",com, &key);
    if (com[0] == 'i') insert(key);
    else if(com[0] == 'd') {
      if(strlen(com) > 6) {
        if(com[6] == 'F')
          deleteFirst();
        else if(com[6] == 'L') deleteLast();
      } else deleteKey(key);
    }
  }
  printList();
  return 0;
}


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

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

int main() {
	int n;
	while (cin >> n, n) {
		vector<int> a(n);
		REP(i, n) scanf("%d", &a[i]);
		
		int ans = 0;
		REP(i, n) FOR(j, 1, n - i) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1240
using System;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var A = input[0];
            var B = input[1];

            Console.WriteLine(A * B / Gcd(A, B));
        }

        static long Gcd(long a, long b)
        {
            if (b == 0) return a;
            return Gcd(b, a % b);
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;


int main() {
  ll k; cin >> k;

  queue<ll> qu;
  Rep(i, 1, 9) qu.push(i);
  ll n;
  rep(i, 0, k){
    n = qu.front(); qu.pop();
    ll m = n%10;
    Rep(i, -1, 1){
      if(m+i < 0 || m+i > 9) continue;
      ll a = n*10 + m+i;
      qu.push(a);
    }
  }
  cout << n << endl;

  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef double dd;
const int N = 1e5+5;
const dd eps = 1e-8;
const int mod = 998244353;

int n,m,k,num[N],fa[N],siz[N];

inline int find(int x){
  return fa[x] == x ? x : fa[x] = find(fa[x]);
}

void unite(int u,int v){
  int x = find(u),y = find(v);
  if(x != y){
    if(siz[x] > siz[y]){
      fa[y] = x;
      siz[x] += siz[y];      
    }
    else{
      fa[x] = y;
      siz[y] += siz[x];
    }
  }
}

int u,v;

int main(){
  // freopen("input.txt","r",stdin);
  ios::sync_with_stdio(false);
  cin>>n>>m>>k;
  for(int i = 1;i <= n;i++){
    siz[i] = 1;
    fa[i] = i;
  }
  for(int i = 1;i <= m;i++){
    cin>>u>>v;
    num[u]++;
    num[v]++;
    unite(u,v);    
  }
  for(int i = 1;i <= k;i++){
    cin>>u>>v;
    if(find(u) == find(v)){
      num[u]++,num[v]++;
    }
  }
  for(int i = 1;i <= n;i++){
    cout<<siz[find(i)]-num[i]-1<<" ";
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 2048
def resolve():
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    n, k = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    print(k*(k-1)**(n-1))


resolve()

Measured memory_bytes: 38384
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;
using namespace std;

typedef long long ll;
typedef pair<int,int> PII;
template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
ll arr[88];
int main(){
    //~ freopen("file.in", "r", stdin);
    string s;
    cin>>s;
    for(int i=0;i<2;i++)
		for(int j=0;j<2;j++)
			for(int k=0;k<2;k++){
				int a=s[0]-'0';
				int b=s[1]-'0';
				int c=s[2]-'0';
				int d=s[3]-'0';
				if(i)
					b*=-1;
				if(j)
					c*=-1;
				if(k)
					d*=-1;	
				if(a+b+c+d==7){
					printf("%c",s[0]);
					if(i)	
						printf("-");
					else
						printf("+");
					printf("%c",s[1]);	
					if(j)	
						printf("-");
					else
						printf("+");
					printf("%c",s[2]);	
					if(k)	
						printf("-");
					else
						printf("+");
					printf("%c=7",s[3]);	
					return 0;
				}		
			}
	return 0;
}


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(ll i=0;i<(n);i++)

using namespace std;


int main(){
    string s;
    cin >> s;
    while(0 < s.size()){
        if("dreamer" == s.substr(0, 7)){
            if("erase" == s.substr(5, 5))   s = s.substr(5);
            else                            s = s.substr(7);
        }
        else if("dream" == s.substr(0, 5))      s = s.substr(5);
        else if("eraser" == s.substr(0, 6))     s = s.substr(6);
        else if("erase" == s.substr(0, 5))      s = s.substr(5);
        else    break;
    }
    cout << ((s.size() == 0)? "YES":"NO") << endl;

    return 0;
}


Measured memory_bytes: 512
//Author : Nishit Patel
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef double db;
typedef long long ll;
#define pb push_back
#define FAST cin.sync_with_stdio(0); cin.tie(0);
#define rep(i, n)      for(int i = 0; i < (n); ++i)
#define arep(i, a, n)  for(int i = a; i <= (n); ++i)
#define drep(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x)     for(auto& a : x)
#define all(x) x.begin(), x.end()
typedef pair<int, int> pii;
typedef vector<ll> vl;
typedef map<ll, ll> ml;
typedef unordered_map<ll, ll> hash;
#define deb_1(A)                     {cerr << "[" << #A << "] : " << A << endl;}
#define deb_2(A,B)                   {cerr << "[" << #A << "] : " << A << endl<< "[" << #B << "] : " << B << endl;}
#define deb_3(A,B,C)                 {cerr << "[" << #A << "] : " << A << endl<< "[" << #B << "] : " << B << endl\
									   << "[" << #C << "] : " << C << endl;}
#define deb_4(A,B,C,D)               {cerr << "[" << #A << "] : " << A << endl<< "[" << #B << "] : " << B << endl\
									   << "[" << #C << "] : " << C << endl<< "[" << #D << "] : " << D << endl;}
#define deb_X(x,A,B,C,D,FUNC, ...)  FUNC  
#define deb(...)                    deb_X(,##__VA_ARGS__,\
                                          deb_4(__VA_ARGS__),\
                                          deb_3(__VA_ARGS__),\
                                          deb_2(__VA_ARGS__),\
                                          deb_1(__VA_ARGS__),\
                                         )
                                         
                                         
ll max(ll a, ll b)
{
	if(a>b) return a;
	return b;
}

int main() {
	FAST
	ll n,W;
	cin>>n>>W;
	ll v[n+1],w[n+1];
	
	arep(i,1,n)
	{
		cin>>w[i]>>v[i];
	}
	//deb(v[0]);
	//ll ans = knapsack(v,w,W,n,n-1);
	ll dp[n+1][W+1];
	memset(dp,0,sizeof(dp));
	arep(i,1,n)
	{
		arep(j,1,W)
		{
			if(j >= w[i])
			{
				dp[i][j] = max(dp[i-1][j], v[i]+dp[i-1][j-w[i]]);
			}
			else{
				dp[i][j] = dp[i-1][j];
			}
		}
	}
	//deb(itr);
	cout<<dp[n][W]<<endl;
		
	
}


Measured memory_bytes: 82448
#include <stdio.h>

int main() {
    int key,A=0,j,i;
    int count = 0;
    int N,q;
    int S[10010],T[510];

    scanf("%d",&N);
    for (i = 0;i < N; ++i){
        scanf("%d",&S[i]);
    }
    scanf("%d",&q);
    for (i = 0;i < q; ++i){
        scanf("%d",&T[i]);
    }

    for(j=0;j<q;j++) {

        key = T[j];
        S[N] = key;
        A = 0;

        while (1) {
            if (S[A] == key) {
                break;
            }
            A++;
        }
        if (A < N) {
            count++;
        }
    }
    printf("%d\n",count);
    return 0;
}


Measured memory_bytes: 2136
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

vector<pair<int, int> > v; //辺の情報
vector<vector<int> > e; //頂点iから行ける頂点
vector<int> memo;
int solve(int k) { //頂点kを含む最長のパス
	if (memo[k] != -1)return memo[k];
	if (e[k].size() == 0) {
		memo[k] = 0;
		return memo[k];
	}
	else {
		int tmp = 0;
		for (int i = 0; i < e[k].size(); i++) {
			tmp = max(solve(e[k][i]) + 1, tmp);
		}
		memo[k] = tmp;
		return tmp;
	}
}

int main() {
	int N, M;
	cin >> N >> M;
	e = vector<vector<int> >(N, vector<int>());
	v = vector <pair<int, int> >(M, pair<int, int>());
	memo = vector<int>(N, -1);
	for (int i = 0; i < M; i++) {
		cin >> v[i].first >> v[i].second;
		v[i].first--; v[i].second--;
		e[v[i].first].push_back(v[i].second);
	}
	int ans = 0;
	for (int i = 0; i < N; i++)ans = max(ans, solve(i));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8960
import java.util.Scanner;

class UnionFindTree {
	int[] par;
	int[] rank;
	int[] peers; //仲間の数
	int[] dis; //根からの距離

	public UnionFindTree(int n){
		par = new int[n];
		rank = new int[n];
		peers = new int[n];

		for(int i=0;i<n;i++){
			par[i] = i;
			peers[i] = 1;
		}
	}

	//木の根を求める
	int find(int x){
		if(par[x] == x){
			return x;
		}
		else{
			return par[x] = find(par[x]);
		}
	}

	//xとyの属する集合を併合
	void unite(int x, int y){
		int px = find(x);
		int py = find(y);

		if(px == py){
			return;
		}
		else if(rank[px] < rank[py]){
			peers[py] += peers[px];
			par[px] = py;

		}
		else{
			peers[px] += peers[py];
			par[py] = px;
			if(rank[px]==rank[py]){
				rank[px]++;
			}
		}

	}


	//xとyが同じ集合に属するか
	boolean isEquivalent(int x, int y){
		return find(x) == find(y);
	}

	//xの仲間の数を求める
	int peersnum(int x){
		return peers[find(x)];
	}
}

public class Main {

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

		int N = sc.nextInt();
		int M = sc.nextInt();

		int[][] S = new int[M][2];
		for(int i = 0 ; i < M ; i++){
			S[i][0] = sc.nextInt();
			S[i][1] = sc.nextInt();
		}
		sc.close();

		int count = 0;
		for(int i = 0 ; i < M ; i++){
			UnionFindTree uf = new UnionFindTree(N);

			for(int j = 0 ; j < i ; j++){
				uf.unite(S[j][0]-1, S[j][1]-1);
			}
			for(int k = i+1 ; k < M ; k++){
				uf.unite(S[k][0]-1, S[k][1]-1);
			}

			int edge = uf.find(0);
			for(int l = 1 ; l < N ; l++){
				if(edge != uf.find(l)){
					count++;
					break;
				}
			}
		}
		System.out.println(count);
	}

}

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

int main(void)
{
	bool flag(false);
	char str[100];
	gets(str);
	for(int i=0;i<strlen(str);i++)
	{
		if(str[i]=='C')
			flag=true;
		if(str[i]=='F'&&flag)
		{
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
    int  v[3];
    cin >> v[0] >> v[1] >> v[2];
    sort(v, v+3);

    if (v[0]==5 and v[1]==5 and v[2] == 7){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;

}


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

int second(int a, int b, int c){
  if (a < b) {
    if (b < c) {
      return 1;
    }
    else {
      return 0;
    }
  }
  else {
    if (b > c) {
      return 1;
    }
    else {
      return 0;
    }
  }
}

int main(){
  int n;
  cin >> n;
  
  vector<int> p(n);
  
  for (int i = 0; i < n; i++) {
    cin >> p.at(i);
  }
  
  int count = 0;
  
  for (int i = 0; i < n - 2; i++) {
    count += second(p.at(i), p.at(i + 1), p.at(i + 2));
  }
  
  cout << count << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(ll 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 MAX_N 1002
#define i197 1000000007
#define Vi vector<int>
#define Vl vector<long long>
#define pb(a) push_back(a)

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=10000000000000000001;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};
ll r=1000000000000000000;
ll a[100001];

int main() {

	ll n;
	cin>>n;

	ll t=1;
	rep(i,n)cin>>a[i];
	sort(a,a+n);

	t*=a[0];
	if(t==0){
		cout<<"0"<<endl;
		return 0;
	}

	rep(i,n-1){
		if(r/t<a[i+1]){
			cout<<"-1"<<endl;
			return 0;
		}
		t*=a[i+1];
	}
	cout<<t<<endl;

	return 0;
}


Measured memory_bytes: 4372
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

struct Trie {
    static constexpr int M = 1, O = '0';
    struct Node {
        int children[2];
        int count;
    };
    Trie() : nodes(1) {}
    void insert(const string& s) {
        int k = 0;
        int n = s.size();
        for (int i = 0; i < n; i++) {
            int c = s[i] - O;
            for (int j = M - 1; j >= 0; j--) {
                int v = c >> j & 1;
                int& p = nodes[k].children[v];
                if (p == 0) {
                    k = p = nodes.size();
                    nodes.push_back(Node());
                } else {
                    k = p;
                }
            }
        }
        nodes[k].count++;
    }
    void dfs(int k, int j, string& s) {
        int64_t d = s.size();

        if (j == 0) s.push_back(0); else s.back() <<= 1;
        if (++j == M) s.back() += O, j = 0;

        int c = 0;
        for (int v = 0; v < 2; v++) {
            int k1 = nodes[k].children[v];
            if (k1 == 0) continue;

            c++;
            if (v) s.back()++;
            int b = s.back(), n = s.size();
            dfs(k1, j, s);
            s.resize(n); s.back() = b;
        }

        if (c == 1) {
            //cout << s.size() << ' ' << s << endl;
            d = l - d;
            g ^= d & -d;
        }
    }
    vector<Node> nodes;
    int64_t g, l;
};

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

    int n;
    cin >> n;

    int64_t l;
    cin >> l;

    Trie tr;
    string s;
    for (int i = 0; i < n; i++) {
        cin >> s;
        tr.insert(s);
    }
    tr.g = 0;
    tr.l = l;
    s.clear();
    tr.dfs(0, 0, s);

    cout << (tr.g != 0 ? "Alice" : "Bob") << endl;

    return 0;
}

Measured memory_bytes: 6852
import sys, math, operator, itertools, collections, heapq, bisect
# sys.setrecursionlimit(10**4)


class Solution:
    def __init__(self):
        pass

    def solve(self, *Input):
        n,edges = Input
        ans = (n * (n+2) * (n+1) // 3) >> 1
        for edge in edges:
            a,b = sorted(edge)
            ans -= a * (n + 1- b)
        return ans

    def create(self, *Input):
        return []

    def check(self, *Input):
        return True

    def sieve_classic(self,a,b):
        self.primes = [True] * (b+1)
        self.primes[0] = self.primes[1] = False
        for i in range(2,b+1):
            if self.primes[i] and i*i <= b:
                for j in range(i*i,b+1,i):
                    self.primes[j] = False
        self.primes = [x for x,y in enumerate(self.primes) if y]
        ind = bisect.bisect_left(self.primes,a)
        self.primes[:ind] = []
        return None


if __name__=='__main__':
    solution = Solution()

    inputs = iter(sys.stdin.readlines())
    n = int(next(inputs))
    edges = [map(int,next(inputs).split()) for _ in range(n-1)]
    ans = solution.solve(n,edges)
    print(ans)


Measured memory_bytes: 110964
S = 0
N,D = input().split()
N = int(N)
D = int(D)
X = [0]*N
Y = [0]*N
for i in range(N):
  X[i],Y[i] = map(int, input().split())
  if ((X[i])**2 + (Y[i])**2) <= (D)**2:
    S = S + 1
print(S)

Measured memory_bytes: 24664
a = int(input())
ar = list(map(int,input().split(" ")))
br = []
for i in range(a):
    if i + 1 == ar[i]:
        br.append('o')
    else:
        br.append('x')
count = 0
for i in range(a):
    if br[i] == 'o':
        if i != a -1 and br[i+1] == 'o':
            br[i+1] = 'x'
        count += 1
print(count)
    

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

#define GET_MACRO(_1,_2,_3,_4,NAME,...) NAME
#define REP2(i,n) for(int i=0;i<(int)(n);i++)
#define REP3(i,m,n) for(int i=m;i<(int)(n);i++)
#define REP4(i,m,n,s) for(int i=m;(s>0 and i<(int)(n)) or (s<0 and i>(int)(n));i+=s)
#define REP(...) GET_MACRO(__VA_ARGS__, REP4, REP3, REP2)(__VA_ARGS__)
#define REPIT(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define PIS(x) printf("%d ",x)
#define PN() putchar('\n')
#define PRINTARR(a,b) for(int i=0;(a+i)!=(b);i++){cout << *(a+i) << " ";}PN();
#define MP make_pair
#define PB push_back
#define EB emplace_back

typedef pair<int,int> PII;
typedef long long LL;
typedef unsigned long long ULL;

void RI() {}
template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d", &head);
    RI(tail...);
}
void RLL() {}
template<typename... T>
void RLL( LL& head, T&... tail ) {
    scanf("%lld", &head);
    RLL(tail...);
}
void print() {putchar('\n');}
template<typename T, typename... U>
void print(T head, U... tail) {
    cout << head << " ";
    print(tail...);
}

const int MOD = 1000000007;
#define MAX_N 100005
map<int, int> cnt;

int main()
{
    int n;
    RI(n);
    REP(i, n) {
        int a;
        RI(a);
        cnt[a] += 1;
    }
    vector<int> a2;
    REPIT(ii, cnt) {
        if(ii->second >= 2) {
            a2.PB(ii->first);
        }
        if(ii->second >= 4) {
            a2.PB(ii->first);
        }
    }
    if(a2.size() < 2) {
        printf("0\n");
        return 0;
    }
    sort(a2.begin(), a2.end(), greater<int>());
    LL ans = ((LL)a2[0]) * a2[1];
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    string s;
    cin >> s;
    
    string ans = "Yes\n";
    int n = s.length();
    for (int i = 0; i < n; i += 2)if (s[i] == 'L')ans = "No\n";
    for (int i = 1; i < n; i += 2)if (s[i] == 'R')ans = "No\n";
    cout << ans;
}

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

int main() {
  char c;
  cin >> c;
  string s = "abcdefghijklmnopqrstuvwxyz";

  for(int i = 0; i < s.size(); i++){
    if (c == s[i]){
      cout << s[i + 1];
      break;
    }
  }

}



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

int main()
{
    int n, q;
    string s;
    cin >> n >> s >> q;
    vector<set<int>> freq(26);
    for(int i=0; i<n; ++i)
        freq[s[i]-'a'].insert(i);
    for(int i=0; i<q; ++i)
    {
        int q1;
        cin >> q1;
        if(q1 == 1)
        {
            int num;
            char ch;
            cin >> num >> ch;
            --num;
            freq[s[num]-'a'].erase(num);
            s[num] = ch;
            freq[ch-'a'].insert(num);
        }
        else
        {
            int num, num1;
            cin >> num >> num1;
            --num;
            int ans = 0;
            for(int j=0; j<26; ++j)
            {
                auto it = freq[j].lower_bound(num);
                if(it != freq[j].end() && *it < num1) ++ans;
            }
            printf("%d\n",ans);
        }
    }
}


Measured memory_bytes: 27268
#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>;

int n;
void dfs(string s, char mx) {
  if (s.size() == n) {
    cout << s << endl;
    return;
  }
  for (char c = 'a'; c <= mx+1; c++) {
    string t = s;
    t += c;
    if(c!=mx+1) dfs(t, mx);
    else dfs(t,mx+1);

  }
}

int main() {
  cin >> n;
  dfs("", 'a'-1);
  return 0;
}


Measured memory_bytes: 1536
N,K = map(int,input().split())
A = [list(map(int,input().split())) for i in range(K*2)]
A_ = [A[i] for i in range(len(A)) if i%2 == 1]
# print(A_)
sunuke = [0]*N
# print(sunuke)
for i in range(K):
    kasi = A_[i]
    for j in range(len(kasi)):
        s = kasi[j]-1
        if sunuke[s] == 0:
            sunuke[s] = 1
print(N-sum(sunuke))


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

int main() {
	long int N,c,d;
	c=0;
	d=0;
	cin >> N;
	if(N==1){
		cout <<"Yes"<<endl;
	}
	else{
		vector<long int> H(N+1);
		for(int i=0;i<N;i++){
			cin >>H.at(i);
		}
		for(int i=0;i<N-1;i++){
			if(H.at(i)==(H.at(i+1)+1)){
				d++;
			}
			if(H.at(i)<H.at(i+1)){
				if(d==1){
					d=0;
				}
			}
			if(H.at(i)>(H.at(i+1)+1)||d>1){
				c++;
			}
		}
		if(c==0){
			cout <<"Yes"<<endl;
		}
		else{
			cout <<"No"<<endl;
		}
	}
}

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

int dp[2][512][256],ara[12][12][12],z=0;


int on(int x,int ps)
{
    return x | (1<<ps);
}


bool ck(int x,int ps)
{
    return (bool)(x & (1<<ps));
}

int main()
{

    int n,m,q,a,b,c,d,i,j,k,mx=0,idx,mask1,mask2,l,fr,sc;
    vector<int>v;

    scanf("%d %d %d",&n,&m,&q);

    for(i=1;i<=q;i++)
    {
        scanf("%d %d %d %d",&a,&b,&c,&d); ara[a][b][c]=d;

        if(d>mx)mx=d;

    }


    if(n==2)printf("%d\n",mx);
    else
    {

        for(idx=n-1;idx>=1;idx--)
        {
            fr=idx%2; sc=(idx+1)%2;

            for(mask1=0;mask1<=511;mask1++)
            {
                for(mask2=0;mask2<=255;mask2++)
                {
                     if(idx==n-1)
                     {

                         int sz=1,t=0,e,f,g,h,r,mx=1,p=0; v.push_back(1);

                         for(i=0;i<=8;i++)
                         {
                             if(ck(mask1,i)==true){  v.push_back(i+2); if(i+2>mx)mx=i+2;  sz++; }
                         }

                         for(i=mx;i<=m;i++)
                         {
                             h=ara[1][idx+1][i-1]; t=0;

                             for(j=1;j<idx;j++)
                             {
                                 if(ck(mask2,j-1)==true)t++;

                                 if(t==sz){ h=-1; break;  }      f=v[t];    h=h+ara[j+1][idx+1][i-f];

                             }

                             if(t!=sz-1)h=-1;

                             p=max(p,h);

                         }

                         dp[fr][mask1][mask2]=p;


                     }
                     else
                     {
                         int sz=1,t=0,e,f,g,h,r,mx=1,p=0; v.push_back(1);

                         for(i=0;i<=8;i++)
                         {
                             if(ck(mask1,i)==true){  v.push_back(i+2); if(i+2>mx)mx=i+2;  sz++; }
                         }

                         for(i=mx;i<=m;i++)
                         {
                             h=ara[1][idx+1][i-1]; t=0;

                             for(j=1;j<idx;j++)
                             {
                                 if(ck(mask2,j-1)==true)t++;

                                 if(t==sz){  h=-1; break; }    f=v[t]; h=h+ara[j+1][idx+1][i-f];

                             }

                             if(t!=sz-1){ h=-1; }

                             if(h!=-1){
                             e=mask1; g=mask2; if(i>mx){ e=on(mask1,i-2);  g=on(mask2,idx-1);   }

                             p=max(p,h+dp[sc][e][g]);

                             }

                         }

                         dp[fr][mask1][mask2]=p;

                     }

                     v.clear();

                }

            }

        }


        printf("%d\n",dp[1][0][0]);


    }



    return 0;
}


Measured memory_bytes: 4772
#include<bits/stdc++.h>
#include <cctype>
#define ll          long long int
#define PB          push_back
#define GO          ll t; cin>>t; while(t--)
#define G(t)        cin>>t; while(t--)
#define ALLR(x)     x.rbegin(), x.rend()
#define PII         pair<ll ,ll >
#define VI          vector<ll >
#define ALL(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define PI          3.141592653589793238
#define SZ(x)       (ll )x.size()
#define hell2        998244353
#define hell        1000000007
#define FO(i,a,b)    for(i=a;i<b;i++)
#define FOREV(i,a,b)    for(i=a;i>=b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define BS          binary_search
#define MP          make_pair
#define ARR(n,i,a)    ll n,i;cin>>n;ll a[n];FO(i,0,n)cin>>a[i];
#define ARRK(k,n,i,a) int n,k,i;scanf("%d%d",&n,&k);ll a[n];FO(i,0,n)scanf("%lld",&a[i]);
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(0);
int main()
{
    fio
    int n,i,p,j,k;cin>>n;
  int a[10005]={0};
  FO(i,1,101)
  {
    FO(j,i,101)
    {
      FO(k,j,101)
      {
        p=i*i+j*j+k*k+i*j+j*k+k*i;
        if(p>10000)continue;
        if(i==j&&j==k){a[p]++;}
        else if(i!=j&&j!=k&&k!=i){a[p]+=6;}
        else {a[p]+=3;}
      }
    }
  }
  FO(i,1,n+1)
  {
    cout<<a[i]<<"\n";
  }
    
return 0;
}

Measured memory_bytes: 3644