akhauriyash/Code-Regression huggingface dataset:
two = Array.new
21.times do |i|
  two << 2 ** i
end

three = Array.new
14.times do |i|
  three << 3 ** i
end

five = Array.new
10.times do |i|
  five << 5 ** i
end

result = Array.new
two.each do |a|
  three.each do |b|
    five.each do |c|
      result << a * b * c
    end
  end
end

while input = $stdin.gets do
  m, n = input.chomp.split(" ").map(&:to_i)
  break if m == 0
  p result.select{|i| m <= i && i <= n}.size
end

Measured memory_bytes: 6192
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define PLL pair<LL, LL>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define pb pop_back
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)

#define Sim template<class n
Sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
Sim> auto operator << (ostream &p, n y) -> 
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
Sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
Sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
Sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define int LL
#define I(x) #x " = ", (x), " "
#define A(a, i) #a "[" #i " = ", i, "] = ", a[i], " "
const int M = 1024 * 1024 * 4;
const LL mod = 998244353;

LL sil[M], odw[M];
LL n, m;

LL poww(LL x, LL e)
{
	if (e == 0)
	{
		return 1;
	}
	if (e % 2 == 0)
	{
		return poww(x * x % mod, e / 2);
	}
	return poww(x, e - 1) * x % mod;
}

LL newt(LL a, LL b)
{
	LL r = sil[a] * odw[b] % mod;
	return r * odw[a - b] % mod;
}

LL pakuj(LL a, LL b)
{
	if (b < 0)
	{
		return 0;
	}
	return newt(a + b - 1, b);
}

main()
{
	//ios_base::sync_with_stdio(0);
	//cin.tie(NULL);
	sil[0] = 1;
	odw[0] = 1;
	FOR(i, 1, M - 1)
	{
		sil[i] = sil[i - 1] * i % mod;
		odw[i] = poww(sil[i], mod - 2);
	}
	scanf("%lld%lld", &n, &m);
	
	LL res = 0;
	
	for (int i = m; i >= 0; i -= 2)
	{
		if (i > n)
		{
			continue;
		}
		LL jed = i;
		LL dwa = m + (m - i) / 2;
		LL ilejed = newt(n, jed);
		LL iledwa = pakuj(n, dwa) - jed * pakuj(n, dwa - m) - (n - jed) * pakuj(n, dwa - m - 1);
		iledwa %= mod;
		iledwa = (iledwa + mod) % mod;
		
		//debug(i, jed, dwa, ilejed, iledwa);
		res = (res + ilejed * iledwa) % mod;
	}
	
	printf("%lld\n", res);
	
	/*LL all = pakuj(n, 3 * m) - (n * pakuj(n, m - 1)) % mod;
	if (all < 0)
	{
		all += mod;
	}
	LL bad = 0;
	
	FOR(i, 2 * m + 1, min(n, 3 * m))
	{
		LL tmp = newt(n, i) * pakuj(i, 3 * m - i);
		bad = (bad + tmp) % mod;
	}
	debug(all, bad);
	
	LL bad2 = 0;
	FOR(i, m + 1, min(2 * m, n))
	{
		
	}
	
	printf("%lld\n", (all - bad - bad2 + 2 * mod) % mod);*/
	return 0;
}





Measured memory_bytes: 65792
#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
const int INF = 1e9; int n;
vector<int> v;int dp[320]; int a[320];
int main() {
	cin >> n;
	if (n % 2 == 0)
		cout << n / 2 - 1 << endl;
	else {
		int y = n / 2;
		cout << y << endl;
	}
}

Measured memory_bytes: 256
n, m = map(int, input().split())

a = []
for i in range(1,n+1):
  a.append(2*i)
for j in range(1, m+1):
  a.append(2*j - 1)

counter = 0
for i in range(len(a)-1):
  for j in range(i+1, len(a)):
    if (a[i] + a[j]) % 2 == 0:
      counter += 1
      
print(counter)

Measured memory_bytes: 3064
#include<iostream>
#include <string>
#include <cstdlib> //絶対値利用のため
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)

//const int INF = INT_MAX / 2;

int main() {
	int n, q;
	cin >> n >> q;
	string s;
	cin >> s;
	int l[100005];
	int r[100005];
	for(int i = 0; i < q; i++) cin >> l[i] >> r[i];
	int dp[100005] = { 0 };
	dp[0] = 0; dp[1] = 0;
	for (int i = 2; i <= n; i++) {
		if (s.substr(i-2, 2) == "AC") dp[i] = dp[i - 1] + 1;
		else dp[i] = dp[i - 1];
//		cout << dp[i] << endl;
	}
	
	for (int i = 0; i < q; i++){
		if (l[i] == 1) {
			cout << dp[r[i]] << endl;
			continue;
		}
		if (s[l[i] - 2] == 'A' && s[l[i] - 1] == 'C') cout << dp[r[i]] - dp[l[i] - 1] - 1 << endl;
		else cout << dp[r[i]] - dp[l[i] - 1] << endl;
	}
	


	return 0;
}

Measured memory_bytes: 2176
use std::io::BufRead;

