akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>

int a[9],b[9],flg[9];
double p,fact9;

void solve(int index,int sumA,int sumB){
	int i;

	if(index == 9 && sumA > sumB){
		p += 1 / fact9;
		return ;
	}

	for(i=0;i<9;i++){
		if(!flg[i]){
			flg[i] = 1;
			if(a[index] > b[i])
				solve(index+1,sumA+a[index]+b[i],sumB);
			else
				solve(index+1,sumA,sumB+a[index]+b[i]);
			flg[i] = 0;
		}
	}
}

int main(void){
	int i,n;

	for(i=2,fact9=1;i<=9;i++) fact9 *= i;

	scanf("%d",&n);

	while(n--){
		for(i=0;i<9;i++) scanf("%d",&a[i]);
		for(i=0;i<9;i++) scanf("%d",&b[i]);

		p = 0;
		memset(flg,0,sizeof(flg));
		solve(0,0,0);

		printf("%.5lf %.5lf\n",p,1-p);
	}

	return 0;
}

Measured memory_bytes: 440
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <numeric>
#include <string>
#include <bitset>
#include <functional>

using ld = long double;
using vld = std::vector<ld>;
using vvld = std::vector<vld>;
using vvvld = std::vector<vvld>;
using ll = int;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pll = std::pair<ll, ll>;
using vpll = std::vector<pll>;
using str = std::string;
using vstr = std::vector<str>;

template<typename T> bool chmin(T a, T &b) { return a < b ? b = a, true : false; }
template<typename T> bool chmax(T a, T &b) { return a > b ? b = a, true : false; }

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool is_prime(ll n) {
    if (n == 1) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}

/*------------------------------------------------------------------------*/

struct edge {
    ll cost, from, to;

    edge(ll &c, ll &f, ll &t) : cost(c), from(f), to(t) {  }

    bool operator<(edge &x) { return cost < x.cost; }
    bool operator>(edge &x) { return cost > x.cost; }
    bool operator==(edge &x) { return cost == x.cost; }
};

struct union_find {
    vll data;

    union_find(ll &size) : data(size, -1) {  }

    ll root(ll &x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }

    bool merge(ll x, ll y) {
        if ((x = root(x)) == (y = root(y))) return false;

        if (data[x] > data[y]) std::swap(x, y);

        data[x] += data[y], data[y] = x;

        return true;
    }
};

void solve();

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15);

    solve();
}

void solve() {
    ll n;
    std::cin >> n;

    std::vector<pll> x(n), y(n);
    for (ll i = 0; i < n; i++) {
        std::cin >> x[i].first >> y[i].first;
        x[i].second = y[i].second = i;
    }

    auto compare = [](pll &a, pll &b) {
        return a.first != b.first ? a.first < b.first
                                  : a.second < b.second;
    };
    std::sort(x.begin(), x.end(), compare);
    std::sort(y.begin(), y.end(), compare);

    std::deque<edge> es;
    for (ll i = 0; i < n - 1; i++) {
        ll cost_x = x[i + 1].first - x[i].first;
        ll cost_y = y[i + 1].first - y[i].first;
        es.push_back(edge(cost_x, x[i].second, x[i + 1].second));
        es.push_back(edge(cost_y, y[i].second, y[i + 1].second));
    }

    auto kruskal = [&]() {
        std::sort(es.begin(), es.end());

        ll res = 0; union_find uf(n);
        for (edge e : es) if (uf.merge(e.from, e.to))
            res += e.cost;

        return res;
    };

    std::cout << kruskal() << '\n';
}


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

using namespace std;

typedef long long	ll;
const int N = 2100;
ll bit[N];
const ll mod = ll(1e9 + 7);

int LSOne(int x){
	return x & (-x);
}

void update(int x){
	while(x < N){
		bit[x] += 1LL;
		x += LSOne(x);
	}
}

ll query(int x){
	ll sum = 0LL;

	while(x > 0){
		sum += bit[x];
		x -= LSOne(x);
	}

	return sum;
}

ll rsq(int l, int r){
	return query(r) - query(l - 1);
}

int a[N];
ll dp[N];

