akhauriyash/Code-Regression huggingface dataset:
def main():
    S = input()
    T = input()

    start = [-1]*26
    goal = [-1]*26
    for i in range(len(S)):
        a = ord(S[i])-ord('a')
        b = ord(T[i])-ord('a')
        if start[a]!=-1 or goal[b]!=-1:
            if start[a]!=b or goal[b]!=a:
                print('No')
                return
        else:
            start[a] = b
            goal[b] = a
    print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 41840
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

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

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(0, 1); \
                 auto rnd = bind(__dis, __gen);

const int INF = 0x7f7f7f7f7f7f7f7f;
const int mod = 1E9 + 7;

int h, w, minDis[55][55];
vector<string> vec;

void bfs() {
    /// Brute-ForceS ///
    for (int i = 0; i < 55; ++i) memset(minDis[i], 0x7f, sizeof(minDis[i]));
    
    minDis[0][0] = 1;
    for (int rep = 0; rep < h*w; ++rep) {
        for (int i = 0; i < h; ++i) {
            for (int j = 0; j < w; ++j) {
                if (vec[i][j] == '#') continue;
                if (i != h-1) minDis[i][j] = min(minDis[i][j], minDis[i+1][j] + 1);
                if (j != w-1) minDis[i][j] = min(minDis[i][j], minDis[i][j+1] + 1);
                if (i) minDis[i][j] = min(minDis[i][j], minDis[i-1][j] + 1);
                if (j) minDis[i][j] = min(minDis[i][j], minDis[i][j-1] + 1);
            }
        }
    }
}

int32_t main() {
    fastIO();
    
    int cnt = 0;
    string s;
    cin >> h >> w;
    
    for (int i = 0; i < h; ++i) cin >> s, vec.eb(s);
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) cnt += vec[i][j] == '#';
    }
    
    bfs();
    
    if (minDis[h-1][w-1] == INF) cout << -1 << "\n";
    else cout << h*w - minDis[h-1][w-1] - cnt << "\n";
    
    return 0;
}

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

struct Node {
  int key;
  Node *right, *left, *parent;
};

Node *root, *NIL;

void preParse(Node *u) {
  if (u == NIL) {
    return;
  }
  cout << " " << u->key;
  preParse(u->left);
  preParse(u->right);
}

void inParse(Node *u) {
  if (u == NIL) {
    return;
  }
  inParse(u->left);
  cout << " " << u->key;
  inParse(u->right);
}

