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

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

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

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

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn f(s: &[char]) -> bool {
    let m = s.len();
    for i in 0..m {
        if s[i] != s[m - 1 - i] {
            return false;
        }
    }
    true
}

use std::iter::Iterator;
use std::cmp;

fn is_odd(x: i32) -> bool {
    if x < 10 {
      return true;
    }
    if x < 100 {
      return false;
    }
    if x < 1000 {
      return true;
    }
    if x < 10000 {
      return false;
    }
    if x < 100000 {
      return true;
    }
    return false;
  }

fn main() {
    input! {
        n : i32,
    }

    let mut count = 0;
    for i in 1 .. n + 1 {
      if is_odd(i) {
        count += 1;
      }
    }
   
    println!("{}", count);

}


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

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

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define int ll

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define ALL(s) (s).begin(),(s).end()
#define ALLn(s,n) s,s+n
#define F first
#define S second
#define pb push_back
#define tc(t) int t; cin >> t; while(t--)
#define _ ios_base::sync_with_stdio(false); cin.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }

const ll MOD = 1e9 + 7;
const ll MAXN = 1e6 + 7;
const ll INF = LONG_LONG_MAX;

bool check(string s) {
	int n = 0;
	for (auto x : s) n += (x - '0');
	return n % 9 == 0;
}

void solve() {
	int n;
	cin >> n;

	int a[n];

	int ans = 0;

	F0R(i, n) cin >> a[i];

	int till = a[0];
	FOR(i, 1, n) {
		if (a[i] < till) ans += till - a[i];
		till = max(till, a[i]);
	}
	cout << ans;
}

int32_t main() {
	_

#ifndef ONLINE_JUDGE
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
#endif

	// tc(t)
	solve();
	cerr << "[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
}


Measured memory_bytes: 5368
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    class QuestionD
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            var n = long.Parse(Console.ReadLine());

            // 整数配列の入力
            var a = Console.ReadLine().Split(' ').Select(q => long.Parse(q)).ToArray();

            var dic = new Dictionary<long, long>();

            for(int i = 0; i < n; i++) {
                if(dic.ContainsKey(a[i]) == false) {
                    dic[a[i]] = 0;
                }

                dic[a[i]]++;
            }

            var count = 0L;

            foreach(var k in dic) {
                if(k.Key == k.Value) {
                    continue;
                }

                if(k.Key > k.Value) {
                    count += k.Value;
                } else {
                    count += k.Value - k.Key;
                }
            }

            Console.WriteLine(count);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 29660
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
using IP = pair<int, int>;

const ll linf = 1LL << 62;
const int inf = 99999999;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };
const ll atcoder = 1e9 + 7;

#define Endl endl
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back
#define pr(x) cout << x << endl
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define rep(i,n) for(int i= 0;i<n;i++)

