akhauriyash/Code-Regression huggingface dataset:
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using D = double;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define RALL(qpqpq)           (qpqpq).rbegin(),(qpqpq).rend()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define RFOR(i,tptpt,ypypy)  for(LL i=(tptpt);i>=(ypypy);i--)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, k;
bool out[10];

bool calc(int n) {
	string s = to_string(n);
	REP(i, s.size()) {
		if (out[s[i] - '0'])return false;
	}
	return true;
}

int main() {
	cin >> n >> k;
	REP(i, k) {
		int num;
		cin >> num;
		out[num] = true;
	}
	while (true) {
		if (calc(n)) {
			cout << n << endl;
			return 0;
		}
		else {
			n++;
		}
	}
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if i*500 + j*100 + k*50 == X:
        ans += 1
print(ans)

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

using namespace std;


template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s)
{
    return '"' + s + '"';
}

string to_string(const char* s)
{
    return to_string((string) s);
}

string to_string(bool b)
{
    return (b ? "true" : "false");
}

string to_string(vector<bool> v)
{
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v)
{
    string res = "";
    for (size_t i = 0; i < N; i++)
    {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v)
{
    bool first = true;
    string res = "{";
    for (const auto &x : v)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p)
{
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out()
{
    cerr << endl;
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            for (int k = j + 1; k < n; k++)
            {
                if (a[i] != a[j] && a[j] != a[k] && a[i] != a[k])
                {
                    if (a[i] + a[j] > a[k] && a[i] + a[k] > a[j] && a[k] + a[j] > a[i])
                    {
                        ans++;
                    }
                }
            }
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3660
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @author Pavel Mavrin
 */
public class Main {

    private void solve() throws IOException {
        int n = nextInt();
        int m = nextInt();
        int d = nextInt();
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                int x = (i + j) % (2 * d);
                int y = (n - i + j) % (2 * d);
                if (x >= d) {
                    if (y >= d) {
                        out.print("R");
                    } else {
                        out.print("Y");
                    }
                } else {
                    if (y >= d) {
                        out.print("G");
                    } else {
                        out.print("B");
                    }
                }
            }
            out.println();
        }
    }



    // ------------------

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st;
    PrintWriter out = new PrintWriter(System.out);

    String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

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

    private void run() throws IOException {
        solve();
        out.close();
    }

}


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

int main() {
	int i=0,x,m,n=0;
	cin>>x>>m;
	x=x-1;
	int j=m;
	int s=(2*x)-1;
	int h[s];
	for(i=0;i<x;i++){
		j--;
		h[n]=j;
		n++;}
	j=m;
	h[n]=j;
	n++;
	for(i=0;i<x;i++){
		j++;
        h[n]=j;
        n++;}
	int k=n;
    sort(h,h+k);
	for(i=0;i<n;i++)
        cout<<h[i]<<" " ;
	return 0;}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, M, LRD):
    # print(LRD)
    g = [[] for _ in range(N)]
    ns = set([])
    for l ,r, d in LRD:
        g[l-1].append((r-1,d))
        g[r-1].append((l-1,-d))
        ns.add(l-1)
        ns.add(r-1)      
    
    G =  [None for _ in range(N)]

    if M == 0:
        return 'Yes'

    ns = {n:n for n in ns}
    while ns:
        # q = [list(ns.keys())[0]]
        for k in ns.keys():
            q = [k]
            break
        ns.pop(q[0])
        # print(q)
        G[q[0]] = 0
        while q:
            n = q.pop()
            for r, d in g[n]:
                if G[r] is None:
                    G[r] = G[n] + d
                    q.append(r)
                    # if r in ns:
                    ns.pop(r)
                else:
                    if G[r] != G[n] + d:
                        return 'No'
                        # pass
    
    return 'Yes'
            



def main():
    N, M = read_int_n()
    LRD = [read_int_n() for _ in range(M)]

    # N = 100000
    # M = 200000
    # LRD = [[random.randint(1, N), random.randint(1, N), random.randint(1, 10000)] for _ in range(M) ]
    print(slv(N, M, LRD))


if __name__ == '__main__':
    main()


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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    int n;
    cin >> n;
    if(n == 1){
        cout << "Hello World" << endl;
        return 0;
    }
    int a, b;
    cin >> a >> b;
    cout << a + b << endl;
    return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	string s;
	cin >> s;

	ll k;
	cin >> k;

	int n = s.size();
	int cnt = 0; 
	char x;
	rep(i, n){
		if(s[i] != '1'){
			x = s[i];
			break;
		} 
		cnt++;
	}

	// cout << x << "," << cnt << endl;
	
	if(k <= cnt) cout << 1 << endl;
	else cout << (""s + x) << endl;
	
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define BUF_SIZE 100

