akhauriyash/Code-Regression huggingface dataset:
# AOJ 0191: Baby Tree
# Python3 2018.6.20 bal4u

while True:
	n, m = list(map(int, input().split()))
	if n == 0: break
	d =  [[0.0 for j in range(n)] for i in range(n)]
	for i in range(n): d[i] = list(map(float, input().split()))
	dp =  [[0.0 for j in range(n)] for k in range(m)]
	for i in range(n): dp[0][i] = 1
	for k in range(1, m):
		for i in range(n):
			for j in range(n):
				dp[k][j] = max(dp[k][j], dp[k-1][i]*d[i][j])
	ans = 0
	for i in range(n):
		if dp[m-1][i] > ans: ans = dp[m-1][i]
	print(format(ans, ".2f"))



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

int main(){
	int n;
	cin>>n;
	int temp;
	vector<double> inva(n);
	for (int i = 0; i < n; i++) {
		cin>>temp;
		inva[i]=1.0/temp;
	}
	float sum=0;
	for (int i = 0; i < n; i++) {
		sum+=inva[i];
	}
	cout<<1.0/sum<<endl;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> inline T bis(T ok, T ng, function<bool(T)> f, T eps = 1) { while (abs(ok - ng) > eps) { T mi = (ok + ng) / 2; (f(mi) ? ok : ng) = mi; } return ok; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n, m;
  cin >> n >> m;
  vi32 a(n);
  cin >> a;
  rep(i, n) a[i] /= 2;
  int l = 0;
  rep(i, n) l = lcm(l, a[i]);
  rep(i, n) {
    if ((l / a[i]) % 2 == 0) {
      cout << 0 << endl;
      return;
    }
  }
  cout << (m + l) / (2 * l) << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int k,n;
  cin>>k>>n;
  if(k%2==0){
    cout<<k/2;
    for(Int i=1;i<n;i++) cout<<" "<<k;
    cout<<endl;
    return 0;
  }
  if(n==1){
    cout<<(k+1)/2<<endl;
    return 0;
  }
  if(k==1){
    for(Int i=0;i<(n+1)/2;i++){
      if(i) cout<<" ";
      cout<<1;
    }
    cout<<endl;
    return 0;
  }
  Int x=n-1,s=1;
  while(x>=s){
    x--;
    s=s*k+1;
  }
  vector<Int> ans(x,(k+1)/2);
  Int z=(s*k+x-1)/2-x;
  //cout<<x<<" "<<s<<" "<<z<<endl;
  while(1){
    //cout<<z<<" "<<s<<endl;
    Int y=z/s;
    ans.emplace_back(y+1);
    z-=y*s;

    if(!z) break;
    s=(s-1)/k;
    z--;
  }
  //while(!ans.back()) ans.pop_back();
  for(Int i=0;i<(Int)ans.size();i++){
    if(i) cout<<" ";
    cout<<ans[i];
  }
  cout<<endl;
  return 0;
}


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

using namespace std;
#define MOD 1000000007
#define pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062
#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define popb pop_back()
#define popf pop_front()
#define ff first
#define ss second
#define vl vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vll vector< pair<ll,ll> >
#define vii vector< pair<int,int> >
#define viii vector< tuple <int,int,int> >
#define vlll vector< tuple <ll,ll,ll> >
#define vvl vector<vector<ll>>
#define vv vector<vector<int>>
#define all(v) v.begin(),v.end()
#define sqrt sqrtl
#define cbrt cbrtl
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mapcl map<char,ll>
#define mapci map<char,int>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define seti set<int>
ifstream fin("input.txt");
ofstream fout("output.txt");
#define FOR(i, l, r) for (int i = int(l); i < int(r); ++i)

int gcd(int a,int b){while (a&&b)a>b?a%=b:b%=a;return a+b;}
ll pows(int a , int b){ll res=1;for(int i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}

vi vis(100001,0);
vi adj[100001];

int main()
{	
    std::ios::sync_with_stdio(false);
    //cin.tie(NULL);
    //cout.tie(NULL);
    int cnt=0;
    int n;
    cin>>n;
    vi vec;
    FOR(i,0,n)
    {
    	int x;
    	cin>>x;
    	vec.pb(x);
    }
    FOR(i,1,n-1)
    {
    	if(vec[i]>vec[i-1] && vec[i+1]>vec[i])
    		++cnt;
    	else if(vec[i]<vec[i-1] && vec[i]>vec[i+1])
    		++cnt;
    }
    cout<<cnt<<"\n";

}

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

using pii = pair<int,int>;
using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream& operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream& operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;


class Solver {
  public:
    bool solve() {
        int H, W; cin >> H >> W;
        vector<string> S(H); cin >> S;
        map<char, int> cnt;
        rep(i, H) rep(j, W) cnt[S[i][j]]++;

        vector<char> components;
        vector<char> others;
        int need = (H / 2) * (W / 2);
        for(auto &p : cnt) {
            while(p.second >= 4 and need > 0) {
                p.second -= 4;
                components.push_back(p.first);
                need--;
            }
        }
        if(need > 0) {
            cout << "No" << endl;
            return 0;
        }
        need = 0;
        if(H % 2) need += W / 2;
        if(W % 2) need += H / 2;
        for(auto &p : cnt) {
            while(p.second >= 2 and need > 0) {
                p.second -= 2;
                need--;
            }
        }
        cout << (need > 0 ? "No" : "Yes") << endl;

        return 0;
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Solver s;
    s.solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

ll gcd_euclid(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r; /* swap */
  }
  return u;
}

int main() {
    int t;
    cin >> t;
    while(t--){
        ll a,b,c,d;
        cin >> a >> b >> c >> d;
        if(b>a){
            cout << "No" << endl;
            continue;
        }
        if(b>d){
            cout << "No" << endl;
            continue;
        }
        if(c>=b){
            cout << "Yes" << endl;
            continue;
        }
        ll g=gcd_euclid(b,d);
        if(b-g+a%g>c){
            cout << "No" << endl;
        }
        else cout << "Yes" << endl;

    }


    
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<unordered_set>
#include<set>
#include<unordered_map>
#include<map>
#include<queue>
#include<stack>
using namespace std;
int main(){
    int a, b;
    cin >> a >> b;
    cout<< 6 - a - b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj),rend(obj)
typedef long long int ll;
typedef long double ld;
const ll INF = (1 << 30);
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
    fill((T*)array, (T*)(array + N), val);
}int a[100010],L[100010],n;
int LIS() {
    L[0] = a[0]; int le = 1;
    rep(i, n) {
        if (L[le - 1] < a[i]) L[le++] = a[i];
        else *lower_bound(L, L + le, a[i]) = a[i];
    }return le;
}
int main() {
    cin >> n;
    rep(i, n) cin >> a[i];
    cout << LIS() << endl;
}


Measured memory_bytes: 3788
#include<stdio.h>
#pragma warning (disable:4996)
int main()
{
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	int min = 0;
	if (a*b > c)min = c;
	else min = a*b;
	printf("%d", min);
}

Measured memory_bytes: 128
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;

int main(void)
{
	int A, B, K;
	cin >> A >> B >> K;

	vector<int> v;
	for (int i = 1; i <= max(A, B); i++) {
		if ((A%i == 0) && (B%i == 0))
			v.push_back(i);
	}

	reverse(v.begin(), v.end());

	cout << v[K - 1] << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
const int INF = 100000000;
using namespace std;
int solve(int a, int b, int c) {
    int now = 0;
    rep(i,1000000){
        rep(j,a){
            now++;
            if(now % 60 == c){
                return now;
            }
        }
        rep(j,b){
            now++;
        }
    }
    return -1;
}

int main(){
    int a, b ,c;
    cin >> a >> b >> c;
    

    cout << solve(a,b,c) << endl; 
}

Measured memory_bytes: 3116
# ABC129D - Lamp
import sys
input = sys.stdin.readline

def main():
    H, W = tuple(map(int, input().split()))
    S = tuple(input().rstrip() for _ in range(H))
    L, R = [[0] * W for _ in range(H)], [[0] * W for _ in range(H)]
    U, D = [[0] * W for _ in range(H)], [[0] * W for _ in range(H)]
    for x1 in range(H):
        for y1 in range(W):
            if S[x1][y1] == ".":  # left and upper sides of S[i][j]
                U[x1][y1] = U[x1 - 1][y1] + 1
                L[x1][y1] = L[x1][y1 - 1] + 1
            x2, y2 = -x1 - 1, -y1 - 1
            if S[x2][y2] == ".":  # right and under sides
                D[x2][y2] = D[x2 + 1][y2] + 1
                R[x2][y2] = R[x2][y2 + 1] + 1
    ans = -float("inf")
    for i in range(H):
        for j in range(W):
            x = L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3
            if x > ans:
                ans = x
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 177160
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N = II()
	l = [False]*101
	for i in range(1,10):
		for j in range(1,10):
			l[i*j] = True
	if(l[N]):print("Yes")
	else:print('No')



main()

Measured memory_bytes: 3064
while True:
    a,op,b = input().split()
    a = int(a)
    b = int(b)
    
    if op == "?":
        break
    if op == "+":
        print(a + b)
    if op == "-":
        print(a - b)
    if op == "*":
        print(a * b)
    if op == "/":
        print(a // b)


Measured memory_bytes: 5592
using System;

class Program
{
    static void Main(string[] args)
    {
        var A = int.Parse(Console.ReadLine());
        var B = int.Parse(Console.ReadLine());
        var C = int.Parse(Console.ReadLine());
        var X = int.Parse(Console.ReadLine());
        var count = 0;

        for(int i=0; i<=A; i++)
        {
            for(int j=0; j<=B; j++)
            {
                for(int k=0; k<=C; k++)
                {
                    var value = 500*i + 100*j + 50*k;
                    if(value == X) { ++count; }
                }
            }
        }
        Console.WriteLine(count);
    }
}

Measured memory_bytes: 11092
LL = [int(input()) for _ in range(5)]

from itertools import permutations

LL = list(permutations(LL))

ans = float("inf")
for L in LL:
    res = 0
    for l in L[:-1]:
        res += (l + 10 - 1) // 10 * 10
    res += L[-1]
    ans = min(ans, res)

print(ans)

Measured memory_bytes: 3060
def main():
    def flatten_list(l):
        for el in l:
            if isinstance(el, list):
                yield from flatten_list(el)
            else:
                yield el
    H, W = list(map(int, input().split()))
    n = int(input())
    A = list(map(int, input().split()))
    ans = []
    for i, a in enumerate(A):
        ans .append([str(i + 1)] * a)
    ans = list(flatten_list(ans))
    ans = [ans[i:i + W] if i // W % 2 == 0 else ans[i + W - 1:i - 1:-1] for i in range(0, len(ans), W)]
    [print(' '.join(a)) for a in ans]

if __name__ == '__main__':
    main()


Measured memory_bytes: 4724
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <queue>
#include <vector>

#define testin freopen("1.txt","r",stdin);
#define testout freopen("out.txt","w",stdout);
#define ll long long

using namespace std;

const int maxn=(int)1e5+10;

struct node{
    char c[20];
    void getdata(){
        cin>>c;
        sort(c,c+strlen(c));
    }
}s[maxn];

int cmp(struct node a,struct node b){
    return strcmp(a.c,b.c)>0;
}

int main(){
    int n;
    ll ans=0,cnt;
    cin>>n;
    for(int i=0;i<n;i++) s[i].getdata();
    sort(s,s+n,cmp);
    int now=0;
    while(now<n){
        cnt=1;
        while(strcmp(s[now+1].c,s[now].c)==0){
            cnt++;
            now++;
            if(now==n-1) break;
        }
        ans+=((cnt-1)*cnt)/2;
        now++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2176
def main():
    from sys import stdin
    input = stdin.readline
    n, m = map(int, input().split())
    s = [i == "B" for i in input()]
    ab = [list(map(int, input().split())) for _ in [0]*m]
    g = [set() for _ in [0]*n]
    [g[a-1].add(b-1) for a, b in ab]
    [g[b-1].add(a-1) for a, b in ab]

    g2 = [[0, 0] for _ in [0]*n]

    for i in range(n):
        for j in g[i]:
            g2[i][s[j]] += 1

    ss = []
    for i, (j, k) in enumerate(g2):
        if (j == 0 and k > 0) or (j > 0 and k == 0):
            ss.append(i)

    while ss:
        i = ss.pop()
        c = s[i]
        for j in g[i]:
            if i != j:
                g[j].remove(i)
            g2[j][c] -= 1
            p, q = g2[j]
            if (p == 0) ^ (q == 0):
                ss.append(j)
        g[i] = set()

    for i in g:
        if len(i) > 0:
            print("Yes")
            return
    print("No")


main()

Measured memory_bytes: 126812
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)

	nums := scanNums(n)

	flag := true
	max := nums[0]

	for _, num := range nums {
		if max < num {
			max = num
		}

		if max - num > 1 {
			flag = false
			break
		}
	}

	if flag {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

func scanNums(len int) (nums []int) {
	var num int
	for i := 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}

func scanStrings(len int) (strings []string) {
	var str string
	for i := 0; i < len; i++ {
		fmt.Scanf("%s", &str)
		strings = append(strings, str)
	}
	return
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}


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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
using ll = long long;

int main() {
    FAST;

    int n, k, i;
    cin >> n;
    k = n-2;

    vector<ll> v(n);
    for (i = 0; i < n; ++i) cin >> v[i];
    sort(v.rbegin(), v.rend());

    ll ans = v[0];
    for (i = 1; k && (i < n); ++i) {
        if (k == 1) {
            ans += v[i];
            break;
        }
        ans += v[i]*2;
        k -= 2;
    }

    cout << ans;

    return 0;
}


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

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

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

    ll h,w;
    cin >> h >> w;
    vector<vector<char>> a(h, vector<char>(w));
    for (ll i = 0;i < h;i++){
        for (ll j = 0;j < w;j++){
            cin >> a[i][j];
        }
    }

    ll n = 0;
    for (ll i = 0; i < h; i++){
        for (ll j = 0; j < w; j++){
            if (a[i][j] == '#'){
                n++;
            }
        }
    }

    if (n == h+w-1){
        cout << "Possible" << endl;
    }
    else{
        cout << "Impossible" << endl;
    }
}

Measured memory_bytes: 3624
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct Node {
	int key;
	struct Node* parent;
	struct Node* left;
	struct Node* right;
};

typedef struct Node * NodePointer;

void insert( NodePointer t , int z){
	NodePointer x;
	if ( t -> key <= z){
		if  ( t -> right  == NULL){
			x =  (NodePointer) malloc (sizeof(struct Node));
			x -> key = z;
			x -> right = NULL;
			x -> left = NULL;
			t -> right = x;
		}else {
			insert ( t -> right , z);
		}

	}else {
		if  ( t -> left  == NULL){
			x =  (NodePointer) malloc (sizeof(struct Node));
			x -> key = z;
			x -> right = NULL;
			x -> left = NULL;
			t -> left = x;
		}else {
			insert ( t -> left , z);
		}
	}
};

void preorder ( NodePointer t){
	if ( t == NULL ){ return; }
	printf(" %d", t -> key);
	preorder( t -> left);
	preorder( t -> right);
};

void inorder (NodePointer t){
	if ( t == NULL ){ return; }
	inorder( t -> left);
	printf(" %d", t -> key);
	inorder( t -> right);
};

void postorder (NodePointer t){
	if ( t == NULL ){ return; }
	postorder( t -> left);
	postorder( t -> right);
	printf(" %d", t -> key);
};


int main (){
	int kazu;
	scanf("%d\n",&kazu);

	NodePointer tree = (NodePointer) malloc (sizeof(struct Node));

	char input [8];
	int k;

	for ( int i = 0; i  < kazu; i++){
		scanf("%s" ,&input);

		if ( strcmp( input , "insert") == 0 ){
			scanf("%d\n",&k);

			if ( i == 0)
			{
			tree -> key = k;
			tree -> right = NULL;
			tree -> left = NULL;
			}

			else {insert(tree , k);
			}
		}else {
			inorder(tree);
			printf("\n");

			preorder(tree);
			printf("\n");
		}
	}


	return 0;
}



Measured memory_bytes: 25140
#include<iostream>
#include<algorithm>
#include<set>
#define LIMIT 100000
using namespace std;

struct card {
	long b;
	long c;
};

bool cmp(const card left, const card right) {
	return right.c < left.c;
}

int main()
{
	int n, m;
	long tmp;
	struct card input[LIMIT];
	long b, c;
	multiset<long> a;
	int i, j;

	cin >> n >> m;
	for (i = 0; i < n; i++) {
		cin >> tmp;
		a.insert(tmp);
	}

	for (i = 0; i < m; i++) {
		cin >> input[i].b >> input[i].c;
	}
	sort(input, input + m, cmp);

	for (i = 0; i < m; i++) {
//		cin >> b >> c;
		b = input[i].b;
		c = input[i].c;
		multiset<long>::iterator k = a.begin();
		for (j = 0; j < b; j++) {
			if (*k >= c) {
				break;
			}
			a.erase(k++);
			a.insert(c);
		}
	}

	/*
	auto itr = a.begin();
	for (i = 0; i < n; i++, itr++) {
		cout << *itr << endl;
	}
	cout << endl;
	*/

	auto itr = a.begin();
	long ans = 0;
	for (i = 0; i < n; i++) {
		ans += *itr;
		itr++;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define rep(i, x, n) for(long i = x; i < n; i++)
#define erep(i, x, n) for(long i = x; i <= n; i++)
#define all(a) a.begin(), a.end()
#define eall(a) a.begin()+1, a.end()
#define show(ans)  cout << ans << endl;
const long MOD = 1000000007;

// 素集合データ構造
struct UnionFind
{
  // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
  vector<long> par;
  // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
  vector<long> sizes;

  UnionFind(long n) : par(n), sizes(n, 1) {
    // 最初は全てのデータiがグループiに存在するものとして初期化
    rep(i, 0, n) par[i] = i;
  }

  // データxが属する木の根を得る
  long find(long x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
  }

  // 2つのデータx, yが属する木をマージする
  void unite(long x, long y) {
    // データの根ノードを得る
    x = find(x);
    y = find(y);

    // 既に同じ木に属しているならマージしない
    if (x == y) return;

     // xの木がyの木より大きくなるようにする
     if (sizes[x] < sizes[y]) swap(x, y);

    // xがyの親になるように連結する
    par[y] = x;
    sizes[x] += sizes[y];
    // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
  }

  // 2つのデータx, yが属する木が同じならtrueを返す
  bool same(long x, long y) {
    return find(x) == find(y);
  }

  // データxが含まれる木の大きさを返す
  long size(long x) {
    return sizes[find(x)];
  }
};

int main(){long N, M;
cin >> N >> M;
vector<long> p(N+1);
vector<long> x(M+1); vector<long> y(M+1);
erep(i, 1, N) cin >> p[i];
erep(i, 1, M) cin >> x[i] >> y[i];
UnionFind uf(N+1);
erep(i, 1, M){
  uf.unite(x[i], y[i]);
}
long ans = 0;
erep(i, 1, N){
  if(uf.same(i, p[i])) ans++;
}
// uf.unite(0, 1);
// uf.unite(2, 0);
// long test = uf.find(0);
show(ans);


return 0;
}

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

int main(){
    int N; cin >> N;
    vector<int> p(N);
    for(int i=0;i<N;i++){
        cin >> p[i];
    }
    sort(p.begin(),p.end());
    int sum = 0;
    for(int i=0;i<N-1;i++){
        sum += p[i];
    }
    cout << sum+p[N-1]/2 << endl;
}

Measured memory_bytes: 256
s=input()
f=int(s[:2])
b=int(s[2:])

if f>=1 and f<=12:
    if b>=1 and b<=12:
        print('AMBIGUOUS')
    else:
        print('MMYY')

else:
    if b>=1 and b<=12:
        print('YYMM')
    else:
        print('NA')

Measured memory_bytes: 3060
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
//const int inf = 1000000000; //10^9
const ll MX = 1e18; //1(1倍)e(指数)18(10^18)
//const ll MOD = 1e9 + 7;
//加算代入演算子は+=
//int 2^31 10^9まで
//intは10桁、long longは18桁、doubleは308桁、long double は4932桁
//10^10くらいまででdoubleは誤差が発生しちゃう。なるべく整数にすること
//doubleからlong longにキャストするときは、+0.5で切り捨ての誤差を調整
//__int128()で128bit対応の整数（多倍長整数）
//||は片方が成り立つとき
int main()
{
    int n;
    cin >> n;
    ll ans = 1;
    bool ng = false;
    rep(i, n)
    {
        ll a;
        cin >> a;
        if (a == 0)
        {
            cout << 0 << endl;
            return 0;
        }
        else
        {
            if (__int128(ans) * a > MX)
            {
                ng = true;
            }
            ans *= a;
        }
    }
    if(ng) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <cctype>
#include <map>
#include <vector>
#include <queue>
#include <list>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main() {
	string s;
	cin >> s;
	int minv1, minv2;minv1 = minv2 = 0;
	rep(i, 0, s.size()) {
		if (i % 2 == 0 && s[i] == '0' || i % 2 == 1 && s[i] == '1') minv1++;
		else minv2++;
	}
	cout << min(minv1, minv2) << endl;
	return 0;
}

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

int main() {
  
  int N  ;
  cin >> N ;
  int A = N/2 ;
  double B = (double) (N - A)/N ;
  if (N %2 == 0 ) cout << 0.5 << endl;
  else cout  <<  B <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<chrono>
using namespace std;
using ll = long long;
#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++)

int main() {
    string s;
    cin >> s;
    priority_queue<int, vector<int>, greater<int>> ans;
    bool same = true;
    rep(i, s.size()-1) {
        if (s[i] != s[i+1]){
            same = false;
            break;
        }
    }
    if (same) {
        cout << 0 << endl;
        return 0;
    }
    for (char i = 'a'; i <= 'z'; i++) {
        int count = 0;
        string t = s;
        while (t.size() > 0) {
            string nt;
            bool check = true;
            rep(j, t.size()-1) {
                if (t[j] == i || t[j+1] == i) {
                    nt += i;
                }
                else {
                    nt += t[j];
                    check = false;
                }
            }
            count++;
            t = nt;
            if (check) {
                break;
            }
        }
        ans.push(count);
    }
    cout << ans.top() << endl;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
  var list = input.split("\n");
  var n = list[0];
  list.shift();
  list = list.map((val, index)=>[val, index]).sort((a, b)=>b[0]-a[0]);
  for(var i=0; i<list[0][1]; i++){
  	console.log(list[0][0]);
  }
  console.log(list[1][0]);
  for(var i=list[0][1]+1; i<n; i++){
  	console.log(list[0][0]);
  }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main(){
    string s;
    cin >> s;
    int k = (int)s.size();
    int cnt = 15 - k;
    for (int i = 0; i < k; i++){
        if (s[i] == 'o') cnt++;
    }
    if (cnt >= 8) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
while (True):
    a, op, b = input().split()
    if op == "+":
        print(int(a) + int(b))
    elif op == "-":
        print(int(a) - int(b))
    elif op == "*":
        print(int(a) * int(b))
    elif op == "/":
        print(int(a) // int(b))
    elif op == "?":
        break




Measured memory_bytes: 5592
#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;

typedef long long LL;
const int MOD = 1e9+7;

void solve(){
	string s;
	int k;
	cin>>k;
	cin>>s;
	int n = s.size();
	for(int i=0;i<min(k,n);i++){
		cout<<s[i];
	}
	if(n>k){
		cout<<"...";
	}
	cout<<endl;
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T = 1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int n;
int moves[100];
int ans[100007]={0};
int solve(int k){
    if(ans[k]){
        return ans[k];
    }
    for(int i=0;i<n;i++){
        if(k>=moves[i]){
        if(solve(k-moves[i])==2){
            ans[k]=1;
            return ans[k];
        }
      }
    }
   ans[k]=2;
   return ans[k];
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	   int k;
	   cin>>n>>k;
	   for(int i=0;i<n;i++){
	       cin>>moves[i];
	   }
	   ans[0]=2;
	   if(solve(k)==1){
	    cout<<"First";   
	   }
	   else{
	       cout<<"Second";
	   }
}


Measured memory_bytes: 3712
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInt2() (int, int) {
	return nextInt(), nextInt()
}

func nextInt3() (int, int, int) {
	return nextInt(), nextInt(), nextInt()
}

func nextInt4() (int, int, int, int) {
	return nextInt(), nextInt(), nextInt(), nextInt()
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextFloat64s(n int) []float64 {
	slice := make([]float64, n)
	for i := 0; i < n; i++ {
		slice[i] = nextFloat64()
	}
	return slice
}

func putf(format string, a ...interface{}) {
	fmt.Fprintf(wt, format, a...)
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

const COMMAX int = 2000
const MOD int = 1000000007

var fac [COMMAX]int
var finv [COMMAX]int
var inv [COMMAX]int

// テーブル作成
func COMinit() {
	fac[0] = 1
	fac[1] = 1
	finv[0] = 1
	finv[1] = 1
	inv[1] = 1
	for i := 2; i < COMMAX; i++ {
		fac[i] = fac[i-1] * i % MOD
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD
		finv[i] = finv[i-1] * inv[i] % MOD
	}
}

// 二項係数nCk
func COM(n, k int) int {
	if n < k {
		return 0
	}
	if n < 0 || k < 0 {
		return 0
	}
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	COMinit()

	s := nextInt()

	ans := 0
	for n := 1; n <= s/3; n++ {
		ans += COM(s-2*n-1, n-1)
		ans %= MOD
	}

	puts(ans)
}


Measured memory_bytes: 1828
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define print(x) cout << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T> >
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

ll n, a, b, c, d;
map<ll, ll> memo;
ll f(ll x) {
  if (x == 0) return 0LL;
  if (x == 1) return memo[x] = d;
  if(x == 2){
    memo[x] = min(d*2,a+d);
  }
  if (memo.count(x)) return memo[x];
  ll res = LLONG_MAX;
  if((2LL<<60)/d > x)res = x*d;
  {
    ll l = x/2*2, r = l+2;
    mins(res, f(l/2)+a+(x-l)*d);
    mins(res, f(r/2)+a+(r-x)*d);
  }
  {
    ll l = x/3*3, r = l+3;
    mins(res, f(l/3)+b+(x-l)*d);
    mins(res, f(r/3)+b+(r-x)*d);
  }
  {
    ll l = x/5*5, r = l+5;
    mins(res, f(l/5)+c+(x-l)*d);
    mins(res, f(r/5)+c+(r-x)*d);
  }
  //cout<<x <<" "<<res << endl;
  return memo[x] = res;
}
int main() {
  int t;
  cin >> t;
  while (t--) {
    memo = map<ll,ll>();
    cin >> n >> a >> b >> c >> d;
    ll ans = f(n);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 4764
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<math.h>
using namespace std;
 
 
int main() {
	int x;
	cin >> x;
	int t = 0;
	int m = 0;
	int k = 0;
	int n = 0;
	for (int i = 1;i <= x;i++) {
		for(int s=2;s<=10;s++)
			if (pow(i, s) == x) {
				t = i;
				m = s;
				break;
			}
			else if (pow(i, s) < x&&pow(i, s) > pow(t, m)) {
				t = i;
				m = s;
			}
	}

	cout << pow(t, m) << endl;
	system("pause");
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;
  int S = 0;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    if (x <= K / 2) { S += 2 * x;}
    else { S += 2 * (K - x);}
  }
  cout << S << endl;
}

Measured memory_bytes: 3636
#!usr/bin/env python3
import sys
import math
import string
import collections
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
import bisect

MOD = 10 ** 9 + 7
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

sys.setrecursionlimit(10 ** 8)


N = list(input())
if not "7" in N:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 10932
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
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; }
//name[i][j]-> vvl name(i,vl(j))
//map<int,int>mp
//余りを切り上げる =>  (a + b - 1) / b 

signed main(){
	string s; cin>>s;
	string a="Sunny",b="Cloudy",c="Rainy";
	if(s==a) cout<<b;
	else if(s==b) cout<<c;
	else cout<<a;
	
	
	return 0;
}

Measured memory_bytes: 256
from collections import deque
import heapq

def dijkstra(s,g,m):
    color=[0]*n
    dis=[float('inf')]*n
    dis[s]=0
    heapq.heappush(pq,[0,s])
    while len(pq)!=0:
        t,u=heapq.heappop(pq)
        color[u]=2
        if dis[u]<t:
            continue
        for v in g[u]:
            if color[v]!=2:
                if dis[u]+m[u][v]<dis[v]:
                    dis[v]=dis[u]+m[u][v]
                    color[v]=1
                    heapq.heappush(pq,[dis[v],v])
    return dis

n,k=map(int,raw_input().split())
cr=[map(int,raw_input().split()) for _ in xrange(n)]
g=[[]*n for _ in xrange(n)]
for i in xrange(k):
    a,b=map(int,raw_input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)

d=[[0]*n for _ in xrange(n)]
cost=[[float('inf')]*n for _ in xrange(n)]
newg=[[]*n for _ in xrange(n)]
for i in xrange(n):
    q=deque([i])
    visited=[0]*n
    visited[i]=1
    while len(q)!=0:
        p=q.popleft()
        for j in g[p]:
            if visited[j]==0:
                visited[j]=1
                d[i][j]=d[i][p]+1
                if d[i][j]<=cr[i][1]:
                    cost[i][j]=cr[i][0]
                    newg[i].append(j)
                    q.append(j)

pq=[]
dis=dijkstra(0,newg,cost)
print(dis[n-1])

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

int main(){
    Init();
    ll n, x, t; cin >> n >> x >> t;
    ll p = n/x;
    ll q = n%x;
    if(q == 0) cout << p*t << endl;
    else cout << p*t+t << endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

int main(){
    ll a;
    string b;
    cin>>a>>b;
    ll B=0;
    B+=100*(b[0]-'0');
    B+=10*(b[2]-'0');
    B+=(b[3]-'0');

    ll ans=a*B/100;

    cout<<ans<<endl;
}

Measured memory_bytes: 3588
/*   -------------------------
    | If you see my code,     |
    | You are ............... |
    |   ^___^        ^- -^    |
     -------------------------
*/
#include<bits/stdc++.h>
#include<iomanip>
typedef long long ll;
typedef unsigned long long ul;
#define to_lower(x)  transform(x.begin(), x.end(), x.begin(), ::tolower)
#define to_upper(x)  transform(x.begin(), x.end(), x.begin(), ::toupper)
#define pi acos(-1)
#define ll long long
#define ull unsigned long long
#define vec vector<ll>
#define f1(i,n) for(i=1;i<n;i++)
#define test   ll ttt;cin>>ttt;while(ttt--)
#define faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define faster2 ios_base::sync_with_stdio(0);
#define en '\n'
#define eps 10e9
ll i,j;
using namespace std;

int main()
{
  int x;cin>>x;
  if(x==0)cout<<1;
  else cout<<0;
}


Measured memory_bytes: 3628
#include<stdio.h>
int bs(int a[],int n){
	int flag = 1,j = 0,l,i,c = 0;;
	for(i = 0;flag;i++){
		flag =0;
		for(j = n-1;j >=1;j--){
			if(a[j] < a[j-1]){
				l = a[j];
				a[j] = a[j-1];
				a[j - 1] = l;
				flag = 1;
				c++;
			}
			
		}
	}
	return c;
}
int main(void){

	int n,i,c;
	scanf("%d",&n);
	int a[n];
	
	for(i = 0;i < n;i++){
		scanf("%d",&a[i]);
	}
	c = bs(a,n);
	
	for(i = 0;i < n-1; i++){
		printf("%d ",a[i]);
	}
	printf("%d\n",a[n-1]);
	printf("%d\n",c);
}



Measured memory_bytes: 2092
#include<stdio.h>
#include<string.h>
int main(void){
    char search[11],ring[11],j,k,len,flag,ans=0;
    int n,i;
    scanf("%s",search);
    len = strlen(search);
    scanf("%d",&n);
    for(i=0; i<n; i++){
        scanf("%s",ring);
        for(j=0; j<10; j++){
            flag=0;
            for(k=0; k<len; k++){
                if(search[k]!=ring[(j+k)%10]){
                    flag = 1;
                    break;
                }
            }
            if(flag==0){
                ans++;
                break;
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}

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

int main() {
	int h,w;cin>>h>>w;
	char c[h][w];
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>c[i][j];
		}
	}
	for(int i=0;i<2*h;i++){
		for(int j=0;j<w;j++){
			cout<<c[i/2][j];
		}
		cout<<endl;
	}
	return 0;
}

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

int main(int argc, char **argv)
{
    char buf[4];
    fscanf(stdin, "%s", buf);

    printf("%d\n", (buf[0] - 0x30)+(buf[1] - 0x30)+(buf[2] - 0x30));
    return 0;
}


Measured memory_bytes: 128
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

const MOD = 10^^9 + 7L;

void add(T)(ref T a, T b) { a = (a + b) % MOD; }

long calc(string s, int d) {
    int n = cast(int) s.length;
    auto dp = new int[][][](n + 1, 2, d);
    // dp[i][j][k]
    // i: 上から i 桁目まで
    // j: n 未満か
    // k: mod d

    dp[0][0][0] = 1;
    foreach (i; 0..n) {
        foreach (j; 0..2) {
            foreach (k; 0..d) {
                int lim = j == 1 ? 9 : s[i] - '0';
                foreach (m; 0..lim+1) {
                    add(dp[i + 1][j || m < lim][(k + m) % d], dp[i][j][k]);
                }
            }
        }
    }

    // -1 は 0 の分
    return (-1L + MOD + dp[n][0][0] + dp[n][1][0]) % MOD;
}

void main() {
    string s = read!string;
    int d = readint;
    writeln(calc(s, d));
}


Measured memory_bytes: 14332
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    count = 0
    S = chomp(readline())
    T = chomp(readline())
    for i in 1:length(S)
        if S[i] != T[i]
            count += 1
        end
    end

    println(count)
end

main()

Measured memory_bytes: 158424
def resolve():
    N, K = list(map(int, input().split()))
    A = sorted(list(map(int, input().split())))
    F = sorted(list(map(int, input().split())), reverse=True)
    q = []
    for i in range(N):
        q.append((A[i]*F[i], A[i], F[i]))

    def isok(time):
        total = 0
        for t, a, f in q:
            acc = time // f
            if acc < a:
                total += a - acc
        return True if total <= K else False

    left = -1
    right = A[-1]*F[0]
    while (right - left > 1):
        mid = left + (right - left) // 2
        if isok(mid):
            right = mid
        else:
            left = mid
    print(right)

    
if __name__ == "__main__":
    resolve()


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

int main() {
  int K, N;
  cin >> K >> N;
  vector<int>A(N);
  vector<int>ans(N);
  for(int i=0; i<N; i++){
    cin >> A.at(i);
  }
  
  sort(A.begin(), A.end());
  
  for(int i=0; i<N-1; i++){
    ans.at(i)=A.at(i+1)-A.at(i);
  }
  
  ans.at(N-1)=K-A.at(N-1)+A.at(0);
  
  sort(ans.begin(), ans.end());
  
  cout << K-ans.at(N-1) << endl;
  
}


Measured memory_bytes: 4852
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <valarray>
#include <utility>
#include <cctype>
#include <numeric>
#include <memory>
#include <functional>
using namespace std;
#define Debug(x) cerr << #x << " = " << x << endl
#define Debug22(x,y) cerr<<#x<<" = "<<x<<" , "<<#y<<" = "<<y<<endl;
#define Debug2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define Debug3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<")\n";
#define Debug_arr(v,n) for(int i=0;i<n;++i) cerr<<#v<<"["<<i<<"]"<<" = "<<v[i]<<endl;
#define SET(p,v) fill((__typeof(**p)*)p,(__typeof(**p)*)p+sizeof(p),v);
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define prl cerr << "called: " << __LINE__ << endl
//#define FILE_JUDGE
//#define TIMES
//#define LINES
//#define home
vector<int> e[100005];
int cnt[100005],n,f;
vector<int> v;
void dfs(int x,int pr)
{
	cnt[x]=1;
	v.push_back(x);
	if (x==n-1) f=v[(v.size()+1)/2];
	for (auto to:e[x])
	{
		if (to==pr) continue;
		dfs(to,x);
		cnt[x]+=cnt[to];
	}
	v.pop_back();
}
int main()
{
	#ifdef FILE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	scanf("%d",&n);
	for (int i=0;i<n-1;++i)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		x--,y--;
		e[x].push_back(y);
		e[y].push_back(x);
	}
	f=-1;
	dfs(0,0);
	bool w=(cnt[f]*2<n);
	if (w) puts("Fennec");
	else puts("Snuke");
	#ifdef TIMES
	eprintf("Times = %d ms.\n",clock());
	#endif
	#ifdef LINES
	eprintf("lines : %d line.\n",__LINE__+3);
	#endif
	return 0;
}


Measured memory_bytes: 12920
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int N;
  cin>>N;
  vector<int>A(N);
  map<int,int>k;
  for(int i=0;i<N;i++){
    cin>>A[i];
    k[A[i]]++;
  }
  int Q;
  cin>>Q;
  vector<int>B(Q),C(Q);
  for(int i=0;i<Q;i++){
    cin>>B[i]>>C[i];
  }
  int64_t sum=0;
  for(int i=0;i<N;i++){
    sum+=A[i];
  }
  for(int i=0;i<Q;i++){
    sum+=(int64_t)k[B[i]]*(C[i]-B[i]);
    k[C[i]]+=k[B[i]];
    k[B[i]]=0;
    cout<<sum<<endl;
  }
  return 0;
}

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

left = []
right = []
for i in range(m):
    a, b = map(int, input().split())
    left.append(a)
    right.append(b)

if min(right) >= max(left):
    print(min(right) - max(left) + 1)
else:
    print(0)


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

int main(void){
    int n;
    cin >> n;
    
    int a[200000];
    int i;
    for(i = 0; i < n; i++){
        cin >> a[i];
    }
    
    i = n - 1;
    while(i >= 0){
        cout << a[i] << " ";
        i -= 2;
    }
    
    if(n == 1){
        return 0;
    }
    
    i = n % 2;
    while(i <= n - 3){
        cout << a[i] << " ";
        i += 2;
    }
    
    cout << a[i] << endl;
    
    return 0;
}


Measured memory_bytes: 2944
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int x =	sc.nextInt();
	if(x == 7 || x == 5 || x == 3) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }

}

Measured memory_bytes: 21204