akhauriyash/Code-Regression huggingface dataset:
#include<cmath>
#include<string>
#include<iostream>

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

using namespace std;

int subset[10];

/*
	<TREE> ::= <LEAF>|(<TREE><OPE><TREE>)
	<LEAF> ::= 1,2,..,8
	<OPE>  ::= a,o,x
*/
int TREE(const string &,int &);
int LEAF(const string &,int &);
char OPE(const string &,int &);

int TREE(const string &exp,int &idx){
	if(isdigit(exp[idx]))	return LEAF(exp,idx);

	idx++;
	int a=TREE(exp,idx);
	char o=OPE(exp,idx);
	int b=TREE(exp,idx);
	idx++;

	if     (o=='a')	return a&b;
	else if(o=='o')	return a|b;
	else			return a^b;
}

int LEAF(const string &exp,int &idx){
	return subset[exp[idx++]-'0'-1];
}

char OPE(const string &exp,int &idx){
	return exp[idx++];
}

int parse(string s){
	int idx=0;
	string exp=s;
	return TREE(exp,idx)==15;
}

int main(){
	for(string s;getline(cin,s),s!="END";){
		int len=s.length();
		int n;	cin>>n;
		rep(i,n){
			subset[i]=0;
			rep(j,4){
				int t;	cin>>t;
				subset[i]|=t<<j;
			}
		}
		cin.ignore();

		int spnum=0,sppos[8];
		rep(i,len) if(s[i]==' ') sppos[spnum++]=i;

		int cnt=0;
		char op[]="aox";
		rep(i,(int)pow(3.,spnum)){
			int k=i;
			string exp=s;
			rep(j,spnum){
				exp[sppos[j]]=op[k%3];
				k/=3;
			}
			if(parse(exp))	cnt++;
		}

		cout<<cnt<<endl;
	}

	return 0;
}

Measured memory_bytes: 944
N = int(input())
T = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
mod = 10**9 + 7
upT = set()
upA = set()
for i in range(N):
    if i == 0 or T[i - 1] < T[i]:
        upT.add(i)
    if i == N - 1 or A[i] > A[i + 1]:
        upA.add(i)
ans = 1
for i in range(N):
    if i in upT:
        if T[i] > A[i]:
            ans = 0
            break
    elif i in upA:
        if T[i] < A[i]:
            ans = 0
            break
    else:
        ans *= min(T[i], A[i])
        ans %= mod
print(ans)


Measured memory_bytes: 19648
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
#define rep(i, n) for(int i = 0; i<n; i++)
#define rep_s(i, start, n) for(int i= start;  i<n; i++)
#define ALL(a) (a).begin(), (a).end()
string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

/*
using edge = struct {int to; ll cost;};
vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d){
  depth[v] = d;
  //cout <<"v: " << v << endl;
  for (auto &e: tree[v]){
    //cout << "e.to: " << e.to << endl;
    if (e.to == p) continue;
    dfs(e.to, v, d+e.cost);
  }
}
*/

