akhauriyash/Code-Regression huggingface dataset:
n = int(input())
list = [[0]*10 for i in range(12)]
for j in range(n):
    b,f,r,v = map(int,input().split())
    list[(b-1)*3+f-1][r-1] += v
for k in range(12):
    print("",*list[k])
    if k%3 == 2 and k <= 10 :print("#"*20)


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

using namespace std;
using ll = long long;

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

    ll m, n;
    ll mod = (ll) 1e9 + 7;
    cin >> m >> n;
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * m % mod;
        m = m * m % mod;
        n >>= 1;
    }
    cout << res << '\n';

    return 0;
}



Measured memory_bytes: 3212
#include<stdio.h>
int main(void)
{
	int i,n,t,x;
	for(i=1;i<=4;i++) {
		scanf("%d %d",&t,&n);
		if(t==1) {
			x=6000*n;
		}
		if(t==2) {
			x=4000*n;
		}
		if(t==3) {
			x=3000*n;
		}
		if(t==4) {
			x=2000*n;
		}
		printf("%d\n",x);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll, ll> pii;
 
#define REP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define PER(a,b,c) for(ll (a)=(b);(a)>=(c);(a)--)
 
void in(ll &x){ cin >> x; }
void pin(ll &x, ll &y){ cin >> x >> y; }


int main(){
    ll N,M,K,a,b,p,q,x,y,z;
    bool reversed=false;
    string ss;
    cin >> ss;
    deque<char> s;
    for(auto c : ss){
        s.push_back(c);
    }

    in(q);
    REP(i,0,q){
        ll t;
        cin >> t;
        if(t==1){
            reversed=!reversed;
        }else{
            ll f;
            string c;
            cin >> f >> c;
            if((!reversed && f==1) || (reversed && f==2)){
                s.push_front(c[0]);
            }else{
                s.push_back(c[0]);
            }
        }
    }
    if(reversed){
        for(auto it=s.rbegin(); it!=s.rend(); it++){
            cout << *it;
        }
    }else{
        for(auto it=s.begin(); it!=s.end(); it++){
            cout << *it;
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 896
#!/usr/bin/env python3
import sys
import itertools
INF = float("inf")


def solve(N: int, s: "List[str]"):

    ABcount = 0
    Aend = 0
    Bstart = 0
    AendBstart = 0
    for i in range(N):
        ABcount += s[i].count("AB")
        if s[i][0] == "B" and s[i][-1] == "A":
            AendBstart += 1
        elif s[i][0] == "B":
            Bstart += 1
        elif s[i][-1] == "A":
            Aend += 1

    if AendBstart == 0:
        ABcount += min(Aend, Bstart)
    else:
        if Aend + Bstart > 0:
            ABcount += min(Aend, Bstart) + AendBstart
        else:
            ABcount += AendBstart - 1
    print(ABcount)
    # if AendBstart > 1:
    #     ABcount += AendBstart - 1
    #     AendBstart = 1
    # if Aend > 0 or Bstart > 0:
    #     ABcount += min(Aend, Bstart)+AendBstart
    # print(ABcount)

    # 愚直
    # print("愚直")
    # ans = []
    # for kumi in itertools.permutations(s, N):
    #     ans.append("".join(kumi).count("AB"))
    # print(max(ans))
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    s = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, s)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3700
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstring>
#include <stdio.h>

using namespace std;

int main() {
	int X;
	cin >> X;
	bool flag;
	for (int i = X; ; i++) {
		flag = true;
		for (int j = 2; j < i / 2; j++) {
			if (i%j == 0) {
				flag = false;
				break;
			}
		}
		if (flag) {
			cout << i << endl;
			break;
		}
	}

	return 0;
}

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

int main(){
  int K;
  cin >>K;
  K--;
  int N=32;
  vector<int> v(N);
  v ={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  
  cout << v.at(K) <<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int main()
{
    int a,b,c,x;
    int res=0;
    scanf("%d%d%d%d",&a,&b,&c,&x);
    for(int i=0;i<=a;i++)
    for(int j=0;j<=b;j++)
    for(int k=0;k<=c;k++)
    if(i*500+j*100+k*50==x)
    res++;
    printf("%d",res);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

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

template<typename T>
class polynomial {
	using value_type = T;
	using size_type = size_t;

	std::vector<value_type> data;
	
	public:
	polynomial() : data(1, 0) {}
	polynomial(const size_type & N) : data(N, 0) {}
	const value_type eval(const value_type & x) {
		value_type ret = data[0], tmp = x;
		for(int i = 1; i < data.size(); i++) {
			ret += data[i] * tmp;
			tmp *= x;
		}
		return ret;
	}

	void resize(const size_type & N) { data.resize(N); }
	value_type & operator[](const size_type & k) { return data[k]; }
	const size_type degree() { return data.size() - 1; }
	const size_type size() { return data.size(); }
};

namespace fast_fourier_transform {
	using Real = double;
	using Complex = std::complex<Real>;
	using poly = polynomial<Complex>;
	
	const Real PI = M_PI;

	const poly DFT(poly f) {
		const int N = f.size();
		if(N == 1) return f;
		
		poly f0(N / 2);
		poly f1(N / 2);
		for(int i = 0; i < f0.size(); i++) f0[i] = f[i << 1];
		for(int i = 0; i < f1.size(); i++) f1[i] = f[i << 1 ^ 1];

		poly inv_f0 = DFT(f0);
		poly inv_f1 = DFT(f1);

		poly inv_f(N);
		for(int i = 0; i < f.size(); i++) {
			Complex zeta_n_i = Complex(cos(2. * PI * i / N), sin(2. * PI * i / N));

			inv_f[i] = inv_f0[i % f0.size()] + zeta_n_i * inv_f1[i % f1.size()];
		}
		return inv_f;
	}

	const poly IDFT(poly inv_f) {
		const int N = inv_f.size();

		poly arranged = DFT(inv_f);

		poly f(N);
		for(int i = 0; i < N; i++) f[i] = arranged[(N - i) % N] / Complex(N, 0);
		return f;
	}

	const poly convolution(poly a, poly b) {
		const int sz = a.size() + b.size() - 1;

		int N = 1;
		while(N < sz) N <<= 1;
		a.resize(N);
		b.resize(N);
		
		poly inv_a = DFT(a);
		poly inv_b = DFT(b);
		poly inv_c(N);
		for(int i = 0; i < N; i++) inv_c[i] = inv_a[i] * inv_b[i];
		return IDFT(inv_c);
	}
};

int main() {
	namespace FFT = fast_fourier_transform;
	using poly = FFT::poly;

	int n; i64 m; scanf("%d%lld", &n, &m); std::vector<i64> a(n);
	for(int i = 0; i < n; i++) scanf("%lld", &a[i]);
	
	const int M = 100001;

	poly F(M);
	for(int i = 0; i < n; i++) F[a[i]] += 1;
	poly c = FFT::convolution(F, F);


	i64 ans = 0;
	for(i64 i = 2 * M; i > 0; i--) {
		i64 tmp = std::min<i64>((i64)std::round(c[i].real()), m);
		ans += tmp * i;
		m -= tmp;
	}

	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 48172
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <iomanip>
#include <math.h>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#define local
#ifdef local
    #include "dbg-macro/dbg.h"
#endif
//#define hacks
#ifdef hacks
    #include <boost/multiprecision/cpp_int.hpp>
#endif
#define p std::pair
#define ll long long
#define ld long double
#define ull unsigned long long
#define pi std::pair<int, int>
#define stdabs std::abs
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (unsigned long long i = 0; i < (unsigned long long)(n); ++i)
#define vec std::vector
#define oreq |=
#define npm next_permutation
using namespace std;
std::vector<unsigned ll> genprimevec(const unsigned ll N);
ll extgcd(ll a, ll b, ll& x, ll& y);
ll nCr(ll n, ll r);
void stat();
template <typename T> T fact(T num);
constexpr ll mod = 1000000000 + 7;

int main()
{
    stat();
    int n;
    cin >> n;
    vec<ll> v(n);
    vec<ll> ls(n), rs(n);
    ull sum = 0;
    rep(i, n)
    {
        cin >> v[i];
        sum += v[i];
        ls[i] = sum;
    }
    rep(i, n) { rs[i] = sum - ls[i]; }
    ull ans = ULLONG_MAX;
#ifdef local
    dbg(sum);
#endif
    rep(i, n - 1)
    {
        auto sub = ls[i] - rs[i];
        ans = min(ans, (ull)abs(sub));
    }
    cout << ans << endl;

    return 0;
}
ll extgcd(ll a, ll b, ll& x, ll& y)
{
    if (b == 0) {
        x = 1, y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}


std::vector<unsigned ll> genprimevec(const unsigned ll N)
{
    std::vector<bool> is_prime(N + 1);
    for (unsigned ll i = 0; i <= N; i++) {
        is_prime[i] = true;
    }
    std::vector<unsigned ll> P;
    for (unsigned ll i = 2; i <= N; i++) {
        if (is_prime[i]) {
            for (unsigned ll j = 2 * i; j <= N; j += i) {
                is_prime[j] = false;
            }
            P.emplace_back(i);
        }
    }
    return P;
}

void stat(){
#ifdef local
    rep(i, 2){std::cout << "local enable" << std::endl;
}
#endif
#ifdef hacks
rep(i, 2) { std::cout << "boost enable" << std::endl; }
#endif
}

ll nCr(ll n, ll r)
{
    ll num = 1;
    for (ll i = 1; i <= r; i++) {
        num = num * (n - i + 1) / i;
    }
    return num;
}

template <typename T> T fact(T num)
{
    if (num == 1) { return 1; }
    return num * fact(num - 1);
}


Measured memory_bytes: 7948
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

template <int D>
struct Basis {
  vector<bitset<D>> v;
  vector<int> msb;

  bool add(bitset<D> val) {
    int n = v.size();
    if (n == D) return false;
    REP(i, n) {
      if (val[msb[i]]) val ^= v[i];
    }
    if (val.none()) return false;
    int m = D - 1;
    while (!val[m]) --m;
    if (v.empty()) {
      v.emplace_back(val);
      msb.emplace_back(m);
      return true;
    }
    int idx = n - distance(msb.rbegin(), upper_bound(msb.rbegin(), msb.rend(), m));
    v.emplace(v.begin() + idx, val);
    msb.emplace(msb.begin() + idx, m);
    for (int i = n; i > idx; --i) {
      if (v[idx][msb[i]]) v[idx] ^= v[i];
    }
    for (int i = idx - 1; i >= 0; --i) {
      if (v[i][m]) v[i] ^= v[idx];
    }
    return true;
  }

  bool add(ll val) { return add(bitset<D>(val)); }

  int rank() const { return v.size(); }

  inline bool operator<(const Basis &x) const {
    int n = v.size();
    if (n != x.v.size()) return n < x.v.size();
    if (n == D) return false;
    REP(i, n) {
      if (msb[i] != x.msb[i]) return msb[i] < x.msb[i];
    }
    REP(i, n) {
      if (v[i] != x.v[i]) {
        for (int j = msb[i] - 1; ; --j) {
          if (v[i][j] != x.v[i][j]) return v[i][j] < x.v[i][j];
        }
      }
    }
    return false;
  }
};

void solve() {
  int n; cin >> n;
  vector<ll> a(n); REP(i, n) cin >> a[i];
  string s; cin >> s;
  Basis<61> basis;
  for (int i = n - 1; i >= 0; --i) {
    if (s[i] == '0') {
      basis.add(a[i]);
    } else if (s[i] == '1') {
      Basis<61> tmp(basis);
      if (tmp.add(a[i])) {
        cout << "1\n";
        return;
      }
    }
  }
  cout << "0\n";
}

int main() {
  int t; cin >> t;
  while (t--) solve();
  return 0;
}


Measured memory_bytes: 3648
#include <iostream>

int main(void) {
	int length, time, speed;
	std::cin >> length >> time >> speed;

	float estimated_time = length / (float)speed;

	if (estimated_time <= time) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}

	return 0;
}

Measured memory_bytes: 3560
use proconio::{fastout, input, marker::Usize1};

#[fastout]
fn main() {
    input! {
        n: usize,
        mut r#as: [Usize1; n - 1],
    }

    r#as.insert(0, 0);

    let mut counter = vec![0; n];
    for &a in &r#as[1..] {
        counter[a] += 1;
    }

    for ans in counter {
        println!("{}", ans);
    }
}


Measured memory_bytes: 5520
#include<bits/stdc++.h>
using namespace std;
using ll= long long;
using p=pair<ll,ll>;
#define rep(i,n) for (ll i=0; i<(ll)n;i++)
int main(){
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  if (k<=a)cout <<k<<endl;
  else if(k<=a+b) cout<<a<<endl;
  else cout << a - (k - a - b) << endl;
  return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>

using namespace std;
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

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

    int r; cin >> r;
    cout << 3*r*r << endl;

    
    
    return 0;
}

Measured memory_bytes: 256
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

x1, y1, x2, y2 = list(map(int, sys.stdin.buffer.readline().split()))

c1 = complex(x1, y1)
c2 = complex(x2, y2)
c3 = c2 + (c2 - c1) * 1j
c4 = c3 + (c3 - c2) * 1j
print(int(c3.real), int(c3.imag), int(c4.real), int(c4.imag))


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

int main(){
  string S;
  cin>>S;
  bool ans=true;
  
  for(int i=0;i<S.size();i++){
     if(i%2==0&&S.at(i)=='L'){
        ans=false;
        break;
     }
     if(i%2!=0&&S.at(i)=='R'){
        ans=false;
        break;
     }
  }
  
  if(ans==true){
     cout<<"Yes"<<endl;
  }
  if(ans==false){
     cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
from collections import deque
N = int(input())

#753数かかくにんするための関数
#引数はstr
def check(num):
  if num.count("3") > 0 and num.count("5") > 0 and num.count("7") > 0:
    return True
  else:
    return False
  
ans = 0  
nums = deque()
nums.append(0)
for i in range(1,10): #一桁から9桁まで
  next_queue_list = deque()
  for j in nums:
    for k in [3,5,7]:
      new_num = j * 10 + k
      if new_num <= N:
        if check(str(new_num)):
          ans += 1
        next_queue_list.append(new_num)
  
  nums = next_queue_list
  
  
print(ans)

Measured memory_bytes: 4340
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <ctime>
using namespace std;

int M;
int a[7];
int s, g;
int N[301];

bool isChecked[301];
vector<int> milestone[301];  //そのマスで出せばゴールにたどり着ける目を格納する

int iabs(int x){ return x >= 0 ? x : -x; }

bool search(int now){
	if (isChecked[now]) return false;
	else if (now == g)  return true;

	isChecked[now] = true;
	for (int dice = 1; dice <= 6; dice++){
		if (now + a[dice] <= M && search(now + a[dice] + N[now + a[dice]])){
			milestone[now].push_back(a[dice]);
		}
		if (now - a[dice] >= 1 && search(now - a[dice] + N[now - a[dice]])){
			milestone[now].push_back(-a[dice]);
		}
	}

	return milestone[now].size() > 0 ? true : false;
}

int main(){
	srand((unsigned int)time(NULL));
	cin >> M;
	for (int i = 1; i <= 6; i++){
		cin >> a[i];
	}
	cin >> s >> g;
	for (int i = 1; i <= M; i++){
		cin >> N[i];
	}
	bool canGoal = search(s);

	int now = s; //自分が今いるマスの番号
	for (;;){
		int dice;
		cin >> dice;

		bool found = false;
		for (vector<int>::iterator it = milestone[now].begin(); it != milestone[now].end(); it++){
			if (iabs(*it) == a[dice]){
				int pm = *it > 0 ? 1 : -1;
				now += pm * a[dice] + N[now + pm * a[dice]];
				cout << pm << endl;

				found = true;
				break;
			}
		}
		if(!found) cout << 0 << endl;
		cout.flush();

		if (now == g) return 0;
	}
	
	return 0;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

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

	int H,N, A;
	int ans = 0;
	cin >> H >> N;
	rep(i, 0, N)
	{
		cin >> A;
		ans += A;
	}

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

	return 0;
}

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

const int NUM_SIZE = 5;

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

  int N;
  cin >> N;

  long long nums[NUM_SIZE] = {0};
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    if (S.at(0) == 'M')
      nums[0]++;
    else if (S.at(0) == 'A')
      nums[1]++;
    else if (S.at(0) == 'R')
      nums[2]++;
    else if (S.at(0) == 'C')
      nums[3]++;
    else if (S.at(0) == 'H')
      nums[4]++;
  }

  long long ans = 0;
  for (int i = 0; i < NUM_SIZE; i++) {
    for (int j = i + 1; j < NUM_SIZE; j++) {
      for (int k = j + 1; k < NUM_SIZE; k++) {
        if (nums[i] == 0 || nums[j] == 0 || nums[k] == 0) continue;
        ans += nums[i] * nums[j] * nums[k];
      }
    }
  }
  printf("%lld", ans);
  return 0;
}


Measured memory_bytes: 256
//  Created by conan1024hao on 2019/11/16.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int r;
    cin>>r;
    cout<<r*r<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------



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;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int year, month, day;
  char c1, c2;
  cin >> year >> c1 >> month >> c2 >> day;
  if(month <= 4)
    cout << "Heisei" << endl;
  else
    cout << "TBD" << endl;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d %d", $n, $m, $q);

$ptn = array();
for ($i=0; $i < $q; $i++) {
  fscanf(STDIN, "%d %d %d %d", $a, $b, $c, $d);
  $ptn[] = array(
    'a' => $a,
    'b' => $b,
    'c' => $c,
    'd' => $d,
  );
}

$ans = 0;
dfs($n, $m, array(0, 1));
echo $ans;

function dfs($n, $m, $array)
{
  if (count($array) == $n+1) {
    $point = 0;
    global $ptn;
    foreach ($ptn as $k => $v) {
      if ($array[$v['b']] - $array[$v['a']] == $v['c']) {
        $point += $v['d'];
      }
    }
    global $ans;
    $ans = max($ans, $point);
    
    return;
  }

  $array[] = $array[count($array)-1];

  while ($array[count($array)-1] <= $m) {
    dfs($n, $m, $array);
    $array[count($array)-1]++;
  }
}


Measured memory_bytes: 16172
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
using namespace std; using ll = long long; using ld = long double;  using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
const ld PI = 3.1415926535897932;
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define mp make_pair
#define mt make_tuple
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define ULL(...) ull __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define LD(...) ld __VA_ARGS__;in(__VA_ARGS__)
void in() {}
void debug_out() { cerr << endl; }
template<typename Head, typename... Tail>
void debug_out(Head h, Tail... t) {
	cerr << " " << h;
	if (sizeof...(t) > 0) cerr << " :";
	debug_out(t...);
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> vec) {
	for (size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	return os;
}
ll ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//bitSearch, bitList, nod, gcdlcm, isPrime, primeFactorize, Npow, divisor, modinv, dfs, bfs, eratos//
//dijkstra, WarshallFloyd, BellmanFord, UnionFind, COM, digitDP ,RMQ//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z, R, Q;
ll MOD = 1000000007; ll INF = 1LL << 62; ll ans = 0; ll z = 0, o = 1;
vl flag, colorX, colorY, D; vll path;
//***********//
ll Npow(ll x, ll n) {
	if (n == 0) return 1;
	if (n % 2 == 0) return Npow(x * x % MOD, n / 2);
	else return x * Npow(x, n - 1) % MOD;
}

int main() {
	cin >> N;
	vl X(N);
	for (i = 0; i < N; i++) cin >> X[i];
	stack<ll> Robots;
	ans = 1;
	for (i = 0; i < N; i++) {
		Robots.push(X[i]);
		ll x = Robots.top();
		ll k = Robots.size();
		if (x < k * 2 - 1) {
			Robots.pop();
			(ans *= k) %= MOD;
		}
	}
	for (k = 1; k <= Robots.size(); k++) {
		(ans *= k) %= MOD;
	}
	cout << ans;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int N,L;
    cin>>N>>L;
    string ans[105];
    for(int i = 0;i < N;i++)
        cin>>ans[i];
    sort(ans,ans+N);
    for(int i = 0;i < N;i++)
        cout<<ans[i];
        cout<<endl;
        return 0;

}


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

int binary[11];

int main() {
    string s;
    cin >> s;
    int s_idx = 0, bin_idx = 0;
    while (s_idx < s.length()) {
        if (s[s_idx] == '0') binary[bin_idx] = 0;
        else if (s[s_idx] == '1') binary[bin_idx] = 1;
        else {
            bin_idx -= 2;
            if (bin_idx < 0) bin_idx = -1;
        }
        bin_idx++;
        s_idx++;
    }
    for (int i = 0; i < bin_idx; i++) cout << binary[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define mod 1000000007
#define iP pair<int,int>
#define gcd(a,b) __gcd(a,b)
#define pb push_back
#define inf 1e15
#define mod1 998244353
#define pi 3.141592653589793238
#define fi first
#define se second
int32_t main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    int z=n-(n/k)*k;
    cout<<min(abs(z-k),z);
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
void sort2array(double *a,long *b,long n){
    for(int i=0;i<n;i++){
        b[i]=i;
    }
    sort(b,b+n,[a](long i,long j)->bool {return a[i]<a[j];} );
}
//bを何回足せばaを超えるか
int wtover(int a,int b){
    if(a%b>0)return (a/b)+1;
    else return a/b;
}
const int INF=100000001,ID_MAX=20;
int bi_e[ID_MAX]={0};
//2進数表示したときの最高桁
int bi_max(long n){
    int m=0;
    for(m;pow(2,m)<=n;m++);m=m-1;
    return m;
}
//bi_eに二進数表示したやつを代入
void bi_exs(long n){
    rep(i,ID_MAX){
        bi_e[i]=0;
    }
    if(n<pow(2,ID_MAX)){
        int m=bi_max(n);
        long l;
        for(m;m>-1;m--){
            l=pow(2,m);
            bi_e[m]=n/l;
            n=n%l;
        }
    }
}
//x^n mod m (nが負の時は０)
long myPow(long x, long n, long m){
  if(n<0)return 0;
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}
const int N=100001;
int n,m;
vector<int> a[N];

int main(){
    int i,x,y;
    //入力
    cin>>n>>m;
    int h[n];
    rep(i,n){
        cin>>h[i];
    }
    rep(i,m){
    cin>>x>>y;
    a[x-1].push_back(y);
    a[y-1].push_back(x);
    }
    //処理
    int cou=0;
    rep(i,n){
        bool tof=true;
        rep(j,a[i].size()){
            if(h[i]<=h[a[i].at(j)-1]){
                tof=false;
                break;
            }
        }
        if(tof)cou=cou+1;
    }
    //出力
    cout<<cou<<endl;
}


Measured memory_bytes: 9152
/* Sometimes you win , sometimes you learn . */
/* Sometimes you win , sometimes you learn . */
#include <bits/stdc++.h>
#define lp(i , N) for(ll i = 0; i < ll (N) ; i++)
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define debug(x) cout<<" [ " << #x << " is: " << x << " ] "<<endl;
using namespace std;
typedef long long ll;
typedef long double ld;
const long double EPS = 1e-6;
const long double pi = acos(-1);
ll lcm(ll a , ll b){
    return a * b / __gcd(a , b);
}
int main(){
    FAST
    ll x;
    cin >> x;
    ll a = x / 500 , cnt = 0;
    cnt+=a * 1000;
    x-=a * 500;
    ll b = x / 5;
    cnt+= b * 5;
    cout << cnt << endl;
    return 0;
}
/*
[#]=============================================================[#]
         ___    ____              ____          ___ _
        |_ _|  / ___|__ _ _ __   |  _ \  ___   |_ _| |_
         | |  | |   / _` | '_ \  | | | |/ _ \   | || __|
         | |  | |__| (_| | | | | | |_| | (_) |  | || |_
        |___|  \____\__,_|_| |_| |____/ \___/  |___|\__|
                     it's just about time

[#]=============================================================[#]
*/


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int N;
	scanf("%d", &N);
	int s[100];
	int sum = 0;
	int min = 100;
	for (int i = 0; i < N; i++) {
		scanf("%d", &s[i]);
		sum += s[i];
	}
	/* ↑総和を求める */

	/*  ↓総和が10の倍数ならば10の倍数でない最小値を探し総和から引く　そうでないならsum出力　すべて10の倍数のときは0出力 */
	
	if (sum % 10 == 0){

		for (int i = 0; i < N; i++){
			if (s[i] % 10 == 0){
				s[i] = 0;
			}
		}

		for (int i = 0; i < N; i++){
			if (s[i] < min&&s[i] != 0){
				min = s[i];
			}
		}

		if (min != 100){
			printf("%d", sum - min);
		}
		else{
			printf("%d", 0);
		}

	}
	else{
		printf("%d", sum);
	}




	return 0;
}

Measured memory_bytes: 128
# 累積じゃね
n = int(input())
arr = list(map(int, input().split()))
ruiseki = [0] * (n + 1)
for i in range(1, n + 1):
    ruiseki[i] = ruiseki[i - 1] + arr[i - 1]
ans = 10**10
for i in range(1, n):
    takahashi = ruiseki[i]
    raskal = ruiseki[n] - takahashi
    ans = min(ans, abs(raskal - takahashi))
print(ans)

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

/* short names and const
using ll = long long;
using vll = vector<long long>;
using df = vector<vector<long long>>;
df data(n, vector<long long>(m));
const int MOD = 1e9 + 7;
const long long INF = 1e18;
*/

/* Boost!
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
using boost::algorithm::split; // split(result, s, boost::is_any_of(","));
#include <boost/algorithm/string/join.hpp>
using boost::algorithm::join; // string s = join(arr, "");
#include <boost/algorithm/string/replace.hpp>
using boost::algorithm::replace_all; // replace_all(s, "AtCoder", "A");
#include <boost/range/algorithm.hpp> // boost::sort(arr)
#include <boost/multiprecision/cpp_int.hpp>
using boost::multiprecision::cpp_int;
*/

/* print(arr)
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}
*/

/* fast cin and precise cout
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  getline(cin, s);
  cout << fixed << setprecision(15);
*/

/* sum function
int sum(vector<int> &arr) {
  int res = accumulate(arr.begin(), arr.end(), 0);
  return res;
}
*/

int main() {
  int a, b;
  cin >> a >> b;
  cout << (a + b) % 24 << endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
food = [0] * M
ans = 0
for _ in range(N):
	array = list(map(int, input().split()))
	for i in range(1,array[0]+1):
		food[array[i]-1] += 1
for i in food:
	if i == N:
		ans += 1
print(ans)

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(a) a.begin(),a.end()
using ll=long long;

class SegmentTree {
    using Val=int;
    int N;
    Val E;
    function<Val(Val,Val)> F;
    vector<Val> dat;

    void update_impl(int pos){
        if(pos==0) return;
        int par=(pos-1)/2;
        int chi1=par*2+1,chi2=par*2+2;
        dat[par]=F(dat[chi1],dat[chi2]);
        update_impl(par);
    }

    Val query_impl(int l,int r,int k,int a,int b){
        if(l<=a && b<=r) return dat[k];
        if(r<=a || b<=l) return E;
        int mid=(a+b)/2;
        Val lhs=query_impl(l,r,k*2+1,a,mid);
        Val rhs=query_impl(l,r,k*2+2,mid,b);
        return F(lhs,rhs);
    }

    public:
    SegmentTree(int n,int e,const function<Val(Val,Val)> f):E(e),F(f){
        N=1;
        while(N<n) N*=2;
        dat.assign(2*N-1,E);
    }

    void update(int pos,Val val){
        pos=pos+N-1;
        dat[pos]=val;
        update_impl(pos);
    }

    Val query(int l,int r){
        assert(l<=r);
        return query_impl(l,r,0,0,N);
    }


    void debug(){
        int i=1;
        int sum=0;
        while(i<=N){
            for(int j=0;j<i;j++){
                cout<<dat[sum+j];
                if(j!=i-1) cout<<" ";
            }
            cout<<endl;
            sum+=i;
            i*=2;
        }
    }
};

int mii(int lhs,int rhs){return min(lhs,rhs);}
int main(){
    int n; cin>>n;
    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin>>p[i];
        p[i]--;
    }

    SegmentTree oddseg(n,int(1e9),mii);
    SegmentTree eveseg(n,int(1e9),mii);
    vector<int> pos(n);
    for(int i=0;i<n;i++){
        pos[p[i]]=i;
    }
    for(int i=0;i<n;i++){
        if(i%2==1) oddseg.update(i,p[i]);
        else eveseg.update(i,p[i]);
    }

    priority_queue<pair<int,pair<int,int>>,vector<pair<int,pair<int,int>>>,greater<>> que;
    que.push({-1,{0,n}});
    vector<int> q;
    while(!que.empty()){
        auto vall=que.top();
        que.pop();
        int num=vall.first;
        int linde=vall.second.first;
        int rinde=vall.second.second;
        
        if(linde==rinde) continue;
        if(num==-1){
            num=eveseg.query(0,n);
        }
        int po=pos[num];
        int po2;
        if((po+1)%2==0) po2=pos[eveseg.query(po+1,rinde)];
        else po2=pos[oddseg.query(po+1,rinde)];
        q.push_back(p[po]);
        q.push_back(p[po2]);
        int val;
        if(linde%2==0) val=eveseg.query(linde,po);
        else val=oddseg.query(linde,po);
        
        que.push({val,{linde,po}});
        if((po+1)%2==0) val=eveseg.query(po+1,po2);
        else val=oddseg.query(po+1,po2);
        
        que.push({val,{po+1,po2}});
        
        if((po2+1)%2==0) val=eveseg.query(po2+1,rinde);
        else val=oddseg.query(po2+1,rinde);
        que.push({val,{po2+1,rinde}});
        
    }
    for(int i=0;i<n;i++){
        cout<<q[i]+1;
        if(i!=n-1) cout<<" ";
        else cout<<endl;
    }

    return 0;
}

Measured memory_bytes: 11952
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
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; }

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


int A, B;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    while (cin >> A >> B) {
        if (A >= 13) cout << B << endl;
        else if (A >= 6) cout << B/2 << endl;
        else cout << 0 << endl;
    }
}


















Measured memory_bytes: 256
A_1 = list(map(int, input().split()))
A_2 = list(map(int, input().split()))
A_3 = list(map(int, input().split()))
A = A_1 + A_2 + A_3
N = int(input())
B = []
for _ in range(N):
  B.append(int(input()))
for b in range(N):
  for a in range(9):
    if B[b] == A[a]:
      A[a] = 0
BINGO = 'No'
for i in range(3):
  if A[i*3] + A[i*3+1] + A[i*3+2] == 0:
    BINGO = 'Yes'
  if A[i] + A[i+3] + A[i+6] == 0:
      BINGO = 'Yes'
if (A[0] + A[4] + A[8] == 0):
  BINGO = 'Yes'
if (A[2] + A[4] + A[6] == 0):
  BINGO = 'Yes'
print(BINGO)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,M,X,num,sum1=0,sum2=0;
cin>>N>>M>>X;
map<int,int>m;
for(int i=1;i<=N;i++){
m[i];
}
for(int i=0;i<M;i++){
    cin>>num;
    m[num]=1;
}
for(int i=X;i<=N;i++){
  sum1+=m[i];
}
for(int i=X;i>0;i--){
    sum2+=m[i];
}
cout<<min(sum1,sum2);


return 0;
}

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

using namespace std;
int main(void)
{
    string a,b;
    cin>>a>>b;
    
    sort(a.begin(),a.end());
    sort(b.begin(),b.end(),greater<char>());
    
    if(b.compare(a)>0)
    cout<<"Yes"<<endl;
    
    else
    cout<<"No"<<endl;


    return 0;
}

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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める

int main(){
    int N;
    cin >> N;
    int ans = 0;
    FOR(i,1,N){
        int a;
        cin >> a;
        if((i*a)%2 == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

set<int> memo[30];


int main(){
  string s, t;
  cin >> s;
  cin >> t;

  rep(i,s.size()){
    memo[(int)(s[i]-'a')].insert(i);
  }

  ll loop = 0;
  ll last = -1;
  rep(i,t.size()){
    set<int>& ss = memo[(int)(t[i]-'a')];

    if(ss.size() == 0){
      cout << -1 << endl;
      return 0;
    }
    
    auto itr = ss.upper_bound(last);
    if(itr == ss.end()){
      loop++;
      last = *(ss.begin());
    }else{
      last = *itr;
    }
  }

  cout << (loop * s.size()) + (last+1) << endl;
  
  return 0;
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define si(x) int(x.size())
const int mod=1000000007,MAX=55,MAX2=2600;
const ll INF=1LL<<59;
vector<pair<pair<int,int>,ll>> G[MAX][MAX2];
ll dis[MAX][MAX2];

void dijkstra(int u,int k){
    dis[u][k]=0;
    priority_queue<pair<ll,pair<int,int>>,vector<pair<ll,pair<int,int>>>,greater<pair<ll,pair<int,int>>>> PQ;
    
    PQ.push(make_pair(0,make_pair(u,k)));
    while(!PQ.empty()){
        ll a=PQ.top().first;
        int b=PQ.top().se.fi;
        int c=PQ.top().se.se;
        PQ.pop();
        if(dis[b][c]<a) continue;
        for(int i=0;i<G[b][c].size();i++){
            int d=G[b][c][i].fi.fi;
            int e=G[b][c][i].fi.se;
            ll f=G[b][c][i].second;
            if(dis[d][e]>dis[b][c]+f){
                dis[d][e]=dis[b][c]+f;
                PQ.push(make_pair(dis[d][e],make_pair(d,e)));
            }
        }
    }
    return;
}//a,dが長さ

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,M,S;cin>>N>>M>>S;
    chmin(S,2500);
    
    for(int i=0;i<M;i++){
        int a,b,c,d;cin>>a>>b>>c>>d;
        a--;b--;
        for(int j=c;j<=2500;j++){
            G[a][j].push_back({{b,j-c},d});
            G[b][j].push_back({{a,j-c},d});
        }
    }
    
    for(int i=0;i<N;i++){
        int a,b;cin>>a>>b;
        for(int j=0;j<2500;j++){
            G[i][j].push_back({{i,min(2500,j+a)},b});
        }
    }
    
    for(int i=0;i<MAX;i++) for(int j=0;j<MAX2;j++) dis[i][j]=INF;
    
    dijkstra(0,S);
    
    for(int i=1;i<N;i++){
        ll ans=INF;
        for(int j=0;j<=2500;j++) chmin(ans,dis[i][j]);
        cout<<ans<<endl;
    }
}





Measured memory_bytes: 24208
import Control.Applicative
import Control.Monad

main :: IO ()
main = do
  n <- readLn
  solve <$> replicateM n readLn >>= print

solve :: [Int] -> Int
solve = length . filter f
  where
    f x = all (g x) $ takeWhile (\i -> 2 * i * (i + 1) <= x) [1..]
    g x y = (x - y) `mod` (2 * y + 1) /= 0



Measured memory_bytes: 34888
#include<bits/stdc++.h>
using namespace std;                                                            
#define pb push_back                                                            
#define mp make_pair                                                                                                                                
#define sqr(a) ((a) * (a))                                                      
#define io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);   
#define co() cout.precision(10);                                                
#define F for(li i=0;i<n;i++)
#define fo(i,a,n) for(i=a;i<n;i++)
#define ne cout<<"\n"; 
#define test int t;cin>>t;while(t--)
//#define oj #ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif

typedef long long li;
typedef long double ld;

const li mod = 1000000007;
int main() 
{
    io();
    char c;
    cin>>c;
    if(c>='a')
    cout<<"a";
    else
    cout<<"A";
}

Measured memory_bytes: 3604
use std::io::*;
use std::str::FromStr;
use std::collections::HashMap;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


fn main() {
    let n:usize = read();
    let mut plan = HashMap::new();
    for _i in 0..n {
        let count = plan.entry(read::<u64>()).or_insert(0);
        *count += 1;
    }
    let m:usize = read();
    let mut problem = HashMap::new();
    for _i in 0..m {
        let count = problem.entry(read::<u64>()).or_insert(0);
        *count += 1;
    }

    let mut ans = true;
    for (key,value) in problem {
        let plan_v = plan.get(&key);
        if plan_v == None {
            ans = false;
        }else{
            if plan_v.unwrap() < &value {
                ans = false;
            }
        } 
    }

    //println!("{:?}", plan);
    //println!("{:?}", problem);

    if ans {
        println!("YES");
    }else{
        println!("NO");
    }
}


Measured memory_bytes: 19584
#include<stdio.h>
#include<string.h>
const int N=1e5+5,P=1e9+7;
char s[N];int n,m,p[N],g[N][3],f[N];
int main(){
	int x,c;
	scanf("%s",s+1),n=strlen(s+1);
	for(x=1;x<n;x++)if(s[x]==s[x+1])break;
	if(x<n){
		for(x=1;x<=n;x++)p[x]=(p[x-1]+(s[x]=='b')+1)%3;
		for(x=n;x>=0;x--)g[x][0]=g[x+1][0],g[x][1]=g[x+1][1],g[x][2]=g[x+1][2],g[x][p[x]]=x;
		f[0]=1;
		for(x=0;x<n;x++)if(f[x])for(c=0;c<3;c++)if(c!=p[x]&&g[x+1][c])f[g[x+1][c]]=(f[g[x+1][c]]+f[x])%P;
		for(x=1;x<=n;x++)if(p[x]==p[n])m=(m+f[x])%P;
	}else m=1;
	printf("%d\n",m);
}

Measured memory_bytes: 2176
# 条件は a+b = a^bよりa&b=0→各ビットごとに(1,0),(0,1),(0,0)の組み合わせのみ
# 上の方から決めていく桁DPになりそう？
# 組み合わせがどれでも良ければ上の3つ、和が0なら1通り、和が1なら上記の2パタ。
# Lは2進数表記
L = input()
keta = len(L)
mod = 10 ** 9 + 7
# dp[桁数][smaller]
dp = [[0] * 2 for _ in range(keta + 2)]
dp[0][0] = 1
for i in range(keta):
    nd = int(L[i])
    for j in range(2):
        ni = i + 1
        nj = j
        if j == 1:
            dp[ni][nj] += 3 * dp[i][j]
            dp[ni][nj] %= mod
        else:
            if nd == 0:
                dp[ni][nj] += dp[i][j]
                dp[ni][nj] %= mod
            else:  # nd==1
                dp[ni][nj] += 2 * dp[i][j]  # (1,0), (0,1)
                dp[ni][1] += dp[i][j]  # (0,0)
                dp[ni][nj] %= mod
ans = dp[keta][0] + dp[keta][1]
ans %= mod
print(ans)


Measured memory_bytes: 19692
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            var ans = 1L;
            for (var i = 1; i <= N; ++i)
                ans = (ans * i) % Mod;
            WriteLine(ans);
            //Out.Flush();
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    int dx = c-a;
    int dy = d-b;
    cout << string(dx,'R') << string(dy,'U');
    cout << string(dx,'L') << string(dy,'D');
    cout << 'D' << string(dx+1,'R') << string(dy+1,'U') << 'L';
    cout << 'U' << string(dx+1,'L') << string(dy+1,'D') << 'R';
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

string s;

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

    int N;
    cin >> s;
    N = s.size();

    int total = 0;
    rep (i, N)
    {
        if (s[i] == 'p')
        {
            ++total;
        }
    }

    cout << (N / 2) - total << "\n";
    return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    int C = 1000000007;
    long long power = 1;
    for (int i = 1; i <= N; i++) {
        power *= i;
        power %= C;
    }

    cout << power << endl;
}

Measured memory_bytes: 256