akhauriyash/Code-Regression huggingface dataset:
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}

}

use input::*;

fn comb(n: usize, r: usize) -> usize {
    let mut ans: usize = 1;
    for z in 0..r {
        ans *= n - z;
    }
    for _ in 1..r + 1 {
        ans /= r;
    }
    ans
}

fn main() {
    let (n, k): (usize, usize);
    input!(n, k);
    let mut ans = 1;
    for z in 0..n {
        if z == 0 {
            ans *= comb(k, 1);
        } else if z == n - 1 {
            ans *= comb(k - 1, 1);
        } else {
            ans *= comb(k - 1, 1);
        }
    }
    p(ans);
}

Measured memory_bytes: 4352
fun main(args : Array<String>) {
    val (N, Q) = readLine()!!.split(" ").map { it.toInt() }
    val S = readLine()!!
    val queries = mutableListOf<Pair<Int, Int>>()
    (1..Q).forEach {
        val (l, r) = readLine()!!.split(" ").map { it.toInt() }
        queries.add(Pair(l, r))
    }

    val cumilativeArray = IntArray(N + 1)
    cumilativeArray[0] = 0
    var Aapperead = false
    S.forEachIndexed { index, c ->
        var ac = 0
        if (c == 'A') {
            Aapperead = true
        } else if (c == 'C' && Aapperead) {
            ac = 1
            Aapperead = false
        } else {
            Aapperead = false
        }
        cumilativeArray[index + 1] = cumilativeArray[index] + ac
    }

    queries.forEach { q ->
        val l = q.first
        val r = q.second
        println(cumilativeArray[r]  - cumilativeArray[l])
    }
}

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

#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using int32 = int;
using int64 = long long;

const int   mod   = 1e9 + 7;
const int32 inf   = 1001001001;
const int64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 10){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = int64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solver() {
  int H = input(), W = input();
  vector< string > s(H);
  for (auto &i : s) cin >> i;

  vector< bool > ph(H), pw(W);
  range(i, 0, H) range(j, 0, W) if (s[i][j] == '#') {
    ph[i] = true;
    pw[j] = true;
  }

  range(i, 0, H) {
    if (!ph[i]) continue;
    range(j, 0, W) if (pw[j]) cout << s[i][j];
    cout << endl;
  }
}

signed main(int argc, char *argv[]) {
  solver();
}


Measured memory_bytes: 256
import java.util.Comparator;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
	public static void main(String[] args) {

		Scanner sysin = new Scanner(System.in);
		final int n = sysin.nextInt();
		int[] d = IntStream.range(0, n)
					.map(i -> sysin.nextInt())
					.boxed()
					.sorted(Comparator.naturalOrder())
					.mapToInt(Integer::intValue)
					.toArray();
		sysin.close();

		int low = d[d.length / 2 - 1];
		int high = d[d.length / 2];

		System.out.println(high - low);
	}
}


Measured memory_bytes: 64292
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x); i<=(y); i++)
#define per(i,x,y) for (int i=(x); i>=(y); i--)
#define ll long long
#define ld long double
#define inf 1000000000
#define INF 1000000000000000000ll
#define pii pair<int,int>
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define sqr(x) ((x)*(x))
#define cmin(x,y) (x)=(y)<(x)?(y):(x)
#define cmax(x,y) (x)=(y)>(x)?(y):(x)
using namespace std;
const ld pi=acos(-1);
const ld eps=1e-8;
//////////////////////// header files ////////////////////////
ll read(){
	char ch=getchar(); ll x=0; int op=1;
	for (; !isdigit(ch); ch=getchar()) if (ch=='-') op=-1;
	for (; isdigit(ch); ch=getchar()) x=(x<<1)+(x<<3)+ch-'0';
	return x*op;
}
void write(ll a){
	if (a<0) putchar('-'),a=-a;
	if (a>=10) write(a/10); putchar(a%10+'0');
}
////////////////////////// fast i/o //////////////////////////
#ifdef mod
ll ksm(ll x,ll p){
	ll ret=1;
	for (; p; p>>=1,x=x*x%mod) if (p&1) ret=ret*x%mod;
	return ret;
}
ll get_inv(ll x){
	return ksm(x,mod-2);
}
#else
ll ksm(ll x,ll p){
	ll ret=1;
	for (; p; p>>=1,x=x*x) if (p&1) ret=ret*x;
	return ret;
}
#endif
//////////////////////////// qpow ////////////////////////////
#define N 20005
int n,cnt,a[N];
//#define local
int main(){
#ifdef local
	freopen("test.in","r",stdin); freopen("test.out","w",stdout);
#endif
	rep (i,1,30000) if (i%2==0 || i%3==0) a[++cnt]=i;
	//if (sum%6==0) cerr<<1; else cerr<<0;
	scanf("%d",&n);
	if (n==20000){ rep (i,1,cnt) cout<<a[i]<<' '; exit(0); }
	ll sum=0;// n--;
	if (n==3){ cout<<2<<' '<<5<<' '<<63; exit(0); }
	rep (i,1,n-1){
		/*cout<<a[i]<<' '; */sum+=a[i];
	}
	int x=n;
	if (sum%6==1 || sum%6==5){
		//cerr<<"??"<<endl;
		sum-=a[n-1];
		while (x<=20000 && ((sum+a[x])%6==1 || (sum+a[x])%6==5)) x++;
		//cerr<<"x="<<x<<endl;
		sum+=a[x];
		rep (i,1,n-2) cout<<a[i]<<' ';// cerr<<"|";
		cout<<a[x]<<' '; x++;//cerr<<"|";
	} else{
		rep (i,1,n-1) cout<<a[i]<<' ';
	}
	//cout<<sum<<endl;
	rep (i,x,20000){
		///cerr<<sum+a[i]<<endl;
		if ((sum+a[i])%6==0){ cout<<a[i]<<' '; exit(0); }
	}
	//puts("-1");
	return 0;
}
// sample data:
/*
3

4

*/