ll gcd(ll a, ll b) {//最大公約数
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

ll lcm(ll a, ll b) {//最小公倍数
	return (a / gcd(a, b))*b;
}

int main(){
	
	ll a[100], b[100], c[100], d[100];
	int n, m;
	cin >> n >> m;
	rep(i, n)cin >> a[i] >> b[i];
	rep(i, m)cin >> c[i] >> d[i];
	
	rep(i, n) {
		ll dist = linf;
		int ansm;
		rep(j, m) {
			if (dist > abs(a[i] - c[j]) + abs(b[i] - d[j])) {
				chmin(dist, abs(a[i] - c[j]) + abs(b[i] - d[j]));
				ansm = j+1;
			}
		}
		pr(ansm);
	}


	//system("pause");
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
from heapq import heappop, heappush


class Graph(object):
    """
    隣接リストによる有向グラフ
    """

    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, src, dst, weight=1):
        self.graph[src].append((dst, weight))

    def get_nodes(self):
        return self.graph.keys()


class Dijkstra(object):
    """
    ダイクストラ法（二分ヒープ）による最短経路探索
    計算量: O((E+V)logV)
    """

    def __init__(self, graph, start):
        self.g = graph.graph

        # startノードからの最短距離
        # startノードは0, それ以外は無限大で初期化
        self.dist = defaultdict(lambda: float('inf'))
        self.dist[start] = 0

        # 最短経路での1つ前のノード
        self.prev = defaultdict(lambda: None)

        # startノードをキューに入れる
        self.Q = []
        heappush(self.Q, (self.dist[start], start))

        while self.Q:
            # 優先度（距離）が最小であるキューを取り出す
            dist_u, u = heappop(self.Q)
            if self.dist[u] < dist_u:
                continue
            for v, weight in self.g[u]:
                alt = dist_u + weight
                if self.dist[v] > alt:
                    self.dist[v] = alt
                    self.prev[v] = u
                    heappush(self.Q, (alt, v))

    def shortest_distance(self, goal):
        """
        startノードからgoalノードまでの最短距離
        """
        return self.dist[goal]

    def shortest_path(self, goal):
        """
        startノードからgoalノードまでの最短経路
        """
        path = []
        node = goal
        while node is not None:
            path.append(node)
            node = self.prev[node]
        return path[::-1]
    
    def sp(self, goal):
        path = []
        node = goal
        for _ in range(2):
            path.append(node)
            node = self.prev[node]
        return path[1]

n, m = map(int, input().split())
g = Graph()
for i in range(m):
    a, b = map(int, input().split())
    g.add_edge(a-1, b-1, 1)
    g.add_edge(b-1, a-1, 1)

d = Dijkstra(g, 0)
A = []
# print(d.sp(2))
for i in range(n):
    a = d.shortest_distance(i)
    if a == float('inf'):
        print("No")
        break
    else:
        A.append(d.shortest_distance(i))

if len(A) == n:
    print("Yes")
    for i in range(1, n):
        print(d.sp(i) + 1)

Measured memory_bytes: 142216
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define inf 1000000007
using namespace std;
ll bcnt[2019][2019], tate[2019][2019],yoko[2019][2019];
signed main(){
	int n,m,q;
	cin>>n>>m>>q;
	vector<string> s;
	for(int i=0;i<n;i++){
		string tmp;
		cin>>tmp;
		s.pb(tmp);
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			bcnt[i][j] = bcnt[i][j-1] + bcnt[i-1][j] - bcnt[i-1][j-1];
			if( s[i-1][j-1] == '1') bcnt[i][j]++;
			tate[i][j] = tate[i][j-1] + tate[i-1][j] - tate[i-1][j-1];
			yoko[i][j] = yoko[i][j-1] + yoko[i-1][j] - yoko[i-1][j-1];
			if( i >= 2 && s[i-1][j-1] =='1' && s[i-2][j-1]=='1')tate[i][j]++;
			if( j >= 2 && s[i-1][j-1] == '1' && s[i-1][j-2] == '1')yoko[i][j]++;
		}
	}
	vector<int> q1,q2,q3,q4;
	for(int i=0;i<q;i++){
		int aa,bb,cc,dd;
		cin>>aa>>bb>>cc>>dd;
		q1.pb(aa);q2.pb(bb);q3.pb(cc);q4.pb(dd);
	}
	/* for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cout<<"("<<bcnt[i][j]<<", "<<tate[i][j]<<", "<<yoko[i][j]<<") ";
		}
		cout<<endl;
	} */
	for(int i=0;i<q;i++){
		int aa,bb,cc,dd;
		aa=q1[i];bb=q2[i];cc=q3[i];dd=q4[i];
		int bl = bcnt[cc][dd] - bcnt[cc][bb-1] - bcnt[aa-1][dd] + bcnt[aa-1][bb-1];
		int tt = tate[cc][dd] - tate[cc][bb-1] - tate[aa][dd] + tate[aa][bb-1];
		int yy = yoko[cc][dd] - yoko[aa-1][dd] - yoko[cc][bb] + yoko[aa-1][bb];
		cout<<bl-tt-yy<<endl;
	} 
	return 0;
}

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