void insert(int k) {
  Node* y = NIL;
  Node* x = root;
  Node* z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->right = NIL;
  z->left = NIL;

  while(x != NIL) {
    y = x;
    if (z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
  z->parent = y;
  if (y == NIL) {
    root = z;
  } else {
    if ( z->key < y->key ) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

int main() {
  int m;
  cin >> m;
  for (int i = 0; i < m; i ++) {
    string command;
    int x;
    cin >> command;
    if (command == "insert") {
      cin >> x;
      insert(x);
    } else if (command == "print") {
      inParse(root);
      cout << endl;
      preParse(root);
      cout << endl;
    }
  }
}



Measured memory_bytes: 26552
import sys
from collections import deque
sys.setrecursionlimit(1000000)
N, M = map(int, input().split())
G = [[] for _ in range(N+1)]
for _ in range(M):
    tmpl, tmpr, tmpd = map(int, input().split())
    G[tmpl].append((tmpr, tmpd))
    G[tmpr].append((tmpl, -tmpd))

field = [None] * (N+1)


def dfs(i):
    #ret = True
    for elem in G[i]:
        if field[elem[0]] is not None:
            if field[elem[0]] != field[i]+elem[1]:
                return False
            continue
        else:
            field[elem[0]] = field[i]+elem[1]
            ret = dfs(elem[0])
            if not ret:
                return False
    return True

    #q = deque()
    #q.append(i)
    #field[i] = 0
    #while q:
    #    tmp = q.pop()
    #    for elem in G[tmp]:
    #        if field[elem[0]] is not None:
    #            if field[elem[0]] != field[tmp]+elem[1]:
    #                return False
    #            continue
    #        else:
    #            q.append(elem[0])
    #            field[elem[0]] = field[tmp]+elem[1]
    #return True


for i in range(1, N+1):
    if field[i] is None:
        field[i] = 0
        if not dfs(i):
            print('No')
            exit()
print('Yes')


Measured memory_bytes: 129252
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Reflection.Emit;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
        checked {
#if DEBUG
            MyDebugger.Test(process, "../TextFile1.txt");
            //TestCaseMaker.MakeTestCase1("../TextFile2.txt");
            //MyDebugger.Test(process, "../TextFile2.txt");
#else
            object ret = process(new StreamReader(Console.OpenStandardInput()));
            Console.WriteLine(ret);
#endif
        }
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var aa = ToIntArray(input.ReadLine(), n);

        long m = 1000;
        long k = 0;

        for(int i=0; i<n-1; i++) {
            var a = aa[i];
            var b = aa[i+1];

            if(b > a) {
                var kk = m / a;
                k += kk;
                m -=  a * kk;
            }
            else if(b < a) {
                m += a * k;
                k = 0;
            }
        }

        return m + (aa.Last() * k);
    }

    static long[] ToIntArray(string strs, int n) {
        var ret = new long[n];
        if (n == 0) return ret;
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = long.Parse(spl[i]);
        return ret;
    }
}


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

using namespace std;

int main() {
	int d, n;
	scanf("%d %d", &d, &n);
	vector <long long> v;
	if (d == 0) {
		if (n == 100) {
			printf("%d\n", 101);
		} else {
			printf("%d\n", n);		
		}
		return 0;
	} else if (d == 1) {
		long long k = 1;		
		for (int i = 0; i < n; i++) {
			if (k == 100) {
				k++;
			}
			v.push_back(1ll * 100 * k);
			k++;
		}
		cout << v[n - 1] << endl;
	} else {
		long long k = 1;
		for (int i = 0; i < n; i++) {
			if (k == 100) {
				k++;
			}
			v.push_back(10000 * k);
			k++;
		}
		cout << v[n - 1] << endl;
	}
	return 0;
}

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

using namespace std;

const int N = 200000 + 10;
char s[N];

long long qpow(long long a, long long k, int p) {
    long long res = 1;
    while (k) {
        if (k & 1)  res = res * a % p;
        k >>= 1;
        a = a * a % p;
    }
    return res;
}

int calc(long long x) {
    int res = 0;
    while (x) {
        if (x & 1)  res++;
        x >>= 1;
    }
    return res;
}

long long calc2(char *s, int n) {
    long long res = 0;
    for (int i = 1; i <= n; i++) {
        res = res * 2 + s[i] - '0';
    }
    return res;
}

int main() {
    int n;  cin >> n;
    cin >> (s + 1);
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        if (s[i] == '1') {
            cnt++;
        }
    }
    if (cnt == 0) {
        for (int i = 1; i <= n; i++) {
            cout << 1 << '\n';
        }
        return 0;
    }
    else if (cnt == 1) {
        for (int i = 1; i <= n; i++) {
            if (s[i] == '1')    cout << 0 << '\n';
            else if (s[i] == '0') {
                if (i == n) cout << 2 << '\n';
                else    cout << (s[n] - '0') + 1 << '\n';
            }
        }
        return 0;
    }
    
    int x1 = 0, x2 = 0;
    for (int i = 1; i <= n; i++)    x1 = (x1 * 2 + s[i] - '0') % (cnt + 1);
    for (int i = 1; i <= n; i++)    x2 = (x2 * 2 + s[i] - '0') % (cnt - 1);
    for (int i = 1; i <= n; i++) {
        if (s[i] == '1') {
            int ans = 1;
            int x = (x2 - qpow(2, n - i, cnt - 1) + (cnt - 1)) % (cnt - 1);
            // s[i] = '0'; cout << i << ' ' << x << ' ' << calc2(s, n) % (cnt - 1) << '\n';    s[i] = '1';
            while (x) {
                x %= calc(x);
                ans++;
            }
            cout << ans << '\n';
        }
        else {
            int ans = 1;
            int x = (x1 + qpow(2, n - i, cnt + 1)) % (cnt + 1);
            // s[i] = '1'; cout << i << ' ' << x << ' ' << calc2(s, n) % (cnt + 1) << '\n';    s[i] = '0';
            while (x) {
                x %= calc(x);
                ans++;
            }
            cout << ans << '\n';
        }
    }
#ifndef ONLINE_JUDGE
    system("pause");
#endif
    return 0;
}

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

int i,j,k,l,m;
int n,e,s,w,un,up;
int a[7];
int t;


void input() {
    for(i=0;i<6;i++){
        
        scanf("%d",&a[i+1]);
        
    }
}

void N() {
    t = a[1];
    a[1] = a[2];
    a[2] = a[6];
    a[6] = a[5];
    a[5] = t;
}

void S() {
    t = a[1];
    a[1] = a[5];
    a[5] = a[6];
    a[6] = a[2];
    a[2] = t;
}

void E() {
    t = a[1];
    a[1] = a[4];
    a[4] = a[6];
    a[6] = a[3];
    a[3] = t;
}

void W() {
    t = a[1];
    a[1] = a[3];
    a[3] = a[6];
    a[6] = a[4];
    a[4] = t;
}

int main(int argc, const char * argv[]) {
    input();
    //  strlen(?) 文字の長さ(数)を表示
    char str[110];
    scanf("%s",str);
    
    for(i=0;i<strlen(str);i++) {
        
        if(str[i] == 'N') {
            N();
        } else if(str[i] == 'S') {
            S();
        } else if(str[i] == 'W') {
            W();
        } else if(str[i] == 'E') {
            E();
        }
    }
    
    printf("%d\n",a[1]);
    
    return 0;
    
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
char a,b;
int ans;
string s,s1;
int main()
{
	cin>>s;
	a+=s[0];
	int len=s.size()-1;
	b=s[len];
	for(int i=1;i<=len-1;i++)
	{
		ans++;
	}
	cout<<a<<ans<<b;
	
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

total = 0
lastmenu = -1
for i in range(N):
    total += B[A[i]-1]
    if A[i]-1 == lastmenu:
        total += C[lastmenu-1]
    lastmenu = A[i]

print(total)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
//i64 mod = 998244353;
int int_max = 2147483647;
i64 INF = 1e16;
int max_n = 1e5;

template<typename IntType>
struct mat2d_t {
    mat2d_t(size_t h, size_t w) : h(h), w(w) {
        mat = std::vector<std::vector<IntType>>(h, std::vector<IntType>(w, 0));
    }
    mat2d_t(size_t h, size_t w, IntType init) : h(h), w(w){
        mat = std::vector<std::vector<IntType>>(h, std::vector<IntType>(w, init));
    }

    std::vector<IntType>& operator[](size_t p) {
        return mat[p];
    }

    const std::vector<IntType>& operator[](size_t p) const {
        return mat[p];
    }
    size_t height() const {
        return h;
    }
    size_t width() const {
        return w;
    }

private:
    std::vector<std::vector<IntType>> mat;
    size_t h;
    size_t w;
};

int main(int argc, char **argv) {
    i64 n, m;
    cin >> n >> m;

    i64 up_n = (1<<n);
    mat2d_t<i64> dp(m+1, up_n, -1);

    vector<i64> as(m);
    vector<i64> bs(m, 0);

    for (int i=0; i<m; ++i) {
        i64 b;
        cin >> as[i] >> b;
        i64 c{0};
        for (int j=0; j<b; ++j) {
            cin >> c;
            --c;
            bs[i] += (1<<c);
        }
    }
    dp[0][0] = 0;
    for (int i=0; i<m; ++i) {
        for (int j=0; j<up_n; ++j) {
            if (dp[i][j] == -1) continue;

            if (dp[i+1][j] == -1) dp[i+1][j] = dp[i][j];
            else dp[i+1][j] = min(dp[i+1][j], dp[i][j]);

            i64 next = j | bs[i];
            //cout << next << endl;

            if (next < 0 || up_n <= next) continue;

            if (dp[i+1][next] == -1) dp[i+1][next] = dp[i][j] + as[i];
            else dp[i+1][next] = min(dp[i+1][next], dp[i][j] + as[i]);
        }
    }
/*
    for (int i=0; i<m+1; ++i) {
        for (int j=0; j<up_n; ++j) {
            cout <<" "<< dp[i][j];
        }
        cout << endl;
    }

*/
    cout << dp[m][up_n-1] << endl;

    return 0;
}

Measured memory_bytes: 35448
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;

int main(){
    long long K=3,N,x,len=1,num=7;
    cin >> K;
    if(K%2==0 || K%5==0){
        len = -1;
    }else{
        while(true){
            x = num % K;
            if(x==0){
                break;
            }else{
                num = x*10 + 7;
                len++;
            }
        }
    }
    cout << len;

}

Measured memory_bytes: 3580
import std.algorithm;
import std.range;
import std.stdio;
import std.math;
import std.array;
import std.string;
import std.conv;

/// 数列の読み込み
auto readNums(T = int)() {
	return readln().chomp.split.map!(to!T).array;
}

/// 数の読み込み
auto readNum(T = int)() {
	return readNums!T.front;
}

/// 指定行数読み込み
auto readRows(size_t rows) {
	return generate(() => readln().chomp).take(rows).array;
}

/// 範囲の計算
auto range(T)(T a, T b, T c, T d) {
    auto start = max(a, c);
    auto end = max(b, d);
    return (start < end) ? tuple(start, end) : tuple(cast(T) 0, cast(T) 0);
}

auto maxElement(R)(R r) {
    return r.reduce!((a, b) => max(a, b));
}

auto minElement(R)(R r) {
    return r.reduce!((a, b) => min(a, b));
}

struct Course {
	int from;
	int to;
	@property int distance() const @safe pure nothrow @nogc {
		return abs(to - from);
	}
	int cumulative;
}

void main() {
	immutable n = readNum();
	const nums = 0 ~ readNums() ~ 0;
	auto courses = zip(nums[0 .. $ - 1], nums[1 .. $])
		.map!(e => Course(e[0], e[1], abs(e[1] - e[0])))
		.array;
	immutable total = courses.map!(e => e.distance).sum;
	int cum = 0;
	foreach(ref c; courses) {
		cum += c.distance;
		c.cumulative = cum;
	}
	foreach(const ref e; zip(courses[0 .. $ - 1], courses[1 .. $])) {
		writefln("%d", total - e[0].distance - e[1].distance + abs(e[1].to - e[0].from));
	}
}


Measured memory_bytes: 5496
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <functional>
#include <stack>
#include <utility>
#include <map>
#include <queue>
#include <set>

using namespace std;

int main(){
	long long n, cnt = 0, a[5]{0}, ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		if (s[0] == 'M') a[0]++;
		if (s[0] == 'A') a[1]++;
		if (s[0] == 'R') a[2]++;
		if (s[0] == 'C') a[3]++;
		if (s[0] == 'H') a[4]++;
	}
	for (int i = 0; i < 5; i++) {
		if (a[i] > 0)cnt++;
	}
	if (cnt < 3) {
		cout << 0 << endl;
		return 0;
	}
	for (int i = 0; i < 3; i++) {
		for (int j = i + 1; j < 4; j++) {
			for (int k = j + 1; k < 5; k++) {
				ans += a[i] * a[j] * a[k];
			}
		}
	}
	cout << ans << endl;
 	return 0;
}



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

static const int DATA_NUM = 1000001;
vector<int> prime;
bool isPrime[DATA_NUM];
void primeCalc()
{
	for(int i = 0; i < DATA_NUM; ++i)
	{
		isPrime[i] = true;
	}
	isPrime[0] = isPrime[1] = false;
	for(int i = 0; i < DATA_NUM; ++i)
	{
		if(isPrime[i])
		{
			prime.push_back(i);
			for(int j = 2 * i; j < DATA_NUM; j += i)
			{
				isPrime[j] = false;
			}
		}
	}
}

void solve()
{
	primeCalc();
	int n;
	while(cin >> n)
	{
		int ans = 0;
		for(int i = 0; i <= n; ++i)
		{
			if(isPrime[i])
			{
				++ans;
			}
		}
		cout << ans << endl;
	}
}

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

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

int main() {
  int a, b;
  cin >> a >> b;
  int ans = (b+a-3)/(a-1);
  cout << ans << endl;
  return 0;
}


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

#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()

using namespace std;
typedef long long ll;
const ll INF = 1e15;

int main() {
  ll n, c, k;
  cin >> n >> c >> k;
  vector<ll> t(n);
  REP(i, n) cin >> t[i];

  sort(ALL(t));

  ll ans = 0, num = 0, l = 0;
  REP(i, n) {
    if (num == c || l < t[i]) {
      l = t[i] + k;
      num = 0;
      ++ans;
    }
    ++num;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
/*
 * Monsters_Battle_Royale.cpp
 *
 *  Created on: 2019/03/10
 *      Author: lum1narie
 */

#include "iostream"
#include "string"
#include "vector"
#include "algorithm"
#include "functional"
#include "cmath"
#include "iterator"

int main(){
    // get values from input
    long n;
    std::vector<long> a;

    std::cin >> n;
    for (long i = 0; i < n; ++i) {
        long a_i;
        std::cin >> a_i;
        a.push_back(a_i);
    }

    // main procedure
    std::vector<long> alive_monsters;
    std::copy(a.begin(), a.end(), std::back_inserter(alive_monsters));

    while(alive_monsters.size() > 1){
        // calc attacking
        std::sort(alive_monsters.begin(), alive_monsters.end());
        for (unsigned int i = 1; i < alive_monsters.size(); ++i) {
            alive_monsters[i] %= alive_monsters[0];
        }

        // calc dead monster
        auto iter_del_end = std::remove_if(alive_monsters.begin(),
                alive_monsters.end(),
                [] (int n)->bool { return n == 0; });
        alive_monsters.erase(iter_del_end, alive_monsters.end());
    }

    // output
    std::cout << alive_monsters[0] << std::endl;

    return 0;
}

Measured memory_bytes: 2548
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <ios>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <forward_list>
#include <random>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm( a, b ) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair< int, int > P;
typedef pair< LL, LL > LP;
typedef pair< int, P > iP;
typedef pair< P, P > PP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 100005;

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

vector< int > Div( int n ) {
    vector< int > ret;
    for( int i = 1; i * i <= n; ++i ) {
        if( n % i == 0 ) {
            ret.pb( i );

            if( i * i != n ) ret.pb( n / i );
        }
    }
    sort( all( ret ) );
    return ret;
}

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

    LL n, a, b;
    cin >> n >> a >> b;

    LL res = 0;
    LL x[n];
    for( int i = 0; i < n; ++i ) cin >> x[i];

    for( int i = 0; i < n - 1; ++i ) {
        res += min( ( x[i + 1] - x[i] ) * a, b );

    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1024
h,w=map(int,input().split())
b=[[1]*(w+2)]
for i in range(h):
  bb=[1]
  s=input()
  for j in range(w):
    if s[j]=="#":bb.append(1)
    else:bb.append(0)
  bb.append(1)
  b.append(bb)
b.append([1]*(w+2))

ans=0
d=[[-1,0],[1,0],[0,-1],[0,1]]
for si in range(1,h+1):
  for sj in range(1,w+1):
    if b[si][sj]:continue
    visited={(si,sj)}
    Q=[(si,sj)]
    count=-1
    while Q:
      P=[]
      for i,j in Q:
        for di,dj in d:
          if b[i+di][j+dj]:continue
          if (i+di,j+dj)in visited:continue
          visited.add((i+di,j+dj))
          P.append((i+di,j+dj))
      Q=P
      count+=1
    ans=max(ans,count)
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define _GLIBCXX_DEBUG
#define int long long
int INF = 1e9+7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
unsigned day;
if(dow < dow1) dow += 7;
day = dow - dow1;
day += 7 * n - 6;
return day;
}
unsigned DayToWeekNumber(unsigned day)
{
  return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
  return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main(){
  int N; cin>>N;
  vector<int>L(N+1);
  L[0]=2;
  L[1]=1;
  for(int i=2;i<=N;i++)L[i]=L[i-1]+L[i-2];
  cout<<L[N];
}

Measured memory_bytes: 3624
from itertools import accumulate
n,k = map(int,input().split())
p = list(map(int,input().split()))

P = []+p
P = list(accumulate(P))

ans = []

if n == 1:
    print((p[0]+1)/2)
elif n == k:
    print((sum(p)+n)/2)
else:    
    for i in range(n-k):
        ans.append(P[i+k]-P[i])
    print((max(ans)+k)/2)

Measured memory_bytes: 27076
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007 
#define pb push_back
//#define mp make_pair
#define INF 2000000011LL
#define INFLL 1000000000000000011LL
#define eps 1e-9
#define pp pair < pair<ll,ll> , ll> 
#define fo(i,j,k) for(int i=j;i<=k;i++)
#define foll(i,j,k) for(ll i=j;i<=k;i++)
#define clr(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vll vector<ll>
#define sz(a) a.size()
#define len(a) a.length()
#define all(a) a.begin(),a.end()
#define io_file freopen("Contest/input_file.in", "r", stdin); freopen("Contest/output_file.in", "w", stdout)

const int MAXN = 2e5+5;
using namespace std;
ll power(ll x, ll y)
{
  ll res = 1;
  while(y>0)
  {
    if(y&1)
       {
         res = (res*x)%mod;
        }
     x = (x*x)%mod;
     y = y>>1;
  }
    return res;
}
// std::vector<ll> divi[100004];
// void divisor(int n)
// {
//    for(ll i=1;i<=n;i++)
//    {
//      for(ll j=i;j<=n;j+=i)
//      {
//        divi[j].pb(i);
//      }
//    }
// }
ll n,m;
int a[100005];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m;
    for(int i=1;i<=m;i++)
    {
      int l,r;
      cin>>l>>r;
      a[l] = a[l] + 1;
      a[r+1] = a[r+1] - 1; 
    }
    int ans=  0;
    for(int i=1;i<=n;i++)
    {
      a[i] = a[i-1] + a[i];
      if(a[i]==m)
        ans++; 
    }
    cout<<ans<<endl;
    return 0;

}



Measured memory_bytes: 640
# その19 ABC112 B - Time Limit Exceeded

N,T = map(int,input().split())
C = []
D = []

for i in range(N):
    A,B = map(int,input().split())
    C.append(A)
    D.append(B)
if min(D) > T:
    print('TLE')
else :
    F=[]
    for i in range(N):
        if D[i] <= T:
            F.append(C[i])
    print(min(F))
    

Measured memory_bytes: 62548
"use strict";
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
    result["default"] = mod;
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
var fs = __importStar(require("fs"));
function main(args) {
    // sardine
    // xxxxxxx
    var result = '';
    for (var i = 1; i < args.length; i++) {
        result = result + 'x';
    }
    console.log(result);
}
main(fs.readFileSync('/dev/stdin', 'utf8'));


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

using ll = long long;

int main() {
	int N, A, B;
	cin >> N >> A >> B;
	vector<int> X(N);
	for (int i = 0; i < N; ++i) cin >> X[i];

	ll ans = 0;
	for (int i = 1; i < N; i++) {
		if ((ll)(X[i] - X[i - 1]) * A < B) {
			ans += (ll)(X[i] - X[i - 1]) * A;
		}
		else {
			ans += B;
		}
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3780
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
//#define i_7 (long long)(1e9+7)
#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
using namespace std;
//using namespace boost::multiprecision;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}



int main(){
  
  long long n,a,b;
  cin>>n>>a>>b;
  if(a > b){
    swap(a,b);
  }
  long long ans = 0;
  if((b-a)%2 == 0){
    ans = (b-a)/2;
    cout<<ans<<endl;
    return 0;
  }
  ans = min(a-1, n-b) + 1 + (b-a)/2;
  cout<<ans<<endl;
  return 0; 
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
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 dp[200005][4];

int main(){
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    int sz = 1;
    if(n % 2) sz++;
    rep(i,n+1){
        rep(j,sz+1){
            dp[i][j] = -1e18;
        }
    }
    dp[0][0] = 0;
    rep(i,n){
        rep(j,sz+1){
            chmax(dp[i+1][j+1], dp[i][j]);
            ll next = dp[i][j];
            if((i+j) % 2 == 0) next += a[i];
            chmax(dp[i+1][j], next);
        }
    }
    cout << dp[n][sz] << endl;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

    ll N,X; cin >> N >> X;
    ll L[100005];
    ll pos = 0;
    ll ans = 1;
    for (int i = 0;i < N;i++){
        cin >> L[i];
        pos += L[i];
        if(pos <= X) ans++;
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

int main(){
    int a,b,c;
    cin>>a>>b>>c;

    int d = c*a-b;
    cout<<d<<endl;
    for(int i=0;i<9;++i){
        d = d*a-b;
        cout<<d<<endl;
    }
}

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

int main(void)
{
    int n;
    cin >> n;
    int card[4][13] = {0};
    int flug[4] = {0};
    char pic[5] = "SHCD";
    for(int i = 0 ; i <  4 ; i++)
    {
        for(int j = 0; j < 13 ; j++)
        {
            card[i][j] = j+1;
        }
    }
    for(int i = 0 ; i < n ; i++)
    {
        int num;
        char str;
        cin >> str >> num;
        
        if(str == 'S')
        {
            card[0][num-1] = 0;
            flug[0]++;
        }
        else if(str == 'H')
        {
            card[1][num-1] = 0;
            flug[1]++;
        }
        else if(str == 'C')
        {
            card[2][num-1] = 0;
            flug[2]++;
        }
        else
        {
            card[3][num-1] = 0;
            flug[3]++;
        }
    }
    
    for(int i = 0 ; i <  4 ; i++)
    {
        if(!(flug[i]==0))
        {
            for(int j = 0; j < 13 ; j++)
            {
                if(card[i][j] != 0)cout << pic[i] << ' ' << card[i][j] << endl;
                flug[i]--;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3064
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn calc(cv: &[isize], sv: &[Vec<isize>], tv: &[usize]) -> isize {
    let mut last = vec![0; 26];
    let mut res = 0;
    for i in 0..sv.len() {
        let t = tv[i];
        res += sv[i][t];
        last[t] = i + 1;
        for j in 0..26 {
            res -= cv[j] * (i + 1 - last[j]) as isize;
        }
    }
    res
}

fn solve() {
    input! {
        d: usize,
        cv: [isize; 26],
        sv: [[isize; 26]; d],
        mut tv: [Usize1; d],
        m: usize,
        dqv: [(Usize1, Usize1); m]
    };

    for (d, q) in dqv {
        tv[d] = q;
        let res = calc(&cv, &sv, &tv);
        println!("{}", res);
    }
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 3680
using System;
using System.Linq;
class p
{
  static void Main()
  {
    int N = int.Parse(Console.ReadLine());
    string[] arr = new string[N];
    for (int i = 0; i < N; i++) {
      arr[i] = Console.ReadLine();
    }
    Console.WriteLine(arr.Distinct().ToArray().Length);
  }
}

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

int main() {
    int d,g;cin>>d>>g;
    int p[d],c[d];
    for (int i=0;i<d;i++)
        cin>>p[i]>>c[i];
    int ans=10000;
    for (int i=0;i<1<<d;i++) {
        int sm=0;
        int mxi;
        int cnt=0;
        for (int j=0;j<d;j++) {
            if (i&1<<j) {
                sm+=100*(j+1)*p[j]+c[j];
                cnt+=p[j];
            } else
                mxi=j;
        }
        if (sm<g) {
            int left=g-sm;
            int one=100*(mxi+1);
            int need=(left+one-1)/one;
            if (p[mxi]<=need)
                continue;
            cnt+=need;
        }
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int x = scanner.nextInt();
        int y = scanner.nextInt();
        char ch;
        if (x < y) System.out.println("a" + " < " + "b");
        else if (x > y) System.out.println("a" + " > " + "b");
        else System.out.println("a" + " == " + "b");
    }
}

Measured memory_bytes: 26332
#include <cstdio>
#include <stack>
#include <algorithm>
using namespace std;

int n;

int main(void){
	stack<int> s;
	char c;
	while(scanf("%c",&c)!=EOF){
		if(c=='+'){
			int a=s.top();
			s.pop();
			int b=s.top();
			s.pop();
			s.push(a+b);
		}
		if(c=='-'){
			int a=s.top();
			s.pop();
			int b=s.top();
			s.pop();
			s.push(b-a);
		}
		if(c=='*'){
			int a=s.top();
			s.pop();
			int b=s.top();
			s.pop();
			s.push(a*b);
		}
		if(c>='0' && c<='9'){
			int d=c-'0';
			while(1){
				scanf("%c",&c);
				if(c>='0' && c<='9')d=d*10+(c-'0');
				else break;
			}
			s.push(d);
		}else scanf("%*c");
	}
	printf("%d\n",s.top());
	return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >>N;
  vector<int> x(N);
  for(int i=0;i<N;i++) cin >> x.at(i);
  vector<int> y = x;
  sort(x.begin(),x.end());
  int ma = x.at(N/2-1);
  int mb = x.at(N/2);
  for(int i=0;i<N;i++){
    if(y.at(i) <= ma) cout << mb << endl;
    else cout << ma << endl;
  }
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
#define PI acos(-1)
#define INF 0x3f3f3f
#define ll long long
#define pb push_back
#define mp make_pair
#define pair pair<int,int>
#define C(a) cout<<a<<endl;
#define CY cout<<"YES"<<endl;
#define CN cout<<"NO"<<endl;
#define Cy cout<<"Yes"<<endl;
#define Cn cout<<"No"<<endl;
#define ull unsigned long long
#define me(a) memset(a,0,sizeof(a));
#define my(a,b) memcpy(a,b,sizeof(b));
#define cio ios::sync_with_stdio(false)
ll mod=1e9+7;
ll gcd(ll a,ll b){return (a%b==0) ? b : gcd(b,a%b);}
int main(){
	
	ll n;
	cin>>n;

	if(n%2==0||n%5==0){
		cout<<-1<<endl;
		return 0;
	}
	int i;
	int x=0;
	for(i=1;;i++){
		x=x*10+7;
		x=x%n;
		if(x==0){
			break;
		}
	}	
	cout<<i<<endl;
	

	return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> ostream& operator<<(ostream &os,const vector<vector<T> > &v) {
    ITR(u,begin(v),end(v))ITR(w,begin(*u),end(*u))os<<*w<<(w==end(*u)-1?"\n":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed << setprecision(10) << val;

int n, counter[100005][26];
signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> n;
  map<string, int> counter;
  rep(i, 0, n) {
    string t;
    cin >> t;
    sort(ALL(t));
    counter[t]++;
  }
  int ans = 0;
  for (auto x: counter) {
    int t = x.second;
    if (t > 1) ans += (t - 1) * t / 2;
  }
  cout << ans << endl;
  return 0;
}




Measured memory_bytes: 11264
#include<iostream>
#include<algorithm>
using namespace std;
int t[5];
int main(){
  for(int i=0;i<5;i++)cin>>t[i];
  sort(t,t+5);
  reverse(t,t+5);
  cout<<t[0];
  for(int i=1;i<5;i++)cout<<" "<<t[i];
  cout<<endl;
  return 0;
}

Measured memory_bytes: 1176
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,i,j,ans,x,y,w,tx,ty,v[502][502],b[502][502],a[1000010],aa[4],bb[4];
queue<int>q;
int main(){
	aa[0]=1;aa[1]=-1;
	bb[2]=1;bb[3]=-1;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	 for(j=1;j<=n;j++)v[i][j]=1,b[i][j]=min(min(i,j),min(n-i+1,n-j+1));
	for(i=1;i<=n*n;i++){
		scanf("%d",&a[i]);
		x=(a[i]-1)/n;y=a[i]-x*n;x++;
		ans+=--b[x][y];v[x][y]=0;
		q.push(a[i]);
		while(!q.empty()){
			w=q.front();q.pop();
			x=(w-1)/n;y=w-x*n;x++;
			for(j=0;j<4;j++){
				tx=x+aa[j];ty=y+bb[j];
				if(!tx||!ty||tx>n||ty>n)continue;
				if(b[x][y]+v[tx][ty]<b[tx][ty]){
					b[tx][ty]=b[x][y]+v[tx][ty];
					q.push((tx-1)*n+ty);
				}
			}
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 6680
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
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 II(): return int(sys.stdin.readline())
def SI(): return input()
from collections import defaultdict

a, i = LI()
print(int((a * 3 + i) / 2))

Measured memory_bytes: 3316
N = int(input())
Info = [list(map(int, input().split())) for i in range(N)]

for Cx in range(101):
    for Cy in range(101):
        H = None
        for x, y, h in Info:
            if h == 0:
                continue

            # hが0以外の情報からHを一意に定める
            tmp_H = abs(Cx - x) + abs(Cy - y) + h
            if (H is None) or (H == tmp_H):
                H = tmp_H
            else:
                break
        # Hが一意に定まっていればh=0の情報すべてと整合性が取れているかチェック
        else:
            for x, y, h in Info:
                if h != 0:
                    continue

                if H - abs(Cx - x) - abs(Cy - y) > 0:
                    break

            # 整合性がとれていれば終わり
            else:
                print(Cx, Cy, H)
                exit()


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define F first
#define S second
using namespace std;
 
struct st {
	int tm, vl;
} a[3005];
int n, t, mx, d[6005]={1};
bool cmp (st p, st q) {
	if(p.tm != q.tm) return p.tm < q.tm;
	else return p.vl > q.vl;
}
int main() {
	int i, j;
	memset(d, -1, sizeof(d));
	d[0] = 0;
	cin >> n >> t;
	for(i=0; i<n; i++) cin >> a[i].tm >> a[i].vl;
	sort(a, a+n, cmp);
	for(j=0; j<n; j++) {
		for(i=t-1; i>=0; i--) {
			if(d[i] != -1) {
				d[i+a[j].tm] = max(d[i+a[j].tm], d[i] + a[j].vl);
			}
		}
	}
	for(i=0; i<6005; i++) mx = max(mx, d[i]);
	cout << mx;
	return 0;
}

Measured memory_bytes: 256
integer N
integer A,B,C
integer,allocatable,dimension(:)::L
read*,N,A,B,C
allocate(L(N))
read*,L
print"(I0)",dfs(N,0,0,0)

contains
recursive function dfs(nokori,forA,forB,forC)result(res)
  integer,intent(in)::nokori,forA,forB,forC
  integer res
  if(nokori==0)then
    res=abs(A-forA)+abs(B-forB)+abs(C-forC)-10*3
	if(forA*forB*forC==0)res=huge(res)/2
  else
    res=dfs(nokori-1,forA,forB,forC)
    res=min(res,dfs(nokori-1,forA+L(nokori),forB,forC)+10)
    res=min(res,dfs(nokori-1,forA,forB+L(nokori),forC)+10)
    res=min(res,dfs(nokori-1,forA,forB,forC+L(nokori))+10)
  endif
end function
end

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <stdlib.h>
#include <stdio.h>

using namespace std;

int my_abs_A(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

int my_abs_B(long long num,long long numb) {
    if (num - numb >= 0)
        return num - numb;
    else
        return -1 * (num - numb);
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

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

int main() {
    string S;
    cin >> S;
    if (S.at(0) == S.at(1) && S.at(1) == S.at(2) || S.at(1) == S.at(2) && S.at(2)== S.at(3)) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if((fabs(a-b)<=d && fabs(b-c)<=d)||fabs(a-c)<=d)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;
const int MaxN = 10005;
 
int N;
LL a[MaxN + 5], b[MaxN + 5];
 
void Init() {
	for(int i = 1; i <= N; i++)
		scanf("%lld", &a[i]);
	for(int i = 1; i <= N; i++)
		scanf("%lld", &b[i]);
}
 
void solve() {
	LL two = 0;
	LL one = 0;
	for(int i = 1; i <= N; i++) {
		if(a[i] < b[i]) two += (b[i] - a[i]) / 2;
		else if(a[i] > b[i]) one += (a[i] - b[i]);
	}
	if(two >= one) printf("Yes\n");
	else printf("No\n");
}
 
int main()
{
	while(scanf("%d", &N) != EOF)
	{
		Init();
		solve();
	}
	return 0;
}

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

int main() {
  string s;
  string out="Yes";
  cin >> s;
  sort(s.begin(),s.end());
  if(s.length()%2 == 0){
    for(int i = 0; i < s.length()/2; i++){
      if(s.at(2*i) != s.at(2*i+1)){
        out = "No";
      }
    }
  }else{
    out = "No";
  }
  cout << out << endl;
}


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

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

    double w, h;
    cin >> w >> h;
    double x, y;
    cin >> x >> y;

    double ans = w * h / 2;
    if (x == w / 2 && y == h / 2) printf("%.10f 1\n", ans);
    else printf("%.10f 0\n", ans);
    return 0;
}


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

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    long long n,m,nn;
    cin>>n>>m;
    vector<long long> a;
    for(int i=0;i<n;i++){
        cin>>nn;
        nn/=2;
        a.push_back(nn);
    }
    
    sort(a.begin(),a.end(),greater<int>());
    a.erase(unique(a.begin(),a.end()),a.end());
    
    long long mul=1;
    for(int i=0;i<a.size();i++){
        mul=abs(mul*a[i])/__gcd(mul,a[i]);
        if(mul>m){
            cout<<"0"<<endl;
            return 0;
        }
    }
    
    
    for(int i=0;i<a.size();i++){
        if(mul/a[i]%2==0){
            cout<<"0"<<endl;
            return 0;
        }
    }
    
    int ans=m/mul-m/mul/2;;
    cout<<ans<<endl;
}

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

#define MAXLEN 1000000

struct sDLL {
    int key;
    int pre;
    int next;
};

int ghead, gtail, gemhead, gemtail, gcnt;
struct sDLL list[MAXLEN+1];

void dllOperation( char *command, int key )
{
	int i;
	int pre;

   	if( 0 == strcmp( "insert", command ) ) {
   		pre=ghead;
		if( gcnt <= (ghead+1) && gcnt < MAXLEN ) {
			ghead=gcnt++;
		} else {
			ghead=gemhead;
			gemhead=list[gemhead].next;
			 if( -1 == gemhead ) {
				gemtail=-1;
			}
		}
		
		if( -1 == pre ) {
   			gtail=0;		
		} else {
   			list[pre].pre=ghead;
   		}
   		list[ghead].key=key;
		list[ghead].pre=-1;
		list[ghead].next=pre;

   	} else if( 0 == strcmp( "delete", command ) ) {
   		i=ghead;
	   	while( -1 != i  ) {
	   		if( key == list[i].key ) {
	   			if( ghead == i ) {
	   				ghead = list[i].next;
                    list[ghead].pre=-1; 
	   			} else if( gtail == i ) {
	   				gtail=pre;
	   				list[gtail].next=-1;
	   			} else {
					list[pre].next = list[i].next;
	   				list[ list[i].next ].pre=list[i].pre;
	   			}
				if( -1 == gemtail ) {
					gemhead=i;
				} else {
					list[gemtail].next=i;
				}
				list[i].pre=gemtail;
				gemtail=i;	
				list[gemtail].next=-1;
	   			break;
	   		}
	   		if( gtail == i ) { break; }
	   		pre=i;
	   		i=list[i].next;
	   	}
   	} else if( 0 == strcmp( "deleteFirst", command ) ) {
   		if( -1 == gemtail ) {
			gemhead=ghead;
		} else {
			list[gemtail].next=ghead;
		}
		list[ghead].pre=gemtail;
		gemtail=ghead;
   		ghead=list[ghead].next;
   		
   		list[gemtail].next=-1;
   	} else {
   		pre=list[gtail].pre;
   		if( -1 == gemtail ) {
			gemhead=gtail;
		} else {
			list[gemtail].next=gtail;
		}
		list[gtail].pre=gemtail;
		gemtail=gtail;
		list[gemtail].next=-1;
		if( ghead == gtail ) {
   			ghead=-1;
   		}					
		gtail=pre;
   	}

	return;
}   	

int main( void ) 
{
    int i;
    int n;
    char command[12];
    int key;
     
    scanf( "%d", &n );
    gemhead=gemtail=ghead=gtail=-1;
    gcnt=0;
    for( i=0; i<n; i++ ) {
        scanf( "%s", command );
        if( 0 == strcmp( "deleteFirst", command ) ) {
        	key=0;        
        } else if( 0 == strcmp( "deleteLast", command ) ) {
        	key=0;
        } else {
        	scanf( "%d", &key );
        }
        dllOperation( command, key );
    }
    

    i=ghead;
    while( -1 != i ) {
      	printf( "%d", list[i].key );
       	if( gtail == i  || -1 == list[i].next ) {
     		break;
     	} else {
     		printf( " " );
     	}
      	i=list[i].next;
     }
	printf( "\n" );
	
	return 0;
}

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

int main(){
    vector<bool> v(301);
    int x, n, a, val, err = 305;
    cin >> x >> n;

    for(int i = 1;i<n+1;i++){
        cin >> a;
        v[a+100] = true;
    }

    for(int i = 0;i<301;i++){
        if(v[i] == false && abs(x-(i-100)) < err){
            err = abs(x-(i-100));
            val = i - 100;
        }
    }

    cout << val << "\n";

    //int end;
    //cin >> end;
    return 0;
}

Measured memory_bytes: 3572
import math

while True:
    n = int(input())
    if n == 0:
        break

    score_list = list(map(int, input().split()))
    ave = sum(score_list) / n
    a2 = 0
    for s in score_list:
        a2 += (s - ave)**2
    a2 /= n
    a = a2**0.5
    print(a)



Measured memory_bytes: 5716