akhauriyash/Code-Regression huggingface dataset:
while 1:
    n = int(raw_input())
    if n == 0: break
    ab = [raw_input().split() for i in xrange(n)]
    s = raw_input()
    g = raw_input()
    memo = set([s])
    que = [[s,0]]
    while que:
        c,i = que.pop(0)
        if c == g:
            print i
            break
        for a,b in ab:
            cc = c.replace(a,b)
            if len(cc) > len(g) or cc in memo: continue
            memo.add(cc)
            que.append([cc,i+1])
    else:
        print -1

Measured memory_bytes: 4472
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
#include <queue>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pll=pair<ll,ll>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vstr=vector<string>;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }



void solve() {
    ll A,B;
    cin >> A >> B;
    print(lcm(A,B));


}
 
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}

Measured memory_bytes: 3648
// Problem : 
// 			B - Making Triangle
// 			
// 		
// Contest : AtCoder - AtCoder Beginner Contest 175
// URL : https://atcoder.jp/contests/abc175/tasks/abc175_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// Delete the dynamically allocated memory

#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define pb              push_back
#define pr              pair<long long,long long>
#define mp(a,b)         make_pair(a,b)
#define vr              vector<long long>
#define mod1            1000000007
#define mod2            998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define fill(a,b)       memset(a, b, sizeof(a))
#define mk(arr,n,type)  type *arr=new type[n];
#define ll              long long
#define ld	            long double
#define w(x)            int x; cin>>x; while(x--)
ll power(ll base, ll exp) {
    ll res=1;
    while(exp>0) {
       if(exp%2==1) res=(res*base);
       base=(base*base);
       exp/=2;
    }
    return res;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
	mk(a,n,ll)
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	ll cnt=0;
	for(ll i=0;i<n;i++){
		for(ll j=i+1;j<n;j++){
			for(ll k=j+1;k<n;k++){
				if(a[i]!=a[j]&&a[i]!=a[k]&&a[j]!=a[k]){
					if((a[i]+a[j]>a[k])&&(a[i]+a[k]>a[j])&&(a[k]+a[j]>a[i])){
						cnt++;
					}
				}
			}
		}
	}
	cout<<cnt<<"\n";
	delete[] a;
	return 0;
	}
	
	
	
	
	
	
	



Measured memory_bytes: 3660
/**
 * @author torith
 * @date 2018-10-31
 */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N; cin >> N;

    cout << (ll) ceil((- 1 + sqrt(1 + 8 * N)) / 2)  << "\n";

    return 0;
}



Measured memory_bytes: 256
def solve(n, g):
    mod = 10 ** 9 + 7

    def dfs(v):
        checked[v] = True

        w = 1
        b = 1
        for u in g[v]:
            if checked[u]:
                continue
            uw, ub = dfs(u)
            w = w * (uw + ub) % mod
            b = b * uw % mod
        return w, b

    stack = [0]
    order = []
    parent = [-1] * n
    checked = [False] * n
    checked[0] = True

    while stack:
        v = stack.pop()
        order.append(v)
        for u in g[v]:
            if checked[u]:
                continue
            checked[u] = True
            parent[u] = v
            stack.append(u)

    order.reverse()

    checked = [False] * n

    dp_w = [1] * n
    dp_b = [1] * n

    for v in order:
        checked[v] = True
        par = parent[v]
        if par == -1:
            continue
        dp_w[par] = (dp_w[par] * (dp_w[v] + dp_b[v])) % mod
        dp_b[par] = (dp_b[par] * dp_w[v]) % mod

    v = order[-1]
    return (dp_w[v] + dp_b[v]) % mod


if __name__ == '__main__':
    import sys

    input = sys.stdin.readline

    n = int(input())
    g = tuple(set() for _ in range(n))
    for _ in range(n - 1):
        x, y = (int(j) - 1 for j in input().rstrip().split())
        g[x].add(y)
        g[y].add(x)
    print(solve(n, g))

# 適当な頂点を根とする
# 2次元配列でdpするより、1次元*2本の方が若干速い


Measured memory_bytes: 82208
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()
#define trace(x) cerr<<#x<<" is "<<x<<'\n';

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