int main() {
    int a, b, c, f = 0;
    cin >> a >> b >> c;
    for (int i = a; i <= b; i++) {
        if (c % i == 0) {
            f += 1;
        }
    }
    cout << f << endl;
    return 0;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
using namespace std;
#define fine cout<<"fine"<<endl;
#define ll long long int
#define pb push_back
#define FASTIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
const ll inf=(ll)2e18;
const int mod=1e9+7;
bool overflow(ll a,ll b){
    if (a <= (inf+b-1)/b) return false;
    return true;
}
string tostring(int x){
    string s;
    if(!x){
        return "0";
    }
    while(x){
        s.pb((char)(x%10+48));
        x/=10;
    }
    reverse(all(s));
    return s;
}
int main(){
FASTIO;
int n,m,i,j;
cin>>n>>m;
vector<pair<int,int> > v(m);
for(i=0;i<m;i++){
    cin>>v[i].ff>>v[i].ss;
}
int x;
if(n==1)
    x=0;
else if(n==2)
    x=10;
else if(n==3)
    x=100;
if(!x){
    string s=tostring(0);
    for(j=0;j<m;j++){
        if(s[v[j].ff-1]!=48+v[j].ss)
            break;
    }
    if(j==m){
        cout<<0<<endl;
        return 0;
    }
    x++;
}
for(i=x;i<10*x;i++){
    string s=tostring(i);
    for(j=0;j<m;j++){
        if(s[v[j].ff-1]!=48+v[j].ss)
            break;
    }
    if(j==m){
        cout<<i<<endl;
        return 0;
    }
}
cout<<-1<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int notomamiko(int x) {
	int hayamisaori = 0;
	do {
		hayamisaori++;
	} while ((x /= 10) > 0);
	return hayamisaori;
}

int main(void) {
	int N;
	int i;
	int mizuhasikaori = 0;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 1; i <= N; i++) {
		if (notomamiko(i) % 2 == 1) mizuhasikaori++;
	}
	printf("%d\n", mizuhasikaori);
	return 0;
}


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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#define itrout(x) for(int i=0;i<x.size();i++) {cout << x[i] << (i==x.size()-1 ? "\n" : " ");}
#ifdef LOCAL
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define debugbit(x, n) cerr << #x << " = " << bitset<n>(x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define itrdebug(x) cerr << #x << " "; for (auto & el : (x)) {cerr << (el) << " ";} cerr << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define debug(x)
#define debugbit(x, n)
#define itrdebug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(std::string S){
    int answer = 0, ss = 0;
    rep(i,0,S.size()) {
        if (S[i] == 'R') ss++;
        else ss = 0;
        answer = max(answer, ss);
    }
    cout << answer << endl;
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

int N, ans;

int main() {
    scanf("%d", &N);
    for(int i=0, x, y; i<N; i++) {
        scanf("%d %d", &x, &y);
        ans += y - x + 1;
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int h,w;cin>>h>>w;
  int res=0;
  int odd=(h+1)/2;
  int even=h/2;
  int oddw=(w+1)/2;
  int evenw=w/2;
  
  res=odd*oddw+even*evenw;
  if(h==1||w==1)res=1;
  cout<<res<<endl;
  return 0;
}


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

using namespace std;

using ll = long long;

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int inf = (int) 1e9;
const int mod = (int) 1e9 + 7;

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;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string s;
	cin >> s;
	
	ll sum = 0;
	ll cnt = 0;
	rep(i, s.length()) {
		if (s[i] == 'W') {
			sum += (ll) (i - cnt);
			cnt++;
		}
	}
	
	cout << sum << endl;
	
	return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

const int mod = 1000000007;
int add(int a, int b) { return (a += b) < mod? a : a - mod; }
int sub(int a, int b) { return (a -= b) >=  0? a : a + mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
void adds(int& a, int b) { a = add(a, b); }
void subs(int& a, int b) { a = sub(a, b); }
void muls(int& a, int b) { a = mul(a, b); }
void maxs(int& a, int b) { a = max(a, b); }
void mins(int& a, int b) { a = min(a, b); }
int pwr(int a, ll p) {
    if (p == 0) return 1;
    if (p & 1) return mul(a, pwr(a, p - 1));
    return pwr(mul(a, a), p / 2);
}
int inv(int a) { return pwr(a, mod - 2); }

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vi primes = {2};
    for (int i = 3; i <= n; i += 2)
    {
        bool prime = true;
        for (int j = 2; j < i && prime; ++j)
            if (i % j == 0)
                prime = false;
        if (prime)
            primes.push_back(i);
    }

    vi pk(primes.size());
    for (int i = 1; i <= n; ++i)
    {
        int m = i;
        for (int j = 0; j < primes.size(); ++j)
        {
            int p = primes[j];
            while (m % p == 0)
                pk[j]++, m /= p;
        }
    }

    int sol = 1;
    for (int k : pk)
        muls(sol, k + 1);
    cout << sol;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#define int long long
#define ll getchar();getchar();return 0;
using namespace std;
signed main() {
	int n,cnt=0,sum=0;
	cin >> n;
	if (n == 10 || n == 100 || n == 1000 || n == 10000 || n == 100000)cout << 10 << endl;
	else {
		for (int i = 10; i <= n * 10; i *= 10) {
			if (i == 10)cnt += n % i;
			else sum += (n%i - n % (i / 10)) / (i / 10);
		}
		cout << cnt + sum << endl;
	}
	ll
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

const int MOD = 1000000007;
typedef long long ll;


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,ans=0;
  cin>>N;
  vector <int> h(N);
  for(int i=0;i<N;i++)cin>>h[i];

  while(true){
    int tmp=0;
    for(int i=0;i<N-1;i++){
      if(h[i]!=0 && h[i+1]==0)tmp++;
    }
    if(h[N-1]!=0)tmp++;
    if(tmp==0)break;
    for(int i=0;i<N;i++){
      if(h[i]!=0)h[i]--;
    }
    ans+=tmp;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String S = sc.next();

		StringBuffer sb = new StringBuffer();
		for (int i=0; i<S.length(); i++){
			sb.append("x");
		}
		System.out.println(sb.toString());
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,M;
    cin >> N >> M;
    vector<P> V(N);
    rep(i,0,N)cin >> V[i].first >> V[i].second;
    sort(V.begin(), V.end());

    int cur = 0;
    priority_queue<int> que;
    ll sum = 0;
    rep(i,max(1,M-N),M+1){
        while(cur < N && V[cur].first <= i){
            que.push(V[cur].second);
            cur++;

        }
        if(!que.empty()){
            sum += que.top();
            que.pop();
        }
    }
    cout << sum << endl;
}

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

using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll LNF = __LONG_LONG_MAX__;
const ll MAX = 200005;
long long fac[MAX], finv[MAX], inv[MAX];

int main(){
    int N; cin >> N;
    ll all=1;
    ll an=1;
    ll ea=1;
    for(int i=0;i<N;i++){
        all *= 10;
        an *= 8;
        ea *= 9;
        all = all%MOD;
        an = an%MOD;
        ea = ea%MOD;
    }
    ea *= 2; ea = ea%MOD;
    ll ans = all - ea + an;
    if(ans<0) ans+=MOD;
    cout << ans << endl;
    return 0;
}


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

int main(){
    long long a[3];
    for(int i = 0; i < 3; ++i)cin >> a[i];
    sort(a, a+3);
    long long tet = a[0]*a[1];
	cout << abs(tet*(a[2]/2) - tet*((a[2]+1)/2)) << endl;
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(m)]

if m == 0:
    if n == 1:
        print(0)
    else:
        print(10 ** (n - 1))
    exit()

if n == 1:
    left = 0
else:
    left = 10 ** (n - 1)
right = 10 ** n

ans = -1
for i in range(left, right):
    i = str(i)
    for s, c in sc:
        if int(i[s - 1]) != c:
            break
    else:
        ans = i
        break

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
        int n;
        cin>>n;
        string st;
        cin>>st;
        if(st.size()<=n)
            cout<<st;
        else
        {
            for(ll i=0;i<n;i++)cout<<st[i];
            cout<<"..."<<endl;
        }

}
               //Alhamdulillla...


Measured memory_bytes: 3628
N, M, Q = map(int, input().split())
cond = []
for i in range(Q):
  a, b, c, d = map(int, input().split())
  cond.append((a - 1, b - 1, c, d))

def dfs(A, head):
  if len(A) == N:
    score = 0
    for a, b, c, d in cond:
      if A[b] - A[a] == c:
        score += d
    return score
  ans = 0
  for n in range(head, M + 1):
    ans = max(ans, dfs(A + [n], n))
  return ans
print(dfs([1], 1))

Measured memory_bytes: 9004
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		double p = 0;
		if(D == 0){
			p = N;
		} else {
			p = 2 * N - 2 * D;
		}
		p /= ((double) N) * ((double) N);
		Console.WriteLine((M - 1) * p);
		
		
	}
	long N,M,D;
	public Sol(){
		var d = rla();
		N = d[0]; M = d[1]; D = d[2];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 11092
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}



int main(){
  
  int n;cin>>n;
  cout << n*n << endl;

}

Measured memory_bytes: 256
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    S1 = input()
    S2 = input()

    MOD = 1000000007

    if N == 1:
        return print(3)

    res = 0
    idx = 0
    is_horizontal = True
    if S1[0] == S2[0]:
        res += 3
        idx += 1
        is_horizontal = False
    else:
        res += 6
        idx += 2
        is_horizontal = True

    while idx < N:
        if S1[idx] == S2[idx]:
            if is_horizontal:
                res *= 1
            else:
                res *= 2
            idx += 1
            is_horizontal = False
        else:
            if is_horizontal:
                res *= 3
            else:
                res *= 2
            idx += 2
            is_horizontal = True
        res %= MOD

    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38380
#include<stdio.h>
#define MAX 1000005
#define NIL -1

struct Node{
  int p;
  int l;
  int r;
};

struct Node T[MAX];
int n,D[MAX],H[MAX];

int getSibling(int u){
  if(T[u].p == NIL){
    return -1;
}
  if(T[T[u].p].l != u && T[T[u].p].l != NIL){
    return T[T[u].p].l;
  }
  if(T[T[u].p].r != u && T[T[u].p].r != NIL){
    return T[T[u].p].r;
  }
  return -1;
}

void print(int u){
  int sub;
  int dgree=0;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].p);
  printf("sibling = %d, ",sub = getSibling(u));
  if(T[u].l != -1){
    dgree++;
      }
  if(T[u].r != -1){
    dgree++;
  }
  printf("degree = %d, ",dgree);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);

  if(T[u].p == NIL){
    printf("root\n");
  }
  else if(T[u].l == NIL&&T[u].r == NIL){
    printf("leaf\n");
  }
  else{
    printf("internal node\n");
  }
}



  void setDepth(int u, int d){
    if(u == NIL){
      return;
    }
    D[u] = d;
    setDepth(T[u].l, d+1);
    setDepth(T[u].r, d+1);
}

