akhauriyash/Code-Regression huggingface dataset:
//
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;

#define MOD 1000000007
#define rp(i,n) for(int i=0;i<(n);i++)
#define irp(i,n) for(int i=(n);i>=0;i--)
#define up(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define dw(i,s,e,d) for(int i=(s);i>(e);i-=(d))
// #define in(x) cin>>(x)
#define ot(x) cout<<(x)
#define ote(x) cout<<(x)<<endl
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define vecmax(v) (*max_element(v.begin(),v.end()))
void bye(auto x, int code=0){cout<<(x)<<endl;exit(code);}
// int in(){int x;cin>>x;return x;}
int in(){int x;scanf("%d",&x);return x;}
// template<class T> T in(){T x;cin>>x;return x;}

void vprn(vector<int> &v){ for(int i=0;i<v.size();i++) cout<<v[i]<<(i<v.size()-1?",\t":"\n"); }
void vvprn(vector<vector<int>> &vv){ for(auto v:vv) vprn(v); }

// template<class T> void vprn(T &v, string s, string m, string e)
// {cout<<s;for(int i=0;i<v.size();i++)cout<<v[i]<<m;cout<<e;}
// template<class T> void vvprn(T &vv, string s, string m, string e)
// {for(auto v:vv) vprn(v,s,m,e);}

int main(){
	int a;cin>>a;
	string s;cin>>s;
	if(a>=3200) ote(s);
	else ote("red");

}

Measured memory_bytes: 256
/*
 * 2584.cc: Broken Cipher Generator
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;

typedef long long ll;

const int INF = 1 << 30;
const ll LINF = 1LL << 60;

/* typedef */

typedef vector<int> vi;
typedef queue<int> qi;
typedef pair<int,int> pii;

/* global variables */

/* subroutines */

string cipher(string &s, int &pos);

char letter(string &s, int &pos) {
  if (s[pos] == '+') {
    pos++; // '+'
    char l = letter(s, pos);
    if (l == '?') return l;
    return (l == 'Z') ? 'A' : l + 1;
  }
  if (s[pos] == '-') {
    pos++; // '-'
    char l = letter(s, pos);
    if (l == '?') return l;
    return (l == 'A') ? 'Z' : l - 1;
  }
  return s[pos++];
}

string str(string &s, int &pos) {
  if (s[pos] != '[') return string(1, letter(s, pos));
  
  pos++; // '['
  string ci = cipher(s, pos);
  pos++; // ']'

  for (int i = 0, j = ci.size() - 1; i < j; i++, j--) swap(ci[i], ci[j]);
  return ci;
}

string cipher(string &s, int &pos) {
  string ci;
  while (pos < s.size() && s[pos] != ']') ci += str(s, pos);
  return ci;
}

/* main */

