akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

const int INF = 100000000;

int main()
{
    int A, B, m;
    cin >> A >> B >> m;
    int a[100005], b[100005];
    int la = INF, lb = INF;
    for(int i = 0; i < A; i++){
        cin >> a[i];
        la = min(la, a[i]);
    }
    for(int i = 0; i < B; i++){
        cin >> b[i];
        lb = min(lb, b[i]);
    }
    int ans = la + lb;
    for(int i = 0; i < m; i++){
        int x, y, c;
        cin >> x >> y >> c;
        x--; y--;
        ans = min(ans, a[x] + b[y] - c);
    }
    cout << ans << endl;
}

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

using namespace std;

int main(void) {
  int n, a, b;
  cin >> n >> a >> b;

  int ans = 0;
  for (int i = 1; i <= n; i++) {
    int sum = 0, ci = i;
    while (ci) {
      sum += ci % 10;
      ci /= 10;
    }
    if (sum < a || sum > b) continue;
    ans += i;
  }
  cout << ans << endl;

  return 0;
}

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

using namespace std;

int main()
{
	unsigned int n[27];
    for (unsigned int i = 0; i < 26; ++i)
		n[i] = 0;

	char ch;
	while (cin >> ch) {
		if (islower(ch))
			n[ch-'a']++;
		else if (isupper(ch))
			n[ch-'A']++;
	}


		for (unsigned int i = 0; i < 26; ++i) {
			cout << (char)('a' + i)  << " : " << n[i] << endl;
		}

	return 0;
}



Measured memory_bytes: 3096
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define repc(i, s, t) for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.setf(ios_base::fixed);
    cout.precision(12);

    vector<int> a(5);
    read(a);
    print(find(all(a), 0) - begin(a) + 1);

    return 0;
}


Measured memory_bytes: 3556
#include<map>
#include<string>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int MAXN=100005;
int N;long long Ans;
string c[MAXN];
map<string,int>Mp;
int main(){
	scanf("%d",&N);
	for(int i=1;i<=N;i++){
		cin>>c[i];
		sort(c[i].begin(),c[i].end());
		//cout<<c[i];
		Ans=Ans+Mp[c[i]];
		Mp[c[i]]++;
	}
	printf("%lld\n",Ans);
}

Measured memory_bytes: 18176
// Package main provides
//
// File:  d.go
// Author: ymiyamoto
//
// Created on Sun Aug  5 09:01:17 2018
//
package main

import "fmt"

var N int
var arr []int64