int setHeight(int u){
  int h1 = 0, h2 = 0;
  if(T[u].l != NIL){
    h1 = setHeight(T[u].l) + 1 ;
  }
  if(T[u].r != NIL){
    h2 = setHeight(T[u].r) + 1;
  }
  if(h1 >= h2){
    H[u] = h1;
    return H[u];
  }
  else{
    H[u] = h2;
    return H[u];
  }
}

int main(){
  int i, v, l, r, root = 0;
  scanf("%d",&n);

  for(i=0 ; i<n ; i++){
    T[i].p = NIL;
  }
  for(i=0 ; i<n ; i++){
    scanf("%d%d%d", &v, &l, &r);
    T[v].l = l;
    T[v].r = r;
    if(l != NIL){
      T[l].p = v;
    }
    if(r != NIL){
      T[r].p = v;
    }
  }

  for(i=0 ; i<n ; i++ ){
    if(T[i].p == NIL){
      root = i;
    }
  }
  setDepth(root, 0);
  setHeight(root);

  for(i=0 ; i<n ; i++){
    print(i);
  }
  return 0;
}




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

const int MAXH = 100;
const int MAXW = 100;
int H, W;
char G[MAXH][MAXW];

void dfs(int i, int j) {
  const static int di[] = {0,1,0,-1};
  const static int dj[] = {1,0,-1,0};
  char c = G[i][j];
  G[i][j] = ' ';
  for(int k = 0; k < 4; ++k) {
    int ni = i + di[k];
    int nj = j + dj[k];
    if(ni < 0 || ni >= H) continue;
    if(nj < 0 || nj >= W) continue;
    if(G[ni][nj] != c) continue;
    dfs(ni, nj);
  }
}