// rest:
/*

*/

Measured memory_bytes: 384
local function str2tbl(s)
    -- limit of #s is approximately 999959
    local t = {string.byte(s, 1, #s)}
    local char = string.char
    for i=1, #t do
        if char(t[i]) == '#' then
            t[i] = 1
        else
            t[i] = 0
        end
    end
    return t
end
--
local N, A, B, C, D = io.read("n", "n", "n", "n", "n", "l")
local S = str2tbl(io.read("l"))

local function YesNo(x)
    print(x and 'Yes' or 'No')
end

local function ok1(src, dst)
    local prev = S[src]
    for i=src+1, dst do
        local cur = S[i]
        if prev == 1 and cur == 1 then
            return false
        end
        prev = cur
    end
    return true
end

local function ok2(src, dst)
    for i=src, dst do
        local prev = S[i-1]
        local cur = S[i]
        local nex = S[i+1]
        if prev == 0 and cur == 0 and nex == 0 then
            return true
        end
    end
    return false
end

local fnuke_ok = ok1(B, D)
local snuke_ok = ok1(A, C)
if C < D then
    YesNo(fnuke_ok and snuke_ok)
else
    YesNo(ok2(B, D))
end


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

public class Main {

	int INF = 1 << 28;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			long n = sc.nextLong();
			if(n == 0) break;
			long f = 5;
			long ans = 0;
			while(n>=f) { ans += n/f; f *= 5; }
			System.out.println(ans);
		}
	}

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

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

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

int main(){
    ll n,ans;
    cin >> n;
    vector<ll> a(n);
    rep(i,n){
        int b;
        cin >> b;
        if(b%2==0){
            a[i] = b;
        }else{
            a[i] = 6;
        } 
    }
    rep(i,n){
        if(a[i]%3!=0 && a[i]%5!=0){
            cout << "DENIED";
            return 0;
        }
    }
    cout << "APPROVED";
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{
  static void trace(int[] a){
    int i;
    for(i = 0; i < a.length - 1; i++)
      System.out.print(a[i] + " ");
    System.out.println(a[i]);
  }

  public static void main(String[] args){
    Scanner stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    int a[] = new int[n];
    for(int i = 0; i < n; i++)
      a[i] = stdIn.nextInt();

    int count = 0;
    boolean flag = true;
    while(flag){
      flag = false;
      for(int j = n-1; j > 0; j--){
        if(a[j] < a[j-1]){
          int tmp = a[j];
          a[j] = a[j-1];
          a[j-1] = tmp;
          count++;
          flag = true;
        }
      }
    }

    trace(a);
    System.out.println(count);

  }
}

Measured memory_bytes: 26264
import sys
input = sys.stdin.readline
from heapq import heappop,heappush

N,Q = map(int,input().split())
task = []

STX = [[int(x) for x in input().split()] for _ in range(N)]
for s,t,x in STX:
  task.append((t-x,0,x))
  task.append((s-x,1,x))

for i in range(Q):
  d = int(input())
  task.append((d,2,i))
answer = [-1]*Q

task.sort()

se = set()
se_hp = []
for a,b,c in task:
  if not b:
    se.remove(c)
  elif b&1:
    se.add(c)
    heappush(se_hp,c)
  else:
    while se_hp and se_hp[0] not in se:
      heappop(se_hp)
    answer[c] = se_hp[0] if se_hp else -1

print('\n'.join(map(str,answer)))


Measured memory_bytes: 142136
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {

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

		ArrayList<Integer> array_number = new ArrayList<>();
		for (int i =0; i < N; i++) {
			int input_number = sc.nextInt();
			array_number.add(input_number);
		}

		Collections.sort(array_number);

		System.out.println(array_number.get(N-1)-array_number.get(0));
	}

}


Measured memory_bytes: 23252
n = gets.to_i
arr = gets.split(" ").map(&:to_i)
arrab = Array.new
pm = 1
for i in 0..n-1 do
    arrab[i] = arr[i].abs
end

sumabs = arrab.inject(:+)

if arr.include?(0)
    puts sumabs
    exit
end

for i in 0..n-1 do
    if arrab[i] != arr[i]
        pm = pm * -1
    end
end
if pm == 1
    puts sumabs
else
    puts sumabs - (arrab.min)*2
end

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

int main(){
    string S;
    cin>>S;

    int N=S.size();
    int c=0;
    int d=0;

    rep(i,N-1){
        if(S.at(i)!=S[N-i-1]){
            c++;
        }
    }


    rep(i,(N-1)/2){

    if(S[i]!=S[(N-3)/2-i]){
        d++;
    }

    }

if(c==0&&d==0){cout<<"Yes"<<endl;}
else{cout<<"No"<<endl;}
    }



Measured memory_bytes: 256
N, M = map(int, input().split())
p = list(map(lambda x: int(x)-1, input().split()))

class UnionFind(object):
    def __init__(self, N):
        self.par = list(range(N))
        self.rank = [0 for _ in range(N)]

    def root(self, i):
        if self.par[i] == i:
            return i
        else:
            j = self.root(self.par[i])
            self.par[i] = j
            return j

    def union(self, i, j):
        i = self.root(i)
        j = self.root(j)
        if i == j:
            return
        if self.rank[i] < self.rank[j]:
            self.par[i] = j
        else:
            self.par[j] = i
            if self.rank[i] == self.rank[j]:
                self.rank[i] += 1

    def same(self, i, j):
        return self.root(i) == self.root(j)


union_find = UnionFind(N)


sets = []
for _ in range(M):
    x, y = map(lambda x: int(x)-1, input().split())
    union_find.union(x, y)


res = 0

for i, n in enumerate(p):
    if union_find.same(i, n):
        res += 1

print(res)


Measured memory_bytes: 13812
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

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

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

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n, -1) {}
    void init(int n) { par.assign(n, -1); }

    int root(int x)
    {
        if (par[x] < 0)
            return x;
        else
            return par[x] = root(par[x]);
    }

    bool issame(int x, int y)
    {
        return root(x) == root(y);
    }

    bool merge(int x, int y)
    {
        x = root(x);
        y = root(y);
        if (x == y)
            return false;
        if (par[x] > par[y])
            swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x)
    {
        return -par[root(x)];
    }
};