func abs(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func min(arr ...int64) int64 {
	var ret int64 = 1 << 60
	for _, a := range arr {
		if a < ret {
			ret = a
		}
	}
	return ret
}

func max(arr ...int64) int64 {
	var ret int64
	for _, a := range arr {
		if ret < a {
			ret = a
		}
	}
	return ret
}

func main() {
	fmt.Scan(&N)
	arr = make([]int64, N)
	for i := range arr {
		fmt.Scan(&arr[i])
	}

	for i := range arr {
		if i+1 < len(arr) {
			arr[i+1] += arr[i]
		}
	}

	p := 2
	pl := 1
	pr := 3
	var ans int64 = 1 << 60
	for p < len(arr)-1 {
		for pl < p-1 && abs(arr[pl]-(arr[p-1]-arr[pl])) < abs(arr[pl-1]-(arr[p-1]-arr[pl-1])) {
			pl++
		}

		for pr < len(arr)-1 && abs(arr[len(arr)-1]-arr[pr]-(arr[pr]-arr[p-1])) < abs(arr[len(arr)-1]-arr[pr-1]-(arr[pr-1]-arr[p-1])) {
			pr++
		}

		P := arr[pl-1]
		Q := arr[p-1] - arr[pl-1]
		R := arr[len(arr)-1] - arr[pr-1]
		S := arr[pr-1] - arr[p-1]
		ans = min(ans, abs(max(P, Q, R, S)-min(P, Q, R, S)))
		p++
	}

	fmt.Println(ans)
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-6;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

const int64 mod = 1e9+7;

const int32 DIRECTED = 0;
const int32 UNDIRECTED = 1;

template<int32 isUNDIRECTED=0>
class Graph{
protected:
	struct Edge{
		int32 u, v, id;
		int64 c;
		Edge(int32 u, int32 v, int64 c=0, int32 id=0):u(u), v(v), c(c), id(id){}
	};

	int32 V, E;
	vector<vector<Edge>> G;
	vector<Edge> Es;
public:
	Graph(){}
	Graph(int32 V):V(V){G.resize(V);}
	Graph(const Graph<isUNDIRECTED>& g):V(g.V), E(g.E), G(g.G), Es(g.Es){}

	void add_edge(int32 u, int32 v, int64 c=0, int32 id=0){
		G[u].emplace_back(u, v, c, id);
		if(isUNDIRECTED) G[v].emplace_back(v, u, c, id);
		Es.emplace_back(u, v, c, id);
		E++;
	}

	const vector<Edge>& operator[](int32 k){
		return G[k];
	}
};

class Dinic : public Graph<DIRECTED>{
	vector<int32> level;
	vector<int32> iter;
public:
	Dinic(){}
	Dinic(int32 V):Graph<DIRECTED>(V){
		level.resize(V);
		iter.resize(V);
	}
	Dinic(const Graph<DIRECTED>& g):Graph<DIRECTED>(g){
		level.resize(V);
		iter.resize(V);
	}

	void add_edge(int32 from, int32 to, int64 cap){
		G[from].push_back(Edge(G[to].size(), to, cap));
		G[to].push_back(Edge(G[from].size()-1, from, 0));
	}

	void bfs(int32 s){
		fill(level.begin(), level.end(), -1);
		queue<int32> que;
		level[s] = 0;
		que.push(s);
		while(!que.empty()){
			int32 v = que.front(); que.pop();
			for(int32 i = 0;i < G[v].size();i++){
				Edge &e = G[v][i];
				if(e.c > 0 && level[e.v] < 0){
					level[e.v] = level[v]+1;
					que.push(e.v);
				}
			}
		}
	}

	int64 dfs(int32 v, int32 t, int64 f){
		if(v == t) return f;
		for(int32 &i = iter[v];i < G[v].size();i++){
			Edge &e = G[v][i];
			if(e.c > 0 && level[v] < level[e.v]){
				int32 d = dfs(e.v, t, min(f, e.c));
				if(d > 0){
					e.c -= d;
					G[e.v][e.u].c += d;
					return d;
				}
			}
		}
		return 0;
	}

	int64 max_flow(int32 s, int32 t){
		int64 flow = 0;
		for(;;){
			bfs(s);
			if(level[t] < 0) return flow;
			fill(iter.begin(), iter.end(), 0);
			int64 f;
			while((f = dfs(s, t, INF)) > 0)
				flow += f;
		}
		return flow;
	}
};

int main(void){
	int32 N;
	cin >> N;
	vector<int64> a(N);
	REP(i, N) cin >> a[i];
	int64 X = max(*max_element(all(a)), (int64)1);
	Dinic din(N+2);
	const int64 inf = (int64)INF*1000;
	REP(i, N){
		din.add_edge(N, i, X-a[i]);
		din.add_edge(i, N+1, X);
		int32 in = i+1;
		for(int32 j = 2;in*j <= N;j++){
			din.add_edge(in-1, in*j-1, inf);
		}
	}
	cout << X*N-din.max_flow(N, N+1) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

int main(){
	int n;
	cin>>n;
	vector<int>c(n);
	int sum = 0;
	rep(i,n){
		char tmp;
		cin>>tmp;
		if(tmp=='R'){
			c[i]=0;
		}else {
			c[i]=1;
			sum++;
		}
	}
	int cnt=0;
	rep(i,sum){
		if(c[n-i-1]==0)cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

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

    ll N, M; cin >> N >> M;
    priority_queue<ll> q;

    rep(i, N) {
        ll A; cin >> A;
        q.push(A);
    }

    rep(i, M) {
        ll A = q.top(); q.pop();
        q.push(A/2);
    }

    ll ans = 0;
    while (!q.empty()) {
        ans += q.top();
        q.pop();
    }

    cout << ans << endl;
}


Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>

using namespace std;

int main(void){
	vector<int> a(4);

	int n;

	cin >> n;

	a[0] = n / 1000;
	a[1] = n % 1000 / 100;
	a[2] = n % 100 / 10;
	a[3] = n% 10;




	do {
		if (a[0] + a[1] + a[2] + a[3] == 7){
			cout << a[0] << "+" << a[1] << "+" << a[2] << "+" << a[3] << "=7";
			break;
		}
		if (a[0] + a[1] + a[2] - a[3] == 7){
			cout << a[0] << "+" << a[1] << "+" << a[2] << "-" << a[3] << "=7";
			break;
		}
		if (a[0] + a[1] - a[2] + a[3] == 7){
			cout << a[0] << "+" << a[1] << "-" << a[2] << "+" << a[3] << "=7";
			break;
		}
		if (a[0] + a[1] - a[2] - a[3] == 7){
			cout << a[0] << "+" << a[1] << "-" << a[2] << "-" << a[3] << "=7";
			break;
		}
		if (a[0] - a[1] + a[2] + a[3] == 7){
			cout << a[0] << "-" << a[1] << "+" << a[2] << "+" << a[3] << "=7";
			break;
		}
		if (a[0] - a[1] + a[2] - a[3] == 7){
			cout << a[0] << "-" << a[1] << "+" << a[2] << "-" << a[3] << "=7";
			break;
		}
		if (a[0] - a[1] - a[2] + a[3] == 7){
			cout << a[0] << "-" << a[1] << "-" << a[2] << "+" << a[3] << "=7";
			break;
		}
		if (a[0] - a[1] - a[2] - a[3] == 7){
			cout << a[0] << "-" << a[1] << "-" << a[2] << "-" << a[3] << "=7";
			break;
		}
	} while(next_permutation(a.begin(), a.end()));

	return 0;
}

Measured memory_bytes: 256
N = int(input())
s= input()

def judge(start):
    ans = start
    for i in range(1, N):
        # 羊の処理
        if ans[i]=="S":
            # o or xで分岐
            if s[i]=="o":
                 ans[i+1]=ans[i-1]
            else:
                  # 羊x
                 ans[i+1]= "S" if ans[i-1]=="W" else "W"
        else:
            if s[i]=="o":
                # 狼o
                ans[i+1]= "S" if ans[i-1]=="W" else "W"
            else:
                  # 狼x
                 ans[i+1]=ans[i-1]

    # 判定
    if ans[0]==ans[N]:
        if ans[0]=="S":
            if s[0]=="o" and ans[1] == ans[N-1]:
                print("".join(ans[:-1]))
                exit()
            elif s[0]=="x" and ans[1] != ans[N-1]:
                print("".join(ans[:-1]))
                exit()
        elif ans[0]=="W":
            if s[0]=="o" and ans[1] != ans[N-1]:
                print("".join(ans[:-1]))
                exit()
            elif s[0]=="x" and ans[1] == ans[N-1]:
                print("".join(ans[:-1]))
                exit()
    else:
        return(-1)

judge(list("W"+"W"*(N)))
judge(list("W"+"S"*(N)))
judge(list("S"+"S"*(N)))
judge(list("S"+"W"*(N)))

print(-1)


Measured memory_bytes: 5024
#include <bits/stdc++.h>
using namespace std;
int n,a[210],ans;

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

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <climits>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define in insert
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define f first
#define s second
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define int ll
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
using namespace std;

 
const ll INF = 1e12;
const ll N =(100+5); // TODO : change value as per problem
const ll MOD = 1e9+7;

int adj[N][N];
void solve(){
	int n;
	cin >> n;
	if(n%2==0){
		// int s = n+1;
		// vector<pll> cand;
		// set<int> vis;
		// for(int i =1;i <= n;i++){
		// 	for(int j = 1;j<=n;j++){
		// 		if(j != i and j+i == s and !vis.count(i) and !vis.count(j)){
		// 			cand.pb({i,j});
		// 			vis.in(i);
		// 			vis.in(j);
		// 		}
		// 	}
		// }
		// for(auto x:cand){
		// 	cout << x.f << " " << x.s << endl;
		// }
		int S = n+1;
		for(int i =1;i<=(n/2);i++){
			adj[i][n-i+1] = 1;
			adj[n-i+1][i] =1;
		}
		vector<pll> ed;
		for(int i = 1;i <= n;i++){
			for(int j = i+1;j<=n;j++){
				if(!adj[i][j]){
					ed.pb({i,j});
				}
			}
		}
		cout << ed.size() << endl;
		for(auto x:ed) 
			cout << x.f << " " << x.s << endl;
	}
	else{
		int k = (n-1)/2;
		for(int i = 1;i<=k;i++){
			adj[i][n-1-i+1] = 1;
			adj[n-1-i+1][i] = 1;
		}
		vector<pll> ed;
		for(int i = 1;i <= n;i++){
			for(int j = i+1;j<=n;j++){
				if(!adj[i][j]){
					ed.pb({i,j});
				}
			}
		}
		cout << ed.size() << endl;
		for(auto x:ed) 
			cout << x.f << " " << x.s << endl;
	}





}
signed main(){
 
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
     // freopen(".in","r",stdin);freopen(".out","w",stdout);
    
     ll tt=1;   
     // cin >> tt;
    while(tt--){    
        solve();
    }    
}

Measured memory_bytes: 3812
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <iostream>
using namespace std;

int main() {
  string s;
  cin >> s;
  cout << s.at(0) << s.at(1) << s.at(2) << s.at(3) << ' ' << s.at(4) << s.at(5) << s.at(6) << s.at(7) << s.at(8) << s.at(9) << s.at(10) << s.at(11) << endl;
}


Measured memory_bytes: 3584
n, m, R = list(map(int, input().split()))
dist = [[float("INF") if i!=j else 0 for i in range(n)] for j in range(n)]
r = list(map(int, input().split()))
for i in range(m):
  a, b, c = list(map(int, input().split()))
  a, b = a-1, b-1
  dist[a][b] = c
  dist[b][a] = c
for k in range(n):
  for i in range(n):
    for j in range(n):
      dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])

from itertools import permutations
ans = float("INF")
for e in permutations(r):
  cur = 0
  for i in range(R-1):
    cur += dist[e[i]-1][e[i+1]-1]
  ans = min(ans, cur)
print(ans)

Measured memory_bytes: 72152
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
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 ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

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

    if (K + 1 <= A) {
        cout << K + 1 << endl;
    } else {
        if (A + 1 < B) {
            K -= (A - 1);
            cout << A + (B - A) * (K / 2) + K % 2 << endl;
        } else {
            cout << K + 1 << endl;
        }
    }
}


Measured memory_bytes: 3636
# ABC131B - Bite Eating
def main():
    n, l = list(map(int, input().rstrip().split()))
    total = (n + 1) * n // 2 + (l - 1) * n
    first, last = 1 + l - 1, n + l - 1
    if first >= 0:
        print(total - first)
    else:
        if last >= 0:
            print(total)
        else:
            print(total - last)


if __name__ == "__main__":
    main()

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
const double PI  = acos(-1.0);

//-------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;


int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    char s[100][100];
    REP(i, 3){
        REP(j, 3){
            cin >> s[i][j];
        }
    }


    cout << s[0][0] <<s[1][1] <<s[2][2] << endl;



    return 0;

}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

