akhauriyash/Code-Regression huggingface dataset:
/**
 * @Author:      K C-L
 * @DateTime:    2018-06-03 20:00:40
 * @Description: 
 */
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef stringstream strstm;
#define fi first
#define se second
#define INF 0X3f3f3f3f
#define SZ(x) ((int)(x).size())
#define pb push_back
#define PI acos(-1.0)
#define E 2.718281829459
#define lowbit(x) (x & (-x))
#define DBG(x) cout << (x) <<  << endl;
#define MST(a,b) memset(a,b,sizeof(a));
#define _for(i,a,b) for(int i = (a); i < (b); ++i)
#define _rep(i,a,b) for(int i = (a); i <= (b); ++i)



int main(int argc, char const *argv[]) {
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


	int a,b; 
	while(cin >> a >> b){
		int ans  = -INF;
		ans = max(ans,a+b);
		ans = max(ans,a-b);
		ans = max(ans,a*b);
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 256
def main():
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #r = input()
    #n = int(input())
    #a, b = map(int, input().split())
    #s, y = input().split()
    #a = input().split()
    #a = [int(input()) for i in range(n)]
    #a = list(map(int, input().split()))
    #a = [list(map(int, input().split())) for i in range(n)]
    #a = [int(s) - 1 for s in input().split()]
    #l=[int(input()) for _ in range(int(input()))]
    #res = 0
    from collections import deque
    deq = deque(input())
    q = int(input())
    r = [input().split() for i in range(q)]
    cnt = 0
    for i in range(q):
        tmp = r[i]
        if tmp[0] == "1":
            cnt += 1
        else:
            if tmp[1] == "1" and cnt % 2 == 0 or tmp[1] != "1" and cnt % 2 != 0:
                deq.appendleft(tmp[2])
            else:
                deq.append(tmp[2])
    if cnt % 2 == 0:
        print(*(deq), sep="")
    else:
        print(*(deque(reversed(deq))), sep="")

if __name__ == '__main__':
    main()



Measured memory_bytes: 122316
#include<stdio.h>
int main(){
  int i,num,min,j,alt,count=0;
  scanf("%d",&num);
  int buf[num];
  for(i=0;i<num;i++){

    scanf("%d",&buf[i]);
  }
  for(i=0;i<num;i++){
    min=i;
    for(j=i;j<num;j++){
      if(buf[j]<buf[min]){
	min=j;
      }
    }
    if( buf[i]>buf[min]){
	alt=buf[i];
	buf[i]=buf[min];
	buf[min]=alt;
	count ++;
    }
      
    
  }
  for(i=0;i<num;i++){
    if(i!=num-1){
      printf("%d ",buf[i]);
    }
    else printf("%d\n",buf[i]);
  }
  printf("%d\n",count);

}



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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll H, A;
    cin >> H >> A;
    cout << (H + A - 1) / A << '\n';
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int> ABC(3);
  cin >> ABC.at(0) >> ABC.at(1) >> ABC.at(2);
  sort(ABC.begin(), ABC.end());
  int ans = (ABC.at(2) - ABC.at(1));
  ABC.at(0) += (ABC.at(2) - ABC.at(1));
  ABC.at(1) += (ABC.at(2) - ABC.at(1));
  if ((ABC.at(2) - ABC.at(0)) % 2 == 1) {
    ans += ((ABC.at(2) - ABC.at(0)) / 2);
    ans += 2;
    cout << ans << endl;
  }
  else {
    ans += ((ABC.at(2) - ABC.at(0)) / 2);
    cout << ans << endl;
  }
}
  

Measured memory_bytes: 3628
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main(){
  ll N; cin >> N;
  vector<ll> a(N), inv(N+1);
  REP(i,N) {
    cin >> a[i];
    inv[a[i]] = i;
  }
  set<ll> st;
  st.insert(-1);
  st.insert(N);
  ll ans = 0;
  FOR(i,1,N+1){
    st.insert(inv[i]);
    auto it = st.lower_bound(inv[i]);
    ans += i * (inv[i] - (*prev(it))) * ((*next(it)) - inv[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 12800
#include<bits/stdc++.h>
#define MAXN 1010
using namespace std;
long long a[MAXN],a1[MAXN],n,sum[2],used[MAXN],flag,r[MAXN],l[MAXN];
bool dele[MAXN];
vector<int> ans;
void del(int x){
    ans.push_back(x+1);
    a[x]=0;
    memset(dele,0,sizeof dele);
    memset(used,0,sizeof used);
    if(x!=0){
        dele[x-1]=1;
        a[x]+=a[x-1];
    }
    if(x!=n-1){
        dele[x+1]=1;
        a[x]+=a[x+1];
    }
    for(int i=0;i<n;i++)
        a1[i]=a[i];
    int cnt=0;
    for(int i=0;i<n;i++)
        if(dele[i]==0)
            a[cnt++]=a1[i];
    for(int i=0;i<n;i++)
        if(a[i]>0&&flag==i%2)
            used[i]=1;
    n=cnt;
}
void work(){
    int maxid=0;
    for(int i=0;i<n;i++)
        if(a[i]>a[maxid])
            maxid=i;
    printf("%lld\n%d\n",a[maxid],n-1);
    int sum=n;
    for(int i=0;i<maxid;i++){
        printf("%d\n",1);
        sum--;
    }
    for(int i=n-1;i>maxid;i--){
        printf("%d\n",sum);
        sum--;
    }
}
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%lld",&a[i]);
    for(int i=0;i<n;i++)
        if(a[i]>0)
            sum[i%2]+=a[i];
    if(sum[0]==0&&sum[1]==0){
        work();
        return 0;
    }
    if(sum[0]>sum[1])
        flag=0;
    else
        flag=1;
    for(int i=0;i<n;i++){
        l[i]=i-1;
        r[i]=i+1;
    }
    for(int i=0;i<n;i++)
        if(a[i]>0&&flag==i%2)
            used[i]=1;
    while(n>1){
        for(int i=0;i<n;i++){
            if(i==0||i==n-1){
                if(used[i]==0){
                    if(i==0)
                        flag^=1;
                    del(i);
                    break;
                }
            }
            else if(used[i-1]==used[i+1]){
                del(i);
                break;
            }
        }
    }
    printf("%lld\n%d\n",a[0],ans.size());
    for(int i=0;i<ans.size();i++)
        printf("%d\n",ans[i]);
}

Measured memory_bytes: 3792
import java.util.*
fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val n = scanner.nextInt()
    val k = scanner.nextInt()
    val list = mutableListOf<Int>()
    for (i in 1..n) {
        val aaa = scanner.nextInt()
        if (aaa >= k) list.add(aaa)
    }
    print(list.size)
}

Measured memory_bytes: 49224
#--Comparing Strings
a, b = map(int, input().split(" "))

def connection(one, two):
  character = " "
  one_str = str(one)
  for i in range(two):
    character = one_str + character 
  return character

aa = connection(a, b)
bb = connection(b, a)

ans = sorted([aa, bb])

print(ans[0])


Measured memory_bytes: 2940
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <chrono>
#include <random>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <iomanip>
#include<string>
#include <complex>
using namespace std;
#define ll long long



int  main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,v,w,t;
    cin>>a>>v>>b>>w>>t;
    if( abs(b-a) <= (v-w)*t) cout<<"YES";
    else cout<<"NO";

}


Measured memory_bytes: 3652
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define SIZE(a) int((a).size())
const int INF=INT_MAX;
const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll a,b,h,m;cin>>a>>b>>h>>m;
  double x=30*h+0.5*m,y=6*m;
  double z=abs(x-y);
  z=min(360-z,z);
  double ans=pow(a*a+b*b-2*a*b*cos(z*(M_PI/180)),0.5);
  cout<<fixed<<setprecision(20)<<ans<<endl;
}

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

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

int abcjudge(int a, int b, int c) {
  if (a == b) {
    if (c >= a-1 && c <= a+1) {
      return 1;
    } else {
      return 0;
    }
  } else {
    return 0;
  }
}

int main() {
  string s;
  cin >> s;
  int a = 0, b = 0, c = 0;
  REP(i, s.size()) {
    if (s[i] == 'a') {
      ++a;
    } else if (s[i] == 'b') {
      ++b;
    } else {
      ++c;
    }
  }
  if (abcjudge(a, b, c) || abcjudge(a, c, b) || abcjudge(b, c, a)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#include <numeric>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool PRIMEOR (int x) {
	if (x ==1)
		return false;
	if (x == 2)
		return true;
	if (x%2==0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}

using namespace std;
#pragma endregion
signed main() {
	string O, E;
	cin >> O >> E;
	rep(i,E.size()) {
		cout << O[i];
		cout << E[i];
	}
	if (O.size() - E.size() == 1)
		cout << LAST(O) << endl;
}

Measured memory_bytes: 256
//Author : pakhandi
//
using namespace std;

#include <bits/stdc++.h>

#define wl(n) while(n--)
#define fl(i,a,b) for(i=a; i<b; i++)
#define rev(i,a,b) for(i=a; i>=b; i--)

#define si(n) scanf("%d", &n)
#define sll(l) scanf("%lld",&l)

#define debug(x) cout<<"\n#("<<x<<")#\n"
#define nline printf("\n")

#define mem(a,i) memset(a,i,sizeof(a))

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

#define PB push_back
#define SZ size
#define MP make_pair

#define IGNORE cin.ignore (std::numeric_limits<std::streamsize>::max(), '\n');

const ll INF = (1LL << 58);
const bool DEBUG = 0;

int limit;
int arr[41][2], c[41], Ma, Mb;
int dp[41][401][401];

int rec(int ind, int A, int B)
{
	if(ind == limit)
	{
		int gg = __gcd(A, B);
		if(gg == 0)
			return 100000;
		A /= gg;
		B /= gg;
		if(A == Ma && B == Mb)
			return 0;
		return 100000;
	}

	int &ret = dp[ind][A][B];
	if(ret != -1)
		return ret;
	ret = 100000;

	ret = min(ret, rec(ind + 1, A, B));
	ret = min(ret, c[ind] + rec(ind + 1, A + arr[ind][0], B + arr[ind][1]));
	return ret;
}

int main()
{
	int i, j;

	mem(dp, -1);

	si(limit);	si(Ma);	si(Mb);

	fl(i,0,limit)
	{
		si(arr[i][0]);	si(arr[i][1]);	si(c[i]);
	}

	int ans = rec(0,0,0);
	if(ans >= 100000)
		ans = -1;

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


	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 25984
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}


using P = pair<int ,int>;
using LP = pair<ll, int>;
int main(){
	int N; 
	ll M;
	cin >> N >> M;

	vector<ll> divs;
	for(ll i=1; i*i<=M;  i++){
		if(M%i == 0){
			divs.push_back(i);
			if(i*i != M)divs.push_back(M/i);
		}
	}
	sort(divs.begin(), divs.end());
	ll ans = 0;
	for(int i=0; i<(int)divs.size(); i++){
		if(M/divs[i] >= N) ans = max(ans, divs[i]);
	}
	// cout << " divs: "; print_vec(divs);
	cout << ans << endl;


	// vector<LP> prime_divisors;
	// ll m = M;
	// //エラトステネスの篩
	// for(ll p=2; p*p<m; p++){
	// 	if(m % p != 0) continue;
	// 	int cnt = 0;
	// 	while(m%p == 0){
	// 		m /= p;
	// 		cnt++;
	// 	}
	// 	prime_divisors.emplace_back(p, cnt);
	// }
	// if(m != 1) prime_divisors.emplace_back(m, 1);


	// vector<ll> divs;// Mの因数となるモノを格納
	// ll ans = 0;

}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> PP;
typedef priority_queue<PP, vector<PP>, greater<PP> > PQ;

int w, h, n;
int sx, sy, ex, ey;
int e[2][501][501];
int dist[501][501];

int main(){
	scanf("%d%d%d",&w,&h,&n);
	scanf("%d%d%d%d",&sx,&sy,&ex,&ey);
	rep(i,n){
		int x, y, t;
		string str;
		scanf("%d%d%d",&x,&y,&t);
		cin >> str;
		rep(j,t) rep(k,str.size()){
			if(str[k] == 'U'){
				if(y == 0) continue;
				e[0][x][y]++;
				y--;
			} else if(str[k] == 'D'){
				if(y == h-1) continue;
				e[0][x][y+1]++;
				y++;
			} else if(str[k] == 'L'){
				if(x == 0) continue;
				e[1][x][y]++;
				x--;
			} else{
				if(x == w-1) continue;
				e[1][x+1][y]++;
				x++;
			}
		}
	}
	rep(i,501) rep(j,501) dist[i][j] = INF;
	dist[sx][sy] = 0;
	PQ que;
	que.push(PP(0,P(sx,sy)));
	while(true){
		if(que.size() == 0) break;
		PP Q = que.top();
		que.pop();
		P q = Q.second;
		if(Q.first > dist[q.first][q.second]) continue;
		if(q.first != 0){
			if(dist[q.first-1][q.second] > dist[q.first][q.second]+e[0][q.first-1][q.second]){
				dist[q.first-1][q.second] = dist[q.first][q.second]+e[0][q.first-1][q.second];
				que.push(PP(dist[q.first-1][q.second],P(q.first-1,q.second)));
			}
		}
		if(q.first != w){
			if(dist[q.first+1][q.second] > dist[q.first][q.second]+e[0][q.first][q.second]){
				dist[q.first+1][q.second] = dist[q.first][q.second]+e[0][q.first][q.second];
				que.push(PP(dist[q.first+1][q.second],P(q.first+1,q.second)));
			}
		}
		if(q.second != 0){
			if(dist[q.first][q.second-1] > dist[q.first][q.second]+e[1][q.first][q.second-1]){
				dist[q.first][q.second-1] = dist[q.first][q.second]+e[1][q.first][q.second-1];
				que.push(PP(dist[q.first][q.second-1],P(q.first,q.second-1)));
			}
		}
		if(q.second != h){
			if(dist[q.first][q.second+1] > dist[q.first][q.second]+e[1][q.first][q.second]){
				dist[q.first][q.second+1] = dist[q.first][q.second]+e[1][q.first][q.second];
				que.push(PP(dist[q.first][q.second+1],P(q.first,q.second+1)));
			}
		}
	}
	cout << dist[ex][ey] << endl;
}

Measured memory_bytes: 8392
from collections import Counter
n=int(input())
v=list(map(int,input().split()))
odd=Counter(v[::2]).most_common(2)
odd.append((0,0))
even=Counter(v[1::2]).most_common(2)
even.append((0,0))
if odd[0][0]==even[0][0]:
	ans=min(n-odd[0][1]-even[1][1],n-odd[1][1]-even[0][1])
else:
	ans=n-odd[0][1]-even[0][1]
print(ans)

Measured memory_bytes: 15588
#include <bits/extc++.h>

#ifndef DUMP
#define DUMP(...) (void)0
#endif

using namespace std;

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int w = 0, r = count(begin(s), end(s), 'R');
  int res = max(w, r);
  for (char c : s) {
    w += c == 'W';
    r -= c == 'R';
    res = min(res, max(w, r));
  }
  cout << res << '\n';
}


Measured memory_bytes: 3788
#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++)
#define pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  ll N;
  cin>>N;
  vl d(N);
  rep(i,N) cin>>d[i];
  sort(all(d));
  ll ans=d[N/2]-d[N/2-1];
  cout<<ans<<endl;
}

Measured memory_bytes: 4044
#include <bits/stdc++.h>
#include <iomanip>
#include <algorithm>
#define ll long long
#include <unordered_map>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  if(S.at(S.size() - 1) == '3') cout << "bon" << endl;
  else if((S.at(S.size() - 1) == '0') || (S.at(S.size() - 1) == '1') || (S.at(S.size() - 1) == '6') || (S.at(S.size() - 1) == '8')) cout << "pon" << endl;
  else cout << "hon" << endl;
}