int kruskal(vector<edge> &graph, int V)
{
    sort(ALL(graph), [](const edge &a, const edge &b) { return a.cost < b.cost; });
    UnionFind uf(V);

    int res = 0;
    for (int v = 0; v < (int)graph.size(); v++)
    {
        edge e = graph[v];
        if (!uf.issame(e.from, e.to))
        {
            uf.merge(e.from, e.to);
            res += e.cost;
        }
    }
    return res;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int V, E;
    cin >> V >> E;
    vector<edge> graph;
    for (int i = 0; i < E; i++)
    {
        int s, t, w;
        cin >> s >> t >> w;
        graph.push_back(edge{s, t, w});
        graph.push_back(edge{t, s, w});
    }
    cout << kruskal(graph, V) << endl;
}


Measured memory_bytes: 6040
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */



// Taken from: https://github.com/bqi343/USACO/blob/master/Implementations/content/contest/templateShort.cpp

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ull> vul;
typedef vector<ll> vl;
typedef vector<pii> vpii;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i,0,a)
#define ROF(i, a, b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i, a) ROF(i,0,a)
#define trav(a, x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

#define mp make_pair
#define pb push_back
#define f first
#define s second

const int MOD = 1e9 + 7; // 998244353; // = (119<<23)+1
const int MX = 2e5 + 5;

template<class T>
bool ckmin(T &a, const T &b) {
    return a > b ? a = b, 1 : 0;
}

template<class T>
bool ckmax(T &a, const T &b) {
    return a < b ? a = b, 1 : 0;
}

mt19937 rng((uint32_t) chrono::steady_clock::now().time_since_epoch().count());


//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element: vec) {
        is >> element;
    }
    return is;
}

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