int main() {
  for (;;) {
    string s;
    cin >> s;
    if (s == ".") break;

    int pos = 0;
    string ans = cipher(s, pos);

    for (int i = 0; i < ans.size(); i++)
      if (ans[i] == '?') ans[i] = 'A';

    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 1200
#include<iostream>
using namespace std;
 
int main()
{
    int a,b;
    cin >> a>> b;
    
 

    int pizza = 16 - a - b;
    int meio = abs(a - b);
    if (pizza >= meio) {
        cout << "Yay!"<<endl;
    } else {
        cout << ":("<<endl;
    }
    return 0;
}

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

int main(int argc, char const* argv[])
{
    int a,b;
    cin >> a >> b;

    if (a%3 == 0)
        cout << "Possible" << endl;
    else if(b%3 == 0)
        cout << "Possible" << endl;
    else if((a+b)%3 == 0)
        cout << "Possible" << endl;
    else
        cout << "Impossible" << endl;

    return 0;
}

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

#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N-1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)

#define MOD 1000000007

using ll = long long;
using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<P> vpi;
typedef pair<ll,ll> Pl;
typedef vector<ll> vl;
typedef vector<Pl> vpl;

ll gcd(ll a, ll b){
    if(a < b) swap(a, b);
    if(b <= 0) return -1;
    ll r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

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


int main() {
    int N, M;
    cin >> N >> M;
    vector<vi> ab(N);
    //vector<vector<bool>> ch(N, vector<bool>(N ,false));
    vi ans(N, -1);
    ans[0] = 0;

    rep(i,M) {
        int a,b;
        cin >> a >> b;
        a--; b--;
        ab[a].push_back(b);
        ab[b].push_back(a);
    }

    queue<int> que;
    que.push(0);
    while(!que.empty()) {
        int nr = que.front(); que.pop();
        rep(i, ab[nr].size()) {
            if(ans[ab[nr][i]] != -1) continue;
            ans[ab[nr][i]] = nr;
            que.push(ab[nr][i]);
        }
    }

    bool flag = true;
    rep(i,N) {
        if(ans[i] == -1){
            flag = false;
            break;
        }
    }
    
    if(flag) {
        cout << "Yes" << "\n";
        rep1(i,N-1) cout << (ans[i]+1) << "\n";
    } else {
        cout << "No" << "\n";
    }
    //string ans = ( flag ? "Yes" : "No" );
    //printf("%.8lf", ans);
    //cout << ans;
    //cout << "\n";
    return 0;
}


Measured memory_bytes: 10268
#include <bits/stdc++.h>
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MAX max<ll>
#define MIN min<ll>
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
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; }
ll devc(ll x, ll y) { return (x + y - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll N;
    cin >> N;
    string S;
    cin >> S;
    ll r = 0, g = 0, b = 0;
    for(auto c : S){
        if(c == 'R') ++r;
        else if(c == 'G') ++g;
        else ++b;
    }

    ll ans = r * g * b;

    ll tp = 0;
    rep(i, N) rep(j, N) if(i < j){
        ll k = 2 * j - i;
        if(k < N) if(S[i] != S[j] and S[j] != S[k] and S[k] != S[i]) ++tp;
    }

    print(ans - tp);

    return 0;
}

Measured memory_bytes: 3668
n, m, q =  list(map(int, input().split()))
aa = []
bb =[]
cc = []
dd =[]
for i in range(q):
    a,b,c,d =  list(map(int, input().split()))
    aa.append(a)
    bb.append(b)
    cc.append(c)
    dd.append(d)

def ev(A):
    s = 0
    for i in range(q):
        if A[bb[i] - 1] - A[aa[i] - 1] == cc[i]:
            s += dd[i]
    return s

A = [0] * n
s = ev(A)
for i0 in range(m):
    for i1 in range(i0, m):
        for i2 in range(i1, m):
            for i3 in range(i2, m):
                for i4 in range(i3, m):
                    for i5 in range(i4, m):
                        for i6 in range(i5, m):
                            for i7 in range(i6, m):
                                for i8 in range(i7, m):
                                    for i9 in range(i8, m):
                                        A = [i0, i1, i2, i3, i4, i5, i6, i7, i8, i9][:n]
                                        s = max([s, ev(A)])
print(s)

Measured memory_bytes: 9280
#include<iostream>
#include<stack>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
ll sum=0;
ll n;
struct node
{
	int boss;
	int under;
	int num;
};
node  s[200005];
int num[200005];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		s[i].num=0;
	}
	for(int i=2;i<=n;i++)
	{
		cin>>num[i];
		s[num[i]].under=i;
		s[num[i]].num++;
	}
	for(int i=1;i<=n;i++)
	{
		cout<<s[i].num<<endl;
	}
	return 0;
 } 

Measured memory_bytes: 6744
import sys
from collections import deque
input = sys.stdin.readline
h, w = map(int, input().split())
g = []
for i in range(h):
    g.append(input())

move = ((0, 1), (1, 0), (-1, 0), (0, -1))
ans = 0

for start in  [[i, j] for i in range(h) for j in range(w)]:
    if g[start[0]][start[1]] == "#":
        continue
    dp = [[0 for i in range(w)] for i in range(h)]
    pre = [-1, -1]
    cur = start
    cnt = 0
    queue = deque([[cur, pre, cnt]])
    while queue:
        cur, pre, cnt = queue.popleft()
        c_x, c_y = cur
        if g[c_x][c_y] == '#':
          continue
        if not dp[c_x][c_y] or (dp[c_x][c_y] and dp[c_x][c_y] > cnt):
            dp[c_x][c_y] = cnt

            for x, y in move:
                next = [cur[0] + x, cur[1] + y]
                if next == start:
                    continue
                if next != pre and next[0] >= 0 and next[0] < h and next[1] >= 0 and next[1] < w:
                    queue.append([next, cur, cnt + 1])
    ans= max(max([dp[i][j] for i in range(h) for j in range(w)]), ans)


print(ans)


Measured memory_bytes: 45916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 60;
int n;
ll ans;
ll a[maxn];
void force()
{
	while(a[1] >= n)
	{
		a[1] -= n;
		for(int i = 2; i <= n; ++i) ++a[i];
		sort(a + 1, a + n + 1, greater<ll>());
		++ans;
	}
}
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) scanf("%lld", &a[i]);
	sort(a + 1, a + n + 1, greater<ll>());
	while(a[1] >= n)
	{
		int r = 1;
		while(r <= n && a[1] - a[r] <= n) ++r;
		--r;
		if(r == n)
		{
			if(a[n] >= n)
			{
				ll c = a[n] - n + 1;
				ans += c * r;
				for(int i = 1; i <= n; ++i) a[i] -= c;
			}
			force();
			break;
		}
		int x = n - r + 1, y = r;
		ll c = (a[1] - a[r + 1]) / (x + y);
		if(a[r] < c * x)
		{
			force();
			break; 
		}
		ans += c * r;
		for(int i = 1; i <= r; ++i) a[i] -= c * x;
		for(int i = r + 1; i <= n; ++i) a[i] += c * y;
		sort(a + 1, a + n + 1, greater<ll>());
	}
	cout << ans << endl;
	return 0;
}
/*
8
2 4 8 9 0 7 0 2
*/

Measured memory_bytes: 256
a = gets.chomp.to_i
b = gets.chomp.to_i
c = gets.chomp.to_i
x = gets.chomp.to_i

cnt = 0
for ai in 0..a
  for bi in 0..b
    for ci in 0..c
      if x == 500*ai + 100*bi + 50*ci
        cnt += 1
      end
    end
  end
end
puts cnt