// size: specify sizeof(str)
int get_str(char *str, int size) {
    if(!fgets(str, size, stdin)) return -1;
    return 0;
}

int get_int(void) {
  int num;
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return 0;
  sscanf(line, "%d", &num);
#else
#error
#endif
  return num;
}

int get_int2(int *a1, int *a2) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, "%d %d", a1, a2);
#else
#error
#endif
  return 0;
}

int get_int3(int *a1, int *a2, int *a3) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, "%d %d %d", a1, a2, a3);
#else
#error
#endif
  return 0;
}

#define VERTEX_MAX 300
#define INF (int)(0x0101010101)
#define QUERY_MAX 100000

struct pair {
    int start;
    int end;
};

int main(void) {
    int vs, es, litters;
    static uint64_t graph[VERTEX_MAX][VERTEX_MAX];
    static int cnt[VERTEX_MAX][VERTEX_MAX];
    memset(graph, 0x01, sizeof(uint64_t)*VERTEX_MAX*VERTEX_MAX);
    memset(cnt, 0x01, sizeof(int)*VERTEX_MAX*VERTEX_MAX);
    get_int3(&vs, &es, &litters);
    int i, j, k;
    for(i = 0; i < es; i++) {
        int v1, v2, cost;
        get_int3(&v1, &v2, &cost);
        // 1-indexed -> 0-indexed
        v1--; v2--;
        // cannot passed
        if(litters < cost) continue;
        graph[v1][v2] = graph[v2][v1] = cost;
        cnt[v1][v2] = cnt[v2][v1] = 0;
    }


    // Warshall-floyd
    for(k = 0; k < vs; k++) {
        for(i = 0; i < vs; i++) {
            for(j = 0; j < vs; j++) {
                uint64_t new = graph[i][k] + graph[k][j];
                if(graph[i][j] > new) {
                    if(new > litters) continue;
                    graph[i][j] = new;
                    cnt[i][j] = 0;
                }
            }
        }
    }

    // Warshall-floyd
    for(k = 0; k < vs; k++) {
        for(i = 0; i < vs; i++) {
            for(j = 0; j < vs; j++) {
                cnt[i][j] = min(cnt[i][k] + cnt[k][j] + 1, cnt[i][j]);
            }
        }
    }

    int qs = get_int();
    int ans[QUERY_MAX];
    int aidx = 0;
    for(i = 0; i < qs; i++) {
        int src, dst;
        get_int2(&src, &dst);
        // 1-indexed -> 0-indexed
        src--; dst--;
        if(cnt[src][dst] == INF) {
            ans[aidx++] = -1;
        } else {
            ans[aidx++] = cnt[src][dst];
        }
    }

    // presentation
    for(i = 0; i < aidx; i++) {
        printf("%d\n", ans[i]);
    }
    return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << endl;
#else
	#define DBG(X)
	#define endl '\n'
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline void goodbye(const T& val) { cout << val << endl; exit(0); }

const int MAX_M = 1007;
const int MAX_N = 12;
const int DP_SZ = (1 << MAX_N) + 228;

ll cost[MAX_M];
int mask[MAX_M];

int n, m;

ll dp[MAX_M][DP_SZ];

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

	for(int i = 0; i < m; ++i)
	{
		int cnt;
		cin >> cost[i] >> cnt;

		while(cnt--)
		{
			int j;
			cin >> j;
			--j;

			mask[i] |= 1 << j;
		}
	}

	for(int i = 0; i <= m; ++i)
	{
		for(int msk = 0; msk < (1 << n); ++msk)
			dp[i][msk] = LL_INF;
	}

	dp[0][0] = 0;

	for(int pos = 0; pos < m; ++pos)
	{
		for(int msk = 0; msk < (1 << n); ++msk)
		{
			int n_msk = msk | mask[pos];

			dp[pos + 1][n_msk] = min(dp[pos + 1][n_msk], dp[pos][msk] + cost[pos]);
			dp[pos + 1][msk] = min(dp[pos + 1][msk], dp[pos][msk]);
		}
	}

	ll answ = dp[m][(1 << n) - 1];
	cout << (answ == LL_INF ? NIL : answ) << endl;
}