class CSkip {
public:
    void solve(std::istream &in, std::ostream &out) {
        int n, x;
        in >> n >> x;
        vi X(n);
        in >> X;
        int res = 0;
        trav(y, X) {
            res = __gcd(res, abs(y - x));
        }
        out << res << '\n';
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    CSkip solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  string s;
  cin>>s;
  rep(i,s.size()){
    if(i%2==0) cout<<s[i];
  }
  cout<<endl;

  return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
int cntDiv(int n){
	int ans = 0;
	for (int i= 1;i*i<=n;i+=2){
		if(n%i==0){
			if(i*i==n)ans++;
			else ans +=2;
		}
	}
	return ans;
}
string w[110];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n,y;
	scanf("%d %d",&n,&y);
	int res10000 = -1, res5000 = -1, res1000 = -1;
	for(int a=0;a<=n;a++){
		for(int b=0;b<=n;b++){
			int c = n-b-a;
			if(c >= 0){
				int total = 10000*a + 5000*b+1000*c;
				if(total == y){
					res10000 = a;
					res5000 = b;
					res1000 = c;
				}
			}
		}
	}
	cout << res10000 << " " << res5000 << " " << res1000 << " " << endl;
	return 0;
}


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

ll A[300000];
ll X[5];

int main(){
  ll N;
  cin >> N;
  rep(i, N) cin >> A[i];
  sort(A, A+N);
  reverse(A, A+N);

  if (N==2){
    cout << A[0] << endl;
    return 0;
  }

  ll ans = 0;
  ans += A[0];
  ans += A[1];

  queue<ll> que;
  que.push(A[1]);
  que.push(A[2]);
  que.push(A[2]);

  rep(i, N-3){
    ll front = que.front();
    ans += front;
    que.pop();
    que.push(A[i+3]);
    que.push(A[i+3]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 6592
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a =sc.nextInt();
		if(a>=400&&a<=599) {
			System.out.println(8);
		}else if(a>=600&&a<=799) {
			System.out.println(7);
		}else if(a>=800&&a<=999) {
			System.out.println(6);
		}else if(a>=1000&&a<=1199) {
			System.out.println(5);
		}else if(a>=1200&&a<=1399) {
			System.out.println(4);
		}else if(a>=1400&&a<=1599) {
			System.out.println(3);
		}else if(a>=1600&&a<=1799) {
			System.out.println(2);
		}else if(a>=1800&&a<=1999) {
			System.out.println(1);
		}


	}

}



Measured memory_bytes: 35748
#include <iostream>
#include <string>

int main()
{
	std::string S, T, U;
	int A = 0, B = 0;
	std::cin >> S >> T;
	std::cin >> A >> B;
	std::cin >> U;

	if (U == S) A--;
	if (U == T) B--;

	std::cout << A << " " << B << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(v, a, b) for(int v = (int)(a); v < (int)(b); ++v)
#define FORE(v, a, b) for(int v = (int)(a); v <= (int)(b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define RS resize
#define CLR clear
#define PB push_back
#define ALL(x) (x).begin(), (x).end()
using namespace std;

void split(string str, char chr, vector< string > *res){
	stringstream ss(str);
	string itm;
	while(getline(ss, itm, chr)){
		(*res).PB(itm);
	}
}


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, x, y, j = 1;
	double area;
	vector< complex< int > > p;
	
	while(cin >> n, n){
		p.CLR();
		p.RS(n);
		REP(i, n){
			cin >> x >> y;
			p[i] = complex< int >(x, y);
		}
		
		area = 0;
		for(int i = 0; i < n; ++i){
			area += (p[i].imag() * p[(i+1)%n].real() - p[i].real() * p[(i+1)%n].imag());
		}
		area /= 2;
		
		printf("%d %.1lf\n", j, abs(area));
		++j;
	}
	
	return 0;
}

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

int main() {
  int a, b;
  cin >> a >> b;
  
  int c = a * b;
  
  if (c%2 ==0){
    cout << "Even" << endl;
  }
  
  else
    cout << "Odd" << endl;
  
}

Measured memory_bytes: 3580
#include <iostream>
#include <string>

using namespace std;
int main()
{
	string S;
	cin >> S;

	int cnt = 0;

	for (int i = 0; S[i]!='\0'; i++) {
		if(S[i] == 'x')cnt++;
	}
	if (cnt > 7) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n);++i)
using namespace std;
using ll = long long; 
using P = pair<int,int>;
using vv = vector<vector<ll> >;
template <class _t> inline bool chmax (_t& a,_t b){if(a<b){a=b;return true;}return false;} template <class _t> inline bool chmin (_t& a,_t b){if(a>b){a=b;return true;}return false;}

const int INF = 2147483647;
const int max_N = 1000000000;
const long long inf = 1ll << 60;
const long long mod = 1000000007;

int dx[4] = {1,0,-1,0};
int dy[4] = {0,-1,0,1};
int main(){
    int n; cin >> n;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    ll ans = 0;
    for(int i=1;i<n;i++){
        if(v[i] < v[i-1]){
            ans += v[i-1]-v[i];
            v[i] = v[i-1];
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
	double a, b, c, d, e, f;
	cout << setprecision(3) << setiosflags(ios::fixed);

	while(cin >> a >> b >> c >> d >> e >> f){
		cout << (c*e-b*f)/(a*e-b*d)+0.00001 << " " << (c*d-a*f)/(b*d-a*e)+0.0001 << endl;
	}

	return 0;

}

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

int main(){
	int n,y;
	cin >> n >> y;
	constexpr  int yukichi=10000;
	constexpr  int higuchi = 5000;
	constexpr  int noguchi =1000;
	for(int i=0;i<=n;i++)
	{
		for(int j=0;(i+j)<=n;j++)
		{
			for(int k=0;(i+j+k)<=n;k++)
			{
				//if(y==(i*yukichi+j*higuchi+k*noguchi)&&(i+j+k)<=n)
				if(y==(i*yukichi+j*higuchi+k*noguchi)&&(i+j+k)==n)
				{
					cout << i << " " << j << " " << k;
					return 0;
				}
			}			
		}
	}
	cout << -1 << " " << -1 << " " << -1;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define F first
#define S second
#define SHN 1e9
#define lSHN 1e18
using namespace std;
string s1,s2;
string res="zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz";
bool ok=0;
int main()
{
	cin >>s1>>s2;
	if (s1.size()<s2.size())
	{
		cout <<"UNRESTORABLE";
		return 0;
	}
	for (int i=0;i<=s1.size()-s2.size();i++)
	{
		bool fl=1;
		for (int j=i;j<i+s2.size();j++)
		{
			if (s1[j]=='?') continue;
			if (s1[j]!=s2[j-i])
			{
				fl=0;
				//cout <<i<<" "<<j<<" ##\n";
				break;
			}
		}
		if (!fl) continue;
		ok=1;
		string st=s1.substr(0,i);
		st+=s2;
		st+=s1.substr(i+s2.size());
		for (int j=0;j<st.size();j++) if (st[j]=='?') st[j]='a';
		res=min(res,st);
		//cout <<i<<" "<<st<<" ################\n";
	}
	if (ok) cout <<res;
	else cout <<"UNRESTORABLE";
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>

using namespace std;

constexpr int mod = 1000000007;

int main()
{
    int N;
    scanf("%d\n", &N);
    int S;
    {
        char temp[5001];
        scanf("%[^\n]\n", temp);
        S = strlen(temp);
    }

    vector<vector<int>> table(N + 1, vector<int>(N + 1, 0));
    table[0][0] = 1;
    for (int n = 1; n <= N; ++n){
        table[n][0] = table[n - 1][0];
        table[n][0] += (table[n - 1][1] * 2) % mod;
        table[n][0] %= mod;
        for (int s = 1; s <= n; ++s){
            table[n][s] = table[n - 1][s - 1];
            table[n][s] += (table[n - 1][s + 1] * 2) % mod;
            table[n][s] %= mod;
        }
    }
    printf("%d\n", table[N][S]);
}


Measured memory_bytes: 98176
import java.util.Scanner;

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

			for(int a = 0 ; a < 400 ; a++ ) {
				for(int b = -400 ; b < 400 ; b++ ) {
					
					long diff = (long)(Math.pow(a, 5) - Math.pow(b, 5));
					
					if ( x == diff ) {
						System.out.println(a + " " + b);
						return;
					}
				}
			}
		}
	}

}

Measured memory_bytes: 38776
from collections import deque

s=input()
s=s.replace("BC","D")
N=len(s)

cnt=0
cntA=0
cntD=0

for i in range(N):
  if s[i]=="A":
    cntA += 1
  elif s[i]=="D":
    cnt += cntA
  else:
    cntA=0
    cntD=0
    
print(cnt)

Measured memory_bytes: 3752
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int N, i, j, end_address, tmpNum, contNum;
    cin >> N;
    vector< int > s(N); // start
    vector< int > h(N); // target
    vector< int > contin; // target

    for (i=0;i<N;i++){
        cin >> h[i];
        s[i] = 0;
    }

    for (j=0; ;j++){
        end_address = 0;
        tmpNum = 0;
        contNum = 0;
        for (i=0;i<N;i++){
            if (s[i] < h[i]){
                tmpNum++;
                if (tmpNum > contNum){
                    contNum = tmpNum;
                    end_address = i;
                }
            }
            else{
                tmpNum = 0;
                }   
            }

        //cout << contNum << '\n';
        if (contNum==0 && tmpNum==0) break;
        else{
            for (i=end_address-(contNum-1); i<=end_address; i++){
                s[i] += 1;
            }
        }
    }

    cout << j << '\n';
}

   

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
ll a[100010];
ll Calc(){
    ll ret=0;
    ll sum=a[0];
    ll preSum;
    for(ll i=1;i<N;i++){
        preSum=sum;
        sum+=a[i];
        if(sum==0 || ((preSum<0)^(sum>0))){
            if(preSum>0){
                ret+=abs(-1-sum);
                sum=-1;
            }else{
                ret+=abs(1-sum);
                sum=1;
            }
        }
    }
    return ret;
}
int main(){
    cin>>N;
    for(ll i=0;i<N;i++) cin>>a[i];
    ll a0=a[0];
    ll ans0=Calc();
    a[0]=1;
    ll ans1=Calc()+abs(1-a0);
    a[0]=-1;
    ll ans2=Calc()+abs(-1-a0);
    cout<<min({ans0,ans1,ans2})<<endl;
    return 0;
}

Measured memory_bytes: 1152
#!/usr/bin/env python3
s = input()
n = len(s)
p = s[0]
i = 1
k = 1
while i < n:
    if s[i:i + 1] != p:
        p = s[i:i + 1]
        i += 1
    elif i < n - 1 and s[i:i + 2] != p:
        p = s[i:i + 2]
        i += 2
    else:
        k -= 1
        i += 1
    k += 1
print(k)


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

int main()
{
	int a,b,c,d,s1,s2;
	cin>>a>>b>>c>>d;
	s1=a+b;
	s2=c+d;
	if (s1<s2)
		cout<<"Right";
	else if (s1==s2)
		cout<<"Balanced";
	else
		cout<<"Left";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<limits.h>
#define MOD 1000000007
#define PI 3.14159265
#define seive_len 1

typedef long long int lli;

int *array;
int seive[seive_len];

long long int min(long long int a, long long int b) {
    return a<b?a:b;
}

long long int max(long long int a, long long int b) {
    return a>b?a:b;
}

int compare(const void* a, const void* b) {
    return *(int*)a-*(int*)b;
}

int cmp(const void *a, const void *b){
    int ia = *(int *)a;
    int ib = *(int *)b;
    return array[ia] < array[ib] ? -1 : array[ia] > array[ib];
}

long double abs1(long double n) {
    if(n < 0)
        return n*(-1.0);
    return n*1.0;
}

void swap(int *a, int *b) {
    *a = (*a)^(*b);
    *b = (*a)^(*b);
    *a = (*a)^(*b);
}

lli binSearch(lli a[], lli x, lli l, lli r) {
    if(r >= l) {
        lli mid = l + ((r-l)>>1);
        if(a[mid] == x)
            return mid;
        if(a[mid] > x) {
            return binSearch(a, x, l, mid-1);
        }
        else if(a[mid] < x) {
            return binSearch(a, x, mid+1, r);
        }
    }
    return -1;
}

void makeSeive() {
    int i;
	seive[1] = 1;
    for(i=2;i<seive_len;i++) {
        if(seive[i] == 0) {
            long long int temp=(long long int)i*i;
            while(temp <= seive_len-1) {
                seive[temp] = 1;
                temp += i;
            }
        }
    }
}

int isPrime(int n) {
    int i;
    for(i=2;i*i<=n;i++)  {
        if(n%i == 0)
            return 0;
    }
    return 1;
}

void getInput(lli a[], lli n) {
    for(lli i=0;i<n;i++)
        scanf("%lld", &a[i]);
}

int titleToNumber(char* s)
{
    int sum = 0;
    while(*s) sum = 26*sum+(*(s++)-'A'+1);
    return sum;
}

void testCase() {
    lli n, i, k;
    scanf("%lld", &n);
    lli a[n];
    getInput(a, n);
    scanf("%lld", &k);
    lli sum = 0;
    for(i=0;i<n;i++)
        sum += a[i];
    // qsort(a, n, sizeof(lli), compare);
    lli b, c;
    lli freq[100001];
    for(i=0;i<100001;i++)
        freq[i] = 0;
    for(i=0;i<n;i++)
        freq[a[i]]++;
    for(i=0;i<k;i++) {
        scanf("%lld%lld", &b, &c);
        sum += (freq[b]*(c-b));
        freq[c] += freq[b];
        freq[b] = 0;
        printf("%lld\n", sum);
    }

}

int main() {
    int t=1;
    // scanf("%d", &t);
    // makeSeive();
    while(t--) {
        testCase();
        // printf("\n");
    }
    return 0;
}


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

template<typename T1, typename T2>
ostream& operator << (ostream& os, const pair<T1, T2>& p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& v) {
    os << "{";
    for(int i = 0; i < v.size(); i++)
        os << v[i] << (i+1<v.size()?", ":"");
    os << "}";
    return os;
}

class range {
  struct Iterator {
    int val, inc;
    int operator*() {return val;}
    bool operator!=(Iterator& rhs) {return val < rhs.val;}
    void operator++() {val += inc;}
  };
  Iterator i, n;
public:
  range(int e) : i({0, 1}), n({e, 1}) {}
  range(int b, int e) : i({b, 1}), n({e, 1}) {}
  range(int b, int e, int inc) : i({b, inc}), n({e, inc}) {}
  Iterator& begin() {return i;}
  Iterator& end() {return n;}
};

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}
//}}}

int main(){
    iostream_init();

    int N, M;
    while(cin >> N) {
        vector<LL> a(N);
        REP(i, N) cin >> a[i];
        sort(a.begin(), a.end());
        vector<LL> sum(N+1);
        REP(i, N) sum[i+1] = sum[i] + a[i];
        cin >> M;
        vector<LL> b(M);
        REP(i, M) cin >> b[i];
        vector<LL> c(M);
        REP(i, M) cin >> c[i];

        REP(i, M) {
            int k = upper_bound(a.begin(), a.end(), b[i]) - a.begin();
            if(sum[k] >= c[i]) {
                cout << "Yes" << endl;
            } else {
                cout << "No" << endl;
            }
        }

    }

    return 0;
}

/* vim:set foldmethod=marker: */

Measured memory_bytes: 10236
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
    int n = 0, k = 0;
    cin >> n >> k;
    int a = (n-1) * (n-2) / 2;
    if (k > a) {
        cout << -1 << endl;
    }
    else {
        cout << n - 1 + a - k << endl;
        for (int i=2; i<=n; i++) {
            cout << 1 << " " << i << endl;
        }
        int now = 2;
        int nownow = 1;
        for (int i=0; i<a-k; i++) {
            cout << now << " " << now+nownow << endl;
            nownow++;
            if (now + nownow > n) {
                now++;
                nownow = 1;
            }
        }
    }
    return 0;
}


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

