akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
using namespace std;
#define INF 10000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,int> P;

int st[3][40];

int main(){
    string ans[16]={"AKIHABARA","KIHABARA","AKIHBARA","AKIHABRA","AKIHABAR","AKIHABR","AKIHBAR","AKIHBRA","KIHABAR","KIHBARA","AKIHBR","KIHABR","KIHBAR","KIHBRA","KIHBR"};
    string s;
    cin>>s;
    for(int i=0;i<16;i++){
        if(ans[i]==s){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
}


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

char S[100005];

int main(){

	scanf("%s",S);

	int len=strlen(S);

	int i;

	int ans=0;

	char prev=S[0];

	for(i=1;i<len;i++){
		if(prev!=S[i]){ans++;}
		prev=S[i];
	}
	printf("%d\n",ans);

	return 0;
}

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

#define N 1000

int n, k, p[N];

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main(){
    int sum=0;
    scanf("%d %d",&n, &k);
    for (int i = 0; i < n; i++){
        scanf("%d",&p[i]);
    }

    qsort(p, n, sizeof(int), compare_int);
    for (int i = 0; i < k; i++){
        sum += p[i];
    }

    printf("%d\n",sum); 
    return 0;
}


Measured memory_bytes: 1744
#include<iostream>
#include<queue>
using namespace std;
int h,w,n,ans=0;
char c[1002][1002];
pair<int,int> a[12],pi;
bool f[1002][1002];

int dist(pair<int,int> s,pair<int,int> g){
	for(int i=0;i<1002;i++)for(int j=0;j<1002;j++)f[i][j]=false;
	//cout<<s.first<<","<<s.second<<" "<<g.first<<","<<g.second<<endl;
	queue<pair<pair<int,int>,int>> que;
	pair<pair<int,int>,int> p;
	p.first=s; p.second=0;
	que.push(p);
	while(que.size()>0){
		p=que.front(); que.pop();
		if(p.first==g)return p.second;
		f[p.first.first][p.first.second]=true;
		//cout<<p.first.first<<","<<p.first.second<<endl;
		//if(p.first.first==g.first&&p.first.second==g.second)return p.second;
		if(c[p.first.first-1][p.first.second]!='X'&&!f[p.first.first-1][p.first.second]){p.first.first--; p.second++; que.push(p); p.first.first++; p.second--; f[p.first.first-1][p.first.second]=true;}
		if(c[p.first.first+1][p.first.second]!='X'&&!f[p.first.first+1][p.first.second]){p.first.first++; p.second++; que.push(p); p.first.first--; p.second--; f[p.first.first+1][p.first.second]=true;}
		if(c[p.first.first][p.first.second-1]!='X'&&!f[p.first.first][p.first.second-1]){p.first.second--; p.second++; que.push(p); p.first.second++; p.second--; f[p.first.first][p.first.second-1]=true;}
		if(c[p.first.first][p.first.second+1]!='X'&&!f[p.first.first][p.first.second+1]){p.first.second++; p.second++; que.push(p); p.first.second--; p.second--; f[p.first.first][p.first.second+1]=true;}
	}
	return -1;
}
	

int main(){
	scanf("%d%d%d",&h,&w,&n);
	for(int i=0;i<1002;i++)for(int j=0;j<1002;j++)c[i][j]='X';
	for(int i=1;i<=h;i++){
		scanf("\n");
		for(int j=1;j<=w;j++){
			scanf("%c",&c[i][j]);
			if('1'<=c[i][j]&&c[i][j]<='9'){
				a[c[i][j]-48].first=i;
				a[c[i][j]-48].second=j;
			}
			if(c[i][j]=='S'){
				a[0].first=i; a[0].second=j;
			}
		}
	}
		/*for(int i=1;i<=h;i++){	
			for(int j=1;j<=w;j++){
				printf("%c",c[i][j]);
			}
			printf("\n");
		}*/
	for(int i=1;i<=n;i++){
		//cout<<i<<endl;
		ans+=dist(a[i-1],a[i]);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 3156
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define Decimal fixed << setprecision(20)
#define SHOWP(x) cerr<<"["<<(x).FI<<", "<<(x).SE<<"]";
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}
constexpr int INF = 1 << 30 - 1;
constexpr long long LLINF = 1LL << 60;
constexpr long long MOD = 1000000007;

typedef long long ll;
typedef pair<ll, ll> P;

int col[110000];
vector<P> edge[110000];
void dfs(ll now, ll par, ll dist)
{
  col[now] = dist % 2;
  for (auto& to : edge[now]) {
    if (to.FI != par) dfs(to.FI, now, dist + to.SE);
  }
}

int main()
{
  REP(i, 110000) col[i] = -1;
  ll N;
  cin >> N;
  REP(i, N - 1) {
    ll u, v, w;
    cin >> u >> v >> w;
    u--,v--;
    edge[u].PB(MP(v, w));
    edge[v].PB(MP(u, w));
  }
  dfs(0, -1, 0);
  REP(i, N) {
    cout << col[i] << endl;
  }
  return 0;
}


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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) FOR(i,0,a)
#define RREP(i,a) RFOR(i,a,0)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) sort(ALL(a))

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<int> VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;
typedef std::pair<int,int> PII;

template<class T>
struct RMQ {
    T sz;
    T sq;

    std::vector<T> data;
    std::vector<T> bucket;
    RMQ(T size){
        sq = std::ceil(std::sqrt(size));
        sz = size;
        data.resize(size, -1);
        bucket.resize(sq, -1);
    }  
    RMQ(T size, T init): data(size, init){
        sq = std::ceil(std::sqrt(size));
        sz = size;
        data.resize(size, init);
        bucket.resize(sq, init);
    }
    void update(T i, T x) {
        data[i] = x;
        T minVal = data[i];
        T k = i / sq;
        FOR(j,k*sq,(k+1)*sq) {
            minVal = std::min(minVal, data[j]);
        }
        bucket[k] = minVal;
    }
    T find(T s, T t) {
        if(s == t) return data[s];
        T val = (1LL << 31) - 1;
        REP(i, sq) {
            T l = i*sq, r = (i+1)*sq;
            if(r <= s || t <= l) {
                continue;
            }
            
            if(s <= l && r <= t) {
                val = std::min(val, bucket[i]);
            } else {
                FOR(j, std::max(s, l), std::min(t, r) + 1) {
                    val = std::min(val, data[j]);
                }
            }
        }
        return val;
    }
};

int main(){
    int n, q, c, x, y;
    std::cin >> n >> q;
    RMQ<long> rmq = RMQ<long>(100000, (1LL << 31) - 1);
    REP(i, q) {
        std::cin >> c >> x >> y;
        if(c == 0) {
            rmq.update(x, y);
        } else {
            std::cout << rmq.find(x, y) << std::endl;
        }
    }
}

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

#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);

int main() {
    fast_io;
    int n,m;
    cin>>n>>m;

    vector<int> height(n);
    vector<bool> accept(n);
    accept.assign(n,true);
    for(int i=0;i<n;i++) {
        int h;
        cin>>h;
        height[i]=h;
    }

    for(int i=0;i<m;i++) {
        int a,b;
        cin>>a>>b;

        if(height[a-1]<height[b-1]) {
            accept[a-1]=false;
        }
        else if (height[a-1]>height[b-1]) {
            accept[b-1]=false;
        }
        else {
            accept[b-1]=false;
            accept[a-1]=false;
        }
    }

    int ans=0;
    for(int i=0;i<n;i++) {
        if(accept[i]) {
            ans++;
        }
    }

    cout<<ans<<endl;


}




Measured memory_bytes: 3724
import numpy as np
N = int(input())

n = np.array([[1,2,3,4,5,6,7,8,9]])
m = np.array([[1],[2],[3],[4],[5],[6],[7],[8],[9]])
l = (n*m).flatten()

if N in l:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 21364
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	p := make([]int, n)

	for i := 0; i < n; i++ {
		fmt.Scan(&p[i])
	}

	c := 0
	for i := 1; i < n - 1; i++ {
		if p[i - 1] < p[i] && p[i] < p[i + 1] {
			c++
		}
		if p[i - 1] > p[i] && p[i] > p[i + 1] {
			c++
		}
	}
	fmt.Println(c)
}

Measured memory_bytes: 512
(defun count2div (n)
    (labels ((f (n i)
                (if (not (zerop (rem n 2))) i
                    (f (floor n 2) (1+ i)))))
        (f n 0)))

(defun main ()
    (let* ((n (read))
           (a-list (loop for i below n collect (read))))
        (format t "~A~%"
            (reduce 'min (map 'list #'count2div a-list)))))

(main)

Measured memory_bytes: 16096
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

using ll = long long;

template <class T>
using grid = vector<vector<T>>;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...);
}

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

int main() {
  int input(x, n);
  vector<bool> other(100 + 2);
  REP(i, n) {
    int input(p);
    other[p] = true;
  }

  int maxv = 1000;
  int ans = -1;
  REP(i, 100 + 2) {
    if (other[i]) continue;

    int d = abs(x - i);
    if (maxv > d) {
      maxv = d;
      ans = i;
    }
  }

  print(ans);
}

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

using namespace std;
typedef long long LL;

int main(){
  int N;
  LL x;
  cin >> N >> x;
  vector<LL> a(N);
  rep(i,N) cin >> a[i];
  LL ans=0;
  rep(i,N-1){
    if(a[i]+a[i+1]>x){
      ans+=a[i]+a[i+1]-x;
      if(x>=a[i]) a[i+1]=x-a[i];
      else a[i+1]=0;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(){
  int n,i,key[250];
  scanf("%d",&n);
  for(i=1;i<=n;i++)scanf("%d",&key[i]);
  
  for(i=1;i<=n;i++){
    printf("node %d: key = %d, ",i,key[i]);
    if(i/2 >= 1)printf("parent key = %d, ",key[i/2]);
    if(2*i<=n) printf("left key = %d, ",key[i*2]);
    if(2*i+1<=n)printf("right key = %d, ",key[i*2+1]);
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2108
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define PER(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9+5)
#define INFLL ((LL)4e18)
#define ALL(x) (x).begin(),(x).end()
#define BIT(x) (1LL << (x))
using namespace std;

LL func(LL x){
	PER(i, 64){
		if(x&BIT(i)){
			return i;
		}
	}
}

int main(){
	LL X, Y;
	cin >> X >> Y;
	cout << func(Y/X) + 1 << endl;
	return 0;
}


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

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

  string r;
  bool st = true;
  rep(i, q) {
    int t;
    cin >> t;

    if(t == 1) {
      st = !st;
      continue;
    }

    int f;
    string c;
    cin >> f >> c;

    if((f == 1 && st) || (f == 2 && !st))
      r += c;
    else
      s += c;
  }
  if(st) {
    reverse(r.begin(), r.end());
    cout << r << s;
  } else {
    reverse(s.begin(), s.end());
    cout << s << r;
  }
}


Measured memory_bytes: 3760
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

def main():
    n, m, l = map(int, input().split())
    inf = 1001001001
    dist = [[inf] * n for _ in range(n)]
    for _ in range(m):
        a, b, c = map(int, input().split())
        a, b = a - 1, b - 1
        dist[a][b] = dist[b][a] = c
    for w in range(n):
        for u in range(n):
            for v in range(n):
                dist[u][v] = min(dist[u][v], dist[u][w] + dist[w][v])
    dist2 = [[inf] * n for _ in range(n)]
    for u in range(n):
        for v in range(n):
            if dist[u][v] <= l: dist2[u][v] = 1
    for w in range(n):
        for u in range(n):
            for v in range(n):
                dist2[u][v] = min(dist2[u][v], dist2[u][w] + dist2[w][v])

    q = int(input())
    for _ in range(q):
        s, t = map(lambda x: int(x) - 1, input().split())
        ans = dist2[s][t]
        if ans == inf:
            print(-1)
        else:
            print(ans - 1)

main()


Measured memory_bytes: 56412
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;


template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}


#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)

int main() {
	ll N,P,A;
	cin >> N >> P;
	map<ll, ll> dic = { {0,1} };
	rep(i, 0, N) {
		cin >> A;
		map<ll,ll> dic2 = dic;
		for (auto itr = dic.begin(); itr != dic.end(); itr++) {
			dic2[itr->first + A] += itr->second;
		}
		dic = dic2;
	}


	ll ans = 0;
	for (auto itr = dic.begin(); itr != dic.end(); itr++) {
		if (itr->first % 2 == P) {
			ans += itr->second;
		}
	}

	cout << ans << endl;
	return 0;

}


Measured memory_bytes: 3936
// 根付き木の表現
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

using namespace std;

#define MAX_N 100005
const int NIL = -1;

typedef struct v_node_num
{
    // 節点の親
    int parent;
    // 節点の左の子
    int left_child;
    // 節点の右の兄弟
    int right_brother;
}Node;

Node T[MAX_N];
int n;
int D[MAX_N];

// u : 要素No.
void print(int u)
{
    int i, c;

    cout << "node " << u << ": ";
    cout << "parent = " << T[u].parent << ", ";
    cout << "depth = " << D[u] << ", ";

    // -----▼▼▼▼▼ ノード情報の表示 ▼▼▼▼▼-----

    if( T[u].parent == NIL )
    {
        // 親が存在しないので、root
        cout << "root, ";
    }
    else if( T[u].left_child == NIL )
    {
        // 左の子がいないので、leaf
        cout << "leaf, ";
    }
    else
    {
        cout << "internal node, ";
    }

    // -----▲▲▲▲▲ ノード情報の表示 ▲▲▲▲▲-----

    // -----▼▼▼▼▼ 各節点の子の要素の表示 ▼▼▼▼▼-----

    cout << "[";

    for ( i = 0, c = T[u].left_child; c != NIL; i++, c = T[c].right_brother )
    {

        if( i )
        {
            cout  << ", ";
        }

        cout << c;
    }

    cout << "]" << endl;

    // -----▲▲▲▲▲ 各節点の子の要素の表示 ▲▲▲▲▲-----

    return;

}

// 再帰的に深さを求める
// u : 要素No.
// p : 要素の深さ
int rec(int u, int p)
{
    D[u] = p;

    if( T[u].right_brother != NIL )
    {
        // 右の兄弟に同じ深さを設定
        rec(T[u].right_brother, p);
    }

    if( T[u].left_child != NIL)
    {
        // 最も左の子に[ 自分の深さ + 1 ]を設定
        rec(T[u].left_child, p + 1);
    }

    return 0;
}

int main(void)
{
    int i, j, d, v, c, left, right;

    cin >> n;

    for( i = 0; i < n; i++)
    {
        T[i].parent = NIL;
        T[i].left_child = NIL;
        T[i].right_brother = NIL;
    }

    for( i = 0; i < n; i++ )
    {
        cin >> v >> d;

        for( j = 0; j < d; j++ )
        {
            cin >> c;

            if( j == 0 )
            {
                T[v].left_child = c;
            }
            else
            {
                T[left].right_brother = c;
            }

            left = c;
            T[c].parent = v;
        }
    }

    for( i = 0; i < n; i++ )
    {
        if( T[i].parent == NIL )
        {
            right = i;
        }
    }

    rec(right, 0);

    for( i = 0; i < n; i++ )
    {
        print(i);
    }

    return 0;
}



Measured memory_bytes: 7760
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <utility>
#include <functional>
#include <queue>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>      // std::setprecision
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor_ct.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/pending/disjoint_sets.hpp>
#include <boost/icl/interval_map.hpp>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/strong_components.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
#include <boost/graph/kruskal_min_spanning_tree.hpp>
#include <boost/graph/graph_utility.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

int main() {
  int A, B;

  cin >> A >> B;
  
  int add = A - 1;

  cout << (int)ceil((double)(B - 1) / (double)add) << endl;

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n, k;
	cin>>n>>k;
	vector<int> v(n), dp(n);
	for(int i=0;i<n;i++)
		cin>>v[i];
	for(int i=n-2;i>=0;i--){
		dp[i]=1e9;
		for(int j=i+1;j<n && j-i<=k;j++)
			dp[i]=min(dp[i],abs(v[i]-v[j])+dp[j]);
	}
	cout<<dp[0];
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
const int N=1000050;
int deg[N];
bool cyc;
bool was[N];
int disc[N],tid;
vector<int> E[N];
void DFS(int u, int p, int x, int y)
{
	disc[u]=++tid;
	was[u]=1;
	for(int v:E[u])
	{
		if(!disc[v])
		{
			DFS(v,u,x,y);
		}
		else if(v!=p && v==x && was[y]==0)
		{
			//printf("%i - %i\n",u,v);
			cyc=1;
		}
	}
	was[u]=0;
}
int main()
{
	int n,m,u,v;
	scanf("%i %i",&n,&m);
	for(int i=1;i<=m;i++) scanf("%i %i",&u,&v),deg[u]++,deg[v]++,E[u].pb(v),E[v].pb(u);
	bool ok=1;
	int cnt4=0,cnt6=0;
	for(int i=1;i<=n;i++)
	{
		if(deg[i]&1) ok=0;
		if(deg[i]==4) cnt4++;
		if(deg[i]>=6) cnt6++;
	}
	if(ok && (cnt4>2 || cnt6>0)) printf("Yes\n");
	else if(ok && cnt4==2)
	{
        int x=0,y=0;
        for(int i=1;i<=n;i++)
		{
			if(deg[i]==4)
			{
				if(x) y=i;
				else x=i;
			}
		}
        DFS(x,0,x,y);
        //printf("%i %i\n",x,y);
        if(cyc) printf("Yes\n");
        else printf("No\n");
	}
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 35968
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
int n,m;
map<string,int> bmp,rmp;
int main(){
  cin >> n;
  for(int i=0;i<n;i++){
    string s;
    cin >> s;
    bmp[s]++;
    rmp[s]=0;
  }
  cin >> m;
  for(int i=0;i<m;i++){
    string t;
    cin >> t;
    rmp[t]++;
  }
  int res=0;
  for(auto i=bmp.begin();i!=bmp.end();i++){
    for(auto j=rmp.begin();j!=rmp.end();j++){
      if(i->first==j->first&&i->second>j->second) res=max(i->second-j->second,res);
    }
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 256
int lots[31];
void change(int a,int b){
      int tem;
      tem =lots[a];
      lots[a]=lots[b];
      lots[b]=tem;
}
 
 
int main(void){
   int w,n,i;
   scanf("%d %d",&w,&n);
    for(i=1;i<=w;i++){
      lots[i]=i;
   }
   while(n>0){
     int a,b;
     scanf("%d,%d",&a,&b);
     change(a,b);
     n--;
   }
   for(i=1;i<=w;i++){
      printf("%d\n",lots[i]);
   }
   return 0;
}

Measured memory_bytes: 596
D = 1_000_000_007
N, M = gets.split.map(&:to_i)
X = gets.split.map(&:to_i) 
Y = gets.split.map(&:to_i)

def calc(a)
  tot = 0 
  while a.size > 1 
    tot += (a.size - 1) * (a.shift - a.pop) % D
  end
  tot 
end

p calc(X) * calc(Y) % D

Measured memory_bytes: 15516
#include<bits/stdc++.h>
#include<algorithm>
#include<string>

using namespace std;


/*
    FILE *f=fopen("data.txt","w");
    fprintf(f,);
    fclose(f);
*/

#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pi acos(-1.0)
#define scan(a) scanf("%d",&a)
#define scanll(a) scanf("%lld",&a)
#define print(a) printf("%d\n",a)
#define printll(a) printf("%lld\n",a)
#define stll(a) stoll(a,nullptr,10)
#define PII pair<ll,ll>
#define mp(a,b) make_pair(a,b)
#define EL printf("\n")
#define ff first
#define ss second

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll n,sum=0,a;
    cin>>n;
    while(n--)
    {
        cin>>a;
        sum+=(a-1);
    }
    cout<<sum<<endl;
}






Measured memory_bytes: 256
from collections import deque
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

h,w,k = inm()
a = []
for i in range(h):
    t = ins()
    a.append(t)
    v = t.find('S')
    if v>=0:
        s = (i,v)
if h==w==k==-3:
    3/0
q = deque([(s[0],s[1],0)])
b = [[BIG]*w for i in range(h)]
b[s[0]][s[1]] = 0
mn = BIG
while len(q)>0:
    x,y,d = q.popleft()
    mn = min([ \
      mn,(x+k-1)//k,(h-1-x+k-1)//k,(y+k-1)//k,(w-1-y+k-1)//k])
    if d>=k:
        continue
    for dx,dy in [(0,1),(0,-1),(1,0),(-1,0)]:
        xx = x+dx
        yy = y+dy
        if 0<=xx<h and 0<=yy<w and a[xx][yy]!='#' and \
           b[xx][yy]==BIG:
            b[xx][yy] = d+1
            q.append((xx,yy,d+1))
print(mn+1)


Measured memory_bytes: 86728
#include <algorithm>
#include <array>
#include <cassert>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <tuple>
#include <vector>
// #include <queue>
// #include <map>

using namespace std;

namespace atcoder {
namespace {

[[gnu::unused]] bool check()
{
  return false;
}

template<typename T>
vector<T> getN(istream& in, const unsigned int N)
{
  vector<T> seq;
  for (auto i = 0u; i < N; ++i) {
    T x;
    in >> x;
    seq.push_back(x);
  }
  return seq;
}

int count(istream& in)
{
  unsigned int N;
  int X;
  in >> N >> X;
  // cout << N << '\t' << X << '\n';
  // assert(1 <= N && N <= 100 && 1 <= X && X <= 10000);
  const auto seq = getN<int>(in, N);
  assert(all_of(seq.begin(), seq.end(), [](const auto x) { return 1 <= x && x <= 100; }));
  std::vector<int> sum(seq.size());
  partial_sum(seq.begin(), seq.end(), sum.begin());
  const auto i = find_if(sum.begin(), sum.end(), [X](const auto y) { return y > X; });
  return i - sum.begin() + 1;
}

[[gnu::unused]] void test()
{
  {
    constexpr auto str = R"(
3 6
3 4 5
)";
    stringstream in{str};
    const auto ans = count(in);
    cout << ans << '\n';
    assert(count(in) == 2);
  }
  {
    constexpr auto str = R"(
4 9
3 3 3 3
)";
    stringstream in{str};
    const auto ans = count(in);
    cout << ans << '\n';
    assert(count(in) == 4);
  }
}

} // namespace
} // namespace atcoder

////////////////////////////////////////////////////////////////
int main()
{
  using namespace atcoder;
  // test();
  cout << count(cin) << '\n';
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;
 
int main() {
	int N,M;
	int a,b;
	cin >> N >> M;
	vector<int> nod(N,0);
	REP(i,M){
		cin >> a >> b;
		nod[a-1]++;
		nod[b-1]++;
	}
	REP(i,N) cout << nod[i] << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int f[5][5],id[5];
int main(){
	for (int i=0;i<3;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		f[x][y]=f[y][x]=1;
	}
	for (int i=1;i<=4;i++) id[i]=i;
	int sum=24;
	while (sum--){
		int ok=f[id[1]][id[2]]&&f[id[2]][id[3]]&&f[id[3]][id[4]];
		if (ok) return puts("YES"),0;
		next_permutation(id+1,id+5);
	}
	puts("NO");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long int N,i,mid,sad1;
  cin >> N;
  
  vector<long long int> A(N);
  for(i=0;i<N;i++){
    cin >> A.at(i);
    A.at(i) -= i;
  }
  sort(A.begin(),A.end());
  if(N%2==1) mid = A.at((N-1)/2);
  else mid = A.at(N/2);
  sad1= 0;
  for(i=0;i<N;i++){
    sad1 += abs(A.at(i)-mid);
  }
  cout << sad1 << endl;
  return 0;
}

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

int main(){
	long double W,H,x,y;
	ll a=0;
	cin >> W >> H >> x >> y;
	cout << fixed;
	if(W/2.0 == x && H/2.0 == y) a = 1;
	cout << setprecision(9) << W*H/2.0 << " " << a;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner input= new Scanner(System.in);
		int a = input.nextInt();
		int b = input.nextInt();
		int c = input.nextInt();
		
		if((a==b&&a!=c)||(a==c&&a!=b)||(b==c&&a!=b)) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21844
#include<stdio.h>
int main()
{
	int n;
	int a,b,c;
	scanf("%d",&n);
	a=n%10;
	n=n/10;
	b=n%10;
	n=n/10;
	c=n%10;
	if(a==9){
		a=1;
	}
	else{
		a=9;
	}
	if(b==9){
		b=1;
	}
	else{
		b=9;
	}
	if(c==9){
		c=1;
	}
	else{
		c=9;
	}
	printf("%d\n",c*100+b*10+a);
	return 0;
}

Measured memory_bytes: 1704
#include <bits/stdc++.h>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;


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

    int r,d,x;


    cin >> r >> d >> x;

    
    for(int i = 1;i<11;i++){
        int xnext = r*x - d; 
        cout << xnext << '\n';
        x = xnext;
    }

    

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int getarea(int d)
{
     int f, g, h=0, i=1;
     
     while(0<1){
	  f = d * i;
	  if(f>=600) break;
	  g = f * f * d;
	  
	  i++;
	  h = h + g;
     }
     
     return h;
}

int main(void)
{
     int d;
     
     while(0<1){
	  if(scanf("%d", &d)==-1) break;

	  printf("%d\n", getarea(d));
     }

     return 0;
}

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

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

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  string s;ll k;
  cin>>s>>k;
  int ichinum = 0;
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == '1') ++ichinum;
    else break;
  }
  if (ichinum >= k) cout << 1 << endl;
  else cout << s[ichinum] << endl;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(all(x), val), x.end())
typedef long long ll;
typedef pair<int, int> P;
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; }
ll MOD = 1000000007;
int INF = 1001001001;

void solve()
{
    int n, a, b; cin >> n >> a >> b;
    if((b - a) % 2 == 0)cout << "Alice" << endl;
    else cout << "Borys" << endl;
    return;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

const int N = 100001;

int n, cnt[N], mod = 998244353;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    for(int i = 0 ; i < n ; i++){
        int x;
        cin >> x;
        if(i == 0 && x > 0) finish(0);
        cnt[x]++;
    }
    if(cnt[0] != 1) finish(0);
    int ans = 1;
    for(int i = 1 ; i < n ; i++){
        for(int j = 0 ; j < cnt[i] ; j++){
            ans = 1LL * ans * cnt[i - 1] % mod;
        }
    }
    cout << ans << endl;
}


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

int main() 
{
	vector<int> c;
	c.push_back(1);
	for(int i=6;i<=100000;i=i*6)
	c.push_back(i);
	for(int i=9;i<=100000;i=i*9)
	c.push_back(i);
	sort(c.begin(),c.end());
	int n;
	cin>>n;
	int a[n+1];
	a[0]=0;
	for(int i=1;i<=n;i++)
	{
		a[i]=INT_MAX;
		for(int j=0;j<c.size();j++)
		{
			if(c[j]<=i)
			{
				int ans= a[i-c[j]];
				if(ans != INT_MAX)
				a[i]=min(a[i],ans+1);
			}
		}
	}
	cout<<a[n]<<endl;
	return 0;
} 

Measured memory_bytes: 640
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;
constexpr long long INF = std::numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, q, last, cnt, sum, ans, dp[3000][3000];
Ppll a[200000];
string str;
bool f;
double Ans;
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ -1,0 } ,{ 0,-1 } };
struct Edge { LL from, to, cost; };
vector<Edge>vec[1000000],edge;
vector<Pll>v;
map<string, LL>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int  par[1000000];
int find(int x) { if (par[x] == x)return x; par[x] = find(par[x]); return par[x]; }
void unite(int x, int y) { x = find(x); y = find(y); if (x == y)return; par[x] = y; }
bool same(int x, int y) { return find(x) == find(y); }
int main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i].fir >> a[i].sec.fir;
		a[i].sec.sec = i;
	}
	for (int i = 0; i<n+100; i++)par[i] = i;  // このように初期化
	sort(a, a + n);
	rep(i, n) {
		edge.push_back(Edge{ a[i].sec.sec,a[i + 1].sec.sec,abs(a[i].fir - a[i+1].fir) });
	}
	sort(a, a + n, [](Ppll x, Ppll y) {return x.sec.fir < y.sec.fir; });
	rep(i, n) {
		edge.push_back(Edge{ a[i].sec.sec,a[i + 1].sec.sec,abs(a[i].sec.fir - a[i+1].sec.fir) });
	}
	sort(edge.begin(), edge.end(), [](Edge x, Edge y) {return x.cost < y.cost; });
	rep(i,edge.size()) {
		if (!same(edge[i].to, edge[i].from)) {
			unite(edge[i].to, edge[i].from);
			ans += edge[i].cost;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
   int N;
   cin >> N;
   int DP[N][3];
   for(int i=0;i<N;i++)
      for(int j=0;j<=2;j++)
         cin >> DP[i][j];
   for(int i=N-2;i>=0;i--)
      for(int j=0;j<=2;j++)
      {
         int m=-1;
         for(int k=0;k<=2;k++)
           if(k!=j)
             m=max(m,DP[i+1][k]);
         DP[i][j]+=m;
      }
    int M=-1;
    for(int j=0;j<=2;j++)
       M=max(M,DP[0][j]);

    cout<<M;
}
    

Measured memory_bytes: 1408
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;

int main(){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if((b - a) == (c - b))
		printf("YES\n");
	else 
		printf("NO\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <list>
#include <cassert>
using namespace std;

template<typename T>
void fill_all(T& a, const T& b)
{
	a = b;
}
template<typename T, size_t N, typename U>
void fill_all(T(& a)[N], const U& b)
{
	for (auto& i : a)
	{
		fill_all(i, b);
	}
}

#if 1
int P, R, Q;
int r_num[500];//r
int cost[500][500];//i,r
int rem[500][500];//i,r
std::list<int>::iterator resolved_iter[500][500];//r,i
std::list<int> resolved[500][501];//r,num
std::pair<int, int> Log[300000];
bool ended[500];
int ended_num;

void run_end(int p)
{
	assert(!ended[p]);
	ended[p] = true;
	++ended_num;
	//for (int r = 0; r < R; r++)
	//{
	//	resolved[r][rem[p][r]].erase(resolved_iter[r][p]);
	//}
	for (int r = 0; r < R; r++)
	{
		r_num[r] += (cost[p][r] - rem[p][r]);
	}
}
void jump()
{
	bool ok = false;
	for (int p = 0; p < P; p++)
	{
		if (ended[p]) { continue; }
		ok = true;
		for (int r = 0; r < R; r++)
		{
			if (rem[p][r] > r_num[r]) {
				ok = false;
				break;
			}
		}
		if (ok) {
			run_end(p);
			break;
		}
	}
	if (ok) {
		jump();
	}
}

int main()
{
	cin >> P >> R >> Q;
	for (int i = 0; i < R; i++)
	{
		cin >> r_num[i];
	}
	for (int i = 0; i < P; i++)
	{
		for (int r = 0; r < R; r++)
		{
			cin >> cost[i][r];
			rem[i][r] = cost[i][r];
		}
	}

	for (int i = 0; i < Q; i++)
	{
		cin >> Log[i].first >> Log[i].second; --Log[i].first; --Log[i].second;
		auto p = Log[i].first;
		assert(!ended[p]);
		--rem[p][Log[i].second];
		--r_num[Log[i].second];
		assert(Log[i].second >= 0);
		assert(Log[i].second < 300);
		assert(r_num[Log[i].second] <= 100);
		assert(r_num[Log[i].second] >= 0);

		if (rem[p][Log[i].second] == 0) {
			bool ok = true;
			for (int r = 0; r < R; r++)
			{
				if (rem[p][r] > 0) {
					ok = false;
					break;
				}
			}
			if (ok) {
				assert(!ended[p]);
				ended[p] = true;
				++ended_num;
				for (int r = 0; r < R; r++)
				{
					r_num[r] += cost[p][r];
					assert(r_num[r] <= 100);
				}
			}
		}
	}
	for (int i = 0; i < P; i++)
	{
		for (int r = 0; r < R; r++)
		{
			assert(rem[i][r] >= 0);
			assert(rem[i][r] <= 100);
			resolved[r][rem[i][r]].push_front(i);
			resolved_iter[r][i] = resolved[r][rem[i][r]].begin();
		}
	}
	jump();
	if (ended_num == P) {
		cout << -1 << endl;
		return 0;
	}

	int q = Q - 1;
	for (; q >= 0; --q)
	{
		auto r = Log[q].second;
		{
			auto p = Log[q].first;
			if (!ended[p]) {
				resolved[r][rem[p][r]].erase(resolved_iter[r][p]);
				++rem[p][r];
				resolved[r][rem[p][r]].push_front(p);
				resolved_iter[r][p] = resolved[r][rem[p][r]].begin();
				++r_num[r];
			}
		}

		bool ok = false;
		for(auto& p : resolved[r][r_num[r]]) {
			if (ended[p]) { continue; }
			ok = true;
			for (int rr = 0; rr < R; rr++)
			{
				if (rem[p][rr] > r_num[rr]) {
					ok = false;
					break;
				}
			}
			if (ok) {
				run_end(p);
				break;
			}
		}
		if (ok) {
			jump();
		}

		if (ended_num >= P) {
			break;
		}
	}
	cout << (q+1) << endl;
}
#endif


Measured memory_bytes: 14440
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
#include <queue>
#include <stack>

using namespace std;


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

int main()
{
	int n,w;
	while(cin>>n>>w,n||w){
		vector<int> v(n);
		int _max;

		cin>>v[0];
		_max=v[0];
		for(int i=1;i<n;i++){
			cin>>v[i];
			_max=max(_max,v[i]);
		}

		vector<int> dist(_max/w+1);
		for(int i=0;i<n;i++) dist[v[i]/w]++;
/*
		for(int i=0;i<dist.size();i++){
			cout<<i*w<<"-"<<(i+1)*w-1<<" "<<dist[i]<<endl;
		}
*/
		int h=dist[0];
		for(int i=1;i<dist.size();i++) h=max(h,dist[i]);

/*
		for(int i=0;i<dist.size();i++){
			cout<<i*w<<"-"<<(i+1)*w-1<<" "<<(double)dist[i]/h<<endl;
		}
*/

		double res=0.01;
		for(int i=0;i<dist.size()-1;i++){
			res+=(double)dist[i]/h*(dist.size()-i-1)/(dist.size()-1);
		}

		printf("%.8f\n",res);

	}

	return 0;
}

Measured memory_bytes: 1200
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        n: i64, a: i64, b: i64,
    }
    let q = n / (a + b);
    let r = n - q * (a + b);
    let mut tot = q * a;
    tot += min(r, a);
    puts!("{}\n", tot);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

using namespace std;

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

int const INF = 1<<29;

int main() {
  
  int N;
  while(cin >> N && N) {
    int t[N][N];
    rep(i, N) rep(j, N)
      cin >> t[i][j];
    
    bool left[N][N]; memset(left, 0, sizeof left);
    // bool right[N][N]; memset(right, 0, sizeof right);
    
    rep(i, N) {
      int mn = INF;
      rep(j, N) {
        mn = min(mn, t[i][j]);
      }
      rep(j, N) {
        if(mn == t[i][j]) { left[i][j] = 1; }
      }
    }
    
    int ans = 0;
    rep(i, N) {
      int mx = 0;
      rep(j, N) {
        mx = max(mx, t[j][i]);
      }
      rep(j, N) {
        //        if(mx == t[j][i]) { right[j][i] = 1; }
        if(left[j][i] && mx == t[j][i]) { ans = t[j][i]; }
      }
    }
    /*
    rep(i, N) rep(j, N) {
      if(left[i][j]&&right[i][j]) {
        cout << t[i][j] << endl;
      }
    }
    */
    cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1168
def function(X):
    B = list(range(31, 0, -1))
    res = 0
    for b in B:
        p = 2
        cp = p
        while True:
            tmp = b ** p
            if tmp > X:
                break
            else:
                res = max(res,tmp)
                if b == 1: break
                cp = p
                p += 1
    return res

X = int(input())
print(function(X))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
namespace mp = boost::multiprecision;
// 任意長整数型
using bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using real1024 = mp::number<mp::cpp_dec_float<1024>>;
// ついでに有理数型
using rat = boost::rational<bint>;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()

void solve(long long N, long long D, std::vector<long long> X, std::vector<long long> Y){
  ll ans = 0;
  for (int i = 0; i < N; i++) {
    if(sqrt(X[i]*X[i] + Y[i]*Y[i]) <= D)ans++;
  }
  cout << ans << endl;
}

int main(){
    long long N;
  scanf("%lld",&N);
  long long D;
  scanf("%lld",&D);
  std::vector<long long> X(N);
  std::vector<long long> Y(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&X[i]);
    scanf("%lld",&Y[i]);
  }
    solve(N, D, std::move(X), std::move(Y));
    return 0;
}


Measured memory_bytes: 6488
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    Int n, k;
    cin >> n >> k;

    Int ans = 0;
    for (Int i = k; i <= n + 1; i++) {
        Int low, up;
        low = i * (i - 1) / 2;
        up = (2 * n - i + 1) * i / 2;

        ans += (up - low + 1);
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdtr1c++.h>

using namespace std;
#define INP "solve"
#define OUT "solve"
const int QQ = 3e5 + 10;
const int maxN = 3e5 + 10;
const int maxM = 3e5 + 10;
const int oo = 1e9;
const int module = 1e9 + 7;

void doc() {
    freopen(INP ".inp","r",stdin);
    freopen(OUT ".out","w",stdout);

}

void solve() {
    int r;
    cin >> r;
    cout << 3 * r * r;
}
int main(int argc,char *argv[]) {
    //srand(time(nullptr));
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
   // doc();
    solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    string s;
    cin>>s;
    sort(ALL(s));
    unique(ALL(s));
    for(int i=0;i<26;i++){
        if(s[i]!=('a'+i)){
            cout<<(char)('a'+i)<<endl;return 0;
        }
    }
    cout<<"None"<<endl;
    return 0;
}


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

int main() {
    int n, A;
    cin >> n;
    int a[n] = {0};
    for(int i = 0; i < n-1; ++i) {
        cin >> A;
        a[A-1]++;
    }
    for(int i = 0; i < n; ++i) {
        cout << a[i] << '\n';
    }

    return 0;
}


Measured memory_bytes: 4428
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();

        if (a + b + c <= 21) {
            System.out.println("win");
        } else {
            System.out.println("bust");
        }
        sc.close();
    }
}

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

int main()
{
  string a,b,c;
  cin >> a >> b >> c;
  if(a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0]) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 3616
#include <stdio.h>

int main(void)
{
	int i,j,H,W,r;
	
	while(!(H==0&&W==0)){
		scanf("%d %d",&H,&W);
		for(i=0;i<H;i++){
			for(j=0;j<W;j++){
				r=(i+j)%2;
				if(r==1){
					printf(".");
				}else{
					printf("#");
				}
			}
			printf("\n");
		}
		if(H==0&&W==0) break;
		printf("\n");
	}
	
	return 0;
}

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

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

    int dig = n;
    int sum = 0;
    while(dig){
        sum += dig % 10;
        dig /= 10;
    }

    if(n % sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<climits>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<functional>
#include <numeric>
#include <map>
using namespace std;
using ll = long long;
ll gcd(ll m,ll n){
  if(n==0)return abs(m);
  return(gcd(n,m%n));
}
vector<ll> ma{0,2,5,5,4,5,6,3,7,6};
map<ll,string> memo;
string dp(ll n,vector<ll> &A){
  if(n<0)return "_";
  if(n==0)return "";
  try{
    return memo.at(n);
  }catch(exception &e){
    
  }
  ll maxlen=0;
  string maxstr="_";
  for(auto a:A){
    string tmp=dp(n-ma[a],A);
    //cout<<tmp<<endl;
    if(tmp=="_")continue;
    if(tmp.size()>=maxlen){
      maxlen=tmp.size();
      maxstr=tmp;
      maxstr.insert(0,to_string(a));
    }
    //cout<<tmp<<endl;
    //if(max_<tmp)max_=tmp;
  }
  memo[n]=maxstr;
  return maxstr;
}

int main(){
  ll N,M;
  cin>>N>>M;
  vector<ll> A;
  for(int i=0;i<M;++i){
    ll tmp;
    cin>>tmp;
    A.push_back(tmp);
  }
  sort(A.begin(),A.end());
  cout<<dp(N,A)<<endl;
  return 0;
}


Measured memory_bytes: 40320