int main(){
	int n;
	ll k;

	scanf("%d %lld", &n, &k);

	for(int i = 1 ; i <= n ; i++){
		scanf("%d", &a[i]);

		dp[i] = rsq(a[i] + 1, N - 1);
		update(a[i]);
	}

	if(k == 1){
		ll sum = 0LL;

		for(int i = 1 ; i <= n ; i++){
			sum += dp[i];
		}

		printf("%lld\n", sum);
	}else{
		ll inv = ll(5e8 + 4);
		ll tot = 0LL;
		ll sum = ((((1LL + k - 1LL) * (k - 1LL)) % mod) * inv) % mod;
		ll ans = 0LL;

		for(int i = 1 ; i <= n ; i++){
			ll current = rsq(a[i] + 1, N - 1);
			ll d = current - dp[i];

			ans = ans + ((dp[i] * k) + d * sum) % mod; 
			// printf("%lld %lld\n", dp[i], d);

			if(ans >= mod) ans -= mod;
			
			update(a[i]);
		}

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

	return 0;
}

Measured memory_bytes: 256
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

func printBinary(n uint32) {
	fmt.Printf("%032b\n", n)
}

func main() {
	scanner.Split(bufio.ScanWords)

	a := uint32(nextInt())
	b := uint32(nextInt())

	printBinary(a & b)
	printBinary(a | b)
	printBinary(a ^ b)
}



Measured memory_bytes: 1128
# -*- coding: utf-8 -*-

import sys


lineNumber = 0
#for line in [ "5", "4", "2,4", "3,5", "1,2", "3,4" ]:
for line in sys.stdin.readlines():
    lineNumber += 1

    # get data
    List = map(int, line.strip().split(","))

    # initial parameter
    if lineNumber == 1:
        w = List[0]
        array = [i for i in xrange(1, w+1)]
        continue
    if lineNumber == 2: continue

    # set data
    [a, b] = List
    a -= 1; b -= 1

    # exchange
    buf = array[a]
    array[a] = array[b]
    array[b] = buf
    
for i in xrange(w):
    print array[i]
    
    

Measured memory_bytes: 4220
using System;

class program
{
public static void Main()
{
int s;
s = int.Parse(Console.ReadLine());
int h = s/3600;
int x = s%3600;
int m = x/60;
int y = x%60;
Console.Write("{0}:{1}:{2}\n",h,m,y);
}
}

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

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1e9+7;

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

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

template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
///////////////////////////////////////////////
/*🍈( '-'  🍈*/

int main(){
	static bool visited[100002] = {};
	int N,M;
	cin >> N >> M;
	vector<int> ans;
	vector<int> ans2;
	vector<VI> adj(N+2);
	int s = 0;
	REP(i,M){
	    int a,b;
	    cin >> a >> b;
	    s = a;
	    adj[a].PB(b);
	    adj[b].PB(a);
	}
	int pos = s;

	ans.PB(pos);
	visited[pos] = true;
	bool term = false;

	while(!term){
		term = true;
		visited[pos] = true;
		REP(i,adj[pos].size()){
			int next = adj[pos][i];
		    if (visited[next]) continue;
		    pos = next;
			ans.PB(pos);
		    term = false;
		    break;
		}
	}

	pos = s;
	term = false;
	while(!term){
		term = true;
		visited[pos] = true;
		REP(i,adj[pos].size()){
			int next = adj[pos][i];
			if (visited[next]) continue;
			pos = next;
			ans2.PB(pos);
			term = false;
			break;
		}
	}

	cout << ans.size() + ans2.size() << "\n";
	reverse(ALL(ans2));

	REP(i,ans2.size()){
	    cout << ans2[i] << " ";
	}

	REP(i,ans.size()){
		cout << ans[i] << " ";
	}

	cout << endl;

}

Measured memory_bytes: 6904
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;

vector<string> board;
ll h, w;

ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, -1, 0, 1};

ll find_longest(ll sx, ll sy) {
    ll max_num = 0;
    vvll costs(h, vll(w, inf));
    costs[sy][sx] = 0;
    priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> q;
    q.push({sx, sy});

    while (q.size()) {
        auto item = q.top(); q.pop();
        ll x = item.first;
        ll y = item.second;

        rep(i, 4) {
            ll nx = x + dx[i];
            ll ny = y + dy[i];

            if (
                0 <= nx && 
                nx < w && 
                0 <= ny && 
                ny < h && 
                board[ny][nx] == '.' &&
                costs[ny][nx] > costs[y][x] + 1
            ) {
                costs[ny][nx] = costs[y][x] + 1;
                q.push({nx, ny});
            }
        }
    }

    //cout << "sx: " << sx << " sy: " << sy << endl;
    rep(i, h) {
        rep(j, w) {
            //cout << costs[i][j] << " ";
            if (costs[i][j] != inf) max_num = max(max_num, costs[i][j]);
        }
        //cout << endl;
    }
    //cout << endl << endl;

    return max_num;
}

int main()
{
    cin >> h >> w;
    board.resize(h);
    ll max_num = 0;
    rep(i, h) cin >> board[i];
    rep(i, h) rep(j, w) {
        if (board[i][j] == '#') continue;
        max_num = max(max_num, find_longest(j, i));
    }
    cout << max_num << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  string s;
  cin>>s;
  for(ll i=0;i<s.size();i++){
  	if(s[i]=='1') cout<<9;
    else if(s[i]=='9') cout<<1;
    else cout<<s[i];
  }
  cout<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
	int n, num,max=0;
	string str;
	cin >> n >> str;
	if (str[0] == 'I') {
		num = max = 1;
	}
	else {
		num = -1;
		max = 0;
	}
	for (int i = 1; i < n; i++) {
		if (str[i] == 'I') {
			num++;
			if (max < num) {
				max = num;
			}
		}
		else {
			num--;
		}
	}
	cout << max << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] line = br.readLine().split(" ");
		Arrays.sort(line);
		int A = Integer.parseInt(line[0]);
		int B = Integer.parseInt(line[1]);
		int C = Integer.parseInt(line[2]);
		
		if(A==5 && B==5 && C==7){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 8020
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef pair<int, int> PI;
const double EPS=1e-9;



int main(void){
  int n, m;
  cin >> n >> m;
  VI sticky(n);
  VI num(n);
  sticky[0] = 1;
  REP(i, 0, n) {
    num[i] = 1;
  }
  REP(i, 0, m) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    if (sticky[x]) {
      sticky[y] = 1;
    }
    num[x]--;
    num[y]++;
    if (num[x] == 0) {
      sticky[x] = 0;
    }
  }
  cout << count(sticky.begin(), sticky.end(), 1) << endl;
}