int main() {
  while(cin >> H >> W && (H|W)) {
    for(int i = 0; i < H; ++i) {
      for(int j = 0; j < W; ++j) {
        cin >> G[i][j];
      }
    }
    int res = 0;
    for(int i = 0; i < H; ++i) {
      for(int j = 0; j < W; ++j) {
        if(G[i][j] != ' ') {
          ++res;
          dfs(i, j);
        }
      }
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1636
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        char s[] = sc.next().toCharArray();
        boolean abc[] = new boolean[3];
        for(int i = 0; i < 3; i++) {
            if( s[i] == 'a' ) abc[0] = true;
            if( s[i] == 'b' ) abc[1] = true;
            if( s[i] == 'c' ) abc[2] = true;
        }
        
        boolean isOK = true;
        for(int i = 0; i < 3; i++) {
            isOK &= abc[i];
        }
        
        System.out.println( (isOK) ? "Yes" : "No" );
    }
}


Measured memory_bytes: 35528
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  ll n,k;
  cin>>n>>k;
  ll m=(n+1)/2;
  ll l=n/2;
  bool ok=true;
  vector<tuple<ll,ll,ll>> vt;
  for(ll i:irange(0l,m)) {
    ll a = k+i;
    ll b = k+n+l+i;
    ll c = k+2*n+2*i;
    if (a+b>c) ok = false;
    vt.emplace_back(a,b,c);
  }
  for(ll i:irange(0l,l)) {
    ll a = k+m+i;
    ll b = k+n+i;
    ll c = k+2*n+2*i+1;
    if (a+b>c) ok = false;
    vt.emplace_back(a,b,c);
  }
  if (ok) {
    for(auto t:vt) {
      ll a,b,c;
      tie(a,b,c) = t;
      cout<<a<<' '<<b<<' '<<c<<endl;
    }
  } else {
    cout<<-1<<endl;
  }
  return 0;
}


Measured memory_bytes: 5232
import fractions
from functools import reduce
import sys
input = sys.stdin.readline

def main():
    N,K =map(int,input().split())
    A = list(map(int,input().split()))
    if K > max(A):
        print("IMPOSSIBLE")
    else:
        def gcd_list(numbers):
            return reduce(fractions.gcd,numbers)
          
        gcd = gcd_list(A)
        if (max(A)-K)%gcd == 0:
            print("POSSIBLE")
        else:
            print("IMPOSSIBLE")

if __name__ == "__main__":
    main()

Measured memory_bytes: 16276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 1000000007


int main() {
	ll n;
	cin>>n;
	ll a[100010],b[100010],x,y;
	for(int i=0;i<100010;i++){
		a[i]=b[i]=0;
	}
	while(cin>>x&&cin>>y){
		a[x]++;b[y]++;
	}
	ll a1,a2,a1n,a2n,b1,b2,b1n,b2n;
	a1=a2=b1=b2=0;
	for(int i=1;i<100010;i++){
		if(a1<=a[i]){
			a2=a1;a2n=a1n;
			a1=a[i];a1n=i;
		}
		else if(a2<=a[i]){
			a2=a[i];a2n=i;
		}
	}
	for(int i=1;i<100010;i++){
		if(b1<=b[i]){
			b2=b1;b2n=b1n;
			b1=b[i];b1n=i;
		}
		else if(b2<=b[i]){
			b2=b[i];b2n=i;
		}
	}
	cout << (a1n!=b1n? n-a1-b1: min(n-a1-b2,n-a2-b1));
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<deque>
#include<set>
using namespace std;

using ll = long long;
const int INF = 1001001001;

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

int main(void)
{
  ll x, y, z, k;
  cin >> x >> y >> z >> k;
  vector<ll> a(x);
  vector<ll> b(y);
  vector<ll> c(z);
  rep(i,x) cin >> a[i];
  rep(i,y) cin >> b[i];
  rep(i,z) cin >> c[i];

  sort(a.begin(), a.end(), greater<ll>());
  sort(b.begin(), b.end(), greater<ll>());
  sort(c.begin(), c.end(), greater<ll>());

  vector<ll> ab;
  rep(i,x) rep(j,y) {
    ab.push_back(a[i]+b[j]);
  }
  sort(ab.begin(), ab.end(), greater<ll>());

  vector<ll> abc;
  rep(i, min((ll)3000, x*y)) rep(j, z) {
    abc.push_back(ab[i]+c[j]);
  }
  sort(abc.begin(), abc.end(), greater<ll>());
  rep(i,k) {
    cout << abc[i] << endl;
  }
}


Measured memory_bytes: 43368
#include <cstdio>
#include <cstring>
#include <climits>
#include <queue>
#include <map>
using namespace std;

typedef map<int, int>::iterator mitr;

map<int, int> w[10000];
int d[10000];
char pos[10000];

priority_queue<pair<int,int> > others;
pair<int,int> p;

void findPath(){
    p = others.top();
    others.pop();
    while(pos[p.second]){
        p = others.top();
        others.pop();
    }
    pos[p.second]=1;

    int tmpu = p.second;
    int tmpd = -p.first;

    for(mitr i=w[tmpu].begin();i!=w[tmpu].end();i++){
        if(tmpd + i->second < d[i->first]){
            d[i->first] = tmpd + i->second;
            others.push(make_pair(-d[i->first],i->first));
        }
    }
}

int main(){
    int i,j,u,k,n,v,c;

    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d %d",&u,&k);
        for(j=0;j<k;j++){
            scanf("%d %d",&v,&c);
            w[u][v] = c;
        }
    }

    memset(pos,0,sizeof(char)*100);
    for(i=0;i<n;i++)d[i]=INT_MAX;
    d[0] = 0;
    others.push(make_pair(0,0));
    for(i=0;i<n;i++)findPath();
    for(i=0;i<n;i++)printf("%d %d\n",i,d[i]);

    return 0;
}