Measured memory_bytes: 1788
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N,M;
		N= sc.nextInt();
		M = sc.nextInt();
		ArrayList<AbstractMap.SimpleEntry<Long,Integer>> list = new ArrayList<AbstractMap.SimpleEntry<Long,Integer>>();
		for(int i = 0; i<N; i++) {
			list.add( new AbstractMap.SimpleEntry<Long, Integer>(sc.nextLong(),sc.nextInt()) );
		}
		list.sort(Comparator.comparing(AbstractMap.SimpleEntry::getKey));
		long ans = 0;
		int count = 0;
		for(AbstractMap.SimpleEntry<Long,Integer> pair : list) {
			if(pair.getValue() < M-count) {
				count += pair.getValue();
				ans += pair.getKey()*pair.getValue();
			} else {
				ans += (M-count) * pair.getKey();
				break;
			}
		}
		System.out.println(ans);
	}

}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - Choose Integers
            var lines = ReadLines<int>(1).ToList();

            if (IsSatisfyConditions(lines[0]))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }        
        }

        static bool IsSatisfyConditions(List<int> numbers)
        {
            int a = numbers[0];
            int b = numbers[1];
            int c = numbers[2];

            for(int i = 1; i <= b; i++)
            {
                if (a * i % b == c)
                {
                    return true;
                }
            }

            return false;
        }
                               
        static IEnumerable<List<T>> ReadLines<T>(int count = 0, char separator = ' ')
        {
            //[summary]コンソールの値を読み込んで、List<T>のコレクションを返却

            //読み込む行数が未指定のときは、1行目の値を"count"とみなす
            if (count == 0)
            {
                string line = Console.ReadLine().TrimEnd();
                count = int.Parse(line);
            }

            for (int i = 0; i < count; i++)
            {
                //コンソールを1行読み込み
                string line = Console.ReadLine().TrimEnd();

                //char型のときは1文字ずつに分割
                if (typeof(T) == typeof(char))
                {
                    var list = line.ToCharArray().ToList();
                    yield return (List<T>)(object)list;
                }
                else
                {
                    //読み込んだ値を"separator"で区切る
                    var list = line.Split(separator).ToList();

                    //int型のときは数値に変換
                    if (typeof(T) == typeof(int))
                    {
                        var numbers = list.ConvertAll(int.Parse);
                        yield return (List<T>)(object)numbers;
                    }
                    else if (typeof(T) == typeof(long))
                    {
                        var numbers = list.ConvertAll(long.Parse);
                        yield return (List<T>)(object)numbers;
                    }
                    else
                    {
                        yield return (List<T>)(object)list;
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 11348
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def main():
    N = I()
    L = LI()
    L = sorted(L)
    cnt = 0
    for i in range(N-1):
        a = L[i]
        for j in range(i+1, N-1):
            b = L[j]
            ok = j + 1
            ng = N - 1
            # ensure ok
            if L[ok] >= a + b:
                ok = ng = j
            # ensure ng is not ok
            elif L[ng] < a + b:
                ok = ng = N - 1
            else:
                pass

            while ng - ok > 1:
                m = (ok + ng) // 2
                c = L[m]
                if c < a + b:
                    ok = m
                else:
                    ng = m
            cnt += (ok - j)
    print(cnt)
main()



Measured memory_bytes: 68312
#include <iostream>

using namespace std;

const int MOD = 1000 * 1000 * 1000 + 7;
const int MAXA = 2010;

int c[MAXA][MAXA];

int add(long long a, long long b)
{
	return (a + b) % MOD;
}

int mul(long long a, long long b)
{
	return (a * b) % MOD;
}

int main()
{
	int a, b;
	cin >> a >> b;
	int ans = 0;
	for (int i = 0; i <= b; i++)
	{
		c[i][0] = c[i][i] = 1;
		for (int j = 1; j < i; j++)
			c[i][j] = add(c[i - 1][j], c[i - 1][j - 1]);
	}
	for (int i = 0; i <= b - 1 && i <= a; i++)
	{
		if (i == 0)
			ans = add(ans, add(a, 1));
		else
			for (int j = 0; j <= i - 1 && (i + j) <= a; j++)
				ans = add(ans, mul(mul(c[b - 1][i], c[i - 1][j]), (a + 1 - i - j) * (a + 2 - i - j) / 2));
	}
	cout << ans << endl;
}

Measured memory_bytes: 15104
#include<bits/stdc++.h>  
using namespace std;
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
const int maxn = 1e9 + 5;
#define INF 100000000000
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;
const ll MAXN = 1e18;



int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
	int x,y;
	cin >> x >> y;
	bool ok = false;
	for(int i=0; i<=x; i++){
		int suma = i;
		int ama = x-i;
		if(suma*2+ama*4 == y){
			ok = true;
		}
	}
	if(ok){
		cout << "Yes\n";
	}else{
		cout << "No\n";
	}
	return 0;
}


Measured memory_bytes: 3616
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int H = sc.nextInt();
            int W = sc.nextInt();
            if (H == 0 && W == 0) {
                break;
            } else {
                for (int i = 0; i < H; i++) {
                    for (int j = 0; j < W; j++) {
                        System.out.print("#");
                    }
                    System.out.println();
                }
                System.out.println();
            }
        }
    }
}


Measured memory_bytes: 34796
#include<stdio.h>
#include<string.h>
int main()
{
    int a[3],a1[3],n;
    scanf("%d %d %d",&a[0],&a[1],&a[2]);
    if(a[0]<a[1] && a[0]<a[2])
    {
        a1[0]=a[0];
        a1[1]=a[1];
        a1[2]=a[2];
    }
    else if(a[1]<a[0] && a[1]<a[2])
    {
        a1[0]=a[1];
        a1[1]=a[0];
        a1[2]=a[2];
    }
     else {
        a1[0]=a[2];
        a1[1]=a[1];
        a1[2]=a[0];

    }

    if(a1[1]>a1[2])
    {
        n=a1[1]*10+a1[2]+a1[0];
    }
    else if(a1[1]==a1[2] && a1[0]==a1[2])
    {
        n=a1[1]*10+a1[2]+a1[0];
    }
    else if(a1[2]>a1[1])
    {
        n=a1[2]*10+a1[1]+a1[0];
    }
    else if(a1[1]==a1[2] && a1[0]<a1[1])
    {
        n=a1[1]*10+a1[2]+a1[0];
    }
    else
    {
        n=a1[0]*10+a1[1]+a1[2];
    }
    printf("%d",n);
    return 0;
}

Measured memory_bytes: 128
package main
 
import (
	"fmt"
)
 