Measured memory_bytes: 1024
/**
 * author:    Ziel
 * created:   12.04.2020 22:49:16
**/

// ~zaletaet~

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define fi first
#define se second
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin, x.rend()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define bpc __builtin_popcountl
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

template <class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T>
using p_queue = priority_queue<T, vector<T>, greater<T>>;

const ll N = 1e5 + 123, MOD = 1e9 + 7, oo = 1e9 + 9, INF = 1e18 + 9;
const db EPS = 1e-9, PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1}, dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

int par[N], size[N];
int fdeg[N], bdeg[N];

inline int find(int x) {
	return (x == par[x] ? x : par[x] = find(par[x]));
}

inline void unite(int a, int b) {
	a = find(a), b = find(b);
	if (a != b) {
		if (size[a] < size[b]) swap(a, b);
		par[b] = a;
		size[a] += size[b];
	}
}

main() {
#ifdef ZVER
	cerr << "Ready\n";
#endif
	fre("");
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	
	int n, m, k;
	cin >> n >> m >> k;
	
	for (int i = 1; i <= n; i++) par[i] = i, size[i] = 1;
	
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		
		unite(a, b);
		fdeg[a]++;
		fdeg[b]++;
	}
	
	for (int i = 0; i < k; i++) {
		int a, b;
		cin >> a >> b;
		
		if (find(a) == find(b)) bdeg[a]++, bdeg[b]++;
	}
	
	for (int i = 1; i <= n; i++) {
		int id = find(i);
		cout << size[id] - fdeg[i] - bdeg[i] - 1 << ' ';
	}
	
	return 0;
}

// uniform_int_distribution<int>(l, r)(rng) -> random in range [l, r]
// assert(condition) -> if (condition == false) Runtime Error
// order_of_key(x) -> number of elements smaller than x
// *find_by_order(k) -> k-th element in 0-based indexation


Measured memory_bytes: 2432
#include <iostream>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>

#define ll long long

using namespace std;

const long long mod = 1e9 + 7;

int main() {
    int n;
    vector<int> ansE;
    vector<int> ansO;
    cin >> n;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        if(i&1){
            ansE.push_back(a);
        }else{
            ansO.push_back(a);
        }
    }

    if(n&1){
        for(int i = n/2; i >= 0; i--){
            cout << ansO[i] << " ";
        }
        for(int i = 0; i < n/2; i++){
            cout << ansE[i] << " ";
        }
    }else{
        for(int i = n/2-1; i >= 0; i--){
            cout << ansE[i] << " ";
        }
        for(int i = 0; i < n/2; i++){
            cout << ansO[i] << " ";
        }
    }

    cout << endl;
}

Measured memory_bytes: 3188
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main()
{
    int x1, y1, x2, y2, x3, y3, x4, y4;
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    int dx = x2 - x1;
    int dy = y2 - y1;
    x3 = x2 - dy;
    y3 = y2 + dx;
    x4 = x1 - dy;
    y4 = y1 + dx;
    printf("%d %d %d %d\n", x3, y3, x4, y4);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
struct UnionFind {
    vector<int> par;
    vector<int> sz;
 
    UnionFind(int n=0){
        if(n>0) initialize(n);
    }
 
    void initialize(int n){
        par.resize(n);
        sz.resize(n);
        for(int i=0; i<n; i++){
            par[i] = i;
            sz[i] = 1;
        }
    }
 
    int find(int x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = find(par[x]);
        }
    }
 
    bool unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return false;
        if(sz[x] > sz[y]) swap(x, y);
        par[x] = y;
        sz[y] += sz[x];
        return true;
    }
 
    bool same(int x, int y){
        return find(x) == find(y);
    }
 
    int size(int x){
        return sz[find(x)];
    }
};
 
int N;
string S[200];
vector<int> edges[200];
 
bool bipart(){
    UnionFind uf(2*N);
    for(int i=0; i<N; i++) for(int j : edges[i]){
        uf.unite(i+N, j);
        uf.unite(j+N, i);
    }
    for(int i=0; i<N; i++) if(uf.same(i, i+N)) return false;
    return true;
}
 
int main(){
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> S[i];
        for(int j=0; j<N; j++) if(S[i][j] == '1') edges[i].push_back(j);
    }
    if(!bipart()){
        cout << -1 << endl;
        return 0;
    }
 
    int ans = 0;
    for(int s=0; s<N; s++){
        vector<int> dist(N, -1);
        dist[s] = 1;
        queue<int> que;
        que.push(s);
        while(que.size()){
            int i = que.front(); que.pop();
            for(int j : edges[i]) if(dist[j] == -1){
                dist[j] = dist[i]+1;
                que.push(j);
            }
        }
        int res = *max_element(dist.begin(), dist.end());
        ans = max(ans, res);
    }
    cout << ans << endl;
    return 0;
}

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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	vector<int> A(3);
	
	cin >> A[0] >> A[1] >> A[2];
	
	sort(A.begin(), A.end());

	int ans = A[2] * 10 + A[1] + A[0];
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  int a,b,c;
  string s="NO";
  cin>>a>>b>>c;
  if(a==5){
    if(b==7&&c==5){
      s="YES";
    }
    else if(b==5&&c==7){
      s="YES";
    }
  }
  else if(a==7){
    if(b==5&&c==5){
      s="YES";
    }
  }
  cout<<s<<endl;
}


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