int main()
{
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 34048
(N,) = [int(x) for x in input().split()]
brackets = [input() for i in range(N)]

delta = []
minDelta = []
for s in brackets:
    balance = 0
    mn = 0
    for c in s:
        if c == "(":
            balance += 1
        else:
            balance -= 1
        mn = min(mn, balance)
    delta.append(balance)
    minDelta.append(mn)

if sum(delta) == 0:
    # Want to get balance as high as possible
    # Take any positive as long there's enough balance to absorb their minDelta
    # Can sort since anything that works will only increase balance and the ones with worse minDelta comes later
    posIndices = [i for i in range(N) if delta[i] > 0]
    posIndices.sort(key=lambda i: minDelta[i], reverse=True)

    # At the top can take all with zero delta, just need to absorb minDelta
    eqIndices = [i for i in range(N) if delta[i] == 0]

    # When going back down, want to preserve existing balance as much as possible but take a hit for stuff that does need to use the balance to absorb minDelta
    negIndices = [i for i in range(N) if delta[i] < 0]
    negIndices.sort(key=lambda i: delta[i] - minDelta[i], reverse=True)

    balance = 0
    for i in posIndices + eqIndices + negIndices:
        if balance + minDelta[i] < 0 or balance + delta[i] < 0:
            print("No")
            exit()
        balance += delta[i]
    assert balance == 0

    print("Yes")
else:
    print("No")


Measured memory_bytes: 248744
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<cmath>

using namespace std;

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

struct edge {int from, to, cost;};

int main(){
    int l;
    cin >> l;
    int r = 0;
    int k = l;
    while(k / 2 != 0){
        k /= 2;
        r++;
        
    }
    vector<edge> G;
    k = 1;
    rep(i, r){
        edge g;
        g.from = i + 1;
        g.to = i + 2;
        g.cost = k;
        G.push_back(g);
        g.cost = 0;
        G.push_back(g);
        k *= 2;
    }
    k = 1;
    rep(i, r-1) k *= 2;
    int bi = k * 2;
    // cout << bi << endl;
    for (int i = r; i >= 1; i--){
        if (l - k >= bi){
            edge g;
            g.from = i;
            g.to = r + 1;
            g.cost = l - k;
            G.push_back(g);
            l -= k;
        }
        k /= 2;
    }
    cout << r + 1 << " " << G.size() << endl;
    rep(i, G.size()){
        cout << G[i].from << " " << G[i].to << " " << G[i].cost << endl;
    }
}


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

int main(){
    long long a, b, c, k;
    cin >> a >> b >> c >> k;
    if(k % 2 == 0){
        long long delta = a - b;
        if(abs(delta) > 1e18){
            printf("Unfair\n");
        }
        else{
            cout << delta << endl;
        }

    }
    else{
        long long delta = b - a;
        if(abs(delta) > 1e18){
            printf("Unfair\n");
        }
        else{
            cout << delta << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3632
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int N = scan.nextInt();
    int[] A = new int[N+1];
    int[] B = new int[N+1];
    int[] C = new int[N];
    
    for (int i=1; i<N+1; i++) {
      A[i] = scan.nextInt();
    }
    
    for (int i=1; i<N+1; i++) {
      B[i] = scan.nextInt();
    }
    
    for (int i=1; i<N; i++) {
      C[i] = scan.nextInt();
    }
   
    int sum= 0;
    
    for (int j=1; j<N+1; j++){
      sum += B[A[j]];
      if (A[j]-A[j-1] ==1 && j!=1) {
        sum += C[A[j-1]];
      }
    }
 
    System.out.println(sum);
  
  }
 
}

Measured memory_bytes: 21844
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

if a < b:
    if a + t * v >= b + t * w:
        print("YES")
    else:
        print("NO")
else:
    if a - t * v <= b - t * w:
        print("YES")
    else:
        print("NO")
        

Measured memory_bytes: 9176
import java.util.*; 
import java.io.*;

public class Main{
    static StringTokenizer st;
    static BufferedReader br;  
    static PrintWriter out;
 
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
 
        int K = nextInt();
        int N = nextInt();

        int[] input = new int[N];
        for (int x=0; x<N; x++) { 
            input[x]  = nextInt();
        }

        Arrays.sort(input);

        int max = Integer.MIN_VALUE;
        
        for (int x=1; x<N; x++) { 
            int tmp = input[x] - input[x-1]; 
            max = Math.max(tmp, max);
        }

        max = Math.max(K-input[N-1]+input[0], max);

        System.out.println(K-max);
    }
    
      
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}

Measured memory_bytes: 55040
#include <iostream>
#include <vector>
using namespace std;
bool judge(vector<vector<char>> a,vector<vector<char>> b,int k,int t,int m){
    for(int i = 0;i<m;i++){
        for(int j = 0;j<m;j++){
            if(b[i][j]!=a[i+k][j+t]) return false;
        }
    }
    return true;
}
int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<char>> a;
    vector<vector<char>> b;
    char t;
    for(int i = 0;i<n;i++){
        a.push_back({});
        b.push_back({});
    }
    //cout << "meu" << endl;
    for(int i = 0;i<n;i++) for(int j = 0;j<n;j++){
        cin >> t;
        a[i].push_back(t);     
    } 
    for(int i = 0;i<m;i++) for(int j = 0;j<m;j++){
        cin >> t;
        b[i].push_back(t);
    }
    //cout << "meu" << endl;
    bool fl = false;
    for(int i = 0;i<n-m+1;i++) for(int j = 0;j<n-m+1;j++) if(judge(a,b,i,j,m)) fl = true;
    if(fl) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}