fn main() {
    let stdin = std::io::stdin();
    let mut val = stdin.lock().gets().split(' ').take(3)
        .map(|x| x.parse().unwrap()).collect::<Vec<u32>>();
    let k = stdin.lock().gets().parse::<u32>().unwrap();
    val.sort();
    val[2] <<= k;
    println!("{}", val.iter().sum::<u32>());
}

trait Gets { fn gets(&mut self) -> String; }
impl<T: std::io::BufRead> Gets for T {
    fn gets(&mut self) -> String { self.lines().next().unwrap().unwrap() } }


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#include<algorithm>
using namespace std;
long long N;
vector<string> field;
int main() {
	cin >> N;
	long long ans = 0;
	for (long long i = 1; i <= N; ++i) {
		if (i*i <= N) ans = i * i;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define FOR(x, to) for(x=0; x<(to); x++)
using namespace std;

int main(){
    long long int W, H, x, y;
    cin >> W >> H >> x >> y;
    double ans = W * H / 2.0;
    if(x * 2 == W && y * 2 == H){
        printf("%.10f 1\n", ans);
    }else{
        printf("%.10f 0\n", ans);
    }
    return 0;
}

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

int main() {
    int A, B;
   cin >> A >> B ;
   int max=A+B-1;
   int min=A+B+1-A*2;
  for(int i=0 ;i<=max-min;i++){
      cout <<min+i<<" ";
  }
  cout << endl;
    return 0;
}

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

int main(){
  int N;
  cin>>N;
  int64_t A[N];
  bool Q=1;
  for(int i=0;i<N;i++){
    cin>>A[i];
    if(A[i]==0){
      Q=0;
      break;
    }
  }

  int64_t ans=1;
  if(Q){
    for(int i=0;i<N;i++){
      if(A[i]>1000000000000000000/ans){
        ans=-1;
        break;
      }
      ans*=A[i];    
    }
    cout<<ans<<endl;
  }

  else{
    cout<<0<<endl;
  }
}

Measured memory_bytes: 4376
n,m,*t=map(int,open(0).read().split())
s=sorted
a=s(t[:n])[::-1]
i=n
for c,b in s(zip(t[n+1::2],t[n::2]))[::-1]:
 while c>a[i-1]and i*b:a[i-1]=c;b-=1;i-=1
print(sum(a))

Measured memory_bytes: 35420
import sys

X, N = map(int, input().split())

if N == 0:
  print(X)
else:
  argv = input().split()
  argv.sort()

  for num in range(100):
    out = 0
    for i in range(N):
      if int(argv[i]) == X - num:
        out = 1
        
    if out == 0:
      print(X - num)
      break;
      
    out = 0
    
    for i in range(N):
      if int(argv[i]) == X + num:
        out = 2
    
    if out == 0:
      print(X + num)
      break;

Measured memory_bytes: 9080
N = int(input())
H = map(int, input().split())
A = map(int, input().split())


class SegmentTree:
    def __init__(self, array, operator, identity_element):
        _len = len(array)
        self.__op = operator
        self.__size = 1 << (_len - 1).bit_length()
        self.__tree = [identity_element] * self.__size + \
            array + [identity_element] * (self.__size - _len)
        self.__ie = identity_element

        for i in range(self.__size - 1, 0, -1):
            self.__tree[i] = operator(
                self.__tree[i * 2], self.__tree[i * 2 + 1])

    def update(self, i, v):
        i += self.__size
        self.__tree[i] = v
        while i:
            i //= 2
            self.__tree[i] = self.__op(
                self.__tree[i * 2], self.__tree[i * 2 + 1])

    def query(self, l, r):
        l += self.__size
        r += self.__size
        ret = self.__ie
        while l < r:
            if l & 1:
                ret = self.__op(ret, self.__tree[l])
                l += 1
            if r & 1:
                r -= 1
                ret = self.__op(ret, self.__tree[r])
            l //= 2
            r //= 2
        return ret

st = SegmentTree([0]*2*(10**5), max, 0)

for _, a, i in sorted(zip(H, A, range(N))):
    st.update(i, st.query(0, i) + a)

print(st.query(0, N))


Measured memory_bytes: 127572
<?php
	$A = fgets(STDIN, 4096);
	$array = explode(" ", $A);
	$check1 = false;
	$check2 = false;
	$check3 = false;

	foreach ($array as $x){
      if($x == 5 && $check1 == false){
        $check1 = true;
      }elseif($x == 7){
        $check2 = true;
      }elseif($x == 5){
        $check3 = true;
      }
    }
	if($check1 == true && $check2 == true && $check3 == true){
      echo 'YES';
    }else{
      echo 'NO';
    }

Measured memory_bytes: 3576
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long lo;
typedef pair< lo,lo > PII;

#define fi first
#define se second
#define int long long
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)

const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;

int n,m,b[li],a[li],k,flag,t;
int cev;
string s;
vector<int> v;

int32_t main(void){
	scanf("%lld",&n);
	FOR{
		if(i%3==0 || i%5==0)continue;
		cev+=i;
	}
	printf("%lld\n",cev);
	return 0;
}



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

int main() {
    int n, m, max_ans;
    cin >> n;
    vector<string> s(n);
    for (int i=0; i<n; i++) {
        cin >> s.at(i);
    }    
    cin >> m;
    vector<string> t(m);
    for (int i=0; i<m; i++) {
        cin >> t.at(i);
    }
    max_ans = 0;

    for (int i=0; i<n; i++) {
        string tmp;
        tmp = s.at(i);
        int tmp_ans = 0;
        for (int i=0; i<n; i++) {
            if (s.at(i)==tmp) tmp_ans++;
        }
        for (int i=0; i<m; i++) {
            if (t.at(i)==tmp) tmp_ans--;
        }
        if (tmp_ans > max_ans) max_ans = tmp_ans;
    }
    cout << max_ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define repf(i, x, n) for (int i = (int)(x); i < (int)(n); i++)
#define repfr(i, x, n) for (int i = (int)(x)-1; i >= (int)(n); i--)
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 INF 1e9
using ll = int64_t;
#define waru 1000000007

std::int64_t gcd(std::int64_t a, std::int64_t b) {
  // a >= b && b != 0
  std::int64_t c;
  do {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}
std::int64_t gcd_s(std::int64_t aa, std::int64_t bb) {
  std::int64_t a = max(aa, bb);
  std::int64_t b = min(aa, bb);
  std::int64_t c;
  if (b == 0) {
    return -1;
  }
  do {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}
void rle(std::vector<std::pair<char, std::int64_t>> &data, std::string str) {
  char now = str[0];
  std::int64_t count = 0;
  for (std::int64_t i = 0; i < str.size() + 1; i++) {
    if (i == str.size()) {
      data.push_back(make_pair(str[i - 1], count));
      break;
    } else if (now != str[i]) {
      data.push_back(make_pair(now, count));
      now = str[i];
      count = 0;
    }
    count++;
  }

  return;
}

void Main() {
  //自動整形防止用
  int n;
  std::cin >> n;
  ll count4 = 0, count2 = 0;
  rep(i, n) {
    ll tmp;
    std::cin >> tmp;
    if (tmp % 4 == 0) {
      count4++;
    } else if (tmp % 2 == 0) {
      count2++;
    }
  }

  // Nのうち、４の倍数の数の個数がN/2以上あればYes
  if (count4 + count2 / 2 >= n / 2) {
    std::cout << "Yes" << '\n';
  } else {
    std::cout << "No" << '\n';
  }

  return;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 384
S = input()
a, b = int(S[:2]), int(S[2:])
c = set(list(range(1, 12 + 1)))

if a in c and b in c:
    print('AMBIGUOUS')
    exit()
if a in c:
    print('MMYY')
    exit()
if b in c:
    print('YYMM')
    exit()
print('NA')
exit()


Measured memory_bytes: 3060
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			n = scanner.nextInt();
			int m = scanner.nextInt();
			int s = scanner.nextInt();
			int g1 = scanner.nextInt();
			int g2 = scanner.nextInt();
			if ((n | m | s | g1 | g2) == 0)
				break;
			s--;
			g1--;
			g2--;
			int[][] smap = new int[n][n];
			int[][] gmap = new int[n][n];
			for (int i = 0; i < n; i++)
				for (int j = 0; j < n; j++) {
					smap[i][j] = gmap[i][j] = i == j ? 0 : INF;

				}

			while (m-- > 0) {
				int b1 = scanner.nextInt() - 1;
				int b2 = scanner.nextInt() - 1;
				int c = scanner.nextInt();
				smap[b1][b2] = gmap[b2][b1] = c;
			}
			int[] acost = slove(s, smap);
			int[] bcost = slove(g1, gmap);
			int[] ccost = slove(g2, gmap);

			int ans = INF;
			for (int i = 0; i < n; i++)
				ans = Math.min(ans, acost[i] + bcost[i] + ccost[i]);
			System.out.println(ans);
		}
	}

	private int[] slove(int s, int[][] map) {
		PriorityQueue<Pair> pq = new PriorityQueue<Main.Pair>();
		pq.offer(new Pair(s, 0));
		int[] dp = new int[n];
		Arrays.fill(dp, INF);
		dp[s] = 0;
		while (!pq.isEmpty()) {
			Pair p = pq.poll();
			if (dp[p.d] < p.cost)
				continue;
			for (int i = 0; i < n; i++) {
				int ncost = p.cost + map[p.d][i];
				if (dp[i] <= ncost)
					continue;
				dp[i] = ncost;
				pq.offer(new Pair(i, ncost));
			}
		}
		return dp;
	}

	int INF = 1 << 29;
	int n;

	class Pair implements Comparable<Pair> {
		int d, cost;

		public Pair(int d, int cost) {
			super();
			this.d = d;
			this.cost = cost;
		}

		@Override
		public String toString() {
			return "Pair [d=" + d + ", cost=" + cost + "]";
		}

		@Override
		public int compareTo(Pair o) {
			return cost - o.cost;
		}

	}
}

Measured memory_bytes: 63468
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
const ll mo = 1000003;
const ll INF = 1LL << 60; //MAX 9223372036854775807
ll ans = 0;
long long int mypow(long long int a,long long int b){
	long long int res=1;
	a%=mo;
	while(b){
		if(b&1)
			res=res*a%mo;
		a=a*a%mo;
		b>>=1;
	}
	return res;
}
int main()
{
ll q;
cin >> q;
ll t[q][3] = {};
vector<ll> kaij;
kaij.push_back(1);
for(ll i = 1; i < mo*2; i++){
    kaij.push_back((kaij[i-1]*i)%mo);
}
rep(i, q)
{
    cin >> t[i][0]>>t[i][1]>>t[i][2];
}
rep(i,q){
    if(t[i][1]==0)ans=mypow(t[i][0],t[i][2]);
    else if(t[i][0]==0)ans=0;
    else{
        t[i][0]=t[i][0]*mypow(t[i][1],mo-2)%mo;
        ll y=t[i][0]+t[i][2]-1;
        if(y>=mo)ans=0;
        else ans=kaij[y]*mypow(t[i][1],t[i][2])*mypow(kaij[t[i][0]-1],mo-2);
    }
    cout << ans%mo << endl;
}


return 0;
}

Measured memory_bytes: 21096
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

typedef long long ll;

const int MAXN = 1005;
const int MAXM = 2005;
const ll MOD = 1000000007;

struct Edge
{
	int to;
	int w;
	int nxt;
}edge[MAXM << 1];

int n,m,id,MAX;
int first[MAXN];
int u[MAXM];
int v[MAXM];
int w[MAXM];
int fa[MAXN];

ll X,tot;
ll pw[MAXM];

bool vis[MAXM];

void addE(int u,int v,int w)
{
	edge[++id] = (Edge){v,w,first[u]};
	first[u] = id;
}

int getroot(int u)
{
	return u == fa[u] ? u : fa[u] = getroot(fa[u]);
}

bool getmax(int u,int fa,int T)
{
	if (u == T)
		return 1;
	for (int i = first[u];i;i = edge[i].nxt)
		if (edge[i].to != fa && getmax(edge[i].to,u,T))
		{
			MAX = max(MAX,edge[i].w);
			return 1;
		}
	return 0;
}

ll solve(ll x)
{
	if (tot >= x)
		return pw[m];
	int cnt = m - n + 1;
	for (int i = 1;i <= m;i++)
		if (!vis[i])
		{
			MAX = 0;
			getmax(u[i],0,v[i]);
			if (tot - MAX + w[i] < x)
				cnt--;
		}
	return pw[cnt + 1];
}

int main()
{
	scanf("%d%d%lld",&n,&m,&X);
	pw[0] = 1;
	for (int i = 1;i <= m;i++)
		pw[i] = pw[i - 1] * 2 % MOD;
	for (int i = 1;i <= m;i++)
		scanf("%d%d%d",&u[i],&v[i],&w[i]);
	for (int i = 1;i <= m;i++)
		for (int j = i + 1;j <= m;j++)
			if (w[i] > w[j])
			{
				swap(u[i],u[j]);
				swap(v[i],v[j]);
				swap(w[i],w[j]);
			}
	for (int i = 1;i <= n;i++)
		fa[i] = i;
	for (int i = 1;i <= m;i++)
		if (getroot(u[i]) != getroot(v[i]))
		{
			vis[i] = 1;
			addE(u[i],v[i],w[i]);
			addE(v[i],u[i],w[i]);
			fa[getroot(u[i])] = getroot(v[i]);
			tot += w[i];
		}
	printf("%lld\n",(solve(X) - solve(X + 1) + MOD) % MOD);
	return 0;
}

Measured memory_bytes: 384
while 1:

    x,op,y = raw_input().split()

    if op == "?":
        break

    x = int(x)
    y = int(y)

    if op == "+":
        print x+y
    elif op == "-":
        print x-y
    elif op == "*":
        print x*y
    else:
        print x/y

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

const int maxn = 430;
int n, m, col[160010], vis[160010], black, white;
char s[maxn][maxn];
inline int code(int x, int y) { return x * m + y + 1; }
vector<int> G[160010];

void dfs(int u) {
    if(col[u]) black++; else white++;
    vis[u] = true;
    for(auto v : G[u]) if(!vis[v]) dfs(v);
}

int main() {
    scanf("%d%d", &n, &m);
    for(int i = 0; i < n; ++i) scanf("%s", s[i]);
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < m; ++j) {
            col[code(i, j)] = s[i][j] == '#';
            auto chkLink = [&](int x, int y) {
                if(x >= 0 && x < n && y >= 0 && y < m) {
                    if(s[x][y] != s[i][j]) {
                        G[code(i, j)].push_back(code(x, y));
                    }
                }
            };
            chkLink(i - 1, j);
            chkLink(i + 1, j);
            chkLink(i, j - 1);
            chkLink(i, j + 1);
        }
    }
    int tot = n * m;
    ll ans = 0;
    for(int i = 1; i <= tot; ++i) if(!vis[i]) {
        black = white = 0;
        dfs(i);
        ans += 1LL * black * white;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 15360
import sys
from collections import deque
readline = sys.stdin.readline
dq = deque()
for _ in range(int(input())):
    c = readline().split()
    if c[0] == "deleteFirst":
        del dq[0]
    elif c[0] == "deleteLast":
        del dq[-1]
    else:
        if c[0] == "insert":
            dq.appendleft(c[1])
        elif c[0] == "delete":
            if c[1] in dq:
                dq.remove(c[1])
print(*dq)



Measured memory_bytes: 69732
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(n**0.5)+1):
    if temp%i==0:
      cnt=0
      while temp%i==0:
        cnt+=1
        temp //= i
      arr.append([i, cnt])
      
  if temp!=1:
    arr.append([temp, 1])
    
  if arr==[]:
    arr.append([n, 1])
    
  return arr

a = factorization(int(input()))
b = [1, 3, 6, 10, 15, 21, 28, 36, 43]

ans = 0

if len(a) == 1 and a[0][0] == 1:
  print(0)
  exit()
  
for i in a:
  for j in range(len(b)):
    if i[1] < b[j]:
      ans+=j
      break
    
print(ans)


Measured memory_bytes: 9384
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  double D,T,S;
  cin >> D >> T >> S;
  double time = D/S;
  if(time<=T){
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;
}
   

Measured memory_bytes: 3628
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        char s = sc.next().charAt(0);
        String ans = null;
        switch(s) {
            case 'A': ans = "T"; break;
            case 'T': ans = "A"; break;
            case 'C': ans = "G"; break;
            case 'G': ans = "C"; break;
        }

        System.out.println(ans);
        
    } 
}