func main() {
	var a, b, c int
	fmt.Scanf("%d %d %d %d", &a, &b, &c)
	plan1 := a * b
	if plan1 > c {
		fmt.Printf("%d", c)
	} else {
		fmt.Printf("%d", plan1)
	}
}

Measured memory_bytes: 1868
#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>> a[100000];
vector<int> ans(100000);
void dfs(int now, int pre, int col){
	ans[now]=col;
	for(auto u:a[now])
        if(u.first!=pre) dfs(u.first,now,col^(u.second&1));
}
int main(){
    int i,u,v,w,n;
	cin>>n;
	for(i=1;i<n;i++){
		cin>>u>>v>>w;
		a[u].emplace_back(v,w);
		a[v].emplace_back(u,w);
	}
	dfs(1,0,0);
	for(i=1;i<=n;i++) cout<<ans[i]<<endl;
}

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

long double calc_p(int p){
	long double ans = 0;
	for (int i = 1; i <= p; i++){
		ans += i;
	}
	ans /= p;
	return (ans);
}

int main(){
	int N, K;
	cin >> N >> K;
	vector <int> p(N);
	for (int i = 0; i < N; i++) cin >> p.at(i);
	vector <long> pS(N-K+1);
	long tmp = 0;
	for (int i = 0; i < K; i++) tmp += p.at(i);
	pS.at(0) = tmp;
	long max_pS = tmp;
	int max_i = 0;
	for (int i = 1; i < N-K+1; i++){
		tmp -= p.at(i - 1);
		tmp += p.at(K - 1 + i);
		pS.at(i) = tmp;
		if (max_pS < tmp){
			max_pS = tmp;
			max_i = i;
		}
	}
	long double ans = 0;
	for (int i = max_i; i < K + max_i; i++){
		ans += calc_p(p.at(i));
	}
	cout << fixed;
	cout << setprecision(20) << ans << endl;
}


Measured memory_bytes: 2560
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include <cassert>
    #include <cmath>
    #include<cstdint>

    #define INF 1e7
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

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

    int main(){
       string s,t;cin>>s>>t;
       int res = 0;
       rep(i,s.size())if(s[i]==t[i])res++;
       cout<<res;
    }
    


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

uint64_t lucas(int x) {
  if (x == 0) {
    return 2;
  }
  
  if (x == 1) {
    return 1;
  }
  
  if (x == 35) {
    return 20633239;
  }
  
  if (x == 36) {
    return 33385282;
  }
  
  if (x == 70) {
    return 425730551631123;
  }
  
  if (x == 71) {
    return 688846502588399;
  }
  
  return lucas(x - 1) + lucas(x - 2);
}