const int INF = 1e18;

vvi abcd(55, vi(4, 0));
int N, M, Q;

int dfs(int n, string s) {
    //cout << s << endl;
    if(s.size()==N) {
        //cout << s << endl;
        int res = 0;
        rep(i, Q) {
            int a = s[abcd[i][0]]-'0';
            int b = s[abcd[i][1]]-'0';
            //cout << b-a << endl;
            if(b-a==abcd[i][2]) res += abcd[i][3];
        }
        return res;
    } else {
        int res = 0;
        FOR(i, n, M+1) {
            res = max(res, dfs(i, s+char(i+'0')));
        }
        return res;
    }
}

signed main() {
    cin >> N >> M >> Q;
    rep(i, Q) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--; b--;
        abcd[i][0] = a;
        abcd[i][1] = b;
        abcd[i][2] = c;
        abcd[i][3] = d;
    }

    cout << dfs(1, "") << endl;

    return 0;
}

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

signed main()
{
    int n , x[3][100000] , y[2][100000] , nasu;
    long long ans = 0;

    cin >> n;
    for(int i=0 ;i<3 ;i++ ){
        for(int j=0 ;j<n ;j++){
            cin >> x[i][j]; 
        }

        sort(x[i] , x[i] + n);
    }

    nasu = 0;
    for(int i=0 ;i<n ;i++ ){
        if(i > 0){
            y[0][i] = y[0][i-1];
        } else {
            y[0][0] = 0;
        }

        while(x[1][i] > x[0][nasu] && nasu < n){
            y[0][i]++;
            nasu++;
        }
    }

    nasu = n-1;
    for(int i=n-1; i>=0 ;i-- ){
        if(i < n-1){
            y[1][i] = y[1][i+1];
        } else {
            y[1][0] = 0;
        }

        while(x[1][i] < x[2][nasu] && nasu >= 0){
            y[1][i]++;
            nasu--;
        }
    }

    for(int i=0 ;i<n ;i++ ){
        ans += (long long) y[1][i] * y[0][i];
    }

    cout << ans << endl;

    return (0);
}

Measured memory_bytes: 5588
function parseInt(x) parse(Int, x) end

function main()
	n = readline() |> parseInt
	a = map(parseInt, readline() |> split)
	b = Array{Int}(n)
	for i in 1:n
		b[i] = a[i] -i
	end
	m = median(b)
	sum = 0
	for i in 1:n
		sum += abs(b[i]-m)
	end
	println(convert(Int, sum))
end

main()

Measured memory_bytes: 154624
n = int(input())
h = list(map(int, input().split()))
move = []
count = 0
tmp = h[0]
for i in range(1, n):
    if h[i] <= tmp:
        count += 1
        tmp = h[i]
    else:
        move.append(count)
        tmp = h[i]
        count =0
move.append(count)
print(max(move))

Measured memory_bytes: 20504
Imports System

Module Program
    Sub Main(args As String())
        Dim Str As String = Console.ReadLine()

        Dim H As Long = Long.Parse(Str.Substring(0, Str.IndexOf(" ")))
        Dim A As Long = Long.Parse(Str.Substring(Str.IndexOf(" ") + 1, Str.Length - Str.IndexOf(" ") - 1))

        Dim counta As Double = Math.Ceiling(H / A)

        Console.WriteLine(counta)

    End Sub
End Module


Measured memory_bytes: 13404
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <set>
#include <stack>
#include <queue>
using namespace std;
#define rep(i,a,n) for (int i=a; i<n; i++)
typedef long long ll;
const int MAXN=2e5;


void solve() {
  int D, T, S;
  scanf("%d%d%d", &D, &T, &S);
  if(D <= T * S) puts("Yes");
  else puts("No");
}

int main() {
  #ifdef Local
  freopen("in.txt", "r", stdin);
  freopen("out.txt", "w", stdout);
  #endif
  solve();
  return 0;  
}