Measured memory_bytes: 21712
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(long long &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(long long x){
  int s=0;
  int m=0;
  char f[20];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
long long N;
int main(){
  long long res = 0;
  rd(N);
  if(N%2){
    wt_L(0);
    wt_L('\n');
    return 0;
  }
  N /= 2;
  while(N){
    res += (N /= 5);
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20191214-1

// --- original code ---
// ll N;
// {
//   ll res = 0;
//   rd(N);
//   if(N%2) wt(0), return 0;
//   N /= 2;
//   while(N) res += (N /= 5);
//   wt(res);
// }


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string>
#include<string.h>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a >= c && c >= b) {
		cout << "Yes" << endl;
	}
	else if (b >= c && c >= a) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<cstdio>
#include<map>
using namespace std;
#define MAX_N 500005
#define MAX_Q 20010
#define MAX_L 40010
 
struct data{
  int y,id;
  bool operator < (const data &p)const{
    return (y==p.y?id<p.id:y<p.y);
  }
};
 
int n;
int px[MAX_N],py[MAX_N];
int ax[MAX_Q],ay[MAX_Q];
int bx[MAX_Q],by[MAX_Q];
 
const int Bs = 205;
set<data> t[Bs];
set<data> u[MAX_L];
  
void Set(int x,int y,int id){
  u[x].insert((data){y,id});
  t[x/Bs].insert((data){y,id});
}
vector<int> ans;
void Find(int ax,int ay,int bx,int by){
  set<data> :: iterator it;
  for(int i=ax;i<bx;i++){
    if(i%Bs==0&&i+Bs<=bx){
      it=t[i/Bs].lower_bound((data){ay,-1});
      while(1){
        if(it==t[i/Bs].end() || by < it->y)break;
        ans.push_back(it->id);
        it++;
      }
      i+=Bs-1;
    }else{
      it=u[i].lower_bound((data){ay,-1});
      while(1){
        if(it==u[i].end() || by < it->y)break;
        ans.push_back(it->id);
        it++;
      }
    }
  }
}

int tx[MAX_L];
int ux[MAX_L];
int size=0;
 
int main(){
  scanf("%d",&n);
  for(int i=0;i<n;i++)scanf("%d %d",&px[i],&py[i]);
   
  int q;
  scanf("%d",&q);
  for(int i=0;i<q;i++){
    scanf("%d %d %d %d",&ax[i],&bx[i],&ay[i],&by[i]);
    bx[i]++;
    tx[size++]=ax[i];
    tx[size++]=bx[i];
  }
  tx[size++]=1e9+2;
  tx[size++]=-1e9-2;
  sort(tx,tx+size);
  ux[0]=1;
  for(int i=1;i<size;i++)ux[i]=ux[i-1]+(tx[i]!=tx[i-1]); 
  for(int i=0;i<n;i++){
    px[i]=ux[ upper_bound(tx,tx+size,px[i])-tx-1 ];
    Set(px[i],py[i],i);
  }
 
  for(int i=0;i<q;i++){
    ans.clear();
    ax[i]=ux[ lower_bound(tx,tx+size,ax[i])-tx ];
    bx[i]=ux[ lower_bound(tx,tx+size,bx[i])-tx ];

    Find(ax[i],ay[i],bx[i],by[i]); 
    sort(ans.begin(),ans.end());
    for(int i=0;i<(int)ans.size();i++){
      if(i&&ans[i]==ans[i-1])continue;
      printf("%d\n",ans[i]);
    }    
    printf("\n");  
  }
  return 0;
}

Measured memory_bytes: 53252
#include<iostream>
using namespace std;
void fun(int n,int x,int t)
{
  if(n%x!=0)
   cout<<(n/x+1)*t;
  else
   cout<<n/x*t;
  
}






int main()
{
 
  int n,x,t;
 cin>>n>>x>>t;
   fun(n,x,t);
  return 0;
}
  

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

int main() {
    int N;
    cin>>N;
    vector<double> V(N, 0);
    REP(i, 0, N) cin >> V[i];
    sort(V.begin(), V.end());
    double ans = V[0];
    REP(i, 1, N){
        ans = (ans + V[i])/2;
    }
    cout << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
N = int(input()) # 数字を変数に格納

List = [[] for i in range(N)]

for i in range(N):
    for j in range(i+1):
        List[i].append(chr(97+j))

flag = 0
point = [0]*(N+1)

while flag != 1:
    chars = ''
    i = 0
    while len(chars) < N:
        if i > 0:
            mx = max(point[0:i])
        if i != 0 and mx+1 < point[i]:
            point[i-1] += 1
            point[i] = 0
            break
        chars += List[i][point[i]]
        if i == N-1:
            point[i] += 1
        if point[i] == N:
            flag = 1
        i += 1
    if len(chars) == N:
        print(chars)    

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

using namespace std;

////////////////////////////////////////////////////////////////////////////////////////////////////
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define wt(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define wt(x...)
#endif
/////////////////////////////////////////////////////////////////////////////////////////////////


#define LL long long
const int MAXN = 212345;
const int INF  = 0x3f3f3f3f;




int main () {

	ios_base::sync_with_stdio(false);  cin.tie(NULL); 

	int n, k;
	cin >> n >> k;

	std::vector<int> v(n);
	for (int i = 0; i < n; ++i)
		cin >> v[i];

	int ans = (n - k) / (k - 1) + 1;
	if ( (n - k) % (k - 1) != 0) ++ans;

	cout << ans << '\n';


	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>

int main()
{
	int i, N, A[100001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(A[i]));
	
	int count[100001] = {}, p = (N + 1) % 2;
	for (i = 1; i <= N; i++) count[A[i]]++;
	for (i = 1; i <= N / 2; i++) if (count[i*2-p] != 2) break;
	if (i <= N / 2 || (p == 0 && count[0] != 1)) {
		printf("0\n");
		fflush(stdout);
		return 0;
	}

	long long ans = 1;
	for (i = 1; i <= N / 2; i++) ans = ans * 2 % 1000000007;
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define PRINT(x) cout<<(x)<<endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
#define PB push_back
#define MP make_pair

const int MAX_N = 200009;

ll N;
ll u, v;

int main() {
    cin >> N;
    ll ans = N*(N+1)*(N+2)/6;
    REP(i, N-1) {
        cin >> u >> v;
        if (u > v) swap(u, v);
        ans -= u * (N - v + 1);
    }
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

using ll = long long;
using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    int max = N - (K - 1);
    if (K == 1) {
        cout << "0" << endl;
    }
    else {

    cout << max - 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort.reverse

s = []

m.times do
  if a.empty?
    s << s.shift / 2
    next
  end

  if s.empty?
    s << a.shift / 2
    next
  end

  if s[0] > a[0]
    s << s.shift / 2
  else
    s << a.shift / 2
  end
end

s += a
puts s.inject(:+)

Measured memory_bytes: 11768
#include <cstdio>
#include<math.h>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <stdlib.h>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a>9||b>9||a<0||b<0)cout<<"-1";
	else
		cout<<a*b;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define ll long long
#define eps 1e-7
#define all(x) ((x).begin()),((x).end())
#define usecppio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

#define int ll
int mod=1000000007;
int dp[2020][2020];
ll binom(int n, int r)
{
	return dp[n][r];
}

int32_t main()
{
	usecppio
	int n, k, r;
	cin >> n >> k;
	r = n-k;
	for (int i = 0; i <=2000; i++)
	{
		for (int j = 0; j <= i; j++)
		{
			if (j == 0 || j == i)
			{
				dp[i][j] = 1;
				continue;
			}
			else
			{
				dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j];
				dp[i][j] %= mod;
			}
		}
	}
	for (int i = 1; i<=k; i++)
	{
		int a = binom(r+1,i);
		int b = binom(k-1,i-1);
		cout << a*b%mod << '\n';
	}
}

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

int main() {
    int a,b,ans=-1;
    cin>>a>>b;
    if (a <= 9 && b <= 9) ans = a*b;

    cout<<ans<<endl;
}


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

int main() {
    int N;
    cin >> N;
    int n = N;
    int sum = 0;
    rep(i, 8) {
        sum += n%10;
        n /= 10;
    }
    if ( N % sum == 0) {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
    string s;
    while(cin>>s)
    {

    int res=s.size();
    int a=s.size();
    for(int i=1; i<s.size(); i++)
    {
        if(s[i]!=s[i-1])
            res=min(res,max(i,a-i));
    }
    cout<<res<<endl;
    }
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(s,i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;
  
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> h(n);
    rep(i,n)cin>>h[i];
    
    int dp[100001];
    rep(i,n)dp[i]=1000000000;
    dp[0]=0;
    for(int i=0;i<n;i++){
        for(int j=1;i+j<n &&j<=k;j++){
            dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
        }
    }
    cout<<dp[n-1]<<endl;
    
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include <string>



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


map<string, int> mp;
#define ll long long



int main() {
    int n, m;
    int t[100];
    int c = 0;
    cin >> n;
    rep(i, n) {
        cin >> t[i];
        c += t[i];
    }
    cin >> m;
    rep(i, m) {
        int p, x;
        cin >> p >> x;
        cout << c - t[p-1] + x << endl;
        
    }

    return 0;
}

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

int MOD=1000000007;

int main()
{
    string S,T,s = "~";
    cin >> S >> T;
    int n = S.size();
 
    for(int i=0; i<n-T.size()+1; i++){
        string tmp = S;
        bool ans = true;
        for(int j=i; j<i+T.size(); j++){
            if(tmp[j]!='?' && tmp[j]!=T[j-i])ans = false;
        }
        if(ans==true){
            for(int j=i; j<i+T.size(); j++){
            tmp[j]=T[j-i];
            }
            for(int j=0; j<n; j++){
                if(tmp[j]=='?')tmp[j] = 'a';
            }
            s=min(tmp,s);
        }        
    }
    if(s == "~"){
        cout << "UNRESTORABLE" << endl;
    }else{
        cout << s << endl;
    }
}


Measured memory_bytes: 256
#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;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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 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; }
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; }


double T, X;

int main() {
    while (cin >> T >> X) {
        cout << fixed << setprecision(10) << T/X << endl;
    }
}














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

using namespace std;

int main(void) {
    int N;
    cin >> N;
    map<int,int> mp;
    while(N--) {
        int A;
        cin >> A;
        mp[A]++;
    }

    int k = mp.size();
    if(k%2) {
        cout << k << endl;
    } else {
        cout << k-1 << endl;
    }
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
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; }
using ll=long long;
using namespace std;
int main(){
 string s;
 cin>>s;
 if(s.at(s.size()-1)=='s'){
     cout<<s<<"es"<<endl;
 }
 else{
     cout<<s<<'s'<<endl;
 }
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

// ±a1 ±a2 ... ±anの最大値を考える問題と読み替える。
// ただし、全ての符号が+または-のいずれか一方のみになる形は不可
// したがって、全てのaiが正であれば最も小さい数をマイナスとして考える。
// 全てのaiが負であれば最も大きい値をプラスと考える。
int main(){
    Init();
    ll n; cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));

    ll sum = 0;
    rep(i, n) sum += abs(a[i]);
    // 全て正の場合
    if(a.front() > 0) sum -= 2 * a.front();
    // 全て負の場合
    if(a.back() < 0) sum += 2 * a.back();
    cout << sum << endl;

    ll acc = a.front();
    for(ll i=1; i<n-1; i++){
        if(a[i] >= 0){
            cout << acc << " " << a[i] << endl;
            acc -= a[i];
        }
    }

    cout << a.back() << " " << acc << endl;
    acc = a.back() - acc;

    for(ll i=1; i<n-1; i++){
        if(a[i] < 0){
            cout << acc << " " << a[i] << endl;
            acc -= a[i];
        }
    }
    return 0;
}

Measured memory_bytes: 3952
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#include<stack>
#include<string.h>
#include <iomanip>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
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; }

int main() {
    vector<int> a(5);
    rep(i,5)cin >> a[i];
    vector<int>p = {0,1,2,3,4};
    int ans = 10000;
    do{
        int sum = 0;
        rep(i,5) {
            if(i==4) {
                sum += a[p[i]];
                break;
            }
            sum += (a[p[i]]+9)/10*10;
        }
        ans = min(ans,sum);
    } while(next_permutation(p.begin(),p.end()));
    cout << ans << endl;
}

Measured memory_bytes: 888
#include<stdio.h>

int main(void)

{
	int n, m, l, x[100][100], y[100][100],a,b,k;
	long long int z[100][100];
	scanf("%d %d %d", &n, &m, &l);
	for (a = 0; a < n; a++)
	{
		for (b = 0; b < l; b++)
		{
			z[a][b] = 0;
		}
	}

	for (a = 0; a < n; a++)
	{
		for (b = 0; b < m; b++)
		{
			scanf("%d", &x[a][b]);
		}
	}
	for (a = 0; a < m; a++)
	{
		for (b = 0; b < l; b++)
		{
			scanf("%d", &y[a][b]);
		}
	}
	for (a = 0; a < n; a++)
	{
		for (b = 0; b < l; b++)
		{
			for (k = 0; k < m; k++)
			{
				z[a][b] =z[a][b]+( x[a][k] * y[k][b]);
			}
		}
	}

	for (a = 0; a < n; a++)
	{
		for (b = 0; b < l; b++)
		{
			if (b == l - 1)
			{
				printf("%lld", z[a][b]);
			}
			else
			{
				printf("%lld ", z[a][b]);
			}
		}
		printf("\n");
	}
		return 0;
}


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

int main() {
	int A, B;
	cin >> A >> B;
	int N[10],j,count=0,x;
	for (int i = A; i <= B; i++) {
		j = 0;
		x = i;
		while (true) {
			N[j] = x % 10;
			x /= 10;
			j++;
			if (x == 0) break;
		}
		if (N[0] == N[4] && N[1] == N[3])++count;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1000000000000000000

using namespace std;

int main(void){
  ll x;
  cin >> x;
  
  if (x <= 599)
    cout << 8 << endl;
  else if (x <= 799)
    cout << 7 << endl;
  else if (x <= 999)
    cout << 6 << endl;
  else if (x <= 1199)
    cout << 5 << endl;
  else if (x <= 1399)
    cout << 4 << endl;
  else if (x <= 1599)
    cout << 3 << endl;
  else if (x <= 1799)
    cout << 2 << endl;
  else if (x <= 1999)
    cout << 1 << endl;

  return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int x,k;
    cin>>x>>k;
    vi r(k);
    for(int i=0;i<k;i++) cin>>r[i];
    int q;
    cin>>q;
    int t,a,p=0;
    int L=0,lv=0,rv=x;
    int tp=-1;
    int curt=0;
    for(int i=0;i<q;i++) 
    {
        cin>>t>>a;
        while(p<k&&r[p]<t)
        {
            if(tp==-1)
            {
                if(lv<=r[p]-curt)
                {
                    L+=r[p]-curt-lv;
                    lv=0;
                }
                else
                    lv-=(r[p]-curt);
                rv-=r[p]-curt;
            }
            else{
                rv+=r[p]-curt;
                lv+=r[p]-curt;
            }
            rv=min(max(0,rv),x);
            lv=min(max(0,lv),x);
            tp*=-1;
            curt=r[p];
            p++;
        }
        if(tp==-1)
        {
            if(lv<=t-curt)
            {
                L+=t-curt-lv;
                lv=0;
            }
            else
                lv-=(t-curt);
            rv-=t-curt;
        }
        else{
            rv+=t-curt;
            lv+=t-curt;
        }
        rv=min(max(0,rv),x);
        lv=min(max(0,lv),x);
        curt=t;
        if(a<=L) print(lv);
        else print(min(rv,lv+a-L));
        //dbg(i,L,lv,rv);
    } 
}

Measured memory_bytes: 1664
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
 
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
#define pb push_back
#define popb pop_back
#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en
#define le length()
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
 
#define forz(i, n) for (int i = 0; i < n; i++)
#define bui(i, m, n) for (int i = m; i < n; i++)
#define rforz(i, n) for (int i = n - 1; i >= 0; i--)
#define mui(i, m, n) for (int i = n - 1; i >= m; i--)
#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)
#define lb lower_bound
#define ub upper_bound
#define er equal_range
#define maxe *max_element
#define mine *min_element
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
 
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
 lli power(lli x,lli y,lli p)
{
  lli res=1;
  x=x%p;
  while(y>0)
  {
    if(y&1)
      res=(res*x)%p;
    //y must be even now
    y=y>>1; //y=y/2
    x=(x*x)%p;
  }
  return res;
}
 
lli gcd(lli a, lli b)
{
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
lli lcm(lli a, lli b)
{ return a * b / gcd(a, b); }
lli max(lli a, lli b)
{
  if (a > b)
    return a;
  return b;
}
lli min(lli a, lli b)
{
  if (a < b)
    return a;
  return b;
}
using namespace std;

int main()
{  
    kira;
    //freopen("input.txt","r",stdin);
    int a;
    string s;
    cin>>a>>s;
    if(a>=3200)
      cout<<s<<endl;
    else
      cout<<"red"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    int N;
    std::cin >> N;

    std::vector<int> a(N+1);
    a[0] = 0;
    for (int i = 1; i <= N; i++) {
        std::cin >> a[i];
    }

    int num = 1;
    int count = 0;
    while(1) {
        if (num == 2) {
            std::cout << count << std::endl;
            break;
        }
        if (count > N) {
            std::cout << -1 << std::endl;
            break;
        }
        count++;
        num = a[num];
    }
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>
#include <set>
using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;
ll BASE_NUM = 1000000007;

struct Magic
{
    ll a, b;
};
int main()
{
    // 整数の入力
    ll H, N;
    vector<Magic> A;
    cin >> H >> N;
    vector<vector<ll>> DP(N, vector<ll>(H + 1, BASE_NUM));

    for (int i = 0; i < N; i++)
    {
        Magic m;
        cin >> m.a >> m.b;
        A.push_back(m);
    }
    DP[0][0] = 0;
    for (int i = 0; i < N; i++)
    {
        Magic m = A[i];
        for (int j = 0; j <= H; j++)
        {
            // cout << i << j << endl;
            if (j < m.a)
            {
                if (i == 0)
                {
                    if (j == 0)
                    {
                        DP[i][j] = 0;
                    }
                    else
                    {
                        DP[i][j] = m.b;
                    }
                }
                else
                {
                    DP[i][j] = min(DP[i - 1][j], m.b);
                }
            }
            else
            {
                if (i == 0)
                {
                    DP[i][j] = DP[i][j - m.a] + m.b;
                }
                else
                {
                    DP[i][j] = min(DP[i - 1][j], DP[i][j - m.a] + m.b);
                }
            }
        }
    }
    cout << DP[N - 1][H] << endl;
    return 0;
}


Measured memory_bytes: 78464