int main() {

    int n,k;

    cin >> n >> k;

    int ans = 1;

    for(int i=0; i<n; i++){
        ans = min(ans*2,ans+k);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import sys

L, R = map(int, input().split())

if R - L + 1 >= 2019:
    print(0)
else:
    for i in range(L, R+1):
        if i % 2019 == 0:
            print(0)
            sys.exit()
    else:
        ans = 10**6
        for i in range(L, R):
            for j in range(i+1, R+1):
                ans = min(ans, i * j % 2019)
                if ans == 0:
                    break
        print(ans)


Measured memory_bytes: 3060
from collections import Counter
N = int(input())
A = [int(i) for i in input().split()]
m = Counter(A)
ls = []
for x, y in m.items():
    if y%2 == 0:
        ls.append(x)
if len(ls)%2 == 0:
    print(len(m))
else:
    print(len(m)-1)


Measured memory_bytes: 18648
n=int(input())
F=[list(map(int, input().split())) for i in range(n)]
P=[list(map(int, input().split())) for i in range(n)]
ans=-float("inf")
for j in range(1,2**10):
  A=list(str(bin(j))[2:])
  for i in range(10-len(A)):
    A.insert(0,"0")  
  prof=0
  for i in range(n):
    k=sum(int(p)*q for p,q in zip(A,F[i]))
    prof+=P[i][k]
  ans=max(ans,prof)
print(ans)

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


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n;cin>>n;
    cout<<n*(n-1)/2;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MSET(x,y) memset(x,y,sizeof(x))
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define SZ size()
#define M 100005
#define ll long long
#define ld long double
#define INF 1e18
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
ll MOD = 1000000007;
string yes = "YES\n";
string no = "NO\n";
#define PI 3.1415926535 
 
 
int32_t main() {
    fastio;
    char a;
    cin>>a;
    if(a-'a'>=0) {
        cout<<"a"<<endl;
    } else cout<<"A"<<endl;
}

Measured memory_bytes: 3612
import numpy as np
X, N=map(int,input().split())
if N==0:
  ans=X
  print(ans)
else:
  ps=map(int,input().split())

  ps_sort=sorted(ps)

  ind_crit=N-1
  for p in ps_sort:
    if p>=X:
      ind_crit=ps_sort.index(p)
      break

  if not ps_sort[ind_crit]==X:
    ans=X
  else:
    diff=0
    while(True):
      diff+=1
      if not X-diff in ps_sort:
        ans=X-diff
        break
      if not X+diff in ps_sort:
        ans=X+diff
        break

  print(ans)

Measured memory_bytes: 27140
#include<stdio.h>

int main()
{
  int a,b,c,i,j,divisor=0,count=0;
  scanf("%d %d %d",&a,&b,&c);

  for(i=1;i<=c;i++){
    if(c%i!=0)
      continue;
    divisor=c/i;
    for(j=a;j<=b;j++){
      if(j==divisor){
	count++;
	break;
      }
    }
  }

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

  
  return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	ll N=in();
	auto A=vecin<ll>(N);
	vector<ll> S(N+1,0);
	REP(i,N){
		S[i+1] = S[i]+A[i];
	}

	map<ll,ll> M;
	REP(i,N+1){
		M[S[i]]++;
	}
	ll K=0;
	for(auto& x:M){
		K += (x.second*(x.second-1LL))/2LL;
	}

	out(K);
	return 0;
}


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

#define int long long
int mod = 1000000007;

int32_t main()
{
    ios_base::sync_with_stdio(false);
        cin.tie(NULL);
    int a,p;
    cin>>a>>p;
    int alpha = 3*a + p;
    cout<<alpha/2;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {

    int N;cin >> N;

    vector<vector<string>> v(N);
    v[0].push_back("a");
    REP(i, N-1){
        for(auto s : v[i]){
            int sz = 0;
            REP(j, s.size()) sz = max(sz, s[j] - 'a');
            REP(j, sz+2) {
                char c = 'a' + j;
                string c1 = to_string(c);
                v[i+1].push_back(s + c);
            }
        }
    }
    REP(i, v[N-1].size()) cout << v[N-1][i] << endl;
 

    return 0;
}


Measured memory_bytes: 11380
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = getInt(sc);
		int[] v = getIntArray(sc);
		Arrays.sort(v);
		double sum = 0;
		for (int i = 0; i < n; i++) {
			if (i == 0) {
				sum = v[i];
			} else {
				sum = (sum + v[i]) / 2;
			}
		}

		System.out.println(sum);

	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をlongで返却
	 *
	 * @return
	 */
	public static long getLong(Scanner sc) {

		return Long.parseLong(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をintで返却
	 *
	 * @return
	 */
	public static int getInt(Scanner sc) {

		return Integer.parseInt(sc.next());
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をStringで返却
	 *
	 * @return
	 */
	public static String getString(Scanner sc) {

		return sc.next();
	}

	/**
	 * *汎用メソッド <br>
	 * スキャナーからの入力値をint配列で返却
	 *
	 * @return
	 */
	public static int[] getIntArray(Scanner sc) {
		String line = "";
		// 直前にnext()を実行していると改行コードだけ取ってしまうのでその対策
		while (line.equals("")) {
			line = sc.nextLine();
		}

		String[] strArray = line.split(" ");
		int[] intArray = new int[strArray.length];
		for (int i = 0; i < strArray.length; i++) {
			intArray[i] = Integer.parseInt(strArray[i]);
		}
		return intArray;
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
queue< pair<int,int> > q;
int original[1010][1010];
int grid[1010][1010];
pair<int,int> cheese[10];
int H, W, N, ans = 0;

void resetGrid(pair<int,int> p) {
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      grid[j][i] = original[j][i];
      if (p.first == j && p.second == i) grid[j][i] = 0;
    }
  }
}

void bfs() {
  int mX[] = { 1, 0, -1, 0 };
  int mY[] = { 0, 1, 0, -1 };
  for (int i = 0; i < N; i++) {
    resetGrid(cheese[i]);
    q.push(cheese[i]);
    while (q.size() > 0) {
      pair<int,int> p = q.front();
      q.pop();
      int x = p.first, y = p.second;
      for (int j = 0; j < 4; j++) {
        int _x =x+mX[j], _y =y+mY[j];
        if (_x < 0 || _y < 0 || _x >= W || _y >= H || grid[_x][_y] != INF) continue;
        grid[_x][_y] = grid[x][y]+1;
        q.push(make_pair(_x, _y));
      }
    }
    ans += grid[cheese[i+1].first][cheese[i+1].second];
  }
}

signed main() {
  cin >> H >> W >> N;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      char c; cin >> c;
      if (c == 'S') {
        original[j][i] = INF;
        cheese[0] = make_pair(j, i);
      } else if (c == 'X') {
        original[j][i] = -1;
      } else if (c == '.') {
        original[j][i] = INF;
      } else {
        original[j][i] = INF;
        cheese[(c-'0')] = make_pair(j, i);
      }
    }
  }

  bfs();

  cout << ans << endl;
}



Measured memory_bytes: 18888
#include<iostream>
int main(){
  int N,K,dist=0,a;
  std::cin>>N>>K;
  for(int i=0;i<N;i++){
    std::cin>>a;
    if(a<=K/2){
      dist+=a*2;
    }else dist+=(K-a)*2;
  }
  std::cout<<dist<<std::endl;
  return 0;
}

Measured memory_bytes: 3584
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#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<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int n,m,u[100005],a[100005],k;
vector<int> v[100005];
void dfs(int x){
    a[++k]=x;
    u[x]=1;
    for(int i=0;i<v[x].size();++i){
        if(!u[v[x][i]]){
            dfs(v[x][i]);
            break;
        }
    }
}
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;++i){
        int x,y;
        scanf("%d%d",&x,&y);
        v[x].pb(y),v[y].pb(x);
    }
    dfs(1);
    int o=k;
    dfs(1);
    printf("%d\n",k-1);
    for(int i=o;i;--i)printf("%d ",a[i]);
    for(int i=o+2;i<=k;++i)printf("%d ",a[i]);
    //system("pause");
    return 0;
}


Measured memory_bytes: 7040
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int n;

int main(){
    cin>>n;
    if(n/100==1)cout<<9;
    else cout<<1;
    if((n/10)%10==1)cout<<9;
    else cout<<1;
    if(n%10==1)cout<<9;
    else cout<<1;
    out("");

}

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

using namespace std;


int main() {
	int N,x=0 ,a=0;
	string S;
	cin >> N >> S;

	for (int i = 0; i <= N; i++) {
		if (S[i] == 'I') {
			x++;

		}
		else {
			x--;
		}
		a = max(x, a);

	}
	cout << a  ;


	return 0;
}

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

using namespace std;

int main(){
    string str;
    cin >> str;
    int i = 0,j = str.size() - 1;
    while(i < j){
    	char tmp;
    	tmp = str[i];
    	str[i] = str[j];
    	str[j] = tmp;
    	++i;
    	--j;
    }
    cout << str << endl;
    return 0;
}

Measured memory_bytes: 0
use proconio::input;
use proconio::marker::Chars;

fn main() {

    input!{
        mut S:Chars,
        mut K:usize,
    }

    let N = S.len();

    for i in 0..N{
        let s = S[i];
        let k = ('a' as usize +26 - s as usize) % 26;
        if K >= k{
            K -= k;
            S[i] = 'a';
        }
    }
    K %= 26;
    S[N-1] = ((S[N-1] as u8 - 'a' as u8 + K as u8)%26 + 'a' as u8) as char;
    
    let mut ans = String::new();
    for &s in &S{
        ans.push(s);
    }
    println!("{}",ans);
}

Measured memory_bytes: 2792