Measured memory_bytes: 3188
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<cstdlib>
using namespace std;
#define REP(i,a,n) for(int i = a ; i < n ; i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;

void solve(){
}

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

int main(){
  int n;

  for(int SET=1;cin>>n,n;SET++){
    int ans[n][n];
    int i = 0, j = 0, d = 0, now = 1;
    while(i != n-1 || j != n-1){
      ans[i][j] = now;
      int ni = i + dy[d];
      int nj = j + dx[d];
      if(0>ni || ni>=n || 0>nj || nj>=n){
        if(d == 0){
          if(nj >= n){
            ni = i + 1;
            nj = n-1;
          }
          else if(ni < 0){
            ni = i;
            nj = j + 1;
          }
          d = 1;
        }
        else if(d == 1){
          if(ni >= n){
            ni = n - 1;
            nj = j + 1;
          }
          else if(nj < 0){
            ni = i + 1;
            nj = j;
          }
          d = 0;
        }
      }

      i = ni;
      j = nj;
      now++;
    }

    ans[n-1][n-1] = now;
    printf("Case %d:\n",SET);
    rep(i,n){
      rep(j,n){
        printf("%3d",ans[i][j]);
      }
      printf("\n");
    }
  }
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define PI 3.14159265359
typedef long long LL;

template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const int INF = 1 << 30;

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

	string ans = s;
	reverse(ALL(ans));

	if (ans == s) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<math.h>
using namespace std;
 
int main() {
	char S[20];
	string T;
	
	
	int ans = 0;
	cin >> T;
	if (T[0] != T[1] && T[1] != T[2] && T[2] != T[3]) {
		cout << "Good";
	}
	else {
		cout << "Bad";
	}
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

string dp[60];

int main()
{
  ll n, x;
  cin >> n >> x;

  ll p = 1, b = 1;
  ll pp[60] = {}, bb[60] = {};
  for (int i = 0; i <= n; ++i)
  {
    p *= 2, b *= 2;
    pp[i] = p - 1, bb[i] = b - 2;
  }
  p -= 1, b -= 2;

  ll ans = 0;
  ll i = n;

  while (x > 0)
  {
    if (x < pp[i] + bb[i])
    {
      i--, x--;
    }
    else if (x > pp[i] + bb[i])
    {
      ans += pp[i];
      x -= pp[i] + bb[i];
      if (x > 0)
      {
        x -= 1, ans++;
      }
    }
    else
    {
      ans += pp[i];
      x = 0;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N=int(input())
H=[int(x) for x in input().split()]
def Solve():
    flag=True
    for i in range(len(H)-1):
        if H[i]>H[i+1]+1:
            return 'No'
        elif H[i]==H[i+1]+1:
            if not flag:
                return 'No'
            flag=False
        elif H[i]<H[i+1]:
            flag=True
            
    return 'Yes'

print(Solve())            


Measured memory_bytes: 14396
#include <stdio.h>

int main() {
	char number[1001];
	int sum, i;

	while (1) 
	{
		sum = 0;
		scanf("%s", number);

		if (number[0] == '0') break;

		for (i = 0; number[i] != '\0'; i++)
			sum += number[i] - '0';

		printf("%d\n", sum);
	}

	return 0;
}

Measured memory_bytes: 536
#include <stdio.h>
#include <stdbool.h>

bool graph[105][105];

int main()
{
	int n;
	int m = 0;

	scanf("%d", &n);

	if (n % 2 == 0) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				if (j != (n - (i - 1)) && i != j) {
					if (!graph[i][j]) {
						m++;
						graph[i][j] = true;
						graph[j][i] = true;
					}
				}
			}
		}
	} else {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				if (j != (n - i) && i != j) {
					if (!graph[i][j]) {
						m++;
						graph[i][j] = true;
						graph[j][i] = true;
					}
				}
			}
		}
	}

	printf("%d\n", m);
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (graph[i][j]) {
				printf("%d %d\n", i, j);
				graph[i][j] = false;
				graph[j][i] = false;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

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

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

    // input
    ll N, T;
    cin >> N >> T;

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A.at(i);
    }

    ll time_sum = 0;
    FOR(i, 0, N-1){
        ll diff = A[i+1] - A[i];
        if(diff < T){
            time_sum += diff;
        }else{
            time_sum += T;
        }
    }

    time_sum += T;

    p(time_sum);
    
    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>

using namespace std;

char s[100001];

int main() {
    int n, ans = 0, i;
    
    scanf("%s", s);
    
    n = strlen(s);
    
    for (i = 0; i < n - 1; i++) {
        if (s[i] != s[i + 1]) ans++;
    }
    
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

void pakuripair_sort(int N, int A[], int B[]) {
	const int b = 8;
	int tmp[200001], tmp2[200001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) {
			tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
			tmp2[kazu[A[i] >> k * b & ((1 << b) - 1)]] = B[i];
		}
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) {
			A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
			B[kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp2[i];
		}
	}
}

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


	int N = getint();
	int A[200000], B[200000];
	rep(i, N) {
		A[i] = getint();
		B[i] = getint();
	}
	pakuripair_sort(N, B, A);

	ll time = 0;
	bool OK = true;
	rep(i, N) {
		time += A[i];
		if (time > B[i]) OK = false;
	}

	if (OK) printf("Yes");
	else printf("No");

	Would you please return 0;
}