Measured memory_bytes: 26636
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cerr << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int a,b,c;
int solve(int num, const vector<int> &d){
    //    show(num);
    int res = 1<<30;
    if(num == 0){
        int n = (int)d.size();
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if(i==j)continue;
                for(int k = 0; k < n; k++){
                    if(i==k or j ==k)continue;
                    if(i!=j and j != k and k != i)res = min(res,abs(a-d[i])+abs(b-d[j])+abs(c-d[k]));
                }
            }
        }
    }else{
        int n = (int)d.size();
        for(int i = 0; i < n-1; i++){
            vector<int>dd;
            for(int j = 0; j < n; j++)if(j != i)dd.push_back(d[j]);
            for(int j = i; j < n-1; j++){
                dd[j]+=d[i];
                res = min(res, solve(num-1,dd)+10);
                dd[j]-=d[i];
            }
            res = min(res, solve(num-1,dd)+10);
        }
    }
    return res;
}
int main(){
    int n;
    cin >> n >> a >> b >> c;
    vector<int>d(n);
    rep(i,n)cin >> d[i];
    int ans = 1<<30;
    //    solve(2,d);
    for(int i = 0; i <= n-3; i++){
        ans = min(ans, solve(i,d));
        //        show(solve(i,d));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD = 1000000007;
//
int fac[MAX], finv[MAX], inv[MAX];


     signed main(){
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)cin>>a[i];
  int t=0;
  for(int i=2;i<n;i++)t^=a[i];
  int s=((a[0]+a[1]-t)),ans=0;
  if(s%2||s<0){
      cout<<-1<<endl;
      return 0;
  }
  s/=2;
  if((s&t)!=0){
      cout<<-1<<endl;
      return 0;
  }
  int p=0;
  while((1ll<<p)<=t)p++;
  for(int i=p-1;i>=0;i--){
      if(t&(1ll<<i)){
          if(s+(1ll<<i)<=a[0])s+=(1ll<<i);
      }
  }
  if(s==0||s>a[0])cout<<-1<<endl;
  else cout<<a[0]-s<<endl;
 


     }


 


 






    





      

        


Measured memory_bytes: 3612
/*
 * Author: Utkal Sinha
 * Created on: 2020-09-19, Sat, 17:48
 * Problem:
 * Platfrom: General
 * */
#if USE_BOOST2
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_bin_float.hpp>
namespace bst = boost::multiprecision;
typedef bst::int1024_t vll; //int512_t or //int128_t
typedef bst::cpp_bin_float_100 vdouble;
#endif

#include <bits/stdc++.h>
using namespace std;
#define GETTIME std::chrono::system_clock::now()
#define DURATION std::chrono::duration<double>
#ifdef MY_DEV_ENV2
#define LOCALDEV
#endif
typedef long long ll;
typedef std::chrono::system_clock::time_point TPT;
static TPT starttime, endtime, timelimit;
static double problem_tle = 1.5;
static inline void calc_problem_end_time() {timelimit = starttime + std::chrono::milliseconds(int (problem_tle * 1000));}
// template end



void love() {
    int n;
    cin >> n;
    int d1[n], d2[n];

    for(int i= 0; i<n; i++) {
        cin >> d1[i] >> d2[i];
    }

    bool fd = false;
    for(int i = 0; i<=n-3; i++) {
        if(d1[i] == d2[i] && d1[i+1] == d2[i+1] && d1[i+2] == d2[i+2]) {
            fd = true;
            break;
        }
    }

    if(fd) cout << "Yes" << endl;
    else cout << "No" << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    srand(time(0));
#ifdef LOCALDEV
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    //cin >> t;
#ifdef LOCALDEV
    starttime = GETTIME;
    calc_problem_end_time();
#endif
    while(t--) love();
#ifdef LOCALDEV
    endtime = GETTIME;
    DURATION elapsed_seconds = endtime - starttime;
    DURATION time_limit_seconds = timelimit - starttime;
    clog << "Elapsed time: " << elapsed_seconds.count() << "s\n";
    clog << "Time limit: " << time_limit_seconds.count() << "s\n";
#endif
    return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>

int main(void) {
	long long int N,K,X,Y;
	scanf("%lld",&N);
	scanf("%lld",&K);
	scanf("%lld",&X);
	scanf("%lld",&Y);
	if(N>K){
		printf("%lld\n",(K*X+(N-K)*Y));
	}
	else if(N<=K){
		printf("%lld\n",(N*X));
	}
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
int main()
{
    int n,a,i,count=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a);
        if(i%2==1 && a%2==1)count++;
    }
    printf("%d\n",count);
}


Measured memory_bytes: 1680
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <numeric>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)