class AtCoder
{
    public void Slove()
    {
        var input = Console.ReadLine();
        int max = 0;
        int count = 0;

        foreach(char c in input)
        {
            if("ACGT".Contains(c))
            {
                count++;
                max = Math.Max(count, max);
            }
            else
            {
                count = 0;
            }
        }
        Console.WriteLine(max);
    }
    static void Main()
    {
        var ac = new AtCoder();
        ac.Slove();
    }
}

Measured memory_bytes: 13152
#include <iostream>

double det(double mat[2][2]) {
    double det = 0.0 ;
    det = mat[0][0]*mat[1][1] ;
    det -= mat[0][1]*mat[1][0] ;
    return det ;
}


double **inv(double (&mat)[2][2]) {
    
    double detNum = 1.0/det(mat) ;
    double dotMat[2][2] = {
        {  mat[1][1]*detNum, -mat[0][1]*detNum },
        { -mat[1][0]*detNum,  mat[0][0]*detNum }
    } ;
    
    double **p = (double **)malloc(sizeof(double *) * 2) ;
    for (int i=0; i<2; i++) {
        p[i] = (double *)malloc(sizeof(double) * 2) ;
        for (int j=0; j<2; j++) {
            p[i][j] = dotMat[i][j] ;
        }
    }
    return p;
    
}