Measured memory_bytes: 3456
n = int(input())
arr = list(map(int, input().split()))

mini = min(arr)
maxi = max(arr)
cost = 10000000000

for i in range(-100, 101+1):
    add = 0
    for j in range(n):
        add = add + (arr[j] - i)**2
    cost = min(cost, add)
print(cost)

Measured memory_bytes: 9096
/**
 * @Author: harshkhajuria
 * @Date:   15-Jul-2019 06:33:52 am
 * @Email:  khajuriaharsh729@gmail.com
 * @Filename: A - T or T.cpp
 * @Last modified by:   harshkhajuria
 * @Last modified time: 15-Jul-2019 06:35:11 am
 */
#include <bits/stdc++.h>
#define ll long long
#define mp(a, b) make_pair(a, b)
#define newline cout << endl;
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(v) v.begin(),v.end()
using namespace std;

template <typename S, typename T> ostream& operator<<(ostream& out, pair<S, T> const& p)
{
	out << '(' << p.ff << ", " << p.ss << ')';
	return out;
}

template <typename T> ostream& operator<<(ostream& out, vector<T> const& v)
{
	int l = v.size();
	for (int i = 0; i < l - 1; i++)
		out << v[i] << ' ';
	if (l > 0)
		out << v[l - 1];
	return out;
}

template <typename T> void trace(const char* name, T&& arg1) { cout << name << " : " << arg1 << endl; }

template <typename T, typename... Args> void trace(const char* names, T&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	cout.write(names, comma - names) << " : " << arg1 << " | ";
	trace(comma + 1, args...);
}

/*Input*/
/*Input*/

int main()
{
	//ios::sync_with_stdio(false);
	//cin.tie(0);
	//cout.tie(0);
	clock_t tStart = clock();
	int test;
	test = 1;
	// cin >> test;
	while (test--) {
    ll n,a,b;
    cin >> n >> a >> b;
    cout << min(n*a, b) << endl;
	}
#ifdef LOCAL_DEFINE
	printf("Time taken: %.2fs\n", (double)(clock() - tStart) / CLOCKS_PER_SEC);
#endif
	return 0;
}


Measured memory_bytes: 256
cin = open(0).read().strip().split('\n')
n = int(cin[0])
xy = [tuple(map(int, a.split(' '))) for a in cin[1:]]

import itertools, math

ret = 0
case = 0
for cases in itertools.permutations(xy):
    case += 1
    for idx in range(n-1):
        ret += math.sqrt((cases[idx][0]-cases[idx+1][0])**2 + (cases[idx][1]-cases[idx+1][1])**2)

print(ret/case)

Measured memory_bytes: 3064
n,k=gets.split.map(&:to_i)
s = gets
i=-1
zo=[-1]
oz=[]
if s[0] == '0'
  oz << -1
else

end
loop do
  i=s.index('01',i+1)
  break if i.nil?
  zo << i
end

i=-1
loop do
  i=s.index('10',i+1)
  break if i.nil?
  oz << i
end
oz << n-1
if s[-1] == '0'
  zo << n-1
end
p (zo.size).times.map { |m|  (oz[m+k] || n-1)- zo[m] }.max


Measured memory_bytes: 3192
n, k = map(int, input().split())

if n == k:
    print(1)