int main() {
    string n;
    cin >> n;
 
    bool yes = false;
    rep(i, n.length()) {
        if (n[i] == '7') {
            yes = true;
            break;
        }
    }
 
    if (yes) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3628
def main1 ():
  X, N =map(int, input().split())
  i = 0
  if N == 0:
    print(X)
  else:
    p = list(map(int, input().split()))
    for i in range(100):
      if X - i not in p:
        return print(X - i)
      elif X + i not in p:
        return print(X + i)
      i += 1

main1()

Measured memory_bytes: 9188
n = int(input())
a,b,c = 0,0,float("Inf")
for i in range(1,int(n**0.5)+1):
    if n % i == 0:
        a = max(i,n//i)
        b = 0
        while not a == 0:
            a //= 10
            b += 1
        c = min(c,b)
print(c)

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

int main() {
  int n;
  string s, t;
  cin >> n >> s >> t;
  int intersection = 0;
  for(int i=n;i>=1;i--) {
    string subS = s.substr(n - i, i);
    string subT = t.substr(0, i);
    if(subS == subT) {
      intersection = i;
      break;
    }
  }

  cout << 2 * n - intersection << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O0")
typedef long long int ll;
typedef long double ld;
const ll mod = 1e9+7;
const ll INF = 1e18;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define Rep(i,a,n) for (ll i = (a); i < (n); ++i)
#define All(a) (a).begin(),(a).end()
#define Pi acos(-1)
using Graph = vector<vector<ll>>;
using V = vector<ll>;
using P = pair<ll,ll>;


// 素集合データ構造
struct UnionFind {
    //自身が親であれば、その集合に属する頂点数に-1を掛けたもの
    //そうでなければ親のid
    vector<int> r;
 
    UnionFind(int N) {
        r = vector<int>(N, -1);
    }

  // データxが属する木の根を得る 
    int root(int x) {
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }

  // 2つのデータx, yが属する木をマージする 
    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }

  // 2つのデータx, yが属する木が同じならtrueを返す
    bool same(int x, int y) {
      return root(x) == root(y);
    }

  // データxが含まれる木の大きさを返す
    ll size(int x) {
        return -r[root(x)];
    }
};

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  chrono::system_clock::time_point start,end;
  start = chrono::system_clock::now();

  ll n, q;
  cin >> n >> q;
  UnionFind UF(n);
  rep(i,q) {
    ll t, u, v;
    cin >> t >> u >> v;
    if (t == 0) {
      UF.unite(u,v);
    }
    else {
      if (UF.same(u,v)) {
        cout << 1 << '\n';
      }
      else {
        cout << 0 << '\n';
      }
    }
  }

  end = chrono::system_clock::now();
  auto elapsed = chrono::duration_cast< chrono::milliseconds >(end - start).count();
  cerr << elapsed << "ms" << '\n';
}

Measured memory_bytes: 4028
import kotlin.math.*
import java.io.BufferedReader
import java.io.InputStreamReader
import java.util.*


private var fs = BufferedReader(InputStreamReader(System.`in`))
private fun readLn() = fs.readLine()!! // string line
private fun readStrings() = readLn().split(" ") // list of strings
private fun readLong() = readLn().toLong()
private fun readLongs() = readStrings().map { it.toLong() } // list of ints
private fun readInt() = readLn().toInt() // single int
private fun readInts() = readStrings().map { it.toInt() } // list of ints

fun main() {
    solveAtc()
}
fun solveAtc() {
    var n = readInt().toString()
    if(n[n.lastIndex] == '3') println("bon")
    else if(n[n.lastIndex] == '0'|| n[n.lastIndex] == '1' || n[n.lastIndex] == '6'|| n[n.lastIndex] == '8')
        println("pon")
    else println("hon")
}


Measured memory_bytes: 35828
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tuple<int,int,int> tp;

const int mod=1000000007;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	map<tp,ll> ct;
	ct[make_tuple(0,0,0)]=1;
	for (int i=0; i<n; i++) {
		int x; cin>>x;
		map<tp,ll> ct2;
		for (auto it : ct) {
			auto key=it.first;
			if(get<0>(key)==x) {
				tp next_key=make_tuple(get<0>(key)+1,get<1>(key),get<2>(key));
				ct2[next_key]=(ct[key]+ct2[next_key])%mod;
			}
			if(get<1>(key)==x) {
				tp next_key=make_tuple(get<0>(key),get<1>(key)+1,get<2>(key));
				ct2[next_key]=(ct[key]+ct2[next_key])%mod;
			}
			if(get<2>(key)==x) {
				tp next_key=make_tuple(get<0>(key),get<1>(key),get<2>(key)+1);
				ct2[next_key]=(ct[key]+ct2[next_key])%mod;
			}
		}
		ct=ct2;
	}

	ll ret=0;
	for (auto it : ct)
		ret=(ret+it.second)%mod;
	cout<<ret<<"\n";
	return 0;
}

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

#include <atcoder/all>
using namespace atcoder;
using namespace std;
using ll = long long;
const ll INF = LONG_LONG_MAX / 2;
const ll mod = 1000000000 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  ll N, Q;
  cin >> N >> Q;
  fenwick_tree<ll> fw(N);
  for (int i = 0; i < N; i++) {
    ll a;
    cin >> a;
    fw.add(i, a);
  }

  for (int i = 0; i < Q; i++) {
    ll p, q, r;
    cin >> p >> q >> r;
    if (p == 0) {
      fw.add(q, r);
    } else if (p == 1) {
      cout << fw.sum(q, r) << "\n";
    }
  }
}

Measured memory_bytes: 8208
#PyPy遅え
import sys
sys.setrecursionlimit(100000000)
inf=1000000000000000000
n,m=map(int,input().split())
x=[inf]*n
#まだ訪問してなければTrue
check=[True]*n
#どこと関係があるかを記録する(maybe right)
lrd=[[] for i in range(n)]
for i in range(m):
    l,r,d=map(int,input().split())
    l-=1
    r-=1
    lrd[l].append((r,d))
    lrd[r].append((l,-d))