double **dot(double (&mat1)[2][2], double (&mat2)[2][1]) {
    
    
    double mat3[2][1] ;
    
    for (int n=0; n<2; n++) {
        double sum = 0 ;
        for (int m=0; m<2; m++) {
            sum += mat1[n][m]*mat2[m][0] ;
        }
        mat3[n][0] = sum ;
    }
    
    
    
    double **p = (double **)malloc(sizeof(double *) * 2) ;
    for (int i=0; i<2; i++) {
        p[i] = (double *)malloc(sizeof(double)) ;
        p[i][0] = mat3[i][0] ;
    }
    return p;
}



int main(int argc, const char * argv[]) {
    double a, b, c, d, e, f ;
    while (1) {
        std::cin >> a >> b >> c >> d >> e >> f ;
        
        if (std::cin.fail()) break ;
        
        double A[2][2] = {
            { a, b },
            { d, e }
        } ;
        double P[2][1] = {
            { c },
            { f }
        } ;
        
        auto invAp = inv(A) ;
        double invA[2][2] ;
        for (int i=0; i<2; i++) {
            for (int j=0; j<2; j++) {
                invA[i][j] = invAp[i][j] ;
            }
        }
        
        
        auto X = dot(invA, P) ;
        
        printf("%.3f %.3f\n", X[0][0], X[1][0]) ;
        
        free(invAp) ;
        free(X) ;
    }
    return 0;
}


Measured memory_bytes: 3156
from math import ceil
from fractions import Fraction
n = int(input())
nums = [list(map(int,input().split())) for _ in range(n)]
a, b = 1, 1
p = 1
for i in range(n):
    x, y = nums[i][0], nums[i][1]
    p = ceil(max(Fraction(a, x), Fraction(b, y)))
    a, b = p * x, p * y
        
print(a + b)

