akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <set>
#include <cmath>

using namespace std;

typedef long double ld;

struct pkt
{
    ld x, y;
};

struct kolo
{
    pkt s;
    ld r;
};

struct kraw
{
    int b;
    ld c;
};

ld Dl(pkt a, pkt b)
{
    return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
}

ld Koszt(kolo a, kolo b)
{
    if (Dl(a.s, b.s) > a.r + b.r)
        return Dl(a.s, b.s) - a.r - b.r;
    return 0.0;
}

void Dijkstra(vector< vector<kraw> >& G, int start, vector<ld>& D)
{
    D[start] = 0.0;
    set< pair<ld, int> > Q;
    int n = G.size();
    Q.insert({D[0], 0});
    while (!Q.empty())
    {
        pair<ld, int> t = *Q.begin();
        Q.erase(Q.begin());
        for (int i = 0; i < G[t.second].size(); ++i)
        {
            if (t.first + G[t.second][i].c < D[G[t.second][i].b])
            {
                Q.erase({D[G[t.second][i].b], G[t.second][i].b});
                D[G[t.second][i].b] = t.first + G[t.second][i].c;
                Q.insert({D[G[t.second][i].b], G[t.second][i].b});
            }
        }
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    pkt A, B;
    cin >> A.x >> A.y >> B.x >> B.y;
    int n;
    cin >> n;
    vector<kolo> K(n);
    for (int i = 0; i < n; ++i)
        cin >> K[i].s.x >> K[i].s.y >> K[i].r;
    vector< vector<kraw> > G(n + 2);
    for (int i = 0; i < n; ++i)
        for (int j = 0; j < n; ++j)
            if (i != j)
                G[i + 1].push_back({j + 1, Koszt(K[i], K[j])});
    for (int i = 0; i < n; ++i)
    {
        ld d1;
        if (Dl(A, K[i].s) <= K[i].r)
            d1 = 0.0;
        else
            d1 = Dl(A, K[i].s) - K[i].r;
        G[0].push_back({i + 1, d1});
        G[i + 1].push_back({0, d1});
        ld d2;
        if (Dl(B, K[i].s) <= K[i].r)
            d2 = 0.0;
        else
            d2 = Dl(B, K[i].s) - K[i].r;
        G[n + 1].push_back({i + 1, d2});
        G[i + 1].push_back({n + 1, d2});
    }
    vector<ld> D(n + 2, 1e18 + 10);
    Dijkstra(G, 0, D);
    cout.setf(std::ios_base::fixed);
    cout.precision(15);
    cout.setf(std::ios_base::showpoint);
    ld odp = D[n + 1];
    if (Dl(A, B) < odp)
        odp = Dl(A, B);
    cout << odp;
    return 0;
}


Measured memory_bytes: 32512
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

int main(){
    string s;
    cin >> s;
    string ans = "";
    rep(i, s.size()){
        if(s[i]!='B')ans+=s[i];
        else if(!ans.empty())ans.pop_back();
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
#include <deque>
using ll = long long;
using Graph = vector<vector<int>>;
#include <queue>
#include <stack>
#include <cmath>



int main(){

    ll n;
    cin >> n;
    vector<ll> a(n,0);
    for(ll i=0LL;i < n -1;i++){
        ll t;
        cin >> t;
        a[--t]++;

    }

    for(ll i=0LL;i < n;i++) cout << a[i] << endl;

    
    
    return 0;
}

Measured memory_bytes: 4364
import java.util.*;

public class Main {	
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int d = sc.nextInt(), n = sc.nextInt();
		if(n == 100) {
			System.out.println(101 * (int)Math.pow(100, d));
		} else {
			System.out.println(n * (int)Math.pow(100, d));
		}
	}
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#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())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



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

  ll countB,sumB;
  countB = sumB = 0;

  FOR(i,0,s.length()-1){
    if(s[i]=='B'){
      ++countB;
      sumB += i;
    }
  }

  ll sumBB = 0;
  ll ref = 0;

  while(countB>0){
    sumBB += s.length()-1-ref;
    --countB;
    ++ref;
  }

  cout << sumBB - sumB << endl;

}



Measured memory_bytes: 640
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define M 1000000007
typedef long T;
//#include "math/mod.h"

/* ax+by=gcd(a,b) */
T gcd_ext(T a, T b, T *x, T *y) {
	if (a == 0) {
		*x = 0;
		*y = 1;
		return b;
	}
	T x1, y1;
	T gcd = gcd_ext(b%a, a, &x1, &y1);
	*x = y1 - (b/a) * x1;
	*y = x1;
	return gcd;
}

T mod_norm(T a, T m) {
	return (a % m + m) % m;
}

T mod_sub(T a, T b, T m) {
	return mod_norm(a-b, m);
}

T mod_add(T a, T b, T m) {
	return mod_norm(a+b, m);
}

T mod_mul(T a, T b, T m) {
	return mod_norm(a, m) * mod_norm(b, m) % m;
}

T mod_div(T a, T b, T m) {
	a = mod_norm(a, m);
	b = mod_norm(b, m);
	T x, y;
	T g = gcd_ext(b, m, &x, &y);
	T d = (g!=1) ? 0 : mod_norm(x, m);
	return (a * d) % m;
}

//this method can avoid integer overflow
T mod_combinations(int n, int k, T m) {
    if (k*2 > n) k = n-k;
    if (n==0) return 0;
    T r = 1; //C(n,0)
    for (int i=1; i<=k; i++) {
        //C(n,i) = C(n,i-1) * (n-i+1) / i
        r = mod_div(r * (n-i+1), i, m);
    }
    return r;
}


int h,w,a,b;

int input() {
	if (scanf("%d %d %d %d", &h, &w, &a, &b) < 0) return 0;
	return 1;
}

void init() {
}

int solve() {
	T r = mod_combinations(h+w-2, h-1, M);
	T x = mod_combinations(h-a+b-1, b-1, M);
	T y = mod_combinations(a-1+w-b-1, w-b-1, M);
	for (int i=0; i<a; i++) {
		//T x = mod_combinations(h-a+i+b-1, b-1, M);
		//T y = mod_combinations(a-1-i+w-b-1, w-b-1, M);
		if (i) {
			T n = h-a+i+b-1, m = b-1;
			x = mod_div(x*n, n-m, M);

			n = a-1-i+w-b-1, m = w-b-1;
			y = mod_div(y*(n+1-m), n+1, M);
		}
		T z = mod_mul(x, y, M);
		//printf("%d: r=%ld %ld %ld %ld\n", i, r, x, y, z);
		r = mod_sub(r, z, M);
		
	}
	return r;
}

void output(int ans) {
	printf("%d\n", ans);
}

void cleanup() {
}

int main() {
	//precalc();
	//int ca; scanf("%d", &ca);
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}




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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(ll i=0;i<(n);i++)

using namespace std;


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

    ll sum = n*m;
    if(n == 1 && m == 1){
        cout << 1 << endl;
        return 0;
    }

    if(m == 1){
        m = n;
        n = 1;
    }

    if(n == 1) sum -= 2;
    else{
        sum -= 4;
        sum -= 2*(n-2);
        sum -= 2*(m-2);
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
def main():
    n, m = map(int, raw_input().split())
    aa = map(int, raw_input().split())
    cb = [[a, 1] for a in aa]
    for _ in range(m):
        b, c = map(int, raw_input().split())
        cb.append([c, b])
    cb.sort(reverse=True)
    s = 0
    count = 0
    for c, b in cb:
        if count + b < n:
            s += b * c
        else:
            b = n - count
            s += b * c
        count += b
        if count >= n:
            break
    print s


if __name__ == '__main__':
    main()


Measured memory_bytes: 66324
#define  _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
#pragma comment (linker, "/STACK:526000000")

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(20);
}

#define int ll
void solve() {
	while (true) {
		int n, l, r;
		cin >> n >> l >> r;
		if (n == 0) return;
		vector<int> inputs;
		REP(i, n) {
			int a;
			cin >> a;
			inputs.push_back(a);
		}
		inputs.push_back(1);
		int ans = 0;
		for (int i = l; i <= r; ++i) {
			for (int q = 0; q < inputs.size(); ++q) {
				if (i % inputs[q] == 0) {
					ans += (q + 1) % 2;
					break;
				}
			}
		}
		cout << ans << endl;
	}
}
#undef int
int main() {
	init();
	solve();
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N;cin >> N;
      int sum = 0;
    int maxL = 0;
  for (int i = 0; i < N; i++) {
    int L;cin >> L;
sum += L;
    maxL = max(maxL,L);
  }
  if (maxL < sum - maxL) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

signed main(void)
{
	int n;
	cin >> n;
	vector<int> a(n), b(n), sum;
	long long cnt, s;

	cnt = s = 0;
	rep(i, n) cin >> a[i];
	rep(i, n) 
	{
		cin >> b[i];
		if (a[i] < b[i])
		{
			s += b[i] - a[i];
			cnt++;
		}
	}
	if (s <= 0)
	{
		cout << cnt << endl;
		return 0;
	}
	rep(i, n)
	{
		if (a[i] > b[i])
			sum.push_back(a[i] - b[i]);
	}
	if (sum.size() != 0)
	{
		sort(sum.rbegin(), sum.rend());
		rep(i, sum.size())
		{
			s -= sum[i];
			cnt++;
			if (s <= 0)
			{
				cout << cnt << endl;
				return 0;
			}
		}
	}
	cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define MIN(a,b) (((a)<(b))?(a):(b))
#define INF 1e10
using namespace std;
typedef long long LL;

int main(){
    int n, m, i, j;
    cin >> n >> m;
    LL w[n], v[n];
    int v_sum = 0;
    for(i = 0; i < n; i++){
        cin >> w[i] >> v[i];
        v_sum += v[i];
    }
    LL dp[n+1][v_sum+1] = {};
    for(i = 1; i <= v_sum; i++){
        dp[0][i] = INF;
    }
    for(i = 0; i < n; i++){
        for(j = 0; j <= v_sum; j++){
            if(j >= v[i]){
                dp[i+1][j] = MIN(dp[i][j], dp[i][j-v[i]] + w[i]);
            }
            else{
                dp[i+1][j] = dp[i][j];
            }
        }
    }
    for(i = v_sum; i >= 0; i--){
        if(dp[n][i] <= m){
            break;
        }
    }
    cout << i << endl;
}

Measured memory_bytes: 79104
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int c[20000+200];
int a[3000000+200];
int n;

void countSort(){
    memset(c,0,sizeof(c));
    for(int i=0;i<n;i++){
        c[a[i]]++;
    }
    int index=0;
    for(int i=0;i<10000+10;i++){
        while(c[i]){
            a[index++]=i;
            c[i]--;
        }
        if(index==n)
            break;
    }
    printf("%d",a[0]);
    for(int i=1;i<n;i++){
        printf(" %d",a[i]);
    }
    cout<<endl;
    return;
}

int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    countSort();
    return 0;
}

Measured memory_bytes: 11088
#include <iostream>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::vector;

int main(void) {
	while (1) {
		int member_num;
		cin >> member_num;
		if (member_num == 0) {
			break;
		}

		vector<vector<int>> member_info;
		for (int i = 0; i < member_num; i++) {
			vector<int> info;
			int info_num;
			cin >> info_num;
			for (int j = 0; j < info_num; j++) {
				int tmp;
				cin >> tmp;
				info.push_back(tmp);
			}
			member_info.push_back(info);
		}

		int leak_num;
		cin >> leak_num;
		vector<int> leak;
		for (int i = 0; i < leak_num; i++) {
			int tmp;
			cin >> tmp;
			leak.push_back(tmp);
		}

		vector<bool> flag(member_num, true);
		int flag_num = member_num;
		for (auto leak_itr = leak.begin(); leak_itr != leak.end(); ++leak_itr) {
			for (int i = 0; i < member_num; i++) {
				if (!flag[i]) {
					continue;
				}

				bool hit = false;
				for (auto info_itr = member_info[i].begin(); info_itr != member_info[i].end(); ++info_itr) {
					if (*info_itr == *leak_itr) {
						hit = true;
						break;
					}
				}
				if (hit == false) {
					flag[i] = false;
					flag_num--;
				}
			}
		}

		if (flag_num != 1) {
			cout << -1 << endl;
		} else {
			for (int i = 0; i < member_num; i++) {
				if (flag[i]) {
					cout << i + 1 << endl;
					break;
				}
			}
		}
	}
	return 0;
}



Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
bool cmp(char a ,char b){
	return a > b;
}
int main(){
    string s,t;
	cin >> s >> t;
	sort (s.begin() ,s.end());
	sort (t.begin() ,t.end() ,cmp);
	if (s < t)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#define fi first
#define se second
#define pb push_back
#define forn(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define forr(i,n) for(int i=n;i>=0;i--)
#define all(x) x.begin(), x.end()
const int MAXN = 1e5 +5;

void fio(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}

int main(){
  fio();
  LL a,b,c, k; cin>>a>>b>>c>>k;
  LL an = 0;
 
  if(k<=a){
  	cout<<k<<endl;
  	return 0;
  }
  else{
  	k-=a;
  	an+=a;
  }

  if(k<=b){
  	cout<<an<<endl;
  	return 0;
  }
  else{
  	k-=b;
  }

  cout<<(k*-1 + an)<<endl;
  return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<pair<int,int>> a(n);
    for(int i = 0; i < n; i++){
        int b;
        cin >> b;
        if(i + 1 < b)
        a[i] = make_pair(i + 1, b);
        else
        a[i] = make_pair(b, i + 1);
    }
    sort(a.begin(),a.end());
    int c = a[0].first,d = a[0].second;
    int cnt = 0;
    for(int i = 1; i < n; i++){
        if(a[i].first == c && a[i].second == d)
        cnt++;
        else
        {
            c = a[i].first;
            d = a[i].second;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 1024
N, K = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
INF = 10**9+7
ans = 0
for i in range(N):
    B = [1 if a < A[i] else 0 for a in A]
    ans = (ans + sum(B[i+1:])*K + sum(B) * (K*(K-1)//2)) % INF
print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb emplace_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=2001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> ostream& operator<<(ostream &os,const vector<vector<T> > &v) {
    ITR(u,begin(v),end(v))ITR(w,begin(*u),end(*u))os<<*w<<(w==end(*u)-1?"\n":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed << setprecision(10) << val;

int L, R;
signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> L >> R;
  if (L / 2019 != R / 2019)
    return cout << 0 << endl, 0;
  L %= 2019, R %= 2019;
  int ans = INF;
  erep(i, L, R) erep(j, L, R)
    if (i != j) ans = min(ans, (int)((i*j)%2019));
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);

int main() {
  FAST;
  string S;
  cin >> S;
  string result;
  if (S.at(0) == S.at(1) && S.at(1) == S.at(2)) {
    result = "No";
  }
  else {
    result = "Yes";
  }
  cout << result << endl;
}

Measured memory_bytes: 256
# coding:utf-8

input =input().split(" ")
X = int(input[0])
A = int(input[1])
B = int(input[2])
dist_XA=abs(A-X)
dist_XB=abs(B-X)

ans = "A" if(dist_XA<dist_XB) else "B"
print(ans)


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

int main() {
	string s;
	cin >> s;
	int k = s.length();int c = 0;
	
	for(int i =0; i < k; i++)
	{
		if(s[i] == 'o')
		c++;
	}
	if( (c+15-k) >= 8 )
	cout << "YES";
	else cout << "NO";
	// your code goes here
	return 0;
}

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

int main(){
  int X,N;
  cin >> X >> N;
  vector<int> P(N);
  rep(i,N) cin >> P[i];
  rep(j,N+1){
    int Jplus = 0;
    int Jminus = 0;
    rep(i,N){
      if(X+j==P[i]){
        Jplus++;
      }
      if(X-j==P[i]){
        Jminus++;
      }
    }
    if(!Jminus){
      cout << X-j << endl;
      return 0;
    }
    if(!Jplus){
      cout << X+j << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define Min(a,b) a=min(a,b);
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
#define N 5010
#define M 4
int n,a[N],d[N][M];
int main(){
    cin>>n;
    lol(i,n)cin>>a[i];
    lol(i,n)lol(j,M)d[i][j]=mod;
    lol(j,M)d[0][j]=j;
    lol(i,n-1){
	for(int j=0;j<=a[i];j++){
	    int low=a[i]-j;
	    int hig=a[i+1];
	    for(int k=0;k<low;k++){
		Min(d[i+1][k],d[i][j]+2*low);
	    }
	    for(int k=low;k<=hig;k++){
		Min(d[i+1][k],d[i][j]+2*k);
	    }
	}
    }
    int ans=mod;
    lol(j,M){
	Min(ans,d[n-1][j]+max(0,a[n-1]-j));
    }
    cout<<ans<<endl;
    return 0;
}



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

using namespace std;

void draw(size_t cols) {
  cout << "Yes\n";
  vector<vector<int>> matrix(cols + 1);
  int next = 1;
  for (size_t i = 0; i < cols + 1; ++i) {
    if (i == 0) {
      for (size_t j = 0; j < cols; ++j) {
        matrix[i].push_back(next++);
      }
    } else {
      for (size_t j = 0; j < i; ++j) {
        matrix[i].push_back(matrix[j][i - 1]);
      }
      while (matrix[i].size() < cols) {
        matrix[i].push_back(next++);
      }
    }
  }
  cout << cols + 1 << "\n";
  for (size_t i = 0; i < cols + 1; ++i) {
    cout << cols;
    for (size_t j = 0; j < cols; ++j) {
      cout << " " << matrix[i][j];
    }
    cout << "\n";
  }
}

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

  int n;
  cin >> n;
  for (int64_t i = 1; i < 100000; ++i) {
    if (i * (i + 1) / 2 == n) {
      draw(i);
      return 0;
    }
    if (n < i * (i + 1) / 2) {
      break;
    }
  }
  cout << "No\n";
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

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

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

int main()
{
	// #ifndef ONLINE_JUDGE
	// freopen(".in.txt", "r", stdin);
	// freopen(".out.txt", "w", stdout);
	// #endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n; cin >> n;
	if(n % 10 == 3) cout << "bon";
	else if(!(n % 10) || n % 10 == 1 || n % 10 == 6 || n % 10 == 8) cout << "pon";
	else cout << "hon";

	return 0;
}

Measured memory_bytes: 3652
n = int(input())
a = n//100
b = (n - a*100)//10
c = n%10

if a == 1:
    a = 9
elif a == 9:
    a = 1

if b == 1:
    b = 9
elif b == 9:
    b = 1

if c == 1:
    c = 9
elif c == 9:
    c = 1

abc = str(a)+str(b)+str(c)
print(abc)


Measured memory_bytes: 3060
#include<stdio.h>
int main (){
	int Na;
	int Ka;
	int hasil = 1;
	
	scanf("%d", &Na);
	scanf("%d", &Ka);
	
	for(int i = 1;i<=Na;i++){
		if(hasil<Ka){
			hasil*=2;
		}else{
			hasil=hasil+Ka;
		}
	}
	printf("%d", hasil);
	return 0;
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;

struct int_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

struct pair_hash {
    size_t operator()(pair<int, int> x) const {
        return int_hash{}(x.first) ^ (int_hash{}(x.second) << 16);
    }
};

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
const int MX = 100001; //check the limits, dummy

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

    int h, n; cin >> h >> n;
    vector<int> a(n);
    vector<int> b(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        cin >> b[i];
    }

    vector<ll> dp(h + 1, inf + 1);
    dp[0] = 0;
    for(int i = 0; i < n; i++)
        for(int j = 0; j <= h; j++)
            dp[j] = min(dp[j], b[i] + dp[max(0, j - a[i])]);

    cout << dp[h] << endl;
}		

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

#define int long long
#define forn(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int) (x).size())


int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int k, x;
	cin >> k >> x;
	k *= 500;
	if (k >= x) cout << "Yes\n";
	else cout << "No\n";
	return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x=sc.nextInt();
        int h=x/60/60;
        int m=x/60%60;
        int s=x%60;
        System.out.printf("%d:%d:%d\n",h,m,s);
    }
}



Measured memory_bytes: 26236
#!usr/bin/env pypy3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)


def main():
    s = input()
    print("A" if ord(s) < 95 else "a")


main()


Measured memory_bytes: 9352
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(v) v.begin(), v.end()
#define ll long long
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;

int main(){
    string s;
    cin>>s;
    rep(i,3){
        if(s[i]=='7'){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define rep(i,start,lim) for(lld i=start;i<lim;i++)
#define repd(i,start,lim) for(lld i=start;i>=lim;i--)
#define scan(x) scanf("%lld",&x)
#define print(x) printf("%lld ",x)
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define br printf("\n")
#define sz(a) lld((a).size())
#define YES printf("YES\n")
#define NO printf("NO\n")
#define all(c) (c).begin(),(c).end()
#define INF         1011111111
#define LLINF       1000111000111000111LL
#define EPS         (double)1e-10
#define MOD         1000000007
#define PI          3.14159265358979323
using namespace std;
typedef long double ldb;
typedef long long lld;
lld powm(lld base,lld exp,lld mod=MOD) {lld ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
lld ctl(char x,char an='a') {return (lld)(x-an);}
char ltc(lld x,char an='a') {return (char)(x+an);}
#define bit(x,j) ((x>>j)&1)
typedef vector<lld> vlld;
typedef pair<lld,lld> plld;
typedef map<lld,lld> mlld;
typedef set<lld> slld;
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define mxm(a,b) a = max(a,b)
#define mnm(a,b) a = min(a,b)
#define endl '\n'
#define fre freopen("1.in","r",stdin); freopen("1.out","w",stdout);
#define N 1000005
vlld v[8];
int main()
{
    //sync;
    lld x,y,z,n,m;
    cin>>n>>m;
    rep(i,1,n+1) {
        cin>>x>>y>>z;
        v[0].pb((x+y+z));
        v[1].pb((x+y-z));
        v[2].pb((x-y+z));
        v[3].pb((x-y-z));
        v[4].pb((-x+y+z));
        v[5].pb((-x+y-z));
        v[6].pb((-x-y+z));
        v[7].pb((-x-y-z));
    }
    lld ans = 0;
    rep(i,0,8) {
        lld curr = 0;
        sort(all(v[i]));
        reverse(all(v[i]));
        rep(j,0,m) curr += v[i][j];
        ans = max(ans, curr);
    }
    cout<<ans;
    return 0;
}

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

class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        # 根への距離を管理
        self.weight = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            # 親への重みを追加しながら根まで走査
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    # 併合
    def unite(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        # xの木の高さ < yの木の高さ
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        # xの木の高さ ≧ yの木の高さ
        else:
            self.par[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            # 木の高さが同じだった場合の処理
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    # 同じ集合に属するか
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # xからyへのコスト
    def diff(self, x, y):
        return self.weight[x] - self.weight[y]

n,m = map(int, input().split())
uf = WeightedUnionFind(n)
for _ in range(m):
    l,r,d = map(int, input().split())
    if uf.same(l,r):
        if uf.diff(l,r) != d:
            print("No")
            exit()
    else:
        uf.unite(l,r,d)

print("Yes")


Measured memory_bytes: 10236
#![allow(unused_imports)]
#![allow(unused_macros)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_variables)]
#![allow(unused_mut)]
#![allow(unused_assignments)]
use proconio::input;
use proconio::marker::Usize1;
use std::collections::*;
use std::cmp::*;
use std::f64::consts::*;

const MOD: u64 = 1000000007;
const INF: usize = std::usize::MAX / 4;

fn main() {
    input! {
        A: u64,
        B: u64,
    };

    println!("{}", A * B);
}


Measured memory_bytes: 2128
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>

using namespace std;

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

	vector<int> X(N), Y(N);
	map<int, int> table;

	for (int i = 0; i < N; i++)
	{
		cin >> X[i];
		Y[i] = X[i];
	}

	sort(X.begin(), X.end());
	for (int i = 0; i < N; i++)
	{
		int ans;
		if (i < N / 2)
		{
			ans = X[N / 2];
		}
		else
		{
			ans = X[N / 2 - 1];
		}

		if (table.find(X[i]) == table.end())
		{
			table[X[i]] = ans;
		}
	}

	for (int i = 0; i < N; i++)
	{
		cout << table[Y[i]] << endl;
	}

	return 0;
}

Measured memory_bytes: 12928
#include <stdio.h>

void swap (int *x, int *y) {
  int temp;    // 値を一時保存する変数

  temp = *x;
  *x = *y;
  *y = temp;
}

/***
* pivotを決め、
* 全データをpivotを境目に振り分け、
* pivotの添え字を返す
***/
int partition (int array[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする

  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { swap(&array[i], &array[j]); }
  } while (i < j);

  swap(&array[pivot], &array[j]);   //pivotを更新

  return j;
}

/* クイックソート */
void quick_sort (int array[], int left, int right) {
  int pivot;

  if (left < right) {
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);   // pivotを境に再帰的にクイックソート
    quick_sort(array, pivot+1, right);
  }
}

int main() {
    int N;
    scanf("%d", &N);
    int X[N], Y[N];
    for (int i = 0; i < N; i++) {
        scanf("%d", &X[i]);
        Y[i] = X[i];
    }

    quick_sort(Y, 0, N - 1);
    int m1 = Y[N/2-1], m2 = Y[N/2];
    float m = (m1 + m2) / 2.0;

    for (int i = 0; i < N; i++) {
        if (X[i] < m) {
            printf("%d\n", m2);
        } else {
            printf("%d\n", m1);
        }
    }

    return 0;
}

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

using namespace std;

using i64 = int64_t;

const i64 MOD = 1e9+7;

const i64 INF = 1e18+7;

signed main(){
    int h, w, a, b;
    cin >> h >> w >> a >> b;

    auto f = [&]{
        if(h == 1 && w == 1){
            cout << "No" << endl;
            return ;
        }
        i64 sum = 0;
        i64 mul = (1e9 - 1) / (a * b - 1);
        vector<vector<i64>> v(h, vector<i64>(w));
        for(int i = 0; i < h; ++i){
            for(int j = 0; j < w; ++j){
                v[i][j] = mul;
                if(i % a == a - 1 && j % b == b - 1)
                    v[i][j] = -mul * (a * b - 1) - 1;
                sum += v[i][j];
            }
        }
        if(sum <= 0){
            cout << "No" << endl;
            return ;
        }
        cout << "Yes" << endl;
        for(int i = 0; i < h; ++i){
            for(int j = 0; j < w; ++j){
                cout << v[i][j] << (j == w - 1 ? "\n" : " ");
            }
        }
        return ;
    };
    f();

}


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

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int n;
    cin >> n;
    set<ll> s;
    rep(i,n) {
        ll ai;
        cin >> ai;
        auto itr = s.find(ai);
        if (itr != s.end()) {
            cout << "NO" << endl;
            return 0;
        }
        s.insert(ai);
    }

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























Measured memory_bytes: 9600
#include<iostream>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
using namespace std;
struct HeapNode{
	int u;
	int d;
	bool operator < (const HeapNode& rhs)const{
		return d>rhs.d;
	}
};
int d[200005],vis[200005];
int main(){
	int k;
	cin>>k;
	priority_queue<HeapNode>Q;
	Q.push((HeapNode){1,0});
	memset(d,0x3f3f3f3f,sizeof(d));
	d[1]=0;
	
	while (!Q.empty()){
		HeapNode x=Q.top();	Q.pop();
		int u=x.u,v;
		if (vis[u]) continue;
		vis[u]=1;
		for (int v=(u+1)%k,cost=1;cost>=0;v=(u*10)%k,cost--){
			if (d[v]>d[u]+cost){
				d[v]=d[u]+cost;
				Q.push((HeapNode){v,d[v]});
			}
		}
	}
	cout<<d[0]+1<<endl;
}

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

using namespace std;

#define MAX 100000
#define INF 2140000000
#define MOD 1000000007

int main() {
	string s;
	cin >> s;
	vector<char> v(4);

	for (int i = 0; i < 4; ++i) {
		v[i] = s[i];
	}

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

	if (v[0] == v[1] && v[2] == v[3] && v[2] != v[1]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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


int main() {
  int M, N;
  cin >> N >> M;

  vector<bitset<10>> light_sw(M); //M=light_num, N=switch_num

  for (int i = 0; i < M; i++) {
    int num;
    cin >> num;
    for (int j = 0; j < num; j++) {
      int k;
      cin >> k;
      light_sw.at(i).set(k - 1);
    }
  }

  vector<bool> light_on(M);	//

  for (int i = 0; i < M; i++) {
    int num;
    cin >> num;
    light_on.at(i) = (num == 1);
  }
  
  int switch_pattern_num = pow(2, N);
  vector<bitset<10>> switch_pattern(switch_pattern_num);
  vector<bool> switch_pattern_b(switch_pattern_num, true);
  int counter = switch_pattern_num;
  for (int i = 0; i < switch_pattern_num; i++) {
    switch_pattern.at(i) = i;
  }

  for (int i = 0; i < M; i++) {
    for (int j = 0; j < switch_pattern_num; j++) {
      if (!switch_pattern_b.at(j)) continue;
      bitset<10> b = light_sw.at(i);
      b &= switch_pattern.at(j);
      if (!((b.count() % 2 && light_on.at(i)) || (!(b.count() % 2) && !light_on.at(i)))) {
	counter--;
	switch_pattern_b.at(j) = false;
      }
    }
  }

  cout << counter << endl;
}

/*
5 2
3 1 2 5
2 2 3
1 0
 */


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <cstdlib>
#include <algorithm>
using namespace std;
const int N=4e6+10;
typedef long long ll;
ll n,m,ans,ask;
ll a[N];
ll xorsum[N],sum[N],r;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
}
   for(int i=1;i<=n;i++){
   	 if(i==1){xorsum[i]=a[i],sum[i]=a[i];}
   	 xorsum[i]=xorsum[i-1]^a[i];
   	 sum[i]=sum[i-1]+a[i];
   }
   r=1;
  // for(int i=1;i<=n;i++)
  // cout<<xorsum[i]<<" "<<sum[i]<<endl;
   for(int l=1;l<=n;l++){
   	 while(((xorsum[r]^xorsum[l-1])==(sum[r]-sum[l-1]))&&r<=n){
   	  r++;
   }
     r--;
   	 //printf("%d %d\n",l,r);
   	 ans+=(r-l+1);
   	// r++;
   }
   cout<<ans<<endl;
   return 0;
}

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

int main()
{
    int N;
    cin >> N;
    vector<ll> ans(45, 1);
    ans[0] = 1;
    ans[1] = 1;
    for (int i = 2; i <= N; i++)
    {
        ans[i] = ans[i - 2] + ans[i - 1];
    }
    cout << ans[N] << endl;

    return 0;
}


Measured memory_bytes: 3100
/* --- author: dxm --- */
#include<bits/stdc++.h>
using namespace std;

#define INF 1e9
#define Inf 1e18
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define fst first
#define snd second
typedef long long ll;
typedef double db;
typedef long double ldb;
typedef unsigned int uint;
typedef unsigned long long ull;
#define DEBUG

int main(){
#ifndef DEBUG
	freopen("my.in","r",stdin);
	freopen("my.out","w",stdout);
#endif
	int a,b;
	cin>>a>>b;
	if(a+b==15)cout<<"+";
	else if(a*b==15)cout<<"*";
	else cout<<"x"; 
	return 0;
}

/*
Input:
-----------------
Output:
*/

Measured memory_bytes: 256
/*
 * @Author: AsilenceBTF
 * @Buff: ︿(￣︶￣)︿  芜湖塔台 起飞
 * @Date: 2019-06-20 09:22:24
 * @LastEditTime: 2020-08-30 14:47:35
 */
// #include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
using namespace std;

#define sz(x) int(x.size())
#define ALL(x) x.begin(), x.end()
#define INF 0x3f3f3f3f
typedef long long ll;

int main(){
    ios::sync_with_stdio(0), cin.tie(0);
    ll d, t, s;
    cin >> d >> t >> s;
    if(s * t < d) cout << "No" << endl;
    else cout << "Yes" << endl;
    // system("pause");
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

int main()
{
  vector<int> dp(1e6 + 1, INT32_MAX), odd_dp(1e6 + 1, INT32_MAX);

  dp[0] = 0;
  odd_dp[0] = 0;
  rep(i, 1e6 + 1) for(int j = 200; j > 0; j--)
  {
    int regular_tetrahedron_number = j * (j + 1) * (j + 2) / 6;
    int ni = i + regular_tetrahedron_number;
    if(ni > 1e6)
      continue;

    if(dp[i] != INT32_MAX)
      dp[ni] = min(dp[ni], dp[i] + 1);

    if(regular_tetrahedron_number % 2 == 1 && odd_dp[i] != INT32_MAX)
      odd_dp[ni] = min(odd_dp[ni], odd_dp[i] + 1);
  }

  while(true)
  {
    int N;
    cin >> N;
    if(N != 0)
      cout << dp[N] << " " << odd_dp[N] << endl;
    else
      break;
  }
  return 0;
}


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

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);

  int n;
  cin >> n;
  vector<long long> x(n), y(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
  }

  bool odd = true, even = true;
  for (int i = 0; i < n; i++) {
    odd &= abs(x[i] + y[i]) % 2 == 1;
    even &= abs(x[i] + y[i]) % 2 == 0;
  }
  if (!odd && !even) {
    cout << -1 << '\n';
    return 0;
  }

  int k = 36;
  cout << k + even << '\n';
  if (even) cout << 1 << ' ';
  for (int i = k - 1; i >= 0; i--) {
    cout << (1LL << i) << ' ';
  }
  cout << '\n';

  auto inside = [](long long i, long long j, int round) {
    return abs(i) + abs(j) <= ((1LL << round) - 1);  
  };

  for (int i = 0; i < n; i++) {
    string ans = "";
    if (even) {
      ans += "D";
      y[i]++;
    }
    for (int j = k - 1; j >= 0; j--) {
      long long step = (1LL << j); 
      if (inside(x[i], y[i] - step, j)) {
        ans += "U";
        y[i] -= step;
      } else if (inside(x[i], y[i] + step, j)) {
        ans += "D";
        y[i] += step;
      } else if (inside(x[i] - step, y[i], j)) {
        ans += "R";
        x[i] -= step;
      } else if (inside(x[i] + step, y[i], j)) {
        ans += "L";
        x[i] += step;
      } else {
        assert(0);
      }
    }
    cout << ans << '\n';
  }

  return 0;
}


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

int main(void){
    int n;
    vector<int> a;
    int i;
    int a_i;
    vector<int>::iterator itr;
    
    cin >> n;
    
    
    for(i = 0; i < n; i++){
        cin >> a_i;
        a.push_back(a_i);
        
    }
    
    reverse(a.begin(), a.end());
    itr = a.begin();
    while(true){
        cout << *itr;
        itr++;
        if(itr == a.end()) break;
        cout << " ";
    }
    
    cout << endl;
    
    return 0;
}

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

using namespace std;

int main() {
	string num;
	cin >> num;
	if ((num[0] == num[1] && num[1] == num[2]) || (num[1] == num[2] && num[2] == num[3]))cout << "Yes" << endl;
	else cout << "No"<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
n=int(input())
edges=[[] for i in range(n)]
for i in range(n-1):
    a,s=map(int,input().split())
    a-=1;s-=1
    edges[a].append(s);edges[s].append(a)

def bfs(pre,now):
    for  i in edges[now]:
        if i==pre:continue
        if i==n-1:return[n-1,now]
        v=bfs(now,i)
        if v:v.append(now);return v
l=bfs(-1,0)
ll=len(l)
snuke_last=-(-ll//2)
table=[-1]*n
def c(now,pre):
    if table[now]!=-1:return table[now]
    if len(edges[now])>1:
        table[now]=1+sum(c(i,now) for i in edges[now] if i!=pre)
        return table[now]
    table[now]=1
    return 1
l=l[::-1]

d=c(l[snuke_last],l[snuke_last-1])

print("Fennec") if n-d>d else print("Snuke")
"""
1
2
3
4
567
"""

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

int N, Q;
string S;
vector<set<int> > si;

void input_init(void) {
	cin >> N >> S >> Q;
	si.resize(26);
	for (int i = 0; i < N; ++i) {
		int id = (int)(S[i] - 'a');
		si[id].insert(i);
	}
}

void type_1(void) {
	int q;
	char c;
	cin >> q >> c;
	--q;
	int old_id = (int)(S[q] - 'a');
	si[old_id].erase(q);
	S[q] = c;
	int new_id = (int)(c - 'a');
	si[new_id].insert(q);
}

void type_2(void) {
	int l, r;
	cin >> l >> r;
	--l;
	--r;
	set<int>::iterator itr;
	int cnt = 0;
	for (int i = 0; i < 26; ++i) {
		itr = si[i].lower_bound(l);
		if (itr != si[i].end()) {
			if (*itr <= r)
				++cnt;
		}
	}
	cout << cnt << '\n';
}

int main(void) {
	input_init();
	for (int i = 0; i < Q; ++i) {
		int t;
		cin >> t;
		if (t == 1)
			type_1();
		else
			type_2();
	}
	return 0;
}


Measured memory_bytes: 24196
n = int(input())
ans = []
taboo = n if n%2 else n+1
for i in range(1,n):
    for j in range(i+1,n+1):
        if i+j == taboo: continue
        ans.append(str(i) + ' ' + str(j))
print(len(ans))
print(*ans,sep='\n')

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

long long N,A,B;

int main(){
	cin >> N >> A >> B;

	long long sm = A + B;
	long long q = N / sm;
	long long r = N % sm;

	long long ans = q * A;
	if(r >= A){
		ans += A;
	}
	else{
		ans += r;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a.insert(0,0)
a.append(0)
sum = 0
for i in range(n+1):
	sum += abs(a[i]-a[i+1])
sum2 = sum
for i in range(1,n+1):
	sum += abs(a[i-1]-a[i+1])-abs(a[i-1]-a[i])-abs(a[i]-a[i+1])
	print(sum)
	sum = sum2

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

vector<pair<ll,int>> factorize(ll n) {
  vector<pair<ll,int>> res;
  for (ll i = 2; i*i <= n; ++i) {
    if (n%i) continue;
    res.emplace_back(i,0);
    while (n%i == 0) {
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1) res.emplace_back(n,1);
  return res;
}

int main(void){
    ll n;
    ll c = 0;

    cin >> n;

    rep(i, n + 1){
        if((i % 2) == 1){
            auto x = factorize(i);
            ll count = 1;
            for(pair<ll, int> j: x){
                count *= j.second + 1;
            }
            if(count == 8){
                c++;
            }
        }
    }

    cout << c << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h> 

int main(void){    

char str[1200];    

char *p;    

int sum;     

while(1){        

gets(str);        

if(str[0] == '0' && str[1] == '\0')break;        

sum = 0;        

for(p = str; *p!='\0'; p++){            

sum += *p - '0';        

}        

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

}     

return 0;

}

Measured memory_bytes: 524
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static String g;
	static String[] a, b;
	static final int INF = 999;

	public static void main(String[] args) {
		while (true) {
			int N = sc.nextInt();
			if (N == 0) break;
			a = new String[N];
			b = new String[N];
			for (int i = 0; i < N; ++i) {
				a[i] = sc.next();
				b[i] = sc.next();
			}
			String s = sc.next();
			g = sc.next();
			int ans = solve(s);
			System.out.println(ans == INF ? -1 : ans);
		}
	}

	static int solve(String cur) {
		if (cur.length() == g.length()) {
			return cur.equals(g) ? 0 : INF;
		}
		if (cur.length() > g.length()) return INF;
		int ret = INF;
		for (int i = 0; i < a.length; ++i) {
			StringBuilder sb = new StringBuilder();
			int pos = 0;
			boolean changed = false;
			while (true) {
				int next = cur.indexOf(a[i], pos);
				if (next == -1) {
					for (int j = pos; j < cur.length(); ++j) {
						sb.append(cur.charAt(j));
					}
					break;
				} else {
					for (int j = pos; j < next; ++j) {
						sb.append(cur.charAt(j));
					}
					sb.append(b[i]);
					pos = next + a[i].length();
					changed = true;
				}
			}
			if (changed) {
				ret = Math.min(ret, solve(sb.toString()) + 1);
			}
		}
		return ret;
	}
}

Measured memory_bytes: 33776
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int r = sc.nextInt();
		sc.close();
		if (n >= 10) {
			System.out.println(r);
		} else {
			System.out.println(r + (100 * (10 - n)));
		}
	}

	public static int arrayMax(int[] array) {
		int ans = Integer.MIN_VALUE;
		for (int i = 0; i < array.length; i++) {
			if (array[i] > ans)
				ans = array[i];
		}
		return ans;
	}

	public static int[] arrayInt(Scanner sc, int n) {
		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		return array;
	}

	public static Integer[] arrayInteger(Scanner sc, int n) {
		Integer[] array = new Integer[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		return array;
	}

	public static long[] arrayLong(Scanner sc, int n) {
		long[] array = new long[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextLong();
		}
		return array;
	}

	public static double[] arrayDouble(Scanner sc, int n) {
		double[] array = new double[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextDouble();
		}
		return array;
	}
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define debug(x) cout<<#x<<" = "<<(x)<<endl
#define debug3(x,y,z) cout<<"("<<#x<<","<<#y<<","<<#z<<") = ("<<(x)<<","<<(y)<<","<<(z)<<")\n"

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

ll lcm(ll a, ll b){
  return a / gcd(a, b) * b;
}

int main(){
  ll A,B,C,D;cin>>A>>B>>C>>D;
  ll L = lcm(C,D);
  //debug(L);

  A--;

  ll P = (B/C) - (A/C);
  ll Q = (B/D) - (A/D);
  ll R = (B/L) - (A/L);
  //debug3(P,Q,R);

  ll ans = (B-A) - (P+Q-R);

  cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);
            int iK = int.Parse(sS[1]);
            List<int> lstSnk = new List<int>();
            for (int i = 0; i < iN; i++) { lstSnk.Add(1); }
            for (int i = 0; i < iK; i++)
            {
                sS = System.Console.ReadLine().Trim().Split(' ');
                sS = System.Console.ReadLine().Trim().Split(' ');
                for (int j = 0; j < sS.Length; j++)
                {
                    lstSnk[int.Parse(sS[j]) - 1] = 0;
                }
            }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iOut = lstSnk.Sum();

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 28644