#wrong thought
#どっちも決まってない場合の処理
#決まってるとこからやれば良い
#ソートして順番に決めておく

#記録した関係から辿っていく
#まず初めのやつ
st=-1
for i in range(n):
    if len(lrd[i])>=1:
        st=i
        break

def bfs(z):
    #globalくらいちゃんとしろ
    global lrd,check,x
    for i in range(len(lrd[z])):
        k=lrd[z][i]
        if check[k[0]]:
            x[k[0]]=x[z]+k[1]
            check[k[0]]=False
            bfs(k[0])

st=0
while any(check):
    for i in range(st,n):
        if len(lrd[i])!=0 and check[i]:
            st=i
            break
        else:
            check[i]=False
    else:
        break
    x[st]=0
    check[st]=False
    bfs(st)

for i in range(n):
    l=len(lrd[i])
    for j in range(l):
        k=lrd[i][j]
        if x[k[0]]!=x[i]+k[1]:
            print("No")
            sys.exit()
print("Yes")

Measured memory_bytes: 128996
#define _CRT_SECURE_NO_WARNINGS
#define __STDC_FORMAT_MACROS
#include <array>
#include <cinttypes>
#include <cstdio>

using namespace std;

int64_t Lucas(int N)
{
    array<int64_t, 86> L;
    L[0] = 2;
    L[1] = 1;

    for (int i = 2; i <= N; i++)
    {
        L[i] = L[i - 1] + L[i - 2];
    }

    return L[N];
}

int main()
{
    int N;
    if (scanf("%d", &N) < 1) return 0;

    if (N == 1)
    {
        printf("%d\n", 1);
    }
    else
    {
        printf("%" PRId64 "\n", Lucas(N));
    }

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include <algorithm>
#include<string>
#include <numeric>
#include<math.h>
#include <bits/stdc++.h>
using namespace std;

int main(void) {
    int a,b,c;
    int count=0;
    cin >>a>>b>>c;
    if(a!=b)count++;
    if(b!=c)count++;
    if(c!=a)count++;
    if(a==b&&a==c)count=1;
    cout<<count<<endl;
}


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

int main(){
  double N; cin >> N;
  int n = static_cast<int>(N);
  int odd_num = (n+1) / 2;
  cout << static_cast<double>(odd_num) / static_cast<double>(N) << endl;
}

Measured memory_bytes: 256
n,l = map(int,input().split())
min_abs = 10**9
tmp = 10**9
for i in range(n):
    if abs(l + i) < min_abs:
        min_abs = abs(l+i)
        tmp = i
ans = 0
for i in range(n):
    if i == tmp:
        continue
    else:
        ans += l + i

print(ans)

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  string S,T; 
  cin>>S>>T;
  int ans=0;
  for(int i=0;i<3;i++){
    ans+=(S[i]==T[i]);
  }
  cout<<ans<<endl;
  return 0;
}


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

void Solve()
{
    int N, M;
    cin >> N >> M;
    int a[M + 1];
    int s[N + 1] = {0};
    for (int i = 1; i < M + 1; i++)
    {
        cin >> a[i];
        s[a[i]]++;
    }
    int dp[N + 1];
    dp[0] = 1;
    if (s[1] == 0)
    {
        dp[1] = 1;
    }
    else
    {
        dp[1] = 0;
    }
    for (int i = 2; i < N + 1; i++)
    {
        if (s[i] == 0)
        {
            dp[i] = dp[i - 1] + dp[i - 2];
            dp[i] %= 1000000007;
        }
        else
        {
            dp[i] = 0;
        }
    }
    cout << dp[N] << endl;
}

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

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

struct puzzle
{
    int f[9];
    int space;
    int cnt;

    bool operator<(const puzzle &p) const
    {
        rep(i, 9)
        {
            if (f[i] == p.f[i])
                continue;
            return f[i] > p.f[i];
        }
        return 0;
    }
};

pair<int, int> d[4] = {{-1, 0}, {0, -1}, {1, 0}, {0, 1}};

int bfs(puzzle s)
{
    queue<puzzle> q;
    map<puzzle, bool> mp;
    mp[s] = 1;
    s.cnt = 0;
    q.push(s);

    while (!q.empty())
    {
        puzzle u = q.front();
        q.pop();

        auto check = [](puzzle p) -> bool {
            rep(i, 9) if (p.f[i] != i + 1) return 0;
            return 1;
        };

        if (check(u))
            return u.cnt;

        int x = u.space / 3, y = u.space % 3;
        rep(i, 4)
        {
            int nx = x + d[i].first, ny = y + d[i].second;
            if (!((0 <= nx && nx < 3) && (0 <= ny && ny < 3)))
                continue;
            puzzle u_copy = u;

            swap(u_copy.f[u.space], u_copy.f[3 * nx + ny]);
            u_copy.space = 3 * nx + ny;

            if (!mp[u_copy])
            {
                mp[u_copy] = 1;
                u_copy.cnt++;
                q.push(u_copy);
            }
        }
    }

    return 0;
}

int main()
{
    puzzle in;
    rep(i, 9)
    {
        cin >> in.f[i];
        if (in.f[i] == 0)
        {
            in.f[i] = 9;
            in.space = i;
        }
    }

    OP(bfs(in));

    return 0;
}


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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int a, b; cin >> a >> b;
    cout << (a*3 + b)/2 << endl;
    return 0;
}

Measured memory_bytes: 256