int main() {
  int N;
  cin >> N;
  cout << lucas(N) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <math.h>

using namespace std;

int main()
{
    int n;
    cin >> n;
    long long int x;
    bool done = false;
    bool zero = false;
    long long int MAX = pow(10, 18);
    long double tot = 1;


    for (int i = 0; i < n; i++) {
        cin >> x;
        tot *= x;
        if (x == 0) {
            zero = true;
        }
        else if (tot > MAX || tot < 0) {
            done = true;
        }
    }

    if (zero) {
        cout << 0 << endl;
    }
    else if (done) {
        cout << -1 << endl;
    }
    else {
        cout << (long long int)tot << endl;
    }


}


Measured memory_bytes: 3640
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

bool ask(ll tmp)
{
    printf("? %lld\n", tmp);
    fflush(stdout);
    char str[5] = { 0 };
    scanf("%s", str);
    if (str[0] == 'Y') {
        return true;
    }
    else {
        return false;
    }
}

void solve()
{
    int i;
    ll curr = 1;
    for (i = 1; i <= 10; i++) {
        if(i>1) curr = curr * 10;
        bool ok=ask(curr);
        if (!ok) {
            break;
        }
    }
    if (i == 11) {
        ll curr = 0;
        for (i = 1; i <= 10; i++) {
            curr = curr * 10 + 9;
            bool ok=ask(curr);
            if (ok) {
                break;
            }
        }
        //assert(i <= 9);
        int k;
        printf("! ");
        for (k = 0; k < i; k++) {
            if (k == 0) printf("1");
            else        printf("0");
        }
        printf("\n");
        fflush(stdout);
        return;
    }
    int keta = i-1;

    curr = 0;
    for (i = 1; i <= keta; i++) {
        int l = 0, r = 10;
        while (r - l > 1) {
            int m = (l + r) / 2;
            ll tmp0 = m;
            int k;
            for (k = 0; k < 9-(i-1); k++) {
                tmp0 *= 10;
            }
            ll tmp = curr + tmp0;
            bool ok = ask(tmp);
            if (ok) {
                r = m;
            }
            else {
                l = m;
            }
        }
        ll tmp0 = l;
        int k;
        for (k = 0; k < 9-(i-1); k++) {
            tmp0 *= 10;
        }
        curr += tmp0;
    }
    for (i = 1; i <= 9 - (keta - 1); i++) {
        curr /= 10;
    }
    printf("! %lld\n", curr+1);
    fflush(stdout);

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d%d", &T, &B);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 504
import sys
import bisect
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort()
C.sort()

ans = 0
for i in range(N):
    b = B[i]
    num_a = bisect.bisect_left(A, b)
    num_c = N - bisect.bisect_right(C, b)

    ans += num_a * num_c
print(ans)

Measured memory_bytes: 22720
#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)
    #define chmax(a, b) a = max(a, b)
    #define chmin(a, b) a = min(a, b)
    #define fi first
    #define se second
    #define INF 1000000009
    #define LLINF 1000000000000000009LL
    using ll = long long;
     
    char x[]={'a','i','u','e','o'};
     
    int main(){
      char c;
      cin>>c;
      rep(i,5){
        if(c==x[i]){
          cout<<"vowel"<<endl;
          return(0);
        }
      }
      cout<<"consonant"<<endl;
      return(0);
    }

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main ()
{
  int a,b;
  cin>>a>>b;
  if (a==1)a=14;
  if (b==1)b=14;
  if(a==b){
    cout<<"Draw"<<endl;
    }
  else if (a<b){
    cout<<"Bob"<<endl;
    }
  else{
    cout<<"Alice"<<endl;
    }
  }

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

#define ll long long

int main() {
	ll a;
	int s;
	cin >> a;
	string ans = "";
	while (a != 0) {
		s = a % 26 - 1;
		if (s < 0)s = 25;
		ans += (char)(s+'a');
		if (a % 26 == 0)a=a / 26 - 1;
		else a /= 26;
	}
	reverse(ans.begin(), ans.end());
	cout << ans;
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()

void solve(){
 string s;
  cin >> s;
  cout << s.substr(0,3) << endl;
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}

Measured memory_bytes: 3656
#D問題
N = int(input())
A = [int(input()) for i in range(N)]

ans = 0
MAX = 1

for i in range(N):
    if i == 0:
        ans+=A[0]-1
        now = 2
    else:
        if A[i] == now:
            now+=1
            continue
        if A[i]%now == 0:
            ans+=(A[i]//now)-1
        else:
            ans+=A[i]//now
            
print(ans)          

Measured memory_bytes: 7080
import java.util.Scanner;

class Main{
  static long[] factorialArray;
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long h = Integer.parseInt(sc.next());
    long w = Integer.parseInt(sc.next());
    long a = Integer.parseInt(sc.next());
    long b = Integer.parseInt(sc.next());
    long mod = 1000000007l;
    
    factorialArray = new long[(int)(h+w)];
    factorialArray[0] = 1l;
    for(long i=1l; i<h+w; i++){
      factorialArray[(int)i] = i%mod*factorialArray[(int)i-1]%mod;
    }
    long total = 0l;
    for(long i=b; i<w; i++){
      total += comb(i+h-a-1l, i, mod)*comb(-i+w-2l+a, a-1l, mod)%mod;
      total %= mod;
    }
    System.out.println(total);
  }
  
  private static long power(long n, long pow, long mod){
    if(pow == 0l){
      return 1l;
    }else if(pow == 1l){
      return n;
    }else{
      long x = power(n, pow/2l, mod);
      if(pow%2l == 0l){
        return x*x%mod;
      }else{
        return x*x%mod*n%mod;
      }
    }
  }
  
  private static long comb(long n, long k, long mod){
    return factorialArray[(int)n]*power(factorialArray[(int)k], mod-2l, mod)%mod*power(factorialArray[(int)(n-k)], mod-2l, mod)%mod;
  }
}


Measured memory_bytes: 25252
#include<bits/stdc++.h>
#define M 1000000007
#define pi ld(acos(-1.0))
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(int i=a;i<=(int)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fi first
#define se second
#define ii pair<int,int>
#define bye(x) {cout<<x;return 0;}
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    cs
    int n,l,r,t=0;cin>>n;
    vector<int> v(n);
    rep(i,n) v[i]=i+1;
    vector<int> vv(n);
    vector<int> vvv(n);
    for(auto &i:vv) cin>>i;
    for(auto &i:vvv) cin>>i;
    do{
        t++;
        if(v==vv) l=t;
        if(v==vvv) r=t;
    }while(next_permutation(v.begin(),v.end()));
    cout<<abs(l-r);
}

Measured memory_bytes: 256
#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 main(){
    int n;
    cin >> n;
    vector <int> a(n),b(n),c(n-1);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n-1) cin >> c[i];
    
    int p;
    int ans;
    ans=0;
    p=-12;
    rep(i,n){
        
        ans+=b[a[i]-1];
        if(p==a[i]-1) {
            ans+=c[p-1];
        }
        p=a[i];
    }
    cout << ans << endl;

    return 0;
}

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

int main() {

  int N;
  cin >> N;
  
  vector<int> A(N);
  for(int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  
  for(int i = 0; i < N; i++) {
    if(A.at(i) % 2 != 0) A.at(i) = 1;
    else {
      if(A.at(i) % 3 == 0 || A.at(i) % 5 == 0) A.at(i) = 1;
      else A.at(i) = 0;
    }
  }
  
  int ans = 1;
    
  for(int i = 0; i < N; i++) {
//    cout << "A.at(" << i << ")" << A.at(i) << ", ";
      ans *= A.at(i);
//    cout << "ans(" << i << ")" << ans << ", ";
  }
  
  if(ans == 1) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
  
}

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

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

	vector<int> count( N );

	for( int i = 0; i < M; ++i ) {
		int a, b;
		cin >> a >> b;

		count.at( a-1 ) += 1;
		count.at( b-1 ) += 1;
	}

	for( int i = 0; i < N; ++i ) {
		cout << count.at(i) << endl;
	}
}


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

int main()
{
    char input_str[1+1];

    // 入力
    scanf("%s", input_str);

    // 入力値チェック
    if( strcmp(input_str, "A") == 0 ) {
        printf("T\n");
    }
    else if( strcmp(input_str, "T") == 0 ) {
        printf("A\n");
    }
    else if( strcmp(input_str, "C") == 0 ) {
        printf("G\n");
    }
    else if( strcmp(input_str, "G") == 0 ) {
        printf("C\n");
    }

    return 0;
}


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

int main(int argc, char const *argv[])
{
	string s; cin >> s;
	int l = stoi(s.substr(0, 2));
	int r = stoi(s.substr(2, 2));
	bool f_yymm = (1 <= r && r <= 12) ? true : false;
	bool f_mmyy = (1 <= l && l <= 12) ? true : false;
	if (f_yymm && f_mmyy) {
		printf("AMBIGUOUS\n");
	} else if (f_yymm) {
		printf("YYMM\n");
	} else if (f_mmyy) {
		printf("MMYY\n");
	} else {
		printf("NA\n");
	}
	return 0;
}


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

int n, m, a, b, c;
vector<vector<int>> rg;

ll bfs(int s, int x) {
  vector<ll> used(x + 1, 0LL);
  queue<P> q;
  q.push({s, 0});
  while (!q.empty()) {
    int u, d;
    tie(u, d) = q.front();
    q.pop();
    if (d == x) return used[d];
    for (auto v : rg[u]) {
      if (used[d + 1] >> v & 1) continue;
      used[d + 1] |= 1LL << v;
      q.push({v, d + 1});
    } 
  }
  return 0LL;
} 

int main() {
  cin >> n >> m >> a >> b >> c;
  rg.resize(n);
  REP(i, m) {
    int u, v;
    cin >> u >> v, u--, v--;
    rg[v].push_back(u);
  }
  ll used = 0LL;
  used |= 1LL << (n - 1);
  queue<P> q;
  q.push({n - 1, 1});
  map<int, ll> bits;
  bits[a] = 0LL;
  bits[b] = 0LL;
  bits[c] = 0LL;
  while (!q.empty()) {
    int s, ans;
    tie(s, ans) = q.front();
    q.pop();
    ll all = (1LL << n) - 1;
    for (auto x : {a, b, c}) {
      auto bit = bfs(s, x);
      bits[x] |= bit;
      all &= bits[x];
    }
    REP (t, n) {
      if (~all >> t & 1) continue;
      if (t == 0) {
        cout << ans << endl;
        return 0;
      }
      if (used >> t & 1) continue;
      used |= 1LL << t;
      q.push({t, ans + 1});
    }
  }
  cout << "IMPOSSIBLE" << endl;
  return 0;
}




Measured memory_bytes: 3176
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;


//arc067_c
//Nの階乗の約数
//素因数分解した値の組み合わせ 素因数が2^x,3^y,4^zの場合: (x+1)*(y+1)*(z+1)
int main(){
  string S[3];
  REP(i,3)cin >> S[i];

  cout << S[0][0] << S[1][1] << S[2][2]<< endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h> 

int main(void){
	int x=0;
	int y=0;
	scanf("%d %d",&x,&y);
	while(x || y){
		if(x > y){
			printf("%d %d\n",y,x);
		}
		else{
			printf("%d %d\n",x,y);
		}
		scanf("%d %d",&x,&y);
	}
	return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
#include <stdlib.h>

#define INF 100000000000000


long long check(int data[],long long dp[],int k,int i){
    long long ret = INF;
    for(int j=k;j<i;j++){
        if(ret>dp[j]+abs(data[j]-data[i]))ret = dp[j]+abs(data[j]-data[i]);
    }
    return ret;
}

int main(){
    int N ;
    int K ;
    scanf("%d%d",&N,&K);
    int h[100100];
    long long dp[100100];
    int i,j;
    for(i=0;i<N;i++){
        scanf("%d",&h[i]);
        dp[i] = INF;
    }
    
    
    dp[0] = 0;
    dp[1] = abs(h[0]-h[1]);
    for(i=2;i<N;i++){
        if(i<K){
        dp[i] = check(h,dp,0,i);
        }else{
            dp[i] = check(h,dp,i-K,i);
        }
    }
    printf("%llu\n",dp[N-1]);
    return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi A(n);
  map<ll,ll>MP;
  vi prime;
  prime.pb(2);
  for(ll i=3;i<=sqrt(1e9+10);i+=2){
    bool hoge=true;
    for(ll j=2;j<=sqrt(i);j++){
      if(i%j==0){
	hoge=false;
	break;
      }
    }
    if(hoge)prime.pb(i);
  }
  ll ans=0;
  for(int i=0;i<n;i++){
    ll a;cin>>a;
    ll ori=a;
    ll now=0;
    set<ll>se;
    while(now<prime.size()&&a>1){
      if(a%prime[now]==0){a/=prime[now];se.insert(prime[now]);}
      else now++;
    }
    if(a>1)se.insert(a);
    for(auto aa:se){
      MP[aa]+=ori;
    }
  }
  for(auto a:MP){
    //  cout<<a.F<<" "<<a.S<<endl;
    ans=max(ans,a.S);
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 3280
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
 
ll power(ll a, ll b){//a^b
    ll res=1;
    while(b>0){
        if(b&1){res=(res*a);b--;}
        a=(a*a);
        b>>=1;
    }
    return res;
}
 
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
	vl v(n);
	for(ll i=0;i<n;i++)
		cin>>v[i];
	sort(all(v));
	ll take=2;
	ll ans=v[n-1];
	for(ll i=n-2;i>=0;i--){
		if(take<n-1){
			ans+=2*v[i];
			take+=2;
		}
		else if(take==n-1){
			ans+=v[i];
			take++;
			break;
		}
		else
			break;
	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 4784
#include <iostream>
#include <assert.h>
#include <vector>

#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <climits>

#define N 4
#define N2 16

using namespace std;

// const int N = 4;
// const int N2 = 16;

static const int dx[4] = {0, -1, 0, 1};
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = {'r', 'u', 'l', 'd'}; 


struct Node
{
	int puzzle[N2];
	int space;
	int md;
};

class Npuzzle
{
private:
	Node s_node;
	Node cur_n;
	int limit;
	int md[N2][N2];
	// vector<int> path;
	int ans;
public:
	Npuzzle() {
		s_node = Node();
		int in[N2];
		for (int i = 0; i < N2; ++i)
		{
			int tmp;
			cin >> tmp;
			if(tmp == 0) {
				tmp = N2;
				s_node.space = i;
			}
			s_node.puzzle[i] = tmp;
		}
		set_md();
		s_node.md = get_md_sum(s_node.puzzle);
	}

	int get_md_sum(int *puzzle) {
		int sum = 0;
		for (int i = 0; i < N2; ++i)
		{
			if(puzzle[i] == N2) continue;
			sum += md[i][puzzle[i]-1];
		}
		return sum;
	}

	void set_md() {
		for (int i = 0; i < N2; ++i)
		{
			for (int j = 0; j < N2; ++j)
			{
				md[i][j] = abs(i / N - j / N) + abs(i % N - j % N);
			}
		}
	}

	bool dfs(int depth, int pre) {
		if(cur_n.md == 0 ) {
			ans = depth;
			return true;
		}
		if(depth + cur_n.md > limit) return false;
		int s_x = cur_n.space / N;
		int s_y = cur_n.space % N;
		for (int i = 0; i < 4; ++i)
		{
			Node tmp = cur_n;
			int new_x = s_x + dx[i];
			int new_y = s_y + dy[i];
			if(new_x < 0  || new_y < 0 || new_x >= N || new_y >= N) continue; 
			if(max(pre, i) - min(pre, i) == 2) continue;

			//incremental manhattan distance
			cur_n.md -= md[new_x * N + new_y][cur_n.puzzle[new_x * N + new_y] - 1];
			cur_n.md += md[s_x * N + s_y][cur_n.puzzle[new_x * N + new_y] - 1];

			swap(cur_n.puzzle[new_x * N + new_y], cur_n.puzzle[s_x * N + s_y]);
			cur_n.space = new_x * N + new_y;
			// assert(get_md_sum(new_n.puzzle) == new_n.md);
			// return dfs(new_n, depth+1, i);
			if(dfs(depth + 1, i)){
				// path[depth] = i;
				return true;
			}
			cur_n = tmp;
		}
		return false;
	}

	void ida_star() {
		for (limit = s_node.md; limit < 1000; ++limit)
		{
			// path.resize(limit);
			cur_n = s_node;
			if(dfs(0, -10)) {
				cout << limit << endl;
				// string str = "";
				// for (int i = 0; i < limit; ++i)
				// {
				// 	str += dir[path[i]];
				// }
				// cout << str << endl;
				return;
			}
		}
	}

	void exec() {
		ida_star();
	}
};


int main() {
	Npuzzle np = Npuzzle();
	np.exec(); 
}

Measured memory_bytes: 3108
#include<stdio.h>
int main(void)
{
    int a,b;
    scanf("%d %d",&a,&b);
    if (a<b){
        printf("a < b\n");
    }
    else if(a==b){
        printf("a == b\n");
    }
    else
        printf("a > b\n");

    return 0;
}

Measured memory_bytes: 580
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;


int main() {
    int n, m, R;
    cin >> n >> m >> R;
    vi r(R);
    rep(i, R) {
        cin >> r[i];
        --r[i];
    }
    sort(r.begin(), r.end());
    vector<vector<pair<int, int> > > G(n);
    rep(i, m) {
        int a, b, c;
        cin >> a >> b >> c;
        --a;
        --b;
        G[a].push_back(make_pair(b, c));
        G[b].push_back(make_pair(a, c));
    }


    vector<vector<int> > Gr(R, vi(R));
    rep(i, R) {
        queue<int> Q;
        Q.push(r[i]);
        vi dis(n, INT_MAX);
        dis[r[i]] = 0;
        while(!Q.empty()) {
            int now = Q.front();
            Q.pop();
            for(auto next:G[now]){
                if(dis[next.first] != INT_MAX) {
                    if(dis[next.first] > dis[now] + next.second) {
                        Q.push(next.first);
                        dis[next.first] = dis[now] + next.second;
                    } else if(dis[next.first] + next.second < dis[now]) {
                        dis[now] = dis[next.first] +next.second;
                        Q.push(now);
                        break;
                    } else {
                        continue;
                    }
                }
                dis[next.first] = dis[now] + next.second;
                Q.push(next.first);
            }
        }
        rep(j, R) {
            Gr[i][j] = dis[r[j]];
        }
        /*rep(j, n) {
            cout << dis[j] << ' ';
        }
        cout << endl;*/
    }


    int ans = INT_MAX;
    vi vec(R);
    rep(i, R) {
        vec[i] = i;
    }

    do{
        int d=0;
        rep(i, R-1) {
            d += Gr[vec[i]][vec[i+1]];
        }
        ans = min(ans, d);
    } while(next_permutation(vec.begin(), vec.end()));

    cout << ans << endl;
}

Measured memory_bytes: 768
#include <stdio.h>
#include <stdlib.h>

typedef struct _node {
	int value;
	int forward;
	int backward;
	int chldNum;
	int *chldHead;
} node;

node *allocNode(int u, int k) {
	node *p = (node *)malloc(sizeof(node));
	p->value = u;
	p->forward = 0;
	p->backward = 0;
	p->chldNum = k;
	p->chldHead = k > 0 ? (int *)malloc(sizeof(int) * k) : NULL;
	return p;
}

void terminate(node **top, int n) {
	int i;
	for (i = 0; i < n; i++)	free(top[i]->chldHead);
	free(top);
}

void dfs(node **top, int u, int *time) {
	int i;
	node *p = top[u];
	if (p->forward > 0) return;
	p->forward = ++(*time);
	for (i = 0; i < p->chldNum; i++) {
		dfs(top, p->chldHead[i], time);
	}
	p->backward = ++(*time);
}

int main() {
	int i, j, u, k, n, v, time;
	node **top;

	scanf("%d", &n);
	top = (node **)malloc(sizeof(node *) * n);
	for (i = 0; i < n; i++) {
		scanf("%d %d", &u, &k);
		top[i] = allocNode(u, k);
		for (j = 0; j < k; j++) {
			scanf("%d", &v);
			top[i]->chldHead[j] = v - 1;
		}
	}

	time = 0;
	for (i = 0; i < n; i++)	if (top[i]->forward == 0) dfs(top, i, &time);

	for (i = 0; i < n; i++)
		printf("%d %d %d\n", top[i]->value, top[i]->forward, top[i]->backward);

	terminate(top, n);

	return 0;
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int sum = 0;
    for(int i=0; i<s.length(); i++){
        sum += (s[i]-'0');
    }
    if(sum%9==0){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3696
read X Y n;
for((;i++<n;))do
	read a b c;
	if [ $c = 1 ];then
		x=$[x<a?a:x]
	elif [ $c = 2 ];then
		X=$[X<a?X:a]
	elif [ $c = 3 ];then
		y=$[y<b?b:y]
	else
		Y=$[Y<b?Y:b]
	fi
done
echo $[(x<X?X-x:0)*(y<Y?Y-y:0)]


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

using namespace std;

using ll = long long;

int Solve() {
    int a, b, c;

    cin >> a >> b >> c;
    int max_abc = max({a, b, c});
    int da = max_abc - a, db = max_abc - b, dc = max_abc - c;
    int cnt = (da % 2) + (db % 2) + (dc % 2);

    if (cnt == 3 || cnt == 1) { ++da; ++db; ++dc; }

    return da / 2 + db / 2 + dc / 2 + (cnt == 1 || cnt == 2);
}

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

    cout << Solve() << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

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

  while(true){
    int n,a,b,c,x;
    cin >> n >> a >> b >> c >> x;
    if(n==0) break;
    int y[n+1];
    for(int i=1;i<=n;i++){
    cin >> y[i];
    }
    int pos=1,flame=0;
    if( x==y[1]){
      pos++;
    }
    while(pos<n+1){
      flame++;
      x = (a*x+b)%c;
      if(x==y[pos]) pos++;
      if(flame>10000){
        cout << -1 << endl;
        break;
      }
    }
    if(flame!=10001) cout << flame << endl;
  }
}

Measured memory_bytes: 3016
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  string s;
  cin >> s;
  ll n = s.length();
  ll cntW = 0;
  ll ans = 0;
  rep(i,n) {
    if (s[i] == 'W') {
      ans += i - cntW;
      cntW++;
    }
  }
  cout << ans << endl;
}

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

Measured memory_bytes: 3768
#include<iostream>
 
using namespace std;
int main()
 
{
 
string s;
 
cin>>s;
 
if(s=="abc"||s=="acb"||s=="bac"||s=="bca"||s=="cab"||s=="cba"){
    cout<<"Yes"<<endl;
}
 
else  {
        cout<<"No"<<endl;
 
}
 
 
return 0;
 
}

Measured memory_bytes: 256
/**
 * The man who codes no bugs
 * McCheng is the man studying Maths in CUHK with IQ200
 * @author McCheng
 */

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

class BJudgeStatusSummary {
public:
    static constexpr int kStressCount = 0;
    static void generateTest(ostream& test) {}
	void solve(istream& cin, ostream& cout) {
int n;
cin>>n;
        vector<int> a(4);
        for (int i = 0; i < n; i++) {
            string s;
            cin>>s;
            if (s=="AC") a[0]++;
            else if (s=="WA") a[1]++;
            else if (s=="TLE") a[2]++;
            else a[3]++;
        }
        cout<<"AC x "<<a[0]<<"\n";
        cout<<"WA x "<<a[1]<<"\n";
        cout<<"TLE x "<<a[2]<<"\n";
        cout<<"RE x "<<a[3]<<"\n";
	}
};

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream &in(cin);
    ostream &out(cout);
    out << fixed;
    out.precision(20);
    BJudgeStatusSummary solver;
    solver.solve(in, out);
}


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <cmath>
#include <limits.h>
#include <utility>
#include <map>
#include <algorithm>
using namespace std;
using P = pair<int,int>;
using ll = long long;
int main(){
    int x,y;
    cin>>x>>y;
    for(int i=0;i<=x;i++){
        if(2*i+4*(x-i)==y){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 3632
print_endline @@ Scanf.scanf "%d" @@ fun n ->
  let u = n * (n+1) / 2 in
  let a = Array.init n (fun _ -> Scanf.scanf " %d" ((+) 0)) in
  if n = 1 then "YES" else
  let s = Array.fold_left (+) 0 a in
  if s mod u <> 0 then "NO" else
  let m = s / u in
  let chk d =
    let k = max 0 ((d+n-2)/(n-1)) in
    let v = k*(n-1) - d in
    v <= m-k && (m-k-v) mod n = 0
  in
  let ok =
    Array.init n (fun i -> chk (a.(i) - a.((i+1) mod n)))
    |> Array.fold_left (&&) true
  in if ok then "YES" else "NO"

Measured memory_bytes: 5376
require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

max = 0
ans = 0
a.each do |h|
  if h < max
    ans += max - h
    h = max
  elsif h > max
    max = h
  end
end

puts ans


Measured memory_bytes: 30468