else:
    i = 0
    for i, a in enumerate(map(int, input().split())):
        if a == 1:
            break
    left = (i - 1) // (k - 1) + 1
    lr = (k - 1) * left + 1
    print(left + (n - lr - 1) // (k - 1) + 1)


Measured memory_bytes: 10420
#include <iostream>
using namespace std;
int main(void){
    int a, b, reverse, num, cnt = 0;
    cin >> a >> b;
    for (int n = a; n <= b; n++){
        reverse = 0;
        num = n;
        while(num > 0){
            reverse = reverse * 10 + num % 10;
            num /= 10;
        }
        
        if(reverse == n){
            cnt++;
        }
    }
    cout << cnt << endl;
}


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

int main(){
  int l,a,b,c,d;
  cin >>l>>a>>b>>c>>d;
  if((a%c==0)&&(b%d==0)){
    cout<<l-max(a/c,b/d)<<endl;
  }
  else if(a%c==0){
    cout <<l-max(a/c,(b/d)+1)<<endl;
  }
  else if(b%d==0){
    cout <<l-max((a/c)+1,b/d)<<endl;
  }
  else{
    cout <<l-max((a/c)+1,(b/d)+1)<<endl;
  }
    return 0;
}

Measured memory_bytes: 3104
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "math.h"
#include "utility"
#include "string"
#include "map"
#include "unordered_map"
#include "iomanip"
#include "random"

using namespace std;
const long long int MOD = 1000000007;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

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



int main() {
	ios::sync_with_stdio(false);
	cin >> N >> L >> R;
	while (N) {
		int num[1000] = {};
		for (int i = 0; i < N; i++)cin >> num[i];
		sort(num, num + N);
		reverse(num, num + N);
		num[N] = 0;
		pair<int, int>ret = { 0,0 };
		for (int i = L; i <= R; i++) {
			ret = max(ret, { num[i - 1] - num[i],i });
		}
		cout << ret.second << endl;
		cin >> N >> L >> R;
	}
	return 0;
}

Measured memory_bytes: 3088
use proconio::{fastout, input, marker::Usize1};
use std::collections::HashSet;

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        ab: [(Usize1, Usize1); m],
    }

    let mut uf = UnionFind::new(n);

    for (a, b) in ab {
        uf.unite(a, b);
    }

    let mut set = HashSet::new();

    for i in 0..n {
        set.insert(uf.find(i));
    }

    let ans = set.len() - 1;
    
    println!("{}", ans);
}

#[derive(Debug, Clone)]
pub struct UnionFind {
    parent: Vec<usize>,
    rank: Vec<usize>,
    size: Vec<usize>,
}

impl UnionFind {
    pub fn new(n: usize) -> Self {
        let parent = (0..n).collect::<Vec<usize>>();
        Self {
            parent,
            rank: vec![0; n],
            size: vec![1; n],
        }
    }

    pub fn find(&mut self, x: usize) -> usize {
        if x == self.parent[x] {
            x
        } else {
            self.parent[x] = self.find(self.parent[x]);
            self.parent[x]
        }
    }

    pub fn unite(&mut self, a: usize, b: usize) {
        let ra = self.find(a);
        let rb = self.find(b);
        if self.rank[ra] > self.rank[rb] {
            self.parent[rb] = ra;
            self.size[ra] += self.size[rb];
        } else if self.rank[ra] < self.rank[rb] {
            self.parent[ra] = rb;
            self.size[rb] += self.size[ra];
        } else if ra != rb {
            self.parent[rb] = ra;
            self.size[ra] += self.size[rb];
            self.rank[ra] += 1;
        }
    }

    pub fn size(&mut self, x: usize) -> usize {
        let rx = self.find(x);
        self.size[rx]
    }

    pub fn same(&mut self, a: usize, b: usize) -> bool {
        self.find(a) == self.find(b)
    }
}


Measured memory_bytes: 7156
($n,$m)=glob<>;$d=1e9+7;
if(abs($n-$m)>1){
    print"0";
    exit;
}
$o=1+($n==$m);
$o=$o*$_%$d for (1..$n);
$o=$o*$_%$d for (1..$m);
print $o

Measured memory_bytes: 768
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.IOException;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String str;
		while ((str = reader.readLine()) != null) {
			StringTokenizer st = new StringTokenizer(str);
			float a = Float.parseFloat(st.nextToken());
			float b = Float.parseFloat(st.nextToken());
			float c = Float.parseFloat(st.nextToken());
			float d = Float.parseFloat(st.nextToken());
			float e = Float.parseFloat(st.nextToken());
			float f = Float.parseFloat(st.nextToken());
			float y = (c*d - f*a) / (b*d - a*e);
			float x = (c - b*y) / a;
			System.out.println(String.format("%.3f %.3f", x, y));
		}
		reader.close();
	}
}