Measured memory_bytes: 5604
program sample
    implicit none
  
    integer(8) :: i,j,m,n
    real(8)::a,b
    integer(8),allocatable :: x(:),y(:)
    character(len=100)::c !文字列

    read(*,*) c
    j=0
    n=len_trim(c)  !len_trimは空白を無視する、大きめに取って
    if (n==7)then
        if (c=='keyence')then
            write(*,*)'YES'
        else
            write(*,*)'NO'
        end if

        stop
    end if

    if (c(1:7)=='keyence')then
        write(*,*)'YES'
        stop
    end if
    if (c(n-6:n)=='keyence')then
        write(*,*)'YES'
        stop
    end if
    

    do i=1,6
    
        if (c(1:i)//c(n+i-6:n)=='keyence')then
            write(*,*)'YES'
            stop
        
        end if

    end do
    write(*,*)'NO'
  
    stop
end program sample
  



Measured memory_bytes: 256
def power(x, n, mod):
    ans = 1
    while n > 0:
        if n % 2 == 1:
            ans = ans * x % mod
        n //= 2
        x = x * x % mod
    return ans

mod = 10 ** 9 + 7

n = int(input())
a = list(map(int, input().split()))
a.sort()

ans = power(2, n//2, mod)
if n % 2:
    print(ans if all(a[i] == (i+1)//2*2 for i in range(n)) else 0)
else:
    print(ans if all(a[i] == i//2*2+1 for i in range(n)) else 0)

    
    


Measured memory_bytes: 84500
W,H,N = map(int,input().split())
xl = 0
xh = W
yl = 0
yh = H
for _ in range(N):
    x,y,a = map(int,input().split())
    if a==1:
        xl = max(xl,x)
    elif a==2:
        xh = min(xh,x)
    elif a==3:
        yl = max(yl,y)
    elif a==4:
        yh = min(yh,y)
dx = max(0,xh-xl)
dy = max(0,yh-yl)
print(dx*dy)

Measured memory_bytes: 62712
<?php
fscanf(STDIN,"%d",$n);
$alfa = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q',
              'r','s','t','u','v','w','x','y','z');

$ans = '';

while($n>0){
  $n--;
  $ans .= $alfa[$n%26];
  $n = intdiv($n,26);
}

echo strrev($ans);

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

int top,S[1000];

int push(int x) {
  S[++top] = x;
}

int pop() {
  top--;
  return S[top + 1];
}


int main() {

  int a,b;
  int top = 0;
  char s[100];
  
  while(scanf("%s",s) != EOF) {
    if(s[0] == '+') {
      a = pop();
      b = pop();
      push(a + b);
    }else if(s[0] == '-') {
      a = pop();
      b = pop();
      push(b - a);
    }else if(s[0] == '*') {
      a = pop();
      b = pop();
      push(a * b);
    }else {
      push(atoi(s));
    }
  }

  printf("%d\n",pop());


  
}


Measured memory_bytes: 3200
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    static long[][] mindist;
    static int[][] graph;

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();

        mindist = new long[110][110110]; // nowまでの最小のコスト
        graph = new int[110][110];

        // dp[0][0] = 0
        for (long[] longs : mindist) {
            Arrays.fill(longs, 0);
        }

        for (int[] longs : graph) {
            Arrays.fill(longs, 0);
        }

        // graph for input
        for (int i = 0; i < N; i++) {
            // scanner
            int w = scanner.nextInt();
            int v = scanner.nextInt();

            graph[i][0] = w; // weight
            graph[i][1] = v; // cost
        }

        for (int i = 0; i < N; i++) { // next_id
            for (int weight = 0; weight <= M; weight++) { // weight
                // buy
                if (weight >= graph[i][0]) {
                    if (mindist[i + 1][weight] < mindist[i][weight - graph[i][0]] + (long) graph[i][1]) {
                        mindist[i + 1][weight] = mindist[i][weight - graph[i][0]] + (long) graph[i][1];
                    }
                }

                // not buy
                if (mindist[i + 1][weight] < mindist[i][weight]) {
                    mindist[i + 1][weight] = mindist[i][weight];
                }
            }
        }

        System.out.println(mindist[N][M]);
    }
}


Measured memory_bytes: 160840
# C - Next Prime

def eratosthenes(n):
    numbers = [True] * (n + 1)
    primes = []
    for i in range(2, int(n ** 0.5 + 1)):
        if numbers[i]:
            for j in range(i*i, n + 1, i):
                numbers[j] = False
    for i in range(n+1):
        if numbers[i]:
            primes.append(i)
    return primes





primes = eratosthenes(1000000)
given = int(input())
for i in primes:
    if i >= given:
        print(i)
        break

Measured memory_bytes: 14064
#include <iostream>
#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 ALL(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << "\n"
#define INF 1000000000
#define MAX 500000
#define SENTINEL 2000000000
typedef long long ll;

using namespace std;

int cnt = 0;
int n;
int S[MAX], SortedS[MAX];
int L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(int A[], int left, int mid, int right)
{
    int n1 = mid - left, n2 = right - mid;
    REP(i, n1) { L[i] = A[left + i]; }
    REP(i, n2) { R[i] = A[mid + i]; }
    L[n1] = R[n2] = SENTINEL;
    int i = 0, j = 0;
    FOR(k, left, right)
    {
        cnt++;
        if ( L[i] <= R[j])
            A[k] = L[i++];
        else
        {
            A[k] = R[j++];
        }
    }
}

void mergeSort(int A[], int left, int right)
{
    if (left+1 < right)
    {
        int mid = (left + right) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int main()
{
    int A[MAX];
    cin >> n;
    REP(i, n) { cin >> A[i]; }
    mergeSort(A, 0, n);

    REP(i, n)
    {
        if (i)
            cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << cnt << endl;
}



Measured memory_bytes: 6912
# 最小公倍数(mathは3.5以降) 
 #参考　https://note.nkmk.me/python-gcd-lcm/
from functools import reduce
import math #(2020-0405  fractions→math)
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y) # 「//」はフロートにせずにintにする
def lcm(*numbers): # a,b,cなど
    return reduce(lcm_base, numbers, 1)
def lcm_list(numbers): #リスト
    return reduce(lcm_base, numbers, 1)


# 初期入力
import sys
input = sys.stdin.readline  #文字列では使わない
N = int(input())
a = list(map(int, input().split()))

saisyo_koubaisu =lcm_list(a)
ans =0
for aa in a:
    ans += (saisyo_koubaisu-1) %aa
print(ans)

Measured memory_bytes: 9596
#include<stdio.h>
char s[5];
int main(void){
  scanf("%s",&s);
  if(s[0]==s[1] && s[1]==s[2]){
    printf("Yes");
  }else if(s[1]==s[2] && s[2]==s[3]){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}


Measured memory_bytes: 128
#!/usr/bin/env python

N = int(input())
A = list(map(int, input().split(" ")))

A.sort()

rectangle_edges = []
prev_edge = A[N - 1]
for i in reversed(range(N - 1)):
    if A[i] == prev_edge:
        rectangle_edges.append(A[i])
        if len(rectangle_edges) == 2:
            break
        prev_edge = -1
    else:
        prev_edge = A[i]

if len(rectangle_edges) != 2:
    print(0)
else:
    print(int(rectangle_edges[0] * rectangle_edges[1]))
        
    


Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long h,w;
  cin>>h>>w;
  if(h==1||w==1){
    cout<<"1"<<endl;
  }else if((h*w)%2==0){
    cout<<h*w/2<<endl;
  }else{
    cout<<(h*w)/2+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
using System;

namespace Ex160424_1{
    public class Program{
        public static void Main(string[] args){
            var input = Console.ReadLine().Split(' ');
            var x = int.Parse(input[0]);
            var y = int.Parse(input[1]);

            Func<int, int, int> gcd = null;
            gcd = (i, j) =>{
                if(j == 0) return i;
                return gcd(j, i % j);
            };

            Console.WriteLine(gcd(Math.Max(x, y), Math.Min(x, y)));
        }
    }
}

Measured memory_bytes: 9360
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)

#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int x;

int main(){
  cin >> x;
  REP(i, 100000) {
    if(x <= i * (i + 1) / 2) {
      cout << i << endl;
      break;
    }
  }

  return 0;
}


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


int main()
{
	string s;
	cin>>s;
	if(s.length()%2)cout<<"No"<<endl;
	else
	{
		for(int i=0;i<s.length()-1;i+=2)
		{
			if(s.substr(i,2)!="hi")
			{
				cout<<"No"<<endl;
				return 0;
			}
		}
		cout<<"Yes"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<algorithm>

#define ll long long
#define sz 100005
#define mod 10000

using namespace std;

int main()
{
    char str[5];

    scanf("%s",str);

    if(str[0]==str[2])
        printf("Yes\n");

    else
        printf("No\n");

    return (0);
}


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

typedef pair<int, int> pii;
typedef long long ll;

int main(int argc, char* argv[]) {

	ll n, k;
	cin >> n >> k;

	ll m = n % k;
	m = min(m, abs(m - k));
	cout << m << endl;
}

Measured memory_bytes: 3596
/****JMD****/
/*
Nagendra Jha-11011
acm18in1495
*/
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ll long long int
#define ss second
#define ff first
#define mem(x,val) memset(x,val,sizeof(x))
#define f(i,n) for(ll i=0;i<n;i++)
#define sz(a) ll(a.size())

using namespace std;

inline void display(vector<ll> v)
{
    for(auto x:v) cout<<x<<" ";
    cout<<"\n";
}

inline string make6(ll x)
{
    string s=to_string(x);
    ll l=s.size();
    ll d=6-l;

    string f;

    while(d)
    {
        f+="0";
        d--;
    }

    f+=s;

    return f;
}

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

    {
        ll n,m;
        cin>>n>>m;

        vector< vector< pair<ll,ll> > > p(n);

        f(i,m)
        {
            ll x,y;
            cin>>x>>y;

            p[x-1].pb(mp(y,i));
        }

        vector< pair<ll,string> > ans;

        f(i,n)
        {
            if(!p[i].empty())
            {
                ll k=p[i].size();
                string fgf=make6(i+1);

                sort(p[i].begin(), p[i].end());

                ll counter=1;

                f(j,k)
                {
                    string temp=fgf;
                    string id=make6(counter);
                    temp+=id;

                    ans.pb(mp(p[i][j].ss,temp));
                    counter++;
                }
            }
        }

        sort(ans.begin(), ans.end());

        f(i,ans.size())
        {
            cout<<ans[i].ss<<"\n";
        }
    }

    return 0;
}


Measured memory_bytes: 13296
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <ctime>
#include <stdio.h>
#include <memory.h>
#include <sstream>
#include <iterator>

int main ()
{
	int n;
	std::cin >> n;
	int dif = 25000;
	std::vector <int> v (n), a(n), b(n);
	for (int i = 0; i < n; i++)
		a[i] = (i + 1) * dif,
		b[n - i - 1] = a[i];
	for (int i = 0, cnt = 1; i < n; i++) {
		int t;
		std::cin >> t;t--;
		a[t] += cnt;
		b[t] += cnt;
		cnt++;
	}
	for (int i = 0; i < n; i++)
		std::cout << a[i] << " ";
	std::cout << std::endl;
	for (int i = 0; i < n; i++)
		std::cout << b[i] << " ";
}

Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

int main(){
    int N, A, B;
    cin >> N >> A >> B;
    int ans = 0;
    for(int i = 1; i <= N; i++){
        int digit_sum = 0;
        for(int j = 0; j < to_string(i).size(); j++){
            digit_sum += to_string(i)[j] - '0';
        }
        if(A <= digit_sum && digit_sum <= B){
            ans += i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

alias Pair = Tuple!(int, "a", int, "b");

void main() {
    string s, t;
    scan(s);
    scan(t);

    int N = s.length.to!int;

    auto rs = new int[](26);
    auto rt = new int[](26);
    rs[] = -1;
    rt[] = -1;

    bool ok = true;

    foreach (i, ch ; s) {
        if (rs[ch - 'a'] == -1) {
            rs[ch - 'a'] = t[i] - 'a';
            if (rt[t[i] - 'a'] != -1 && rt[t[i] - 'a'] != ch - 'a') ok = false;
            else rt[t[i] - 'a'] = ch - 'a';
        }
        else {
            if (rs[ch - 'a'] != t[i] - 'a') ok = false;
        }
    }

    writeln(ok ? "Yes" : "No");
}






void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 2760
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
use proconio::fastout;
use proconio::input;
use proconio::marker::Usize1;
//use proconio::marker::Chars;
//use std::collections::HashSet;
// use std::cmp::*;
use std::collections::VecDeque;

#[fastout]
fn main() {
    input! {
    N:usize,
    M:usize,
    AB:[(Usize1,Usize1);M]
    }
    // 部屋iから繋がっている部屋のリスト
    let mut tonari: Vec<Vec<usize>> = vec![Vec::with_capacity(M); N];
    let mut ans: Vec<usize> = vec![N; N];
    for (a, b) in AB {
        tonari[a].push(b);
        tonari[b].push(a);
    }
    //    for i in 0..N {
    //        println!("{}={:?}", i, tonari[i]);
    //    }
    let mut nexts: VecDeque<usize> = VecDeque::new();
    nexts.push_back(0);
    while let Some(i) = nexts.pop_front() {
        //        println!("{}={:?}", i, tonari[i]);
        for &j in tonari[i].iter() {
            if ans[j] == N {
                ans[j] = i;
                nexts.push_back(j);
            }
        }
    }
    println!("Yes");
    for &j in ans.iter().skip(1) {
        println!("{}", j + 1);
    }
}


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

using namespace std;

int main() {
	char c; cin >> c;

	if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
		cout << "vowel" << endl;
	}
	else {
		cout << "consonant" << endl;
	}
}

Measured memory_bytes: 256
n,m=map(int,input().split())
num1=0
ans=1
num=[0,1]
for i in range(n):
    num.append(num[-1]+num[-2])
for i in range(m):
    a=int(input())
    if num1==a:
        ans=0
        break
    else:
        ans*=num[a-num1]
        ans%=10**9+7
        num1=a+1
ans*=num[n-num1+1]
ans%=10**9+7
print(ans)


Measured memory_bytes: 466012
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    string str;
    cin >> str;
    sort(begin(str),end(str));
    bool bRet = true;
    for(size_t i=0; i<str.size();)
    {
        char cmp = str[i];
        int icount = 0;
        for(size_t j=i;j<str.size();j++,icount++)
        {
            if(cmp != str[j])
            {
                break;
            }
        }
        if(icount%2 !=0)
        {
            bRet = false;
            break;
        }
        else
        {
            i+= icount;
        }
    }
    if(bRet)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int sum[2010][2010];
int dots[2010][2010];
int query(int x1, int y1, int x2, int y2) {
    if (x1 > x2 || y1 > y2) return 0;
    //cout << sum[x2][y2] << " " << sum[x1 + 1][y1] << " " << sum[x1][y1 + 1] << " " << sum[x1][y1] << endl;
    return sum[x2][y2] - sum[x2][y1 - 1] - sum[x1 - 1][y2] + sum[x1 - 1][y1 - 1];
}
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    rep(i, N) {
        int x, y; cin >> x >> y;
        char c; cin >> c;
        if(c == 'W') x += K;
        x %= K * 2;
        y %= K * 2;
        dots[x + 1][y + 1]++;
    }
    rep(i, K * 2 + 3) {
        rep(j, K * 2 + 3) {
            sum[i + 1][j + 1] += dots[i + 1][j + 1] + sum[i][j + 1] + sum[i + 1][j] - sum[i][j];
        }
    }
    // rep(i, K * 2 + 3) {
    //     rep(j, K * 2 + 3) {
    //         cout << sum[i][j];
    //     }
    //     cout << endl;
    // }
    int ans = 0;
    REP(i, 1, K) {
        REP(j, 1, K) {
            int tmp[5] = {};
            tmp[0] = query(1, 1, i - 1, j - 1);
            tmp[1] = query(i, j, K + i - 1, K + j - 1);
            tmp[2] = query(K + i, K + j, K * 2, K * 2);
            tmp[3] = query(K + i, 1, K * 2, j - 1);
            tmp[4] = query(1, K + j, i - 1, K * 2);
            int S = 0;
            rep(k, 5) 
                S += tmp[k];
            
            ans = max(ans, S);
            ans = max(ans, N - S);
        }
    }
    cout << ans << endl;

    return 0;
}



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

int main(){
    ll N;cin>>N;
    ll info[N],div[N-1];
    rep(i,N)cin>>info[i];
    rep(i,N-1)div[i]=info[i+1]-info[i];
    ll count=1,check=0;
    if(div[0]>0)check=1;
    else if(div[0]<0) check=-1;

    for(int i=1;i<N-1;i++){
        if(div[i]*check>=0){
            if(div[i]>0)check=1;
            else if(div[i]<0) check=-1;
            continue;
        }
        else{
            count++;
            if(i==N-2)continue;
            if(div[i+1]>0)check=1;
            else if(div[i+1]==0)check=0;
            else check=-1;
            i++;
        }
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <sstream>
#include <string>
#include <cstdio>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstring>
#include <tuple>
#include <utility>
#include <list>
#include <cmath>

using namespace std;

typedef long long LL;
typedef vector<int> Array;
typedef pair<int, int> P;

const int INF = 1 << 29;
const LL MOD = 100000;
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define all(c) (c).begin(), (c).end()

struct edge{ LL to, cost; edge(int t, LL c) :to(t), cost(c){} };

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

int bitcount(int a)
{
	int ret = 0;
	while (a != 0) { ret++; a = (a - 1) & a; }
	return ret;
}

int main()
{
	int d, n, m;
	while (cin >> d && d)
	{
		cin >> n >> m;
		vector<int> places(n + 1);
		places[0] = 0;
		places[n] = d;
		rep(i, n - 1) cin >> places[i + 1];
		sort(all(places));
		int ans = 0;
		rep(i, m)
		{
			int x; cin >> x;
			if (x == 0) continue;
			auto t = lower_bound(all(places), x);
			ans += min(abs(*t - x), abs(*(t - 1) - x));
		}
		cout << ans << endl;
	}

	return 0;
}

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

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    string s; cin >> s;
    string t = "AKIHABARA";

    if(s.size() > 9){
        cout << "NO" << endl;
        return 0;
    }

    int c1=0, c2=0;
    for(c1=0; c1<9; c1++){
        if(t[c1] == s[c2]){
            c2++;
        }
        else if(t[c1] == 'A'){
            continue;
        }
        else{
            cout << "NO" << endl;
            return 0;
        }
    }

    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
typedef pair<int, int> P;

/** Problem0569 : Illumination **/
int dx1[6] = {-1, 0, 1, 1, 1, 0};
int dx2[6] = {-1, -1, 0, 1, 0, -1};
int dy1[6] = {0, -1, -1, 0, 1, 1};

int main()
{
	int W, H;
	cin>>W>>H;
	bool a[W+2][H+2], b[W+2][H+2], vis[W+2][H+2];
	
	rep(y, H) {
		rep(x, W) {
			cin>>a[x+1][y+1];
		}
	}
	rep(x, W+2) {
		a[x][0] = false;
		a[x][H+1] = false;
	}
	
	rep(y, H+2) {
		a[0][y] = false;
		a[W+1][y] = false;
	}
	
	fill(b[0], b[0]+(W+2)*(H+2), true);
	fill(vis[0], vis[0]+(W+2)*(H+2), false);

	queue<P> Q;
	Q.push(P(0, 0));
	vis[0][0] = true;
	while (Q.size()) {
		P p = Q.front(); Q.pop();
		b[p.first][p.second] = false;
		int x = p.first, y = p.second;
		rep(i, 6) {
			int nx, ny = y + dy1[i];
			if (y%2 == 0)
				nx = x + dx2[i];
			else
				nx = x + dx1[i];
			
			if_range(nx, ny, W+2, H+2) {
				if (!vis[nx][ny] && !a[nx][ny]) {
					Q.push(P(nx, ny));
					vis[nx][ny] = true;
				}
			}
		}
	}
	
	int ans=0;
	rep(y, H+2) {
		rep(x, W+2) {
			if (b[x][y]) {
				rep(i, 6) {
					int nx, ny = y + dy1[i];
					if (y%2 == 0)
						nx = x + dx2[i];
					else
						nx = x + dx1[i];
					
					if_range(nx, ny, W+2, H+2) {
						if (!b[nx][ny])
							ans++;
					}
				}
			}
		}
	}
	
	cout << ans << endl;
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

struct Dist{
    double x;
    double y;
};
signed main()
{   
    gearup;
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) a[i]=i;
    vector<Dist> d(n);
    rep(i,n) cin >> d[i].x >> d[i].y;
    double res = 0.0;
    int count = 0;
    do{
        double ans = 0.0;
        rep(i,n-1){
            ans+= hypot(d[a[i]].x-d[a[i+1]].x,d[a[i]].y-d[a[i+1]].y);
        }
        count++;
        res += ans;
    }while(next_permutation(all(a)));
    cout << fixed << setprecision(10) << res/count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>
#include<chrono>
using namespace std;
using namespace std::chrono;
//using namespace __gnu_pbds;
#define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define fi         first
#define se         second
#define int         long long
#define pb         push_back
#define emp        emplace_back
#define vv(x)      vector<x>
#define mp(x,y)    map<x,y>
#define dq(x)      deque<x>
#define pql(x)     priority_queue<x>
#define pqs(x)     priority_queue<x,vv(x),greater<x> >
#define mod         1000000007
#define forf(i,a,b) for(int i=a;i<b;i++)
#define it(x)      x::iterator
#define ll         long long
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
#define vii        vector<int>
#define big        3e18
#define sm         -2e9
#define mkr        make_pair
#define vpi        vector<pair<int,int> >
#define pii        pair<int,int>
#define rng        500005
#define sz(x)      (int)x.size()
#define rv(x)      reverse(x.begin(),x.end())
#define out(x)     cout<<x.fi<<" "<<x.se<<endl;
 
//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
 
void pr_init()
{
 
#ifndef ONLINE_JUDGE
  freopen("gin.txt", "r", stdin);
  freopen("gout.txt", "w", stdout);
 
#endif
}

void solve()
{
  
 int a,b,c,k;
 cin >> a >> b >> c >> k;
 while(b<=a && k>0) 
 {
   k--;
   b*=2;
 }
 while(c<=b && k>0) 
 {
   k--;
   c*=2;
 }

 if(b>a && c>b) cout<<"Yes\n";
 else cout<<"No\n";
 
  
  
}
 
 
int32_t main()
{
  pr_init();
  //fastio;
 
  auto start = high_resolution_clock::now();
 
  solve();
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start);
  // cout << "Time taken by function: "
  //       << duration.count() << " microseconds" << endl;
 
}
 

Measured memory_bytes: 3624