Measured memory_bytes: 3620
#include <cstdio>
#define N 100005
int n, l, r, pr[N], s[N];
int main() {
	int i, j;
	for(i=2; i*i<N; i++) if(!pr[i])
		for(j=i*i; j<N; j+=i) pr[j]=1;
	for(i=3; i<N; i++) s[i] = s[i-1] + (!pr[i] & !pr[(i+1)/2]);
	scanf("%d", &n);
	while(n--) {
		scanf("%d%d", &l, &r);
		printf("%d\n", s[r] - s[l-1]);
	}
	return 0;
}

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

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

 if(b ==0){
 cout << "0" << endl;
}
else{
  if((b-1)%(a-1) == 0) {
   cout << (b-1)/(a-1) << endl;
 }
else{
 cout << (b-1)/(a-1) + 1 << endl;
}
}

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1 ; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1 ; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const bool debug = 0;
/***************************************/

string to_str(int a) {
	ostringstream ss;
	ss << a;
	return ss.str();
}

int solve(int a, int n) {
	string s = to_str(a);
	while (s.size() < n) s += '0';
	sort(ALL(s), greater<int>());
	int ma = atoi(s.c_str());
	sort(ALL(s));
	int mi = atoi(s.c_str());
	return ma - mi;
}

int main() {
	int a[31], l;
	while (cin >> a[0] >> l, a[0] || l) {
		if (debug) printf("@ ");
		REP(i, 30) a[i + 1] = solve(a[i], l);
		
		bool done = false;
		REP(i, 31) {
			if (done) break;
			FOR(j, i + 1, 31) {
				if (a[i] == a[j]) {
					printf("%d %d %d\n", i, a[j], j - i);
					done = true;
					break;
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include<stdio.h>
#include<math.h>

using namespace std;

int main(void){
    // Your code here!
    //int r;//double f=0;
    double r;
    
    scanf("%lf",&r);//scanf("%d",&r);

    printf("%.6f %.6f\n",r*r*M_PI,2*r*M_PI);//printf("%d %d %.5f\n",a/b,a%b,(double)a/b);//printf("%d %d %.5f",a/b,a%b,f); //2*r //2r is ng

    return 0;
}



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

using namespace std;

bool hantei(int x){
    bool f=true;
    for(int i=pow(x,0.5)+1;2<=i;i--){
        if(x%i==0){
            return false;
        }
    }
    return true;
}

int main(){
    long long int N,ans=1;
    vector<int> sosu;
    cin >> N;

    for(int i=3;i<=N;i++){
        if(hantei(i)){
            sosu.push_back(i);
        }
    }

    sosu.push_back(2);

    for(int i=0;i<sosu.size();i++){
        int div=sosu[i],done=N,pw=0;
        while(div<=done){
            pw += done/div;
            div *= sosu[i];
        }
        ans *= (pw+1);
        ans %= 1000000007;
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
N = int(input())

W_list = []
check = True

for i in range(N):
  W = input()
  if i == 0:
    W_list.append(W)
    continue
    
  if W in W_list:
    check = False
    break
    
  if W_list[i-1][-1] != W[0]:
    check = False
    break
    
  W_list.append(W)
    
print("Yes" if check else "No")
    

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

int a[5];
int modif[5];
int main()
{
	

	int n, s, c, m;
	cin >> n >> m;

	int modified = 0;
	if(n==1)
	{
		for( int i=0; i<m; i++)
		{
			cin >> s >> c;
			if(a[s]!=c && modified)
			{
				cout << "-1";
				return 0;
			}
			modified = 1;
			a[s] = c;
		}
		cout << a[1];
		return 0;
	}


	for( int i=0; i<m; i++)
	{
		cin >> s >> c;

		if( s==1 && c==0)
		{
			cout << "-1";
			return 0;
		}

		if(modif[s] && a[s]!=c)
		{
			cout << "-1";
			return 0;
		}
		modif[s] = 1;
		a[s] = c;
	}
	

	if(a[1]==0)
		a[1] = 1;
	
	for(int i=1; i<=n; i++)
	{
		cout << a[i];
	}

	
	return 0;
}


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

int main(){
  int N; cin >> N;
  map<int, int>mp;
  rep(i, N){
    ll a; cin >> a; mp[a]++;
  }
  bool ans = true;
  for(auto p: mp){
    if(p.second!=1) ans = false;
  }
  if(ans) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 9600
#include "bits/stdc++.h"
using namespace std;

long long int mod=1e9+7;
long long int n;
vector<long long int> a(101010);
vector<long long int> bit(202020);

int sum(long long int i){
  long long int s=0;
  while(i>0){
    s+=bit[i];
    i-=i&-i;
  }
  return s;
}

void add(long long int i,long long int x){
  while(i<=202020){
    bit[i]+=x;
    i+=i&-i;
  }
}

bool ch(long long int x){
  for(long long int i=0;i<202020;i++)bit[i]=0;
  vector<long long int> b(n);
  for(long long int i=0;i<n;i++){
    if(a[i]>=x){
      b[i]=1;
    }else{
      b[i]=-1;
    }
  }
  vector<long long int> rui(n+1);
  rui[0]=n+1;
  for(long long int i=1;i<n+1;i++)rui[i]=rui[i-1]+b[i-1];
  long long int tmp=0;
  //for(int i=0;i<n+1;i++)cout<<rui[i]<<" ";
  //cout<<endl;
  for(long long int i=0;i<n+1;i++){
    tmp+=i-sum(rui[i]);
    add(rui[i],1);
  }
  long long int y=(n*(n+1)/2)/2;
  //cout<<y<<" "<<tmp<<endl;
  if(tmp>y){
    return true;
  }else{
    return false;
  }
}

int main(){
  cin>>n;
  for(long long int i=0;i<n;i++){
    cin>>a[i];
    bit[i]=0;
  }

  long long int l,r,mid;
  l=0;
  r=1e9+1;
  while(r-l>1){
    mid=(l+r)/2;
    //cout<<mid<<endl;
    if(ch(mid)){
      r=mid;
    }else{
      l=mid;
    }
  }
  cout<<l<<endl;
}


Measured memory_bytes: 4236
n = int(input())
p = list(map(int, input().split()))
index_list = []
value_list = []
for i in range(1, n+1):
  if i != p[i-1]:
    index_list.append(i)
    value_list.append(p[i-1])
if len(index_list) == 0:
  print("YES")
elif len(index_list) == 2 and value_list[0] == index_list[1] and value_list[1] == index_list[0]:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string.h>
#include <queue>

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

using namespace std;

typedef long long ll;

int input[6];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    REP(i, 6) {
        cin >> input[i];
    }
    
    if (input[4] - input[0] > input[5]) {
        cout << ":(" << endl;
    } else {
        cout << "Yay!" << endl;
    }
}



Measured memory_bytes: 256
def main():
    result = sub()
    print(result)


def sub():
    maskA = '10' * 10 ** 5
    maskB = '01' * 10 ** 5

    raw = input()
    length = len(raw)

    maskA = maskA[:length]
    maskB = maskB[:length]
    a = int(raw, 2) ^ int(maskA, 2)
    b = int(raw, 2) ^ int(maskB, 2)
    tmp = min(bin(a).count("1"), bin(b).count("1"))
    return min(tmp, length - tmp)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3632
N = gets.chomp.to_i
h = gets.chomp.split(" ").map(&:to_i)

umi = 1
hmax = h[0]

(1..N-1).each do |i|
  if hmax <= h[i]
    umi += 1
    hmax = h[i]
  end
end

puts umi

Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int n;
    cin >> n;
    map<int, int> m;
    rep(i, n)
    {
        int a;
        cin >> a;
        m[a]++;
    }
    ll ans = 0;
    for (auto p : m)
    {
        ans += p.first * p.second;
    }
    int q;
    cin >> q;
    rep(i, q)
    {
        ll b, c;
        cin >> b >> c;
        ll cnt = m[b];
        m[c] += cnt;
        m[b] = 0;
        ans -= b * cnt;
        ans += c * cnt;

        cout << ans;
        if (i != q - 1)
        {
            cout << '\n';
        }
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 7920
#include "bits/stdc++.h"

using namespace std;

typedef long double ld;
typedef long long ll;

#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define f first
#define s second

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

int h, w, k, res = 0, cur = 0;
vector<int> vert, hor;
vector<vector<char>> board;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> h >> w >> k;
    vert.assign(h, 0);
    hor.assign(w, 0);
    board.assign(h, vector<char>(w, ' '));
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            cin >> board[i][j];
            cur += board[i][j] == '#';
        }
    }
    for(int i = 0; i < h; ++i){
        int x = 0;
        for(int j = 0; j < w; ++j){
            x += board[i][j] == '#';
        }
        vert[i] = x;
    }
    for(int i = 0; i < w; ++i){
        int x = 0;
        for(int j = 0; j < h; ++j){
            x += board[j][i] == '#';
        }
        hor[i] = x;
    }
    for(int i = 0; i < (1 << h) - 1; ++i){
        for(int j = 0; j < (1 << w) - 1; ++j){
            int cc = 0;
            for(int x = 0; x < h; ++x){
                if((i >> x) & 1) cc += vert[x];
            }
            for(int x = 0; x < w; ++x){
                if((j >> x) & 1) cc += hor[x];
            }
            for(int x = 0; x < h; ++x){
                for(int y = 0; y < w; ++y){
                    if(((i >> x) & 1) && ((j >> y) & 1)){
                        cc -= board[x][y] == '#';
                    }
                }
            }
            if(cur - cc == k) res++;
        }
    }
    cout << res;
    return 0;
}

Measured memory_bytes: 3652
#pragma comment(linker, "/STACK:1000000000")
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <bitset>
#include <memory>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <ctime> 
#include <stack>

#define mp make_pair
#define pb push_back

typedef long long ll;
typedef long double ld;

using namespace std;

const int MAXN = 200001;
int a[MAXN];
int b[MAXN];
ll s[MAXN];
const ll INF = 1000ll * 1000ll * 1000ll * 1000ll * 1000ll * 100ll;

struct node
{
	ll mdf;
	ll val;
	ll val2;
	node* l;
	node* r;
};

typedef node* pnode;

void setval(pnode t, int l, int r, ll vl)
{
	t->mdf = t->val = vl;
	t->val2 = vl + l;
}

pnode newnode(int l, int r)
{
	pnode ans = new node();
	setval(ans, l, r, 0);
	return ans;
}

void upd(pnode t)
{
	t->val = min(t->l->val, t->r->val);
	t->val2 = min(t->l->val2, t->r->val2);
}

void push(pnode t, int l, int r)
{
	int md = (l + r) / 2;
	if (!(t->l)) t->l = newnode(l, md);
	if (!(t->r)) t->r = newnode(md + 1, r);
	if (t->mdf != -1)
	{
		setval(t->l, l, md, t->mdf);
		setval(t->r, md + 1, r, t->mdf);
		t->mdf = -1;
	}
}

pnode root;

int n;
int k;
int lv, rv;
ll nval;

ll rmq_get(pnode t, int l, int r)
{
	if ((l > rv) || (lv > r)) return INF;
	if ((lv <= l) && (r <= rv)) return t->val2;
	push(t, l, r);
	return min(rmq_get(t->l, l, (l + r) / 2),
		rmq_get(t->r, (l + r) / 2 + 1, r));
}

void rmq_modify(pnode t, int l, int r)
{
	if ((l > rv) || (lv > r)) return;
	if ((lv <= l) && (r <= rv))
	{
		setval(t, l, r, nval);
		return;
	}
	push(t, l, r);
	rmq_modify(t->l, l, (l + r) / 2);
	rmq_modify(t->r, (l + r) / 2 + 1, r);
	upd(t);
}

ll g2(int md)
{
	lv = 0, rv = md;
	ll ans = INF;
	ans = min(ans, rmq_get(root, 0, k - 1) + k - md);
	lv = md, rv = k - 1;
	ans = min(ans, rmq_get(root, 0, k - 1) - md);
	return ans;
}



int main()
{
	ios_base::sync_with_stdio(0);
	//	freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	cin >> n >> k;
	root = newnode(0, k - 1);
	ll sm = 0;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i] >> b[i];
		a[i] *= 2;
		sm += a[i];
	}
	ll md = 0;
	for (int i = 0; i < n; i++)
	{
		if ((a[i] > k) && (b[i] == 1))
		{
			cout << -1 << endl;
			return 0;
		}
		if (b[i] == 1)
		{
			ll val = g2(md);
			int  dlv = (md + 1) % k, drv = (md + a[i] - 1) % k;
			nval = INF;
			if (dlv > drv)
			{
				lv = 0, rv = drv;
				rmq_modify(root, 0, k - 1);
				lv = dlv, rv = k - 1;
				rmq_modify(root, 0, k - 1);
			}
			else
			{
				lv = dlv, rv = drv;
				rmq_modify(root, 0, k - 1);
			}
			nval = val;
			lv = rv = md;
			rmq_modify(root, 0, k - 1);
			md = (md + a[i]) % k;
		}
		else
		{
			md = (md + a[i]) % k;
			nval = g2(md);
			lv = rv = md;
			rmq_modify(root, 0, k - 1);
		}
	}
	if (root->val < INF) cout << sm + root->val << endl;
	else cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 127360
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
#define ll long long
using namespace std;
 
const int N=300005;
const int inf=1000000000;
 
struct seg{
	int x,id;
	seg(){}
	seg(int x,int id):x(x),id(id){}
	friend bool operator<(seg a,seg b){
		if (a.x!=b.x) return a.x<b.x;
		return a.id<b.id;
	}
};
struct node{
	int l,r;
	node(){}
	node(int l,int r):l(l),r(r){}
}a[N];
int n,l,r,now,cnt,l1,l2,r1,r2,d1,d2,nx1,nx2,fir;
ll ans,sum;
bool vis[N];
set<seg> s1,s2;
set<seg>::iterator it;
 
ll solve(){
	int i;ll sum=0;
	s1.clear(); s2.clear();
	for (i=1;i<=n;i++){
		s1.insert(seg(a[i].r,i));
		s2.insert(seg(-a[i].l,i));
		vis[i]=0;
	}
	for (i=1;i<=n;i++){
		if ((i&1)!=(fir&1)){
			it=s1.begin();
			while (vis[(*it).id]){
				s1.erase(s1.find(*it));
				it=s1.begin();
			}
			vis[(*it).id]=1;
			l=a[(*it).id].l; r=a[(*it).id].r;
			if (now<l) sum+=1ll*abs(l-now),now=l;
			if (now>r) sum+=1ll*abs(now-r),now=r;
			s1.erase(it);
		}
		else{
			it=s2.begin();
			while (vis[(*it).id]){
				s2.erase(s2.find(*it));
				it=s2.begin();
			}
			vis[(*it).id]=1;
			l=a[(*it).id].l; r=a[(*it).id].r;
			if (now<l) sum+=1ll*abs(l-now),now=l;
			if (now>r) sum+=1ll*abs(now-r),now=r;
			s2.erase(it);
		}
	}
	sum+=1ll*abs(now);
	return sum;
}

int main(){
	int i,j;
	scanf("%d",&n);
	for (i=1;i<=n;i++){
		scanf("%d%d",&l,&r);
		a[i]=node(l,r);
	}
	fir=0; now=0;
	ans=solve();
	fir=1; now=0;
	ans=max(ans,solve());
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 10496
#include<iostream>

using namespace std;

int main(void)

{
    long long int a, b, v, w, t, flag = 0;
    cin>>a>>v>>b>>w>>t;
    flag = a-b;
    if(flag < 0)flag *= (-1);
    if(w >= v)
        cout<<"NO\n";
    else{
    if(flag <= (v-w)*t)cout<<"YES\n";
    else cout<<"NO\n";
    }
    return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll d, t, s;
    cin >> d >> t >> s;
    if (s * t >= d) cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3632
// https://atcoder.jp/contests/abc143/tasks/abc143_b
#include <iostream>
#include <vector>

int main()
{
	std::cin.sync_with_stdio(false);
	std::cout.sync_with_stdio(false);

	int elems = 0;
	int sum = 0;
	std::cin >> elems;
	std::vector<int> values(elems);
	for (auto& val : values)
	{
		std::cin >> val;
		sum += val;
	}

	int solution = 0;

	for (const auto& val : values)
	{
		solution += (sum - val) * val;
	}

	solution >>= 1;

	std::cout << solution;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int n;
  int cnt=0;
  cin>>n;
  while(n!=1){
    if(n%3==0) n/=3;
    else n=(n/3)+1;
    cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}



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

//+付き文字列の計算結果を出してくれる奴
ll make_sum(string &t) {
    int n   = t.size();
    ll sum = 0;
    string temp = "";

    for (int i = 0; i < n; i++) {
        if (t.at(i) == '+') {
            sum  += stoll(temp);
            temp =  "";
        }else{
            temp += t.at(i);
        }
    }

    sum += stoll(temp);
    return sum;
}

int main() {
    string s;
    cin >> s;
    
    ll sum = 0;
    for (int flags = 0; flags < (1 << (s.size()-1)); flags++) {
        string t = "";
        t += s.at(0);
        for (int i = 0; i < s.size() - 1; i++) {
            if ((flags >> i) & 1) {
                t += '+';
            }
            t += s.at(i+1);
        }
        sum += make_sum(t);
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 101

int main()
{
	int i,j,num,max;
	int arr[MAX] = { 0 };

	while (scanf("%d", &num) != EOF)
	{
		arr[num]++;
	}

	max = arr[1];
	for (i = 2; i < MAX; i++)
	{
		if (arr[i]!=0 &&arr[i]>max)
		{
			max = arr[i];
		}
	}

	for (i = 1; i < MAX; i++)
	{
		if (arr[i] == max)
		{
			printf("%d\n",i);
		}
	}
	
	return 0;
}


Measured memory_bytes: 592
N,M,K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = [0]
b = [0]

for i in range(N):
    a.append(a[i] + A[i])
for j in range(M):
    b.append(b[j] + B[j])
ans = 0
j = M
for i in range(N+1):
    if a[i] > K:
        break
    while a[i] + b[j] > K:
        j -= 1
    ans = max(ans, i+j)
print(ans)

Measured memory_bytes: 47344
from collections import deque

K = int(input())

arr = ["1","2","3","4","5","6","7","8","9"]
bases = [0,1,2,3,4,5,6,7,8,9]
cnt = 9
q = deque(arr)

while cnt < K:
    num = q.popleft()
    idx = int(num[-1])
    for i in range(idx-1, idx+2):
        if i < 0 or i > 9:
            continue

        q.append(num + str(i))
        arr.append(num + str(i))
        cnt += 1

print(arr[K-1])
    


Measured memory_bytes: 15352
#include <bits/stdc++.h>
using namespace std;
int n,x,y,arr[100001];
int pre[100001],dp[100001];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>x;
    string s;
    cin>>s;
    for (int i=0;i<s.size()-2;i++){
        if (s[i]=='A' && s[i+1]=='B' && s[i+2]=='C') n++;
    }
    cout<<n;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

int n, k;
vector<int> seen, connect;
vector<vector<int>> graph;
ll mod = 1e9 + 7;
ll ans = 1;

//深さ優先探索のテンプレ.デフォルトでは参照渡ししたsetに探索済みの頂点が格納される.
//graphは隣接リスト.vは探索開始地点.seenは空のセット.
void dfs(int v,int m,int p=-1){
	seen[v] = 1;
	int t;
	if (p == -1)
		t = k;
	else if (p == 0){
		t = k - 1;
	}
	else {
		t = k - 2;
	}
	t -= m;
	ans = ((ans % mod) * (t % mod)) % mod;
	int a = 0;
	for (int i = 0; i < graph[v].size(); i++)
	{
		int nxt = graph[v][i];
		if (seen[nxt]==1) continue;
		dfs(nxt,a,v);
		a++;
	}
}

int main(){
	cin >> n >> k;
	graph = vector<vector<int>>(n);
	seen = connect = vector<int>(n,0);
	rep(i, n) seen[i] = 0;
	rep(i, n - 1)
	{
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
		connect[a]++;
		connect[b]++;
	}
	dfs(0, 0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9984
#include <iostream>

using namespace std;

int main(void){
    long long int N;

    long long int **field;
    field = new long long int*[1005];
    for(int i=0;i<1005;i++){
        field[i] = new long long int[1005];
        for(int j=0;j<1005;j++) field[i][j] = 0;
    }

    cin >> N;
    int x1, y1, x2, y2;
    for(long long int i=0;i<N;i++){
        cin >> x1 >> y1 >> x2 >> y2;

        field[y1][x1] ++;
        field[y1][x2] --;
        field[y2][x1] --;
        field[y2][x2] ++;
    }

    long long int **result, **result2;
    result = new long long int*[1005];
    result2 = new long long int*[1005];
    for(int i=0;i<1005;i++){
        result[i] = new long long int[1005];
        result2[i] = new long long int[1005];
        for(int j=0;j<1005;j++){
            result[i][j] = 0;
            result2[i][j] = 0;
        }

    }

    int now;
    for(int y=0;y<1005;y++){
        now = 0;
        for(int x=0;x<1005;x++){
            now += field[y][x];
            result[y][x] += now;
        }
    }
    int max = 0;
    for(int x=0;x<1005;x++){
        now = 0;
        for(int y=0;y<1005;y++){
            now += result[y][x];
            result2[y][x] += now;
            if(max < result2[y][x]) max = result2[y][x];
        }
    }
    cout << max << endl;
    return 0;
}


Measured memory_bytes: 26808
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    vector<int> v(5);
    for (int i = 0; i < 5; i++)
    {
        scanf("%d", &v[i]);
    }

    int k;
    scanf("%d", &k);
    for (int i = 0; i < 5; i++)
    {
        for (int j = 0; j < 5; j++)
        {
            if (abs(v[i] - v[j]) > k)
            {
                printf(":(\n");
                return 0;
            }
        }
    }

    printf("Yay!\n");
    return 0;
}

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

using namespace std;

int main()
{
    string s,t;

    int i;

    cin >> s >> t;

    int cnt=0;

    for(i=0;i<s.size();i++)
    {
        if(s[i]!=t[i])
        {
            cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3924
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long

using namespace std;

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

  bool easy = true;

  for (int i = 0; i < str.length(); i++) {
    string ch = str.substr(i, 1);
    if ((i + 1) % 2 == 1) {
      if (!(ch == "R" || ch == "U" || ch == "D")) {
        easy = false;
        break;
      }
    } else {
      if (!(ch == "L" || ch == "U" || ch == "D")) {
        easy = false;
        break;
      }
    }
  }

  cout << (easy ? "Yes" : "No") << endl;
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll tmp = a.at(0);
    for(i = 1;i < n;++i){
        tmp = gcd(tmp, a[i]);
    }
    if(tmp != 1){
        cout << "not coprime" << endl;
        return 0;
    }
    map<ll, ll> mp;
    for(i = 0;i < n;++i){
        for(j = 2;j < sqrt(a[i]);++j){
            if(a[i]%j == 0){
                if(mp.count(j)){
                    cout << "setwise coprime" << endl;
                    return 0;
                }
                ++mp[j];
                while(a[i]%j == 0) a[i] /= j;
            }
            
        }
        if(a[i] != 1){
            if(mp.count(a[i])){
                cout << "setwise coprime" << endl;
                return 0;
            }else ++mp[a[i]];
        }
    }
    cout << "pairwise coprime" << endl;

    return 0;
}


Measured memory_bytes: 11156
N = int(input())
a = list(map(int, input().split()))
li = []
cnt = 0
for i in range(N):
    if a[i] >= 1 and a[i] <= 399:
        li.append(1)
    elif a[i] >= 400 and a[i] <= 799:
        li.append(2)
    elif a[i] >= 800 and a[i] <= 1199:
        li.append(3)
    elif a[i] >= 1200 and a[i] <= 1599:
        li.append(4)
    elif a[i] >= 1600 and a[i] <= 1999:
        li.append(5)
    elif a[i] >= 2000 and a[i] <= 2399:
        li.append(6)
    elif a[i] >= 2400 and a[i] <= 2799:
        li.append(7)
    elif a[i] >= 2800 and a[i] <= 3199:
        li.append(8)
    else:
        cnt += 1
c = len(set(li))
print(max(1,c), c+cnt)

Measured memory_bytes: 3064
use proconio::input;

fn main() {
    input! {
        mut n: i64,
    }

    let mut tmp = 26;
    let mut l = 1;
    while n > tmp {
        n -= tmp;
        tmp *= 26;
        l += 1;
    }
    n -= 1;
    // dbg!(l, n);

    let mut v = vec![];
    for _ in 0..l {
        let c = n % 26;
        n = n / 26;
        let c = (c as u8 + b'a') as char;
        v.push(c);
    }
    v.reverse();
    let ans: String = v.iter().collect();
    println!("{}", ans);
}


Measured memory_bytes: 2144
/* All men have limits. They learn what they are and learn
   not to exceed them, I ignore mine. -Batman           */
#include <bits/stdc++.h>
//#include <iostream>
//#include <vector>
//#include <Windows.h>
using namespace std;

int main(){
int n;
vector<int> f;
while(cin>>n){
	f.push_back(n);
	
}
sort(f.begin(),f.end(), greater<int>());
cout<<f[0]<<endl<<f[1]<<endl<<f[2]<<endl;
	
	return 0;
}

Measured memory_bytes: 3156
#![allow(unused_imports)]
#![allow(dead_code)]
#![macro_use]
use std::io::prelude::*;
use std::cmp::{max, min};
use std::collections::BinaryHeap;

const MOD: i64 = 1e9 as i64 + 7;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($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:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }
    let mut sum = 0;
    let mut r = 0;
    let mut ans = 0;
    for l in 0..n{
        while r < n && sum + a[r] == sum ^ a[r]{
            sum += a[r];
            r += 1;
        }
        ans += r - l;
        sum -= a[l];
    }
    println!("{}", ans);
}


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

int main(){
    int n;
    cin>>n;
    if(n%10==2 || n%10==4 || n%10==5 || n%10==7 || n%10==9)
    {
        cout<<"hon"<<endl;
    }
    else if(n%10==3)
    {
        cout<<"bon"<<endl;
    }
    else
    {
        cout<<"pon"<<endl;
    }
    
}

Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.function.LongSupplier;

public class Main{ // 

	static class ConsoleScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			try {
				while (!st.hasMoreElements())
					st = new StringTokenizer(br.readLine());
				return st.nextToken();
			} catch (IOException e) {
				throw new AssertionError(e);
			}
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

	static LongSupplier now = new LongSupplier() {
		private long t = System.currentTimeMillis();

		@Override
		public long getAsLong() {
			long a = t;
			t = System.currentTimeMillis();
			long ans = t - a;
			return ans;
		}
	};

	public static void main(String args[]) {
		ConsoleScanner cin = new ConsoleScanner();
		PrintWriter cout = new PrintWriter(System.out);
		solve(cin, cout);
		cout.flush();
	}

	static int tr(Object... objects) {
		System.out.println("tr:" + Arrays.deepToString(objects));
		return 0;
	}

	private static void solve(ConsoleScanner cin, PrintWriter cout) {
		// assert solve(1) == 1;

		int n = cin.nextInt();
		int a = cin.nextInt();

		now.getAsLong();

		cout.println(n * n - a);

		assert 0 == tr("elapsed", now.getAsLong());
	}

}


Measured memory_bytes: 23252