Measured memory_bytes: 24640
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();									//入力数
        Deque<Integer> num = new ArrayDeque<Integer>();	//トレイ
        //入力の処理
        for(int i = 0; i < n; i++) {
            String s = scan.next();
            if(s.equals("insert")) {
                num.push(Integer.parseInt(scan.next()));
            }else if(s.equals("delete")) {
                int key = Integer.parseInt(scan.next());
                num.remove(key);
            }else if(s.equals("deleteFirst")) {
                num.removeFirst();
            }else if(s.equals("deleteLast")) {
                num.removeLast();
            }
        }

        scan.close();

       int t = num.getFirst();
        int k = num.size() - 1;
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < k; i++) {
            sb.append(num.poll() + " ");
        }
 
        if(num.size() != 0) {
            System.out.print(sb.toString());
           System.out.println(num.poll());
 
        }else {
          System.out.println(t);
        
        }
 
    }
}



Measured memory_bytes: 324956
#include <iostream>
#include <cstdlib>
#include <string>
#include <typeinfo>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;
    int F[50];
    F[0] = F[1] = 1;
    for(int i = 2; i <= n; i++)F[i] = F[i -1] + F[i - 2];
        cout << F[n] << endl;
    return 0;
}








Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a, b;
  cin >> a >> b;
  int c = a + b;
  if (c % 2 == 0) { 
    cout << c/2 << endl;
  } else {
    cout << c/2 + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 3560
/* ***********************************************
Author        :yang12138
Created Time  :2017年04月18日 星期二 20时30分32秒
File Name     :C.cpp
************************************************ */
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define mem(a,b) memset(a,b,sizeof(a))
typedef long long ll;
typedef pair<int,int>pii;
#define lson (root<<1)
#define rson (root<<1|1)

const int N=1005;
int ans[10000];
bool vis[50];

int main(){
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

	ll n;
	scanf("%lld",&n);
	mem(ans,0);

	int tmpn=45,tot=0;

	while(n<((1LL<<tmpn)-1)) tmpn--;
	n-=(1LL<<tmpn)-1;

	for(int i=0;i<45;i++) if((n>>i)&1) vis[i]=1,tot++;

	for(int i=1;i<=tmpn+tot;i++) ans[i]=i;
	int cur1=1,cur2=tmpn+tot;

	int pre=0;
	for(int i=0;i<45;i++){
		if(vis[i]) ans[tmpn+tot+i+1+pre]=cur2--,pre++;
	}

	for(int i=tmpn+tot+1;i<=2*(tmpn+tot);i++){
		if(!ans[i]) ans[i]=cur1++;
	}

	int cnt=2*(tmpn+tot);
	printf("%d\n",cnt);
	for(int i=1;i<=cnt;i++) printf("%d%c",ans[i],i==cnt?'\n':' ');
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;

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

		// 入力
		int n = sc.nextInt();//
		int m = sc.nextInt();//

		int[] x = new int[m]; 
		for(int i = 0; i < m; i++){
			x[i] = sc.nextInt();
		}

		Arrays.sort(x);

		int[] sabun = new int[m - 1];
		for(int i = 0; i < m - 1; i++){
			sabun[i] = x[i + 1] - x[i];
		}
		
		Arrays.sort(sabun);

		int minStep = 0;
		if(n < m){
			for(int i = 0; i < m - n; i++){
				minStep = minStep + sabun[i];
			}
		}

		// 出力
		System.out.println(minStep);
	}

}




Measured memory_bytes: 49036
#[allow(unused_macros)]
macro_rules! input_byline {
    ($($r:tt)* ) => {
        let stdin = std::io::stdin();
        let mut q = std::collections::VecDeque::new();
        let mut next = || {
            if q.is_empty() {
                let mut s = String::new();
                stdin.read_line(&mut s);
                for v in s.split_whitespace() {
                    q.push_back(v.to_string());
                }
            }
            q.pop_front().unwrap()
        };
        input_inner!{next, $($r)*}
    };

}

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

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

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

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

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

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

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

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

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

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

trait Printable {
    fn p(&self);
}

impl<T: std::fmt::Display> Printable for T {
    fn p(&self) {
        println!("{}", self);
    }
}

impl<T: std::fmt::Display> Printable for [T] {
    fn p(&self) {
        for i in 0..self.len() {
            if i != 0 {
                print!(" ");
            }
            print!("{}", self[i]);
        }
        println!("");
    }
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap};

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;

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

    let mut cnt = 0;
    let mut l = 0;
    for &c in &s {
        if c == ')' {
            if cnt == 0 {
                l += 1;
            } else {
                cnt -= 1;
            }
        } else if c == '(' {
            cnt += 1;
        }
    }
    for i in 0..l {
        print!("(");
    }
    print!("{}", s.iter().cloned().collect::<String>());
    for i in 0..cnt {
        print!(")");
    }
    println!("");
}


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

Measured memory_bytes: 3608