int main() {
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> C(N+1, 0);
    vector<int> A(M);
    for (int i=0; i<M; i++) cin >> A.at(i);
    for (int i=0; i<M; i++) C.at(A.at(i))=1;
    int res1=0;
    int res2=0;
    for (int i=X; i<=N; i++) res1+=C.at(i);
    for (int i=X; i>=0; i--) res2+=C.at(i);
    cout << min(res1, res2) << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include <bits/stdc++.h> 
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pll pair<ll,ll>
#define pint pll
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int n,m;
  cin >> n >> m;
  if(n==m)cout << "Yes" << endl;
  else cout << "No" << endl;
return 0;}

Measured memory_bytes: 256
#include <iostream>
#include<cmath>
using namespace std;
int H, W;
char C[101][101];
int main()
{
   
    cin >> H >> W;
    for (int i = 1; i <= H; i++) 
    {
        for (int j = 1; j <= W; j++)
        {
            cin >> C[i][j];
        }
    }
    for (int i = 1; i <= 2 * H; i++)
    {
        for (int j = 1; j <= W; j++)
        {
            int m = ceil((i + 1) / 2);
            cout << C[m][j];
        }
        cout << endl;
    }
     return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

const int maxn = 100000;

int main(){
    
    int n;
    ll h[maxn];
    ll pre=0;
    
    cin >> n;
    rep(i,n){
        cin >> h[i];
    }
    
    rep(i,n){
        if(pre>h[i]){
            No;
            return 0;
        }else if(pre == h[i]){
            pre = h[i];
        }else{
            pre = h[i]-1;
        }
    }
    
    Yes;
    
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main()
{
    int n; cin>>n;
    ll a[200020];
    for(int i=0; i<n; i++) cin>>a[i];
    sort(a, a+n);
    ll ans=0;
    ans+=a[n-1];
    for(int i=0; i<n-2; i++){
        ans+=a[n-2-i/2];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5200
fn main() {
    let v = read_vec::<u32>();
    let a = v[0];
    let b = v[1];
    let c = v[2];
    yn(a + b >= c);
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include<algorithm>

using namespace std;

const int maxx = 100050*3;
//int a[maxx];
long long n;
long long a[3][maxx];
int l,r;

int main()
{
    scanf("%d",&n);
    for(int i = 0; i < 3; i++)
    {
        for(int j = 0; j < n; j++)
        scanf("%lld",&a[i][j]);
    }
    sort(a[0],a[0]+n);
    sort(a[2],a[2]+n);
 /*   for(int i = 0; i < n; i++)
    {
        printf("%d ",a[0][i]);
    }
    printf("\n");
    for(int i = 0; i < n; i++)
    {
        printf("%d ",a[2][i]);
    }
    printf("\n");*/
    long long ans = 0;
    for(int i = 0; i < n; i++)
    {
        l = 0,r = n-1;
        int t1 = lower_bound(a[0],a[0]+n,a[1][i])-a[0];
        l = 0,r = n-1;
        int t2 = upper_bound(a[2],a[2]+n,a[1][i])-a[2];
        ans += t1 *(n-t2);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 5120
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    a = list(map(int, input().split()))

    b = []
    box = [0] * (N + 1)
    for i, r in zip(reversed(range(1, N + 1)), a[::-1]):
        total_r = sum(box[j] for j in range(i, N + 1, i)) % 2
        if r == 0 and total_r == 1:
            box[i] = 1
            b.append(i)
        elif r == 1 and total_r == 0:
            box[i] = 1
            b.append(i)

    M = len(b)
    if M == 0:
        print(0)
    else:
        print(M)
        print(" ".join(map(str, b)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 26988
#include<bits/stdc++.h>
using namespace std;
const int maxn=300100;
const int md=1e9+7;
char str[maxn];
int dp[maxn][2][3][3];
void Add(int &x,int y){
	(x+=y)%=md;
}
int main(){
//	freopen("E.in","r",stdin);
	int n;
	scanf("%s",str+1);
	n=strlen(str+1);
	str[n+1]='1';
	dp[0][0][0][0]=1;
	for(int i=1;i<=n+1;i++){
		if(str[i]!='1'){
			for(int j=0;j<=1;j++)
				for(int k=0;k<3;k++)
					for(int l=0;l<3;l++)
						Add(dp[i][j][k>1?k-1:k+1][l],dp[i-1][j][k][l]);
		}
		if(str[i]!='0'){
			Add(dp[i][1][0][1],dp[i-1][0][0][0]);
			Add(dp[i][1][0][1],dp[i-1][0][0][1]);
			Add(dp[i][1][0][2],dp[i-1][0][0][2]);

			Add(dp[i][0][0][0],dp[i-1][1][0][0]);
			Add(dp[i][0][0][2],dp[i-1][1][0][1]);
			Add(dp[i][0][0][2],dp[i-1][1][0][2]);

			for(int j=0;j<=1;j++)
				for(int l=0;l<3;l++)
					Add(dp[i][j][0][l],dp[i-1][j][1][l]);

			for(int j=0;j<=1;j++)
				for(int l=0;l<3;l++)
					Add(dp[i][j^1][0][l],dp[i-1][j][2][l]);
		}
	}
	int ans=0;
	for(int j=0;j<=1;j++)
		Add(ans,dp[n+1][j][0][2]);
	printf("%d\n",ans);
	return 0;
}


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

typedef long long ll;

int main() {
  ll N, T;
  cin >> N >> T;
  int t[N];
  ll _time = 0; // お湯が出るのが被っている時間の総和
  cin >> t[0];
  for (int i = 1; i < N; i++) {
    cin >> t[i];
    if (t[i-1] + T > t[i]) {
      _time += t[i-1] + T - t[i];
    }
  }

  // 解答
  cout << N * T - _time << endl;
  return 0;
}


Measured memory_bytes: 1024
import java.io.*;
import java.util.*;

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long A;
        A = sc.nextLong();
        long B;
        B = sc.nextLong();

        final Solver solver = new Solver();
        solver.solve(A, B);
    }
}

class Solver {
    public void solve(long A, long B) {

        for (int i = 0; i < 10; i++) {
            double testA = A + 0.1 * i;
            int oriA = (int) Math.round(testA / 0.08);
            for (int j = 0; j < 10; j++) {
                double testB = B + 0.1 * j;
                int oriB = (int) Math.round(testB / 0.10);

                if (oriA == oriB) {
                    System.out.println(oriA);
                    return;
                }
            }
        }
        System.out.println(-1);
    }
}



Measured memory_bytes: 23252
#include <bits/stdc++.h>
#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 per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
template<class T,class U>bool chmax(T &a, const U &b) { if (a<b) { a=b; return true; } return false; }
template<class T,class U>bool chmin(T &a, const U &b) { if (b<a) { a=b; return true; } return false; }
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cii(x);
    cii(a);
    int ans = (x >= a)
            ?10
            :0;
    co(ans);
    return 0;
}

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

// #define fi first
// #define se second
#define rep(i, n) for (ll i=0;i<(n); i++)
#define ALL(v) (v).begin(), (v).end()
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
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 (a>b) { a=b; return 1; } return 0; }

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pi;

const ll M=1000000007ll;
const ll MOD=1000000007ll;
const ll MAX=100000001ll;
//const ll M = 1000000000+7;

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
   return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint f(ll n){
  if(n==0) return 1;
  mint ans = f(n/2);
  ans *= ans;
  if(n%2==1) ans*= 2;
  return ans;
}

mint choose(ll n, ll k){
  mint x=1, y=1;
  rep(i,k){
    x *= (n-i);
    y *= (i+1);
  }
  return x / y;
}

struct BIT {
  private:
   vector<ll> bit;
   ll N;
 
  public:
   BIT(ll size) {
     N = size;
     bit.resize(N + 1);
   }
 
   // 一点更新です
   void add(ll a, ll w) {
     for (ll x = a; x <= N; x += x & -x) bit[x] += w;
   }
 
   // 1~Nまでの和を求める。
   int sum(ll a) {
     ll ret = 0;
     for (ll x = a; x > 0; x -= x & -x) ret += bit[x];
     return ret;
   }
 };
 
ll fff(ll n, vector<ll>& v, ll i, ll j, ll rl){
  ll can = 0;
  ll can_i = 0;

  cout << v[0]<<endl;
  
  // right
  if(rl == 0){
    rep(k, n){
      if(v[k]*(j-k)>can){
	can = v[k]*(j-k);
	can_i = k;
      }
      //cout << can<<endl;
    }
    v[can_i] = 0;
    return can;
  }
  // left
  else{
    rep(k, n){
      if(v[k]*(k-i)>can){
	can = v[k]*(k-i);
	can_i = k;
      }
      //cout << can<<endl;

    }
    v[can_i] = 0;
    return can;
  }
  
}


int main(){
  ll n,t;
  ll ans = 0;
  
  cin>>n;

  ll min_C=1000;
  
  rep(i, n){
    cin>>t;
    ans += t;
    if((t<min_C) && (t%10!=0)) min_C = t;
  }

  if(ans%10==0){
    if(min_C<500) ans -= min_C;
    else ans = 0;
  }
  
  
  cout << ans  <<endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 12 20:58:59 2020

@author: H_Hoshigi
"""

N = input()
answer = False
for i in range(len(N)):
    if N[i] == "7":
        answer = True
if answer:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 9036
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
pii p[55];
int x[55], y[55];
map<pii, int> vis;
int solve(int p, int q, int n){
    int ans = n;
    for(int i=1;i<=n;i++){
        if(vis.count(pii(x[i]-p, y[i]-q))) ans--;
    }
    return ans;
}
int main(){
    int n;
    scanf("%d", &n);
    for(int i=1;i<=n;i++){
        scanf("%d%d", &x[i], &y[i]);
        p[i] = pii(x[i], y[i]);
        vis[pii(x[i], y[i])] = 1;
    }
    sort(p+1, p+1+n);
    for(int i=1;i<=n;i++) x[i] = p[i].first, y[i] = p[i].second;
    int ans = 1e9;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            if(i == j) continue;
            int p = x[i]-x[j], q = y[i]-y[j];
            ans = min(ans, solve(p, q, n));
        }
    }
    if(n == 1) ans = 1;
    printf("%d\n", ans);
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void setIO(string s = "") {
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
 
int rnd (int l, int r) {
	return uniform_int_distribution<int> (l, r)(gen);
}
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;



int main () {
	SpeedForce;
	setIO();
	int a, a1, b, b1, c;
	cin >> a >> a1 >> b >> b1 >> c;

	int need = abs(a-b);
	if(!need) {
		cout << "YES\n";
		return 0;
	}
	if (b1 >= a1) {
		cout << "NO\n";
		return 0; 
	}

	need = (need + a1 - b1 - 1) / (a1 - b1);
	cout << (need <= c ? "YES\n" : "NO\n"); 

	return Accepted;
}

// B...a

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

int main(void) {
    int n,y;
    cin >> n >> y;
    int res;
    rep(i,n+1){
        rep(j,n+1-i){
            res=i*10000+j*5000+(n-i-j)*1000;
            if(res==y){
                printf("%d %d %d\n",i,j,n-i-j);
                return 0;
            }
        }
    }
    printf("-1 -1 -1\n");
    return 0;
}

Measured memory_bytes: 256
from statistics import mean, median,variance,stdev
import sys
import math
import fractions

def j(q):
    if q==1: print("Three")
    else:print("Four")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())




#n = ip()                              #入力整数1つ
#a,b= (int(i) for i in input().split())      #入力整数横2つ
#k,a,b = (int(i) for i in input().split())    #入力整数横3つ
#n,m,x,y= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
a = ip()+1
b = ip()+1
c = ip()+1
x = ip()
sum = 0
for i in range(a):
    for l in  range(b):
        for m in range(c):
            if 500*i+100*l+50*m == x:sum+=1
print(sum)

Measured memory_bytes: 5400
a, b, m = map(int, input().split())
a_list = list(map(int, input().split()))
b_list = list(map(int, input().split()))

min_price = min(a_list) + min(b_list)
for i in range(m):
    x, y, c = map(int, input().split())
    val = a_list[x-1] + b_list[y-1] - c
    if min_price > val:
        min_price = val

print(min_price)


Measured memory_bytes: 18684
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  ll n; cin >> n;
  ll ans = 0;
  REP(i, n){
    ll l,r; cin >> l >> r;
    ans += r-(l-1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
int main()
{
	long double a,b,x;
	scanf("%Lf %Lf %Lf",&a,&b,&x);
	long double v=a*a*b;
	if(v==x){
		printf("0\n");
		return 0;
	}
	if(x>=v/2.0){
		long double c=(2*b)-((2*x)/(a*a));
		long double ans=atan(a/c)*180.0/3.1415926535898;
		printf("%.9Lf\n",90.0-ans);
	}else{
		long double ans=atan((2*x)/(a*b*b))*180.0/3.1415926535898;
		printf("%.9Lf\n",90.0-ans);
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int flg[1000000];
int main(void)
{
    int n,i,j,x;
	
    while(scanf("%d",&n)!=EOF){
		for(i=2;i<=n;i++)	{
			flg[i]=1;
		}
		for(i=2;i*i<=n;i++){
			if(flg[i]==1){
				for(j=2;j*i<=n;j++){
					flg[i*j]=0;
				}
			}
		}
		x=0;
		for(i=2;i<=n;i++)	{
			if(flg[i]==1){
				x++;
			}
		}
		printf("%d\n",x);
	}
	return 0;
}

Measured memory_bytes: 6520
#include <bits/stdc++.h>
using namespace std;
int main () {
  string S;
  cin >> S;
  int fail = 0;
  int Fail = 0;
  int N = S.size();
  if (S.at(0) != 'A') {
    fail++;
  }
  if (isupper(S.at(1))) {
    fail++;
  }
  for (int i = 2; i < N - 1; i++) {
    if (isupper(S.at(i))) {
      if (S.at(i) != 'C') {
        fail++;
      }
      Fail++;
    }
  }
  if (isupper(S.at(N - 1))) {
    fail++;
  }
  if (fail == 0 && Fail == 1) {
    cout << "AC" << endl;
  }
  else {
    cout << "WA" << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int a = sc.nextInt();

		// 出力
		System.out.println(a == 3 || a == 5 || a == 7 ? "YES" : "NO");
	}
}


Measured memory_bytes: 21844
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

/*
?????¶?????°??¨
??????add
??????sum
*/

const int MAX_N = 1<<17;

int n;
ll dat[2*MAX_N-1], lazy[2*MAX_N-1];

void init(int n_) {
  n = 1;
  while(n < n_) n *= 2;
  REP(i, 2*n-1) dat[i] = lazy[i] = 0;
}

// k???????????????????????????????????¶???????????????
void eval(int k, int l, int r) {
  if(lazy[k] != 0) {
    dat[k] += lazy[k];

    if(r-l>1) {
      lazy[2*k+1] += lazy[k] / 2;
      lazy[2*k+2] += lazy[k] / 2;
    }

    lazy[k] = 0;
  }
}

void add(int a, int b, ll x, int k=0, int l=0, int r=-1) {
  if(r < 0) r = n;
  // cout << a << " " << b << " " << x << " " << k << " " << l << " " << r << endl;

  eval(k, l, r);

  if(b <= l || r <= a) {
    // cout << "a" << endl;
    return;
  }

  if(a <= l && r <= b) {
    // cout << "b" << endl;
    lazy[k] += (r-l)*x;
    eval(k, l, r);
  } else {
    // cout << "c" << endl;
    add(a, b, x, 2*k+1, l, (l+r)/2);
    add(a, b, x, 2*k+2, (l+r)/2, r);
    dat[k] = dat[2*k+1] + dat[2*k+2];
  }
}

ll getSum(int a, int b, int k=0, int l=0, int r=-1) {
  if(r < 0) r = n;

  eval(k, l, r);

  if(b <= l || r <= a) return 0;
  if(a <= l && r <= b) return dat[k];
  ll vl = getSum(a, b, 2*k+1, l, (l+r)/2);
  ll vr = getSum(a, b, 2*k+2, (l+r)/2, r);
  return vl + vr;
}

signed main(void)
{
  int nn, q;
  cin >> nn >> q;
  init(nn);
  REP(i, q) {
    int a;
    cin >> a;
    if(a == 0) {
      int s, t, x;
      cin >> s >> t >> x;
      s--;
      add(s, t, x);
    } else {
      int s, t;
      cin >> s >> t;
      s--;
      cout << getSum(s, t) << endl;
    }
    // cout << "dat: ";
    // REP(i, 2*n-1) cout << dat[i] << " "; cout << endl;
    // cout << "laz: ";
    // REP(i, 2*n-1) cout << lazy[i] << " "; cout << endl;
    // cout << "i:" << i << endl;
  }

  return 0;
}

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

int main(){
    int A,B,C,D;
    cin >> A >> B >> C >> D;

    int Takahashi=0,Aoki=0;
    while(A>0){
        Takahashi +=1;
        A -= D;
    }
    while(C>0){
        Aoki +=1;
        C -= B;
    }
    if(Takahashi >= Aoki){
        cout << "Yes"  << endl; 
    }
    else cout << "No"  << endl; 
}

Measured memory_bytes: 3616
#include <cstdio>

using namespace std;

const int N=2010,Mod=1e9+7;

int n,k,fact[N*N],inv[N*N],f[2*N][N];

void Init() { scanf("%d%d",&n,&k); }

void Prepare()
{
	fact[0]=1; for (int i=1;i<=n*k;++i) fact[i]=1ll*fact[i-1]*i%Mod;
	inv[0]=inv[1]=1; for (int i=2;i<=n*k;++i) inv[i]=1ll*(Mod-Mod/i)*inv[Mod%i]%Mod;
	for (int i=1;i<=n*k;++i) inv[i]=1ll*inv[i-1]*inv[i]%Mod;
}

int Calc(int n,int m) { if (n<0 || n<m) return 0; return 1ll*fact[n]*inv[n-m]%Mod*inv[m]%Mod; }

void Solve()
{
	if (k==1) { printf("1\n"); return ; }
	Prepare();
	f[0][0]=1;
	for (int i=0;i<2*n;++i)
		for (int j=0;j<=i && j<=n;++j)
			if (f[i][j])
			{
				if (j<n) f[i+1][j+1]=(f[i+1][j+1]+f[i][j])%Mod;
				if (j>0) f[i+1][j-1]=(f[i+1][j-1]+1ll*f[i][j]%Mod*Calc(n*k-(i-j)/2*k-j-1,k-2)%Mod)%Mod;
			}
	printf("%lld\n",1ll*f[2*n][0]*fact[n]%Mod);
}

int main()
{
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 62208
import sys

while True:
    n = int(sys.stdin.readline().rstrip())
    if n == 0:
        break;
    students = []
    for i in range(n):
        students.append(list(map(int, sys.stdin.readline().rstrip().split(' '))))
    s_list=[[min(row)==s for s in row] for row in students]
    t_list=[[max(col)==s for s in col] for col in zip(*students)]
    ret = [0]
    for i,data in enumerate(zip(s_list, zip(*t_list))):
        for j,d in enumerate(zip(*data)):
            if all(d):
                ret.append(students[i][j])
    print(max(ret))

Measured memory_bytes: 6256
/*#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
*/

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll INF = 1LL<<60;
const ll mod = 1e9 + 7;
const int MAX_N = 5e5 + 5;
int dx[] = { -1,0,1,0 }, dy[] = { 0,1,0,-1 };
vector<ll> prime;

ll inv[MAX_N], fac[MAX_N];

template <class T = ll> T in() { T x; cin >> x; return (x); }
inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1; while (b > 0) { if (b & 1) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; }
inline void _nCr() { fac[0] = 1; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; }
inline void PRI(ll n) { bool a[n + 1]; for (int i = 0; i < n + 1; i++) { a[i] = 1; }for (int i = 2; i < n + 1; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } }

typedef pair<int, pair<int, int>> edge;

class UnionFind {
private:
	vector<int> par;
public:
	UnionFind(int N) { par = vector<int>(N, -1LL); }
	int find(int x);
	ll size(int x);
	void unite(int x, int y);
	bool same(int x, int y);
};



class Kruskal {
private:
	UnionFind *uf;
	vector<edge> e;
public:
	vector<edge> mst;
	Kruskal(int N) { uf = new UnionFind(N); }
	void add(int x, int y, ll z);
	void run();
};



//----UnionFind-------------------------------
int UnionFind::find(int x) {
	if (par[x] < 0) return x;
	else return par[x] = find(par[x]);
}

ll UnionFind::size(int x) {
	return -par[find(x)];
}

void UnionFind::unite(int x, int y) {
	x = find(x);
	y = find(y);

	//大きい方に小さい方をくっ付ける
	if (size(x) < size(y)) swap(x, y);
	par[x] += par[y];
	par[y] = x;
}

bool UnionFind::same(int x, int y) {
	x = find(x);
	y = find(y);
	return x == y;
}



//----Kruskal-------------------------------
void Kruskal::add(int x, int y, ll z) {
	//x < y
	if (x > y) swap(x, y);
	e.push_back({ z,{x,y} });
}

void Kruskal::run() {
	sort(e.begin(), e.end());
	e.erase(unique(e.begin(), e.end()), e.end());
	for (auto x : e) {
		if (uf->same(x.second.first, x.second.second)) {
			continue;
		}
		else {
			mst.push_back(x);
			uf->unite(x.second.first, x.second.second);
		}
	}
}

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

Measured memory_bytes: 256
n = int(input())
x = [list(map(int, list(input().split()))) for i in range(n)]

x.sort(key=lambda x: x[2])

for cx in range(101):
    for cy in range(101):
        height = abs(x[n - 1][0] - cx) + abs(x[n - 1][1] - cy) + x[n - 1][2]
        for i in range(n):
            sub = max(height - abs(x[i][0] - cx) - abs(x[i][1] - cy), 0)
            if sub != x[i][2]:
                break
            if i == n - 1:
                print(cx, cy, height)
                exit()


Measured memory_bytes: 3064
import java.util.*;

public class Main {
	static int MAX = 100000;
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int Q = in.nextInt();
		int[] primes = new int[MAX+1];
		int[] yes = new int[MAX+1];
		int[] wooh = new int[MAX+1];
		primes[0] = 1;
		primes[1] = 1;
		for( int i = 2; i <= MAX; i++ ) {
			if(primes[i] == 0) {
				for( int j = i*2; j <= MAX; j+=i ) {
					if(primes[i] == 0 ) primes[j] = 1;
				}
			}
		}
		yes[1] = 0;
		for( int i = 2; i <= MAX; i++ ) {
			if( primes[i] == 0 && primes[(int)((i+1)/2)] == 0 ) {
				yes[i] = 1;
			}
		}
		yes[2017] = 1;
		for( int i = 1; i <= MAX; i++ ) {
			wooh[i] = wooh[i-1] + yes[i];
		}
		// for( int i = 19; i <= 51; i++ ) {
		// 	System.out.print(yes[i]+", ");
		// }
		// System.out.println();
		// for( int i = 19; i <= 51; i++ ) {
		// 	System.out.print(wooh[i]+", ");
		// }
		// System.out.println();
		while( Q-- > 0 ) {
			int l = in.nextInt();
			int r = in.nextInt();
			System.out.println(wooh[r]-wooh[l-1]);
		}
	}
}

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

string merge(string tr1, string tr2){
  string str="";
  int p1,p2;
  int depth;
  for(p1=1, depth=1; depth>0; p1++){
    if(tr1[p1]=='(') depth++;
    if(tr1[p1]==')') depth--;
  }
  for(p2=1, depth=1; depth>0; p2++){
    if(tr2[p2]=='(') depth++;
    if(tr2[p2]==')') depth--;
  }
  str += "(";
  if(p1!=2 && p2!=2){
    str +=  merge(tr1.substr(1,p1-2), tr2.substr(1,p2-2));
  }
  str += ")";
  
  p1++; p2++;
  int n1=1,n2=1;
  while(tr1[p1+n1]!=']') n1++;
  while(tr2[p2+n2]!=']') n2++;
  str += "[" + to_string( stoi(tr1.substr(p1,n1)) +stoi(tr2.substr(p2,n2)))  + "]";
  
  p1+=n1+2; p2+=n2+2;
  int size1 = tr1.length()-(p1+1);
  int size2 = tr2.length()-(p2+1);
  str += "(";
  if(size1!=0 && size2!=0){
    str += merge(tr1.substr(p1,size1), tr2.substr(p2,size2));
  }
  str += ")";
  return str;
}

int main(){
  string tr1,tr2;
  cin >> tr1 >> tr2;
  string ans = merge(tr1, tr2);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3368
package main

import (
	"fmt"
)

func main() {

	var N, K int
	fmt.Scanf("%d %d", &N, &K)

	var count int
	count = 1
	for {
		N = N / K
		if N != 0 {
			count++
		} else {
			break
		}
	}

	fmt.Println(count)

}


Measured memory_bytes: 1832