void solve()
{
	long double r;
	cin>>r;
	cout<<r*M_PIl*2;
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3808
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >>c;
    int ans = c - (a-b);
    if(ans < 0) ans = 0;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int y, x;
    scanf("%d%d", &y, &x);
    while (y != 0 || x != 0)
    {
        for (int i = 0; i < y; i++)
        {
            for (int j = 0; j < x; j++)
            {
                printf("#");
            }
            printf("\n");
        }printf("\n");
        scanf("%d%d", &y, &x);
    }
    return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
//const int MAX=;

int main(){
	int N,M;
	cin>>N>>M;
	
	int ct[31];
	rep1(i,M)ct[i]=0;
	rep(i,N){
		int K;
		cin>>K;
		rep(j,K){
			int A;
			cin>>A;
			ct[A]++;
		}
	}
	
	int ans=0;
	rep1(i,M)if(ct[i]==N)ans++;
	cout<<ans;
}

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

int w,h,x,y,r;

int main(){
	cin >> w >> h >> x >> y >> r;
	if(x-r<0) cout << "No" << endl;
	else if(x+r>w) cout << "No" << endl;
	else if(y-r<0) cout << "No" << endl;
	else if(y+r>h) cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int a, b;
  string s;
  cin >> a >> s >> b;
  if(s=="+") co(a+b);
  else co(a-b);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define print(a) cout << (a) << endl; 
typedef long long ll;
const int MOD = 1000000007; 


int main() {
    string s;
    cin >> s;
    list<char> ls(s.begin(), s.end());
    int q;
    cin >> q;
    int order = 1;
    rep(i, q) {
        int t;
        cin >> t;
        if (t == 1) order *= -1;
        else {
            int o;
            char p;
            cin >> o >> p;
            if (o == 2) o = -1;
            o *= order;
            if (o == 1) ls.push_front(p);
            else ls.push_back(p);
        }
    } 
    if (order < 0) reverse(ls.begin(), ls.end());
    for (char x : ls) cout << x;
    cout << endl;
    return 0;
}

Measured memory_bytes: 9984
import Foundation

extension String {
    var argi: [Int] { return self.characters.split(" ").map { Int(String($0))! } }
}

let inp = readLine()!.argi

let n = inp[0]
let m = inp[1]

var res = [Int]()
for _ in 0..<n
{
    res.append(0)
}

for _ in 0..<m {
    let inp = readLine()!.argi
    let a = inp[0] - 1
    let b = inp[1] - 1

    res[a] += 1
    res[b] += 1
}

for i in 0..<n {
    print(res[i])
}



Measured memory_bytes: 7016
#include <stdio.h>

int main(void)
{
	int a, b;
	
	scanf("%d %d", &a, &b);
	
	if (a < b) {
		printf("a < b\n");
	}
	
	else if (a > b) {
		printf("a > b\n");
	}
	
	else if (a == b) {
		printf("a == b\n");
	}
	
	return 0;
}

Measured memory_bytes: 580
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const S = arg[0].split("");
    
    let list = {};
    let stringCnt = [...new Set(S)].length;
    let cnt = 0;
    
    if(stringCnt === 1) {
        console.log(0);
        return;
    }
    
    for(let i in S) {
        if(list[S[i]]) {
            list[S[i]]++;
        } else {
            list[S[i]] = 1;
        }
    }
    
    for(let key of Object.keys(list)) {
        let previous = S;
        
        while(stringCnt !== 1) {
            let next = [];
            
            for(let i=0; i<previous.length-1; i++) {
                if(previous[i] === key || previous[~~i+1] === key) {
                    next.push(key);
                } else {
                    next.push(S[i]);
                }
            }
            
            previous  = next.join("");
            stringCnt = [...new Set(previous)].length;
        }
        
        cnt = Math.max(previous.length, cnt);
        
        stringCnt = [...new Set(S)].length;
    }
    
    console.log(S.length - cnt)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21448
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;

int main(){
  
  vector<int> a(9);
  for (int i = 0; i < 9; i++) {
    cin >> a.at(i);
  }
  
  int n;
  cin >> n;
  vector<int> b(n);
  for (int i = 0; i < n; i++) cin >> b.at(i);
  
  vector<bool> c(9, false);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 9; j++) {
      if (b.at(i) == a.at(j)) {
        c.at(j) = true;
      }
    }
  }
  
  if (c.at(0) && c.at(1) && c.at(2)) cout << "Yes";
  else if (c.at(3) && c.at(4) && c.at(5)) cout << "Yes";
  else if (c.at(6) && c.at(7) && c.at(8)) cout << "Yes";
  else if (c.at(0) && c.at(3) && c.at(6)) cout << "Yes";
  else if (c.at(1) && c.at(4) && c.at(7)) cout << "Yes";
  else if (c.at(2) && c.at(5) && c.at(8)) cout << "Yes";
  else if (c.at(0) && c.at(4) && c.at(8)) cout << "Yes";
  else if (c.at(2) && c.at(4) && c.at(6)) cout << "Yes";
  else cout << "No";
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
int main(){
  long n,m,d;
  cin>>n>>m>>d;
  double ans;
  if(d==0){
    ans=(double)(m-1)/n;
  }
  else{
    ans=(double)2*(m-1)*(n-d)/n/n;
  }
  cout << fixed << setprecision(15);
  cout<<ans<<endl;
}



Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    if(n*500>=k){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

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

int main() {
    int n;
    string s;
    cin >> n >> s;

    int ans = 0;
    for (int i = 1; i < n - 1; i++) {
        set<char> l, r;
        rep(j, i) l.insert(s[j]);
        for (int j = i; j < n; j++) r.insert(s[j]);

        int cnt = 0;
        for (auto a : l) {
            for (auto b : r) {
                if (a == b) cnt++;
            }
        }
        ans = max(ans, cnt);
    }

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


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

bool huiwen(char *s,int start,int end)
{

    for(int i=start;start<=end;start++)
    {
       // cout<<s[start]<<" "<<s[end]<<endl;
        if(s[start]!=s[end])
        {
            return false;
        }
        end--;
    }
    return true;
}


int main()
{
    char s[105];
    int n;
    cin>>s;
    n=strlen(s);
    n--;
    if(huiwen(s,0,n)==false)
    {
        cout<<"No";
    }
    else
    {
        if(huiwen(s,0,(n-1)/2)==true)
        {
            if(huiwen(s,(n+3)/2,n)==true)
            {
                cout<<"Yes";
            }
            else
            {
                cout<<"No";
            }
        }
        else
        {
            cout<<"No";
        }
    }

}


Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

fn main() {
    input! {
        k: i32,
        x: i32,
    }
    if 500 * k >= x {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 2100
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>

using ll = long long;

int ans = 0;
int N;

bool check(ll n) {
    int c1 = 0, c2 = 0, c3 = 0;
    while (n > 0) {
        int c = n % 10;
        n /= 10;
        if (c == 3)c1++;
        else if (c == 5)c2++;
        else if (c == 7)c3++;
    }
    return(c1 > 0 && c2 > 0 && c3 > 0);
}

void dfs(ll n) {
    if (!(n <= N))return;
    if (check(n))
        ans++;
    n *= 10;
    dfs(n + 3);
    dfs(n + 5);
    dfs(n + 7);
}

int main() {
    std::cin >> N;
    dfs(0);
    std::cout << ans << std::endl;
}


Measured memory_bytes: 384
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)


def main():
	s = input()
	a = []
	b = []
	for i in range(len(s)//2):
		a.append('1')
		a.append('0')
		b.append('0')
		b.append('1')
	if(len(s)%2==1):
		a.append('1')
		b.append('0')
	ac = 0
	bc = 0
	for i in range(len(s)):
		if(a[i] != s[i]):
			ac+=1
		if(b[i] != s[i]):
			bc+=1
	print(min(ac,bc))

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()

Measured memory_bytes: 76780
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
using namespace std;
#define ll long long
#define rep(i, s, n) for(int i = s; i < n; i++) 

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    vector<ll> b(n);
    vector<ll> c(n);
    
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n) cin >> b[i];
    rep(i, 0, n) cin >> c[i];

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    ll ans = 0;
    rep(i, 0, n) {
        ll value = b[i];
        ll a_num = lower_bound(a.begin(), a.end(), value)-a.begin();
        ll c_num = c.end()-upper_bound(c.begin(), c.end(), value);
        ans += a_num*c_num;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;

int main() {
string s;
cin>>s;
stack<int> ss;

rep(i,s.size()){
    if(s[i]=='B'){
        if(!ss.empty()){
            ss.pop();
        }
    }else{
        ss.push(s[i]-'0');
    }
}

vector<int> v;
while(!ss.empty()){
    v.push_back(ss.top());
    ss.pop();
}
reverse(v.begin(),v.end());
rep(i,v.size()){
    cout<<v[i];
}
cout<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int a,b,c,d,x,y;
    cin>>a>>b>>c>>d;
    x=c/b;
    if(c%b!=0)
        x++;
    y=a/d;
    if(a%d!=0)
        y++;
    if(x<=y)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3592
// c++ cpp.cpp -o cpp.exe -std=c++14

#include <iostream>
#include <vector>
using namespace std;

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

class Dice
{
    int faces[6];

  public:
    int top, front, right, left, back, bottom;
    void in()
    {
        rep(i, sizeof(faces) / sizeof(int))
        {
            cin >> faces[i];
        }
        top = faces[0];
        front = faces[1];
        right = faces[2];
        left = faces[3];
        back = faces[4];
        bottom = faces[5];
    }

    void rotate(char command)
    {
        int pre_top = top;
        switch (command)
        {
        case 'N':
            top = front;
            front = bottom;
            bottom = back;
            back = pre_top;
            break;
        case 'E':
            top = left;
            left = bottom;
            bottom = right;
            right = pre_top;
            break;
        case 'W':
            top = right;
            right = bottom;
            bottom = left;
            left = pre_top;
            break;
        case 'S':
            top = back;
            back = bottom;
            bottom = front;
            front = pre_top;
            break;
        case 'R':
            int pre_front = front;
            front = left;
            left = back;
            back = right;
            right = pre_front;
            break;
        }
    }
};

int main()
{
    int n;
    cin >> n;
    vector<Dice> dices(n);
    rep(i, n)
    {
        dices[i].in();
    }

    rep(a, dices.size())
    {
        rep(b, a)
        {
            Dice dice_x = dices[a];
            Dice dice_y = dices[b];

            rep(i, 4)
            {
                dice_x.rotate('N');
                rep(j, 4)
                {
                    dice_x.rotate('E');
                    rep(k, 4)
                    {
                        dice_x.rotate('R');
                        if (dice_x.top != dice_y.top)
                        {
                        }
                        else if (dice_x.bottom != dice_y.bottom)
                        {
                        }
                        else if (dice_x.left != dice_y.left)
                        {
                        }
                        else if (dice_x.right != dice_y.right)
                        {
                        }
                        else if (dice_x.front != dice_y.front)
                        {
                        }
                        else if (dice_x.back != dice_y.back)
                        {
                        }
                        else
                        {
                            cout << "No" << endl;
                            return 0;
                        }
                    }
                }
            }
        }
    }
    cout << "Yes" << endl;
}



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

int main(void){
    string s,t; cin >> s >> t;
    sort(s.begin(),s.end());
    sort(t.rbegin(),t.rend());
    if(s < t) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include<string.h>
int main(){
    
   char s[1005];
   scanf("%s", s);
   if(s[strlen(s) - 1] == 's'){
       printf("%ses", s);
   }
   else{
       printf("%ss", s);
   }
}

Measured memory_bytes: 1732
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.IOException;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
        String[] st = br.readLine().split(" ");
        int n = Integer.parseInt(st[0]);
        int m = Integer.parseInt(st[1]);
        int[][] matrix = new int[n][m];
        for (int i = 0; i < n; i++) {
            st = br.readLine().split(" ");
            for (int j = 0; j < m; j++) {
                matrix[i][j] = Integer.parseInt(st[j]);
            }
        }
        int[] mul = new int[m];
        for (int i = 0; i < m; i++) {
            mul[i] = Integer.parseInt(br.readLine());
        }
        // calculate
        for (int i = 0; i < n; i++) {
            int sum = 0;
            for (int j = 0; j < m; j++) {
                sum += matrix[i][j] * mul[j];
            }
            bw.append(sum + "\n");
        }


        bw.flush();
    }
}


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

int main() {
  vector<char> v(3);
  int a,b;
  for (int i=0; i<3; i++) {
    cin >> v.at(i);
    if (v.at(i) == 'R') {
      a++;
      b++;
    } else {
      a = 0;
    }
  }
  if (v.at(0) == 'R' && v.at(1) == 'S') {
    cout << 1;
    exit(0);
  }
  if (a > b) {
    cout << a;
  } else {
    cout << b;
  }
}

Measured memory_bytes: 3600
import java.util.Scanner;
public class Main {

@SuppressWarnings("resource")
public static void main(String[] args) {
	Scanner sc =new Scanner(System.in);
	int N=sc.nextInt();
	long sum=0;
	for(int i=1;i<=N;i++) {
		if(i%3!=0&&i%5!=0) {
			sum+=i;
		}
	}
	System.out.println(sum);
	}
}


Measured memory_bytes: 35792
#include <iostream>

using namespace std;

int n,gx,gy;//秘密の場所ｇｘｇｙ
int matatabi[110][4];//またたびの座標
int num_m;//またたびのカズ

int ans(int x,int y){
  if (x<0||y<0)
  {
    return 0;
  }
  if (x==0 && y==0)
  {
    return 1;
  }
  bool flag1=true;
  bool flag2=true;
  for (int i = 0; i < num_m; ++i)
  {
    if((matatabi[i][0]==x-1 && matatabi[i][1]==y &&matatabi[i][2]== x &&matatabi[i][3]== y)||(matatabi[i][2]==x-1 && matatabi[i][3]==y &&matatabi[i][0]== x &&matatabi[i][1]== y))flag1=false;
    if((matatabi[i][0]==x && matatabi[i][1]==y-1 &&matatabi[i][2]== x &&matatabi[i][3]== y)||(matatabi[i][2]==x && matatabi[i][3]==y-1 &&matatabi[i][0]== x &&matatabi[i][1]== y)) flag2=false;
  }
  if (flag1 == true && flag2==true)
  {
    return ans(x,y-1)+ans(x-1,y);
  }
  if (flag1 == false && flag2==false)
  {
    return 0;
  }
  if (flag1==false)
  {
    return ans(x,y-1);
  }else{
    return ans(x-1,y);
  }

}
int main(){
  cin >> n;
  for (int i = 0; i < n; ++i)
  {
    cin >> gx >> gy;
    cin >> num_m;
    for (int j = 0; j < num_m; ++j)
    {
      cin >> matatabi[j][0]>>matatabi[j][1]>>matatabi[j][2]>>matatabi[j][3];
    }
    if (ans(gx,gy)!=0)
    {
      cout << ans(gx,gy) <<endl;
    }else
    {
      cout <<"Miserable Hokusai!" <<endl;
    }
  }

}

Measured memory_bytes: 1160
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>

#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	int n,maxi = 0,sum = 0;
	cin >> n;

	for (int i = 0; i < n; i++) {
		int l;
		cin >> l;
		CHMAX(maxi,l);
		sum += l;
	}

	if (sum > maxi * 2) {
		COUT("Yes");
	}
	else {
		COUT("No");
	}


	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
  int i,j,len;
  char s[120],t[120],temp;
  scanf("%s",s );
  scanf("%s",t );
  len=strlen(s);
  for(i=0;i<len;i++){
    for(j=0;j<len-1;j++){
    temp=s[j];
    s[j]=s[j+1];
    s[j+1]=temp;
  }
  if (strcmp(s,t)==0) {
    printf("Yes" );
    return 0;
  }
}
printf("No" );
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define mod 1000000007
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll power(ll a,ll b){
	ll ans=1;
	while(b>0){
		if(b%2!=0){
			ans=(ans*a)%mod;
		}
		a=(a*a)%mod;
		b>>=1;
	}
	return ans;
}
ll check(ll a[],ll m,ll n){
	ll b[n];
	for(int i=0;i<n;i++){
		b[i]=a[i]%m;
	}
	sort(b,b+n);
	ll cnt=0;
	int i=0,j=n-1;
	while(i<j){
		if(b[i]==0){
			i++;
			continue;
		}
		if(b[j]==0){
			j--;
			continue;
		}
		int lo=min(b[i],m-b[j]);
		cnt+=lo;
		b[i]-=lo;
		b[j]+=lo;
		b[i]%=m;
		b[j]%=m;
	}
	for(int i=0;i<n;i++){
		if(b[i]!=0)
		return 1e18;
	}
	return cnt;
}

int main() {
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		ll n,k;
		cin>>n>>k;
		ll s=0;
		ll a[n];
		for(ll i=0;i<n;i++){
			cin>>a[i];
			s+=a[i];
		}
		vector<ll> v;
		for(ll i=1;i*i<=s;i++){
			if(s%i!=0)
			continue;
			v.push_back(i);
			if(i*i!=s)
			v.push_back(s/i);
		}
		sort(v.begin(),v.end(),greater<ll>());
		for(int i=0;i<v.size();i++){
			ll z=check(a,v[i],n);
			if(z<=k){
				cout<<v[i];
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

n=I()
lis=[[]for i in range(n)]
lis[0].append([1])
for i in range(n-1):
    for j in lis[i]:
        for m in range(max(j)+1):
            lis[i+1].append(j+[m+1])
        #print(max(j))
#print(lis[n-1])
alpha=["a","b","c","d","e","f","g","h","i","j"]
for u in lis[n-1]:
    ans=""
    for j in u:
        ans+=alpha[j-1]
    print(ans)

Measured memory_bytes: 77148
W, H, N = map(int, input().split())
paint_dot = {}
for _ in range(N):
  t1, t2, t3 = map(int,input().split())
  paint_dot[(t1, t2)] = t3

mat = [[1]*W for i in range(H)]

for key in paint_dot:
  x = paint_dot[key]
  if x == 1:
    for row in mat:
      for i in range(key[0]):
        row[i] = 0    
  elif x == 2:    
    for row in mat:
      for i in range(key[0], W):
        row[i] = 0
  elif x == 3:
    for i in range(key[1]):
      for j in range(W):
      	mat[i][j] = 0
  else:
    for i in range(key[1], H):
      for j in range(W):
      	mat[i][j] = 0

#print(mat)
print(sum(map(sum,mat)))
        

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String input = br.readLine();
        String[] strArray = input.split(" ");

        int r = Integer.parseInt(strArray[0]);  //???r
        int c = Integer.parseInt(strArray[1]);  //???c

        int[][] table = new int[r+1][c+1];

//      ??????A???????????????
        for(int i = 0; i < r; i++){
            input = br.readLine();
            strArray = input.split(" ");

            for(int j = 0; j < c; j++){
                table[i][j] = Integer.parseInt(strArray[j]);
            }
        }

//      ???????????????????????¨??????????????????????¨????????±???????
        for(int i = 0; i < r; i++){
            int sum = 0;

            for(int j = 0; j < c; j++){
                sum += table[i][j];
            }
            table[i][c] = sum;
        }

//      ???????????????????????¨??????????????????????¨????????±???????
//      ?????????????¨??????§?????????????????????????¨??????????????????§???
//      i????????????c+1??¨?????????
        for(int i = 0; i < c+1; i++){
            int sum = 0;

            for(int j = 0; j < r; j++){
                sum += table[j][i];
            }
            table[r][i] = sum;
        }

//      (r+1) ?? (c+1) ?????°????????¨?????????
        for(int i = 0; i < r+1; i++){

            for(int j = 0; j < c+1; j++){
                System.out.print(table[i][j]);

                if(j != c){
                    System.out.print(" ");
                }else{
                    System.out.print("\n");
                }
            }
        }
    }
}

Measured memory_bytes: 33728
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
using namespace std;
#define int long long
int let[30];
signed main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		let[s[i] - 'a']++;
	}
	int n = s.size();
	int ans = (n - 1)*n / 2;
	ans++;
	for (int i = 0; i < 26; i++) {
		ans -= (let[i] * (let[i] - 1) / 2);
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    private static int helper(int pos, int cnt, int tight, int k, int[][][] dp, List<BigInteger> nums) {
        if (pos == nums.size()) {
            if (cnt == k) {
                return 1;
            } else {
                return 0;
            }
        } else if (dp[pos][cnt][tight] != -1) {
            return dp[pos][cnt][tight];
        }

        int res = 0;
        BigInteger limit = (tight != 0 ? BigInteger.valueOf(9) : nums.get(pos));

        for (int dig = 0; limit.compareTo(BigInteger.valueOf(dig)) >= 0; dig++) {
            int currCnt = cnt;
            if (dig != 0)
                currCnt++;
            int currTight = tight;
            if (nums.get(pos).compareTo(BigInteger.valueOf(dig)) > 0)
                currTight = 1;
            res += helper(pos + 1, currCnt, currTight, k, dp, nums);
        }
        dp[pos][cnt][tight] = res;
        return res;
    }

    private static int countUntil(BigInteger n, int k) {
        final int M = 100;
        int dp[][][] = new int[M][M][2];

        List<BigInteger> nums = new ArrayList<>();
        while (n.intValue() != 0) {
            nums.add(n.mod(BigInteger.TEN));
            n = n.divide(BigInteger.TEN);
        }
        Collections.reverse(nums);

        for (int i = 0; i < M; i++)
            for (int j = 0; j < M; j++)
                for (int h = 0; h < 2; h++)
                    dp[i][j][h] = -1;
        return helper(0, 0, 0, k, dp, nums);
    }

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

        System.out.println(countUntil(n, k));
    }
}

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

int main() {
  int N,W;
  cin >> N;
  int S = N;
  for(; N>0; N /= 10){
    W += N%10;
  }
  if(S%W == 0){
    cout << "Yes" << endl;
  return 0;
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3592
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)

int main(void){
  int n;
  while(cin>>n){
    if(n==0) break;
    int mid = (n-1)/2;
    int grid[15][15] = {0};
    int x=mid; int y=mid+1;
    grid[y][x] = 1;
    for(int i=2; i<=n*n; i++){
      x++,y++;
      if(x<0) x = n-1;
      if(x>=n) x = 0;
      if(y>=n) y = 0;
      while(grid[y][x]!=0){
        x--,y++;
        if(x<0) x = n-1;
        if(x>=n) x = 0;
        if(y>=n) y = 0;
      }
      grid[y][x] = i;
    }
    REP(y,n){
      REP(x,n){
        printf("%4d",grid[y][x]);
      }
      cout<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#!/usr/bin/env python3

#import
#import math
#import numpy as np
H, W = map(int, input().split())
A = [list(input()) for _ in range(H)]

def mod(num):
    return num % (10 ** 9 + 7)
    
dp = [[0] * W for _ in range(H)]

for i in range(H):
    for j in range(W):
        if i == 0 and j == 0:
            dp[i][j] = 1
            continue

        if A[i][j] == "#":
            continue

        if i == 0:
            dp[i][j] = dp[i][j - 1]
        elif j == 0:
            dp[i][j] = dp[i - 1][j]
        else:
            dp[i][j] = mod(dp[i - 1][j] + dp[i][j - 1])
            
print(dp[-1][-1])


Measured memory_bytes: 117096
while n=gets
 a,b,c,d,e,f=n.chomp.split
 a,b,c,d,e,f=a.to_i,b.to_i,c.to_i,d.to_i,e.to_i,f.to_i
 if f>=c
  x=f-c
   if e>=b
    y=e-b
    z=d-a
   else
    y=60+e-b
    z=d-1-a
   end
 else
  x=60+f-c
   if e-1>=b
    y=e-1-b
    z=d-a
   else
    y=59+e-b
    z=d-1-a
   end
 end
puts z.to_s+' '+y.to_s+' '+x.to_s
end

Measured memory_bytes: 6104
#include<stdio.h>

int main(void){
  int N,K;
  scanf("%d%d",&N,&K);
  int P[N];
  int count = 0;
  for(int i = 0;i < N;i++)
    scanf("%d",&P[i]);
  for(int i = 0;i < N;i++){
    if(P[i] >= K)
      count++;
  }
  printf("%d",count);
  return 0;
}


Measured memory_bytes: 512
/*input

2
0
10
20
30
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

ll ans=1;
vector<pii> v;
int b[maxn],r[maxn];
int main(){
	IOS;
	int n;
	cin>>n;
	REP(i,n) cin>>r[i];
	REP(i,n) cin>>b[i];
	sort(r,r+n);
	sort(b,b+n);

	ll cur=0;
	REP(i,n) v.pb(MP(r[i],-1));
	REP(i,n) v.pb(MP(b[i],1));

	sort(ALL(v));

	REP(i,n+n){
		if(v[i].S==-1){
			if(cur<=0) cur--;
			else{
				ans=ans*cur%MOD;
				cur--;
			} 
		}
		else{
			if(cur>=0) cur++;
			else{
				ans=ans*(-cur)%MOD;
				cur++;
			}
		}
	}
	cout<<ans<<'\n';

	return 0;
}


Measured memory_bytes: 3188
require 'bigdecimal/math'

N, K = gets.split.map {|e| BigDecimal e }
tmp = 0

1.upto([N, K - 1].min) do |i|
  tmp += 0.5 ** (Math.log2(K / i)).ceil
end

puts ((tmp + [(N - K + 1), 0].max) / N).to_s 'F'

Measured memory_bytes: 2044
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int m, k;
    std::cin >> m >> k;
    if (k == 0) {
        for (int i = 0; i < (1 << m); i++) std::cout << i << " ";
        for (int i = (1 << m) - 1; i >= 0; i--) std::cout << i << " ";
        std::cout << std::endl;
        return 0;
    }
    int x = 0;
    for (int i = 0; i < (1 << m); i++) {
        if (i != k) x ^= i;
    }
    if (x != k) {
        std::cout << -1 << std::endl;
        return 0;
    }

    std::cout << k << " ";
    for (int i = 0; i < (1 << m); i++) {
        if (i != k) std::cout << i << " ";
    }
    std::cout << k << " ";
    for (int i = (1 << m) - 1; i >= 0; i--) {
        if (i != k) std::cout << i << " ";
    }
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep_lr(i,l,r) for(int i=(l);i<(r);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<double, int, int> T;
constexpr int INF = INT_MAX >> 1;
constexpr ll LINF = 5000000000000000LL;
constexpr int MOD = 1000000007;

int main() {

	int n, m;
	cin >> n >> m;
	int L = -INF, R = INF;
	rep(i, m) {
		int l, r;
		cin >> l >> r;
		L = max(L, l);
		R = min(R, r);
	}
	cout << max(0, R - L + 1) << endl;
}

Measured memory_bytes: 3592
#include <iostream>
using namespace std;
int main(void){
    int n,sum=0,ans=0;
    string s;
    cin >>n >>s;
    for(int i=0;i<n;i++){
        if(s[i]=='I'){
            sum++;
        }    
        else sum--;
    
        if(sum>ans) 
        ans=sum;
    }    
    cout <<ans;

    return 0;
}

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

using namespace std;

int main() {

	int N;
	cin >> N;
	int a;
	int j1 = 0, j2 = 0, j4 = 0;
	for (int i = 0; i < N; i++) {
		cin >> a;
		if (a % 4 == 0) j4++;
		if (a % 4 == 2) j2++;
		if (a % 2 == 1) j1++;
	}
	if (j1 <= j4 || (j1 == j4 + 1 && j2 == 0)) {
		cout << "Yes" << endl;
		return 0;
	}
	else {
		cout << "No" << endl;
		return 0;
	}


	}
	

Measured memory_bytes: 256
K, X = input().split(' ')
K, X = int(K), int(X)

min_val = X-K+1
max_val = K+X-1

min_val = -1000000 if min_val < -1000000 else min_val
max_val = +1000000 if max_val > +1000000 else max_val

for val in range(min_val, max_val+1):
	if val == max_val:
		print(val)
	else:
		print(val, end=' ')

Measured memory_bytes: 3064
// E.cpp
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 440, mod = 998244353;

int n, ai[MAX_N], bi[MAX_N], sa, sb, inv[MAX_N], fac[MAX_N], dp[2][MAX_N][MAX_N];

int fpow(int bas, int tim)
{
	int ret = 1;
	while (tim)
	{
		if (tim & 1)
			ret = 1LL * ret * bas % mod;
		bas = 1LL * bas * bas % mod;
		tim >>= 1;
	}
	return ret;
}

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d%d", &ai[i], &bi[i]), sa += ai[i], sb += bi[i];
	inv[0] = inv[1] = 1;
	for (int i = 2; i < MAX_N; i++)
		inv[i] = 1LL * (mod - mod / i) * inv[mod % i] % mod;
	for (int i = fac[0] = 1; i < MAX_N; i++)
		fac[i] = 1LL * fac[i - 1] * i % mod;
	for (int i = 1; i < MAX_N; i++)
		inv[i] = 1LL * inv[i] * inv[i - 1] % mod;
	
	int b = 0;
	dp[0][0][0] = mod - 1;
	for (int i = 1; i <= n; i++)
	{
		b ^= 1;
		for (int s = 0; s <= sa; s++)
			for (int c = 0; c <= sb; c++)
			{
				dp[b][s][c] = dp[!b][s][c];
				if (s < ai[i])
					continue;
				for (int idx = 0, acc = 1; idx < bi[i] && idx <= c; idx++, acc = 1LL * acc * ai[i] % mod)
					dp[b][s][c] = (0LL + dp[b][s][c] + mod - 1LL * acc * inv[idx] % mod * dp[!b][s - ai[i]][c - idx] % mod) % mod;
			}
	}
	int ans = 0;
	for (int s = 0; s <= sa; s++)
	{
		int unit = fpow(s, mod - 2);
		for (int idx = 0, acc = unit; idx <= sb; idx++, acc = 1LL * acc * unit % mod)
			ans = (0LL + ans + 1LL * fac[idx] * acc % mod * dp[b][s][idx] % mod) % mod;
	}
	ans = 1LL * ans * sa % mod, printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 5192
#include <algorithm>
#include <iostream>
#include <math.h>
using namespace std;
void trace(int N, int A[]) {
    for(int i = 0; i < N; i++) {
        if(i >= 1) {
            cout << " ";
        }
        cout << A[i];
    }
    cout << endl;
}

void swap(int a[], int n1, int n2) {
    int temp = a[n1];
    a[n1] = a[n2];
    a[n2] = temp;
}

int main(){
    int n,count=0;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<n;i++){
        int minj=i;
        for(int j =i;j<n;j++){
            if(a[minj]>a[j]){
                minj=j;
            }
        }
        if(minj != i){
            swap(a,minj,i);
            count++;
        }
    }
    trace(n,a);
    cout << count << endl;
}


Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#define INT long long int
#define MOD 1000000007
#define oo 978654321
#define OO 9999999987654321ll
using namespace std;
INT n, a, b, d, s[100010];
bool poss(INT x)
{
    INT y = x*b, cnt = 0;
    for(int i = 0 ; i < n ; i++ )
        if( s[i] > y ) cnt += (y-s[i])/d + (bool)((y-s[i])%d);
    return cnt <= x;
}
int main()
{
    ios::sync_with_stdio(false);
    cin>>n>>a>>b; d = b-a;
    for(int i = 0 ; i < n ; i++ ) cin>>s[i];
    sort(s, s+n);
    INT lb = 0, ub = 1000000001;
    while( lb < ub )
    {
        INT m = (lb + ub - 1)/2;
        if( poss(m) ) ub = m;
        else lb = m+1;
    }
    cout<<ub<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define the_flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
 
using namespace std;
 
int main()
{
    the_flash;
    int n, x, t;
    cin >> n >> x >> t;
    
    cout << (int)(ceil(n / (double)x) * t) << "\n";
    return 0;
}


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

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

ll lcm(ll a, ll b){
  return a/gcd(a,b) * b;
}
ll func2(ll n){
  ll res = 0;
  while(n%2 == 0){
    n /= 2;
    res++;
  }
  return res;
}

ll zyou(ll a,ll b){//a＾b
  ll res = 1;
  for(int i = 1;i<=b;i++){
    res *= a;
  }
  return res;
}
struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t),weight(w){ }
};

typedef pair<int,int> P;
using Graph = vector<vector<Edge>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}



bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int dfs(int x,int y,int H,int W,vector<vector<char>> &masu){
  if(masu[x][y] == '#'){

  }
}
bool palin(string S){
  int n = S.size();
  bool flag = true;
  if(n%2 == 0){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  else if(n%2 == 1){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  return flag;
}
int main(){
  int H,W;
  cin >> H >> W;
  vector<vector<int>> masu(H, vector<int>(W));
  rep(i,H){
    rep(j,W){
      cin >> masu[i][j];
    }
  }
  vector<vector<int>> ans(250000);
  int c = 0;
  rep(i,H){
    rep(j,W){
      if(i != H-1){
        if(masu[i][j]%2){
          masu[i+1][j]++;
          
          ans[c].push_back(i+1);
          ans[c].push_back(j+1);
          ans[c].push_back(i+2);
          ans[c].push_back(j+1);
          c++;
        }
      }
      else if(i == H-1){
        if(j == W-1) break;
        
        else if(masu[i][j]%2){
          masu[i][j+1]++;
          
          ans[c].push_back(i+1);
          ans[c].push_back(j+1);
          ans[c].push_back(i+1);
          ans[c].push_back(j+2);
          c++;
        }
      }
    }
  }
  cout << c << endl;
  rep(i,c){
    rep(j,4){
      if(j <3){
       cout << ans[i][j] << " ";
      }
      else cout << ans[i][j] << endl;
    }
  }
}

Measured memory_bytes: 12928
n = int(input())
mod = int(1e9+7)
dp = [[0 for i in range(4)]for k in range(n+1)] #ACGTの順
for i in range(4):
    dp[1][i] = 1
    dp[2][i] = 4
dp[3][0] = 16
dp[3][1] = 14
dp[3][2] = 15
dp[3][3] = 16
for i in range(4,n+1):
    for k in range(4):
        dp[i][k] = sum(dp[i-1])%mod
    dp[i][1] = dp[i][1] - (dp[i-2][0] + dp[i-2][2]) - dp[i-3][0]*3
    dp[i][2] = dp[i][2] - dp[i-2][0] + dp[i-3][2]
print(sum(dp[n])%mod)

Measured memory_bytes: 3064