int main(void){
  int K;
  cin >> K;
  vector<bool> vis(K, false);
  deque<pair<int, int>> dq;
  dq.push_back(make_pair(1, 1));
  while(!dq.empty()){
    auto p = dq.front();
    dq.pop_front();
    int x = p.first;
    int d = p.second;
    //cout << "x: " << x << ", d: " << d << endl;
    if (vis[x]) continue;
    vis[x] = true;
    if (x == 0){
      cout << d << endl;
      return 0;
    }
    dq.push_back(make_pair((x+1)%K, d+1));
    dq.push_front(make_pair((10*x)%K, d));
  }
  return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

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

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


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

    string s;
    cin >> s;
    F0R(i,4){
      int sq = 0;
      F0R(j,4) if(s[i] == s[j]) ++sq;
      if(sq != 2) {
        cout << "No"; return 0;
      }
    }
    cout << "Yes";
    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


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

int main()
{
	int a, b, c;
	while (cin >> a >> b >> c)
	{
		int sum = a + b;
		int count = 0;
		for (int i = 1; i <= 10; i++)
		{
			if (i != a && i != b && i != c && sum + i <= 20) count++;
		}
		if (count >= 4) cout << "YES" << endl;
		else cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>

int main(void)
{
	int a, b, d, r;
	double  f;

	scanf("%d", &a);
	scanf("%d", &b);

	d = a / b;
	r = a % b;
	f = (double)a / b;

	printf("%d %d %lf\n", d, r, f);

	return 0;
}


Measured memory_bytes: 2104
import sys
whi,bla=map(int,input().split())
if(bla==0):
    print("1 1")
    print(".")
    sys.exit()
elif(whi==0):
    print("1 1")
    print("#")
    sys.exit()



whi-=1
bla-=1

field=[]
while(whi//50 >0):
    field.append(["#."]*50)
    field.append(["#"]*100)
    whi-=50

field.append(["#."]*whi + ["##"]*(50-whi))
field.append(["#"]*100)
field.append(["."]*100)

while(bla//50 >0):
    field.append(["#."]*50)
    field.append(["."]*100)
    bla-=50

field.append(["#."]*bla +[".."]*(50-bla))

print("{} 100".format(len(field)))
for i in range(len(field)):
    print("".join(field[i]))

Measured memory_bytes: 3064
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define rep(N) for(int i=0;i<N;i++)
#define rep2(N1,N2) for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)
#define rep3(N1,N2,N3)for(int i=0;i<N1;i++)for(int j=0;j<N2;j++)for(int k=0;k<N3;k++)
#define For(i,N) for(int i=0;i<N;i++)
void yn(bool b) {
	if (b)printf("yes\n");
	else printf("no\n");
}

void Yn(bool b) {
	if (b)printf("Yes\n");
	else printf("No\n");
}

void YN(bool b) {
	if (b)printf("YES\n");
	else printf("NO\n");
}

int main(){
	vector<vector<int>>A(3);
	rep(3)A[i].resize(3);
	rep2(3, 3)
		cin >> A[i][j];
	int N;
	cin >> N;
	vector<int>b(N);
	rep(N)cin >> b[i];
	For(i, N) {
		For(j, 3) {
			For(k, 3) {
				if (b[i] == A[j][k])
					A[j][k] = 0;
			}
		}
	}
	int flag = 0;
	int flag2 = 1;
	vector<int>vflag(8, 1);
	rep(3) {
		if (A[0][i] != 0)
			vflag[0] = 0;
		if (A[1][i] != 0)
			vflag[1] = 0;
		if (A[2][i] != 0)
			vflag[2] = 0;
		if (A[i][0] != 0)
			vflag[3] = 0;
		if (A[i][1] != 0)
			vflag[4] = 0;
		if (A[i][2] != 0)
			vflag[5] = 0;
		if (A[i][i] != 0)
			vflag[6] = 0;
		if (A[2 - i][i] != 0)
			vflag[7] = 0;
	}
	rep(8) {
		if (vflag[i] == 1)
			flag = 1;
	}
	Yn(flag);

}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  long long L = 0;
  long long R = 0;
  long long  i = 0;
  long long j = 0;
  long long ans = 0;
  long long min = -1;
  scanf("%lld %lld",&L,&R);
  if(R-L>=2019){
    min = 0;
  }else{
    for(i=0;L+i<R;i++){
      for(j=i+1;L+j<=R;j++){
        ans = (((L+i)%2019)*((L+j)%2019))%2019;
        //printf("%ld/",ans);
        if(ans < min || min == -1){
          min = ans;
        }
      }
    }
  }
  printf("%lld",min);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define SWAP(type, x, y){type tmp = x; x = y; y = tmp;}
using namespace std;

using lint = long long;

lint gcd(lint x, lint y){
    if(x < y) SWAP(lint, x, y);
    while(y != 0){
        lint tmp = x%y;
        x = y;
        y = tmp;
    }
    return x;
}

lint lcm(lint x, lint y){
    return x / gcd(x, y) * y;
}

int main(){
    int N;
    lint T, ans;
    cin >> N >> T;
    ans = T;
    for(int i=0;i<N-1;i++){
        cin >> T;
        ans = lcm(ans, T);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>

#define rep(loop, N) for (int loop = 0; loop < N; loop++)

using namespace std;

map<long long, int> factorization(long long N) {
	map<long long, int> re;
	while (true) {
		if (N % 2 == 0) {
			N /= 2;
			re[2]++;
			if (N == 1) break;
		}
		else {
			break;
		}
	}
	for (int loop = 3; (long long)loop * (long long)loop <= N; loop += 2) {
		if (N % loop == 0) {
			N /= loop;
			re[loop]++;
			loop -= 2;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	return re;
}

struct Memo {
	long long fact = 0;
	long long fact_inv = 0;
	long long inv = 0;
};
class Combination1 {
private:
	int m_module = 1000000007;
	vector<struct Memo> memo;
public:
	int calculate(int, int);
	Combination1(int, int);
};
int Combination1::calculate(int n, int k) {
	return ((memo[n].fact * memo[k].fact_inv) % m_module * memo[n - k].fact_inv) % m_module;
}
Combination1::Combination1(int memo_max, int module = 1000000007) {
	m_module = module;
	memo.push_back({ 1,1,0 });
	memo.push_back({ 1,1,1 });
	for (int loop = 2; loop <= memo_max; loop++) {
		struct Memo temp;
		temp.fact = (memo[loop - 1].fact * loop) % m_module;
		temp.inv = m_module - (memo[m_module % loop].inv * int(m_module / loop)) % m_module;
		temp.fact_inv = (memo[loop - 1].fact_inv * temp.inv) % m_module;
		memo.push_back(temp);
	}
}

class Combination2 {
private:
	int size = 0;
	bool add(int);
public:
	vector<int> sequence;
	bool next_combination(void);
	Combination2(int, int);
};
bool Combination2::add(int index) {
	if (index == (int)sequence.size() - 1 && sequence[index] == size - 1
		|| index < (int)sequence.size() - 1 && sequence[index] == sequence[index + 1] - 1) {
		if (index == 0) {
			return false;
		}
		else {
			bool re = add(index - 1);
			sequence[index] = sequence[index - 1] + 1;
			return re;
		}
	}
	else {
		sequence[index]++;
		return true;
	}
}
bool Combination2::next_combination(void) {
	return (sequence.size() == 0) ? false : add(sequence.size() - 1);
}
Combination2::Combination2(int n, int r) {
	size = n;
	for (int loop = 0; loop < r; loop++) sequence.push_back(loop);
	return;
}

void A_ABC_Swap(void) {

	int X, Y, Z; cin >> X >> Y >> Z;

	cout << Z << " " << X << " " << Y;
	return;
}

int main(void) {

	A_ABC_Swap();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; using ll = long long; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    ll A, B, N;
    cin >> A >> B >> N;

    if (B == 1) {
        write(0);
    }
    else if (B == 2) {
        write(A / B);
    }
    else if (N >= B - 1) {
        write(A * (B - 1) / B);
    }
    else {
        write(A * N / B);
    }
}

Measured memory_bytes: 3652
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)



int main() {

	vll A(3);
	rep(i, 0, 3) {
		std::cin >> A[i];
	}
	sort(A.begin(), A.end());

	A.erase(std::unique(A.begin(), A.end()), A.end());
	if (A.size() == 2) {
		std::cout << "Yes" << endl;
	}
	else {
	std:cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public void kami(){
    Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		
		int x3 = x * x * x;
		System.out.println(x3);

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

}

Measured memory_bytes: 17172
process.stdin.resume();
process.stdin.setEncoding('ascii');

var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;

process.stdin.on('data', function (data) {
    input_stdin += data;
});

process.on('SIGINT', function(){
    input_stdin_array = input_stdin.split("\n");
    main();
    process.exit();
});

process.stdin.on('end', function () {
    input_stdin_array = input_stdin.split("\n");
    main();    
});

function readLine() {
    return input_stdin_array[input_currentline++];
}

/////////////// ignore above this line ////////////////////

function digits(N){
	var ret = 0;
	while (N >= 1){
		ret ++;
		N /= 10;
	}
	return ret;
}

function main() {
	var N = parseInt(readLine());
	
	var ans = digits(N);	
	for (var i=2; i * i <= N; i++){
		if (N % i == 0){
			ans = digits(N/i);
		}
	}
	
	console.log(ans.toString());
}


Measured memory_bytes: 21064
#include<stdio.h>
int main(){
  int n,m,i,j,k,l;
  scanf("%d%d",&n,&m);
  char a[n+1][n+1],b[m+1][m+1];
  for(i=0;i<n;i++)
    scanf("%*c%s",a[i]);
  for(i=0;i<m;i++)
    scanf("%*c%s",b[i]);
  for(i=0;i<=n-m;i++){
    for(j=0;j<=n-m;j++){
      int check=0;
      for(k=0;k<m;k++){
        for(l=0;l<m;l++){
          if(a[i+k][j+l]!=b[k][l])
            check=1;
        }
      }
      if(check==0){
        puts("Yes");
        return 0;
      }
    }
  }
  puts("No");
  return 0;
}

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


int main() {
  int n, l;
  cin >> n >> l;
  vector<string> s(n);
  rep (i, n) {
      cin >> s.at(i);
  }
  sort(s.begin(), s.end());
  string ans;
  rep (i, n) {
      ans += s.at(i);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var t = new int[n];
        var tsum = 0;
        for (int i = 0; i < n; i++)
        {
            t[i] = int.Parse(Console.ReadLine().Trim());
            tsum += t[i];
        }
        var tmax = tsum + 1;
        var dp = new bool[n + 1, tmax, tmax];
        dp[0, 0, 0] = true;
        for (int i = 0; i < n; i++)
            for (int j = 0; j < tmax; j++)
                for (int k = 0; k < tmax; k++)
                {
                    if (!dp[i, j, k]) continue;
                    dp[i + 1, j + t[i], k] = true;
                    dp[i + 1, j, k + t[i]] = true;
                    dp[i + 1, j, k] = true;
                }
        var res = int.MaxValue;
        for (int i = 0; i < tmax; i++)
            for (int j = 0; j < tmax; j++)
                if (dp[n, i, j])
                {
                    var cp3 = tsum - i - j;
                    var tm = Math.Max(cp3, Math.Max(i, j));
                    res = Math.Min(res, tm);
                }
        Console.WriteLine(res);
    }
}



Measured memory_bytes: 112812
n = gets.to_i
a = gets.split.map { |s| s.to_i }
b = gets.split.map { |s| s.to_i }
c = gets.split.map { |s| s.to_i }
s = b.reduce(:+)
(0...n - 1).each { |i|
  s += c[a[i] - 1] if a[i] + 1 == a[i + 1]
}
puts s


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

int main(){
    int h, w;
    cin >> h >> w;
    char x;
    vector<vector<bool>> maze(h, vector<bool>(w));
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++) {
            cin >> x;
            if (x == '.') maze[i][j] = 1;
            else maze[i][j] = 0;
        }
    }
    vector<int> dx = {0, 0, 1, -1};
    vector<int> dy = {1, -1, 0, 0};
    vector<vector<long long>> y(h * w, vector<long long>(h * w, 1e9));
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            if (!maze[i][j]) continue;
            for (int k = 0; k < 4; k++){
                if (i + dx[k] < 0 || i + dx[k] >= h) continue;
                if (j + dy[k] < 0 || j + dy[k] >= w) continue;
                if (maze[i + dx[k]][j + dy[k]]) y[i * w + j][(i + dx[k]) * w + (j + dy[k])] = 1;
            }
        }
    }
    for (int k = 0; k < h * w; k++){
        for (int i = 0; i < h * w; i++){
            for (int j = 0; j < h * w; j++) {
                if (i == j) continue;
                y[i][j] = min(y[i][j], y[i][k] + y[k][j]);
            }
        }
    }
    long long ans = 0;
    for (int i = 0; i < h * w; i++){
        for (int j = 0; j < h * w; j++) {
            if (y[i][j] >= 1e9) continue;
            ans = max(ans, y[i][j]);
        }
    }
    cout << ans << endl;
}

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

int main() {

  int m, f, r;

  for(;;) {
    std::cin >> m >> f >> r;
    if( m == -1 && f == -1 && r == -1 ) {
      break;
    }

    if( m == -1 || f == -1 ) {
      std::cout << "F" << std::endl;
    }
    else if( m + f >= 80 ) {
      std::cout << "A" << std::endl;
    }
    else if( 65 <= m + f && m + f < 80 ) {
      std::cout << "B" << std::endl;
    }
    else if( 50 <= m + f && m + f < 65 ) {
      std::cout << "C" << std::endl;
    }
    else if( 30 <= m + f && m + f < 50 && r >= 50 ) {
      std::cout << "C" << std::endl;
    }
    else if( 30 <= m + f && m + f < 50 ) {
      std::cout << "D" << std::endl;
    }
    else {
      std::cout << "F" << std::endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 1152
//tokenakatta
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
const long long INF = 1LL << 60;


int main() {
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a.at(i);

    vector<vector<ll>> dp(n+1, vector<ll>(2));
    dp.at(0).at(0) = 0;
    dp.at(0).at(1) = -1000000001;

    for(int i=0; i<n; i++){
        dp.at(i+1).at(0) = max(dp.at(i).at(0)+a.at(i), dp.at(i).at(1)-a.at(i));
        dp.at(i+1).at(1) = max(dp.at(i).at(0)-a.at(i), dp.at(i).at(1)+a.at(i));
    }

    cout << dp.at(n).at(0) << endl;

}




Measured memory_bytes: 6528
#include <cstdio>
#include <algorithm>

int main()
{
  int n;
  int a[1000];
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
  {
    scanf("%d", a + i);
  }
  std::sort(a, a + n);
  printf("%d\n", a[n - 1] - a[0]);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll i,j;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s,t,ss;
    cin>>s>>t;
    ss=s;
    ll sl=s.length(),tl=t.length();
    ll f=0;
    for(i=sl-tl; i>=0; i--)
    {
        ll ff=1,k;
        for(j=i,k=0; j<i+tl; j++,k++)
            if(s[j]!='?' && s[j]!=t[k])
                ff=0;
        if(ff==1)
        {
            for(j=i,k=0; j<i+tl; j++,k++)
                if(s[j]=='?')
                    ss[j]=t[k];
            f=1;
            break;
        }
    }
    if(f==0)
        cout<<"UNRESTORABLE"<<endl;
    else
    {
        for(i=0;i<sl;i++)
            if(ss[i]=='?')
                ss[i]='a';
        cout<<ss<<endl;
    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    rep(i, 10) rep(j, 10) rep(k, 10)
    {
        bool first = false, second = false;
        rep(l, n)
        {
            if (!first && s.at(l) - '0' == i)
            {
                first = true;
                continue;
            }
            if (first && !second && s.at(l) - '0' == j)
            {
                second = true;
                continue;
            }
            if (second && s.at(l) - '0' == k)
            {
                ans++;
                break;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), d = sc.nextInt(), e = sc.nextInt(), k = sc.nextInt();

        if(Math.abs(a-b) > k)
            System.out.println(":(");
        else if(Math.abs(a-c) > k)
            System.out.println(":(");
        else if(Math.abs(a-d) > k)
            System.out.println(":(");
        else if(Math.abs(a-e) > k)
            System.out.println(":(");
        else if(Math.abs(b-c) > k)
            System.out.println(":(");
        else if(Math.abs(b-d) > k)
            System.out.println(":(");
        else if(Math.abs(b-e) > k)
            System.out.println(":(");
        else if(Math.abs(c-d) > k)
            System.out.println(":(");
        else if(Math.abs(c-e) > k)
            System.out.println(":(");
        else if(Math.abs(e-d) > k)
            System.out.println(":(");
        else
            System.out.println("Yay!");
    }


}


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

int main() {
  int N;
  scanf("%d", &N);
  int a[N];
  for (int i = 0; i < N; ++i) {
    scanf("%d", &a[i]);
  }

  int ans = 0;

  for (int i = 0; i < N-2; ++i){
    int b[3];
    b[0] = a[i];
    b[1] = a[i+1];
    b[2] = a[i+2];
    if(b[1]<b[2] && b[1]>b[0]) ++ans;
    if(b[1]<b[0] && b[1]>b[2]) ++ans;
  }

  cout << ans << endl;

}



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

using namespace std;

int main(){
  int N,S;
  cin >> N;
  int n=N;
  S = 0;
  for(int i=1e9;i>=1;i/=10){
    int tmp = n/i;
    S+=tmp;
    n-=tmp*i;
  }

  if(N%S==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

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

int main()
{
	int a,b; cin>>a>>b;
	float c=(a-b-1)*(1.0)/(b*2+1);
	c*=100;
	int d=c;
	d%100 < 50 ?cout<<d/100 + 1:cout<<d/100 + 2;
}


Measured memory_bytes: 3164
import java.util.*;
import java.util.Arrays;
public class Main{
    public static void main(String[] args){
       Scanner sc = new Scanner(System.in);
       int n = sc.nextInt();
       int a = sc.nextInt();
       int b = sc.nextInt();
       System.out.println(Math.min(a*n,b));

    }
   
    
       
    
}

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

int main()
{
  int l, r;
  cin >> l >> r;

  if (r - l + 1 >= 2019) {
    cout << 0 << endl;
    return 0;
  }

  int64_t ans = 2019;
  for (int j = l + 1; j <= r; j++) {
    for (int i = l; i < j; i++) {
      ans = min(ans, int64_t(i) * j % 2019);
      if (ans == 0) goto endloop;
    }
  }
 endloop:

  cout << ans << endl;
}


Measured memory_bytes: 256
n,k,c=map(int,input().split())
s=input()
INF=float("inf")
left=[0]*(n+1)
right=[0]*(n+1)

mleft=0
last=-c-1
for i in range(n):
    if s[i]=="o" and i-last>c:
        mleft+=1
        last=i
        left[i+1]=mleft

mright=0
last=-c-1
t=s[::-1]
for i in range(n):
    if t[i]=="o" and i-last>c:
        mright+=1
        last=i
        right[i+1]=mright

for i in range(n):
    left[i+1]=max(left[i+1],left[i])
    right[i + 1] = max(right[i + 1], right[i])

left.remove(left[0])
right.remove(right[0])
right=right[::-1]
left.append(0)
right.append(0)

ans=[]
for i in range(1,n+1):
    if s[i-1]=="o":
        if left[i-2]+right[i]<k:
            ans.append(i)


for i in range(len(ans)):
    print(ans[i])




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

int main() {
  vector<int> arr(3);
  int k;
  cin >> arr[0] >> arr[1] >> arr[2] >> k;

  sort(arr.begin(), arr.end(), greater<int>());
  for (int i = 1; i <= k; i++) {
    arr[0] = arr[0] * 2;
  }
  cout << arr[0] + arr[1] + arr[2] << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a,b=0,c=0,d,e,f,i;
	scanf("%d",&a);
	while(a!=0)
	{
		for(i=0;i<a;i++){
			scanf("%d%d%d",&d,&e,&f);
			if(b<e+f){
				b=e+f;
				c=d;
			}
		}
		printf("%d %d\n",c,b);
		b=0;
		c=0;
		scanf("%d",&a);
	}
	return 0;
}

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

int main() {
  double N,A,ans;
  ans = 0;
  cin >> N;
  for (int i=0; i<N; i++) {
    cin >> A;
    A = 1 / A;
    ans += A;
  }
  cout << 1/ans << endl;
  return 0;
}

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

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> cnt(m + 1);
    for(int i = 1; i <= n; ++i) {
        int k;
        cin >> k;
        while(k--) {
            int x;
            cin >> x;
            cnt[x] += 1;
        }
    }
    int ans = count_if(begin(cnt), end(cnt), [&](int x)->bool{return x == n; });
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int A, B, C, X, c50, count = 0;
  
  scanf("%d %d %d %d", &A, &B, &C, &X);
  
  if(X%50 != 0 || (X/50%2 == 1 && C == 0)){
    printf("0\n");
    return 0;
  } 
  
  c50 = X/50;
  for (int i = 0; i <= A; i++){
    for (int j = 0; j <= B; j++){
      for (int k = 0; k <= C; k++){
        if(10*i + 2*j + k == c50){
          count++;
        }
      }
    }
  }
  
  printf("%d\n", count);
  
  return 0;
}

Measured memory_bytes: 128
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

def prob_d(n=None, k=None):
    if n is None and k is None:
        n, k = [int(a) for a in input().split()]
    div = 10 ** 9 + 7
    for i in range(k):
        if n - k + 1 < i + 1:
            print("0")
        else:
            if k == 1:
                ans = cmb(n, i+1) % div
                print(str(ans))
            else:
                ans = cmb(k-1, i) % div
                ans *= (cmb(n - k + 1, i + 1) % div)
                ans = ans % div
                print(str(ans))


prob_d()

Measured memory_bytes: 3944
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;

const int Inf = 10000*100000+100;

int main() {
    int v, e, r;
    cin >> v >> e >> r;
    priority_queue<int> x;
    vector<int> s; 
    vector<int> t;
    vector<int> d;
    for(int i = 0; i < e; i++){
        int start, end, cost;
        cin >> start >> end >> cost;
        s.push_back(start);
        t.push_back(end);
        d.push_back(cost);
    }

    vector<int> ans(v, Inf);
    ans[r] = 0;
    for(int i = 0; i < v; i++){
        bool update = false;
        for(int j = 0; j < e; j++){
            if(ans[s[j]]<Inf && ans[s[j]]+d[j]<ans[t[j]]){
                ans[t[j]] = ans[s[j]]+d[j];
                update = true;
            }
        }
        if(!update){
            break;
        }
    }
    for(int i = 0; i < v; i++){
        if(ans[i] != Inf){
            cout << ans[i] << endl;
        }
        else {
            cout << "INF" << endl;
        }
    }
}


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


int a[100];

int count1=0;

void sub(int r,int l){
  for(int i=r;i<l;i++)
    a[i]--;
}

int search(int l,int r){
  for(int i=l;i<r;i++){
    if(a[i]==0)return i;
  }
  return r;
}


void solve(int l,int r){
  if(l==r)return;
  if(search(l,r)==r){
    sub(l,r);
    count1++;
  }
  solve(l,search(l,r));
  solve(search(l,r)+1,r);
}

int main(){
  int N;
  cin>>N;
  for(int i=0;i<N;i++)cin>>a[i];

  solve(0,N);

  cout<<count1;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {

	while(true) {
		int N;
		cin >> N;
		if(N == 0) break;
		int count = 0;
		bool na = true;
		for(int i = 0; i < N; i++) {
			int k;
			cin >> k;
			if (k > 1)
				na = false;
			if (k > 0)
				count++;
		}
		if (na == true)
			cout << "NA" << endl;
		else 
			cout << count + 1 << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
import math

a, b, x = map(int, input().split())
if a * a * b / 2 < x:
    y = 2 * b - (2 * x) / (a * a)
    print(math.degrees(math.atan(y / a)))
else:
    y = (2 * x) / (a * b)
    print(math.degrees(math.atan(b / y)))


Measured memory_bytes: 3188
#include<stdio.h>
#include<iostream>
using namespace std;
int h,w,n,ans[105][105],a=1,b=1,x,way=1;
void pf(int c,int cnt)
{
	if(cnt>x)return;
	ans[a][b]=c;
	if(way){
		b++;
		if(b>w)
		{
			b--;a++;
			way=0;
			pf(c,cnt+1);
			return;
		}
		else pf(c,cnt+1);return;
	}
	if(!way)
	{
		b--;
		if(b<1)
		{
			b++;
			a++;
			way=1;
			pf(c,cnt+1);
			return;
		}
		else pf(c,cnt+1);
		return ;
	}
}
main()
{
	int i,j,k,y;
	scanf("%d%d%d",&h,&w,&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&x);
		pf(i,1);
	}
	for(i=1;i<=h;i++)
	{
	for(j=1;j<=w-1;j++)
	{
		printf("%d ",ans[i][j]);
	}
	printf("%d\n",ans[i][w]);
    }
 } 

Measured memory_bytes: 384
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int h = scanner.nextInt();
        int w = scanner.nextInt();
        int d = scanner.nextInt();
        int[] x = new int[h * w];
        int[] y = new int[h * w];

        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                int a = scanner.nextInt() - 1;
                x[a] = j;
                y[a] = i;
            }
        }

        long[] dist = new long[h * w];
        for (int i = d; i < h * w; i++) {
            dist[i] = dist[i - d] + Math.abs(x[i - d] - x[i]) + Math.abs(y[i - d] - y[i]);
        }

        int q = scanner.nextInt();
        for (int i = 0; i < q; i++) {
            int l = scanner.nextInt() - 1;
            int r = scanner.nextInt() - 1;
            System.out.println(dist[r] - dist[l]);
        }
    }
}

Measured memory_bytes: 91036
<?php
  fscanf(STDIN, "%i", $n);
  for ($i = 1; $i < $n; $i++)
  {
      fscanf(STDIN, "%i %i", $a, $b);
      $tree[$a][] = $b;
      $tree[$b][] = $a;
  }

  for ($i = 1; $i <= $n; $i++)
  {
      $uni[$i]   = 0;
      $multi[$i] = 0;
  }
  
  $v = 1;
  $crumbs = [];
  while (!is_null($v))
  {
      $c = array_pop($tree[$v]);
      if (!is_null($c))
      {
          array_remove($tree[$c], $v);
          array_push($crumbs, $v);
          $v = $c;
      }
      else
      {
          $c = $v;
          $v = array_pop($crumbs);

          $bits = 1 << msb($multi[$c]);
          $uni[$c] &= ~($bits - 1);
          $uni[$c] += $bits;
          $multi[$v] |= $uni[$v] & $uni[$c];
          $uni[$v]   |= $uni[$c];
      }
  }
  echo (msb($uni[1]) - 1).PHP_EOL;

  function array_remove(&$array, $elem)
  {
      $array = array_values(array_diff($array, [$elem]));
  }

  function msb($x)
  {
      $p = 0;
      while ($x !== 0)
      {
          $x >>= 1;
          $p++;
      }
      return $p;
  }
?>


Measured memory_bytes: 63568
H, N = map(int, input().split(' '))
magic = [[0 for _ in range(3)] for j in range(N)]
for i in range(N):
  temp_a, temp_b = map(int, input().split())
  magic[i][0] = temp_a
  magic[i][1] = temp_b

dp = [float('inf')] * (H + 1)
dp[0] = 0

for i in range(1, H + 1):
  for j in range(N):
    if i >= magic[j][0]:
      dp[i] = min(dp[i - magic[j][0]] + magic[j][1], dp[i])
    else:
      dp[i] = min(magic[j][1], dp[i])

print(dp[H])

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

int main (){
    int n = 0, m = 0;
    while(true){
        int ans = 0; //for answer
        std::cin >> n >> m;
        //exit when n = m = 0
        if(n == 0 && m == 0){
            break;
        }
        std::vector<int> price(n); //each vegetable price
        //put price to vector
        for(int i = 0; i < n; ++i){
            std::cin >> price[i];
        }
        //descending sort
        std::sort(price.begin(), price.end(), std::greater<int>());
        //m'th vegetable don't add
        for(int i = 0; i < n; ++i){
            if((i+1) % m != 0){
                ans += price[i];
            }
        }
        std::cout << ans << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3108
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return [init]*size1
  else
    return [[init]*size2]*size1
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

X,Y=get_i
0.upto(X) do|i|
    if i*2+(X-i)*4==Y
        puts "Yes"
        exit
    end
end
puts "No"

Measured memory_bytes: 14340
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<vector<vector<int>>> v3int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef vector<vector<vector<ll>>> v3ll;
typedef list<int> liint;
typedef pair<int, int> pint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, int>> vpll_int;
typedef vector<pair<int, ll>> vpint_ll;
typedef set<pair<int, int>> spint;
typedef set<pair<ll, int>> spll;
typedef unordered_map<int, unordered_set<int>> Graph;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    int ans = 0;
    int t = 400;
    rep(i, 8) {
        if (t <= N && N < t + 200) {
            ans = 8 - i;
            break;
        }
        t += 200;
    }
    cout << ans << endl;
    return 0;
}

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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
	ll n, i, c = 0, j;
	cin >> n;
	vector< ll >v(n, 1);
	rep(i,2,n){
		for(j = i; j < n; j += i){
			v[j]++; 
		}
	}
	ll ans = accumulate(all(v), 0);
	cout << ans - 1 << nl;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}


Measured memory_bytes: 11020
#include<bits/stdc++.h>
#define N 20005
using namespace std;
int f[N][2],n,Z,W,a[N];bool vis[N][2];
int dp(int last,int who){
	if (vis[last][who]) return f[last][who];
	int ret=abs(a[n]-a[last]);
	vis[last][who]=1;
	if (!who){
		for (int i=last+1;i<n;i++) ret=max(ret,abs(dp(i,!who)));
		return f[last][who]=ret;
	}
	if (who){
		for (int i=last+1;i<n;i++) ret=min(ret,abs(dp(i,!who)));
		return f[last][who]=ret;
	}
}
int main(){
	scanf("%d%d%d",&n,&Z,&W);a[0]=W;
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	printf("%d\n",abs(dp(0,0)));
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include <iomanip>
using namespace std;


int main(void){
    string a,b;
    cin >> a;
    cin >> b;
    for(int i =0; i < a.size() || i < b.size(); i++){
        if(i < a.size())
            cout << a[i];
        if(i < b.size())
            cout << b[i];
    }
    return 0;
    
}   

Measured memory_bytes: 3652
// management

func main() {
    let n = Int(readLine()!)!
    let a = readLine()!.split(separator: " ").map{Int($0)!}
    var counts = Array(repeating: 0, count: n+1)
    for ai in a {
        counts[ai] += 1
    }
    for i in 1...(n) {
        print(counts[i])
    }
}

main()

Measured memory_bytes: 18416
io = STDIN
n,m=io.gets.split.map(&:to_i)
$req=[]
m.times do
  $req<<io.gets.split.map(&:to_i)
end
$req.sort_by!{|a,b|b}
cnt,right_limit=0,0
$req.each do |a,b|
  if right_limit<=a
    right_limit=b
    cnt+=1
  end
end
puts cnt


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

int main(void){
  char Word[20],Ring[20],temp[20];
  int n,i,cnt = 0;

  scanf("%s" ,Word);

  scanf("%d" ,&n);

  for( i = 0 ; i < n ; i++ ){

    scanf("%s" ,Ring);

    strcpy( temp , Ring ); 
    strcat( Ring , temp );

    if( strstr( Ring , Word ) ) cnt++;
 
  }

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

  return 0;

} 

Measured memory_bytes: 624
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
using namespace std;

#define rep(i,n) for((i)=0; (i)<(int)(n); ++(i))
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef pair<int,int> P;

int n, m, d, t;
vector<P> V[502];
const int inf = 1<<28;
int dp[502];

int dijkstra(int s, int g) {
  priority_queue<P,vector<P>,greater<P> > q;
  fill(dp, dp + n, inf);
  dp[s] = 0;
  q.push(P(0,s));
  
  while (!q.empty()) {
    P p = q.top(); q.pop();
    int v = p.second;
    if (dp[v] < p.first) continue;
    for (int i = 0; i < V[v].size(); i++) {
      P p2 = V[v][i];
      if (dp[p2.first] > dp[v] + p2.second) {
        dp[p2.first] = dp[v] + p2.second;
        q.push(P(dp[p2.first], p2.first));
      }
    }
  }
  
  return dp[g];
}

int main() {
  int i, j;
  while (cin >> n >> m, n|m) {
    rep (i,n) V[i].clear();
    
    map<string,int> hash;
    string spg[3], a[2];
    int station_count = 0;

    rep (i,3) cin >> spg[i];
    rep (i,3) {
      if (!hash.count(spg[i])) {
        hash.insert(make_pair(spg[i], station_count));
        station_count++;
      }
    }
        
    rep (i,m) {
      cin >> a[0] >> a[1] >> d >> t;
      rep (j,2) if (!hash.count(a[j])) {
        hash.insert(make_pair(a[j], station_count));
        station_count++;
      }
      int u = hash[a[0]], v = hash[a[1]];
      int cost = d / 40 + t;
      V[u].push_back(P(v, cost));
      V[v].push_back(P(u, cost));
    }
    
    int ans = dijkstra(hash[spg[0]], hash[spg[1]]) 
      + dijkstra(hash[spg[1]], hash[spg[2]]);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <utility>
#include <bitset>
using namespace std;
typedef long long ll;
const ll inf = 4e18;
const ll mod = 1e9+7;
#define print(X) cout << X << endl
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (ll (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (ll (i) = (m); (i) < (n); ++(i))
#define repd(i, m, n) for (ll (i) = (m); (i) > (n); --(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

template <class T>
string join(const vector<T>& v, const char* delim = 0) {
  string s;
  if (!v.empty()) {
    s += v[0];
    for (decltype(v.size()) i = 1, c = v.size(); i < c; ++i) {
      if (delim) s += delim;
      s += v[i];
    }
  }
  return s;
}
//         100
// .........
// .........
// #########
// .########

int main(void)
{
    ll A,B;
    ll N=100;
    cin >> A >> B;
    vec<vec<char>> s(N, vec<char>(N, '#'));

    rep (y,N/2) {
        rep (x,N) {
            s[y][x] = '.';
        }
    }
    repp (y,N/2,N) {
        rep (x,N) {
            s[y][x] = '#';
        }
    }
    A -= 1;
    B -= 1;
    ll x, y;
    x = 0;
    y = 0;
    while (B--) {
        s[y][x] = '#';
        x+=2;
        if (x>=N) {
            x=0;
            y+=2;
        }
    }
    x = 0;
    y = N-1;
    while (A--) {
        s[y][x] = '.';
        x+=2;
        if (x>=N) {
            x=0;
            y-=2;
        }
    }
    print(N<<" "<<N);
    rep(y,N) {
        print(join(s[y]));
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <bitset>
#include <queue>
#include <set>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;

#define LL long long
#define ULL unsigned long long
#define eps 1e-9
#define N 2010
#define M 600050
#define pii pair<int,int>
#define MP make_pair
#define inf 0x3f3f3f3f
#define md ((ll+rr)>>1)
#define lson ll, md, ls
#define rson md + 1, rr, rs
#define ls rt<<1
#define rs rt<<1|1
#define Pi acos(-1.0)
#define mod 1000000007
#define ui unsigned int
// curiosity , go.
LL powmod(LL a,LL b,LL p){
    if(b < 0) return 0;
    LL res = 1; a %= p;
    for(;b;b>>=1){
        if(b & 1) res = res * a % p;
        a = a * a % p;
    }
    return res;
}

int a[N];
int ans[N],ansa[N];

int main(){
    int n,m;
    scanf("%d%d",&n,&m);
    int odd = 0;
    for(int i = 1; i <= m; i++){
        scanf("%d",&a[i]);
        odd += a[i] & 1;
    }
    if(odd > 2){
        puts("Impossible");
        return 0;
    }
    int st = 0,tot = 0,tota = 0;
    if(odd > 0){
        for(int i = 1; i <= m; i++)
            if(a[i] & 1) st = i;
        ansa[++tota] = a[st];
        if(a[st] != 1) ans[++tot] = a[st] - 1;
        for(int i = 1; i <= m; i++){
            if(!(a[i] & 1)){
                ans[++tot] = a[i];
                ansa[++tota] = a[i];
            }
        }
        for(int i =1; i <= m; i++)
            if(i != st && a[i] & 1) ans[++tot] = a[i] + 1,ansa[++tota] = a[i];
        if(odd == 1){
            if(m == 1) ans[++tot] = 1;
            else ans[tot]++;
        }
    }
    else{
        int now = 0;
        ans[++tot] = a[1] - 1;
        now += a[1] - 1;
        ansa[1] = a[1];
        for(int i = 2; i < m; i++)
            ans[++tot] = a[i], now += a[i],ansa[i] = a[i];
        ans[++tot] = n - now;
        ansa[m] = a[m];
    }
    for(int i = 1; i <= m; i++)
        printf("%d%c",ansa[i],i == m ? '\n' : ' ');
    printf("%d\n",tot);
    for(int i = 1; i <= tot; i++)
        printf("%d%c",ans[i],i == tot ? '\n' : ' ');
    return 0;
}

Measured memory_bytes: 888
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	if(a<=8 && b<=8){	
  		cout << "Yay!" << endl;
    }else{
    	cout << ":(" << endl;
    }
	return 0;
}

Measured memory_bytes: 256
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}

fn main() {
    // 入力
    let N = get!(i64);
    let A = if N == 1 { 0 } else { get!(i64) };
    let B = if N == 1 { 0 } else { get!(i64) };

    let ans = if N == 1 {
        "Hello World".to_string()
    } else {
        (A + B).to_string()
    };

    // 出力
    println!("{}", ans);
}


Measured memory_bytes: 4352
from functools import reduce

N = int(input())
A = input()
A = map(lambda Ai: int(Ai), A.split())

sum = lambda list: reduce(lambda x, y: x + y, list, 0)
reciprocal = lambda value: 1 / value

reciprocal_A = map(reciprocal, A)
sum_reciprocal_A = sum(reciprocal_A)
answer = reciprocal(sum_reciprocal_A)

print(answer)


Measured memory_bytes: 3572
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    String s = sc.next();
    if(s.equals("ARC")){
      System.out.println("ABC");
    }
    else{
      System.out.println("ARC");
    }
  }
}

Measured memory_bytes: 35616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    ll ans = 0;
    int cnt = 0;
    for(auto &ai : a){
        cin >> ai;
        if(ai < 0) cnt ++;
        ai = abs(ai);
        ans += ai;
    }
    if(cnt % 2){
        ans -= 2*(*min_element(a.begin(), a.end()));
    }
    cout << ans << endl;

}

Measured memory_bytes: 768
#include<stdio.h>

int main(){
	
	int a,b,c,d,ap,bp;
	while(1){
		scanf("%d",&c);
		if(c==0)break;
		ap=0,bp=0;
		for(d=0;d<c;d++){
			scanf("%d %d",&a,&b);
			if(a>b)ap+=a+b;
			if(a<b)bp+=a+b;
			if(a==b)ap+=a,bp+=b;
		}
		printf("%d %d\n",ap,bp);
	}
	 
	return 0;
}

Measured memory_bytes: 0