akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<iterator>
#include<vector>
#include<string>
#include<map>

using namespace std;


#define mod(cans) cans%10**9+7
#define cin_pl(x,y) for(int i=0;i<x;i++){cin>>y[i];}
#define pl_twin(x,y,z) for(int i=0;i<x;i++){cin>>y[i]>>z[i];}
#define debug(x) cout << "Debug" << x << "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define st(s) size_t size = s.length()
#define prians(Answer) cout<<Answer<<"\n"
#define make_pair mp;
#define com_div(x,Co) for(int i=1;i<x+1;i++){if(x%i==0){Co++;}}
#define TF(X) X==1?cout<<"Yes\n":cout<<"No\n"
#define elcon else{continue;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vector<int>> matrix;
typedef pair<int,int> pr;
typedef vector<pr> vpt;
typedef greater<int> gi;

int main()
{
    vi p(3);
    cin_pl(3,p);
    sort(all(p));
    prians(p[0]+p[1]);
}

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

using namespace std;
const int INF = INT_MAX;
const int MOD = 1000000007;

bool cmp(pair<int, int> a, int b){
    return a.second < b;
}

int main() {
    ios::sync_with_stdio(false);
    string a, b;
    cin >> a >> b;
    cout << b << a;
}


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

template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
ll min(int a,ll b){return min((ll)a,b);} ll min(ll a,int b){return min(a,(ll)b);}
template <class S> void print(vector<S> &v){for(ll i=0; i<(ll)v.size(); i++){cerr << v[i] << ' ';}cerr << endl;}
template <class S> void print(vector<vector<S>> &v) {for (ll i = 0; i < (ll)v.size(); i++) {for (ll j = 0; j < (ll)v[i].size(); j++) {cerr << v[i][j] << ' ';}cerr << endl;}}

void Main();

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



vector<ll> prime_enum(ll n){
    vector<ll> res;
    vector<bool> is_prime(n, true);
    is_prime[0] = false;
    is_prime[1] = false;
    for(ll i = 2; i < n; i++){
        if(!is_prime[i]) continue;
        res.push_back(i);
        for(ll j = 2; i * j < n; j++){
            is_prime[i * j] = false;
        }
    }
    return res;
}

auto primes = prime_enum(1000001);
int psize = primes.size();
vector<bool> isused(psize, false);
vector<int> idx(1000001,-1);

bool ispairwise(int n){
	for(int p: primes){
        if(p * p > n) break;
		if(n % p == 0){
			if(isused[idx[p]]) return false;
			isused[idx[p]] = true;
			while(n % p == 0){
				n /= p;
			}
		}
	}
	if(n != 1){
		if(isused[idx[n]]) return false;
		isused[idx[n]] = true;
	}
	return true;
}

void Main(){
	int n; cin >> n;
	
	rep(i,primes.size()){
		idx[primes[i]] = i;
	}
	int g;
	cin >> g;
	bool pairwise = ispairwise(g);
	Rep(n-1){
		int t; cin >> t;
		g = gcd(g, t);
		if(pairwise){
			pairwise = ispairwise(t);
		}
	}
	if(pairwise){
		cout << "pairwise coprime\n";
	}else if(g == 1){
		cout << "setwise coprime\n";
	}else{
		cout << "not coprime\n";
	}
}

Measured memory_bytes: 7892
#include <cstdlib>
#include <iostream>
#include <map>
#include <utility>
#include <vector>
using namespace std;

#define operation(x, y) \
{\
	if(house[y][x] >= 0 && !((visited >> house[y][x]) & 1)) {	\
		can_pass[y][x] = true;									\
		res += dfs(x, y, (visited | (1 << house[y][x])));		\
		can_pass[y][x] = false;									\
		break;													\
	}\
	if(!can_pass[y][x])\
		break;\
}

int w, h, num;
int sx, sy;
map<pair<short, int>, int> memo;
vector<vector<bool> > can_pass;
vector<vector<short> > house;

int dfs(int x, int y, int visited = 0) {
	if(visited == (1 << num) - 1)
		if(x == sx || y == sy)
			return 1;
		else
			return 0;

	if(memo.count(make_pair(house[y][x], visited)))
		return memo[make_pair(house[y][x], visited)];

	int res = 0;
	for(int i = x + 1; i < w; ++i)
		operation(i, y)

	for(int i = x - 1; i >= 0; --i)
		operation(i, y)

	for(int i = y + 1; i < h; ++i)
		operation(x, i)

	for(int i = y - 1; i >= 0; --i)
		operation(x, i)

	if(__builtin_popcount(visited) < 19)
		memo[make_pair(house[y][x], visited)] = res;
			
	return res;
}


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

	while(cin >> w >> h, w) {
		can_pass.clear();
		can_pass.resize(h, vector<bool>(w, false));
		house.clear();
		house.resize(h, vector<short>(w, -1));

		num = 0;
		for(int i = 0; i < h; ++i) {
			for(int j = 0; j < w; ++j) {
				int in;
				cin >> in;

				if(in == 1) {
					house[i][j] = num++;
				}

				else {
					can_pass[i][j] = true;
					if(in == 2) {
						sx = j;
						sy = i;
					}
				}
			}
		}

		memo.clear();
		cout << dfs(sx, sy) << endl;
	}


	return EXIT_SUCCESS;
}

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

#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define setbits(x) __builtin_popcount(x)
#define zerobits(x) __builtin_ctz(x)
#define setbitsll(x) __builtin_popcountll(x)
#define zerobitsll(x) __builtin_ctzll(x)
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x

typedef vector<int> vi;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef unsigned long long ull;
typedef map<int,int> mii;

const int MOD = 1e9+7;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,a,b;
	cin >> n >> a >> b;
	ll ans = 0;
	ans += (n/(a+b))*a;
	ll rem = n%(a+b);
	ans += min(rem,a);
	cout << ans << '\n';
	return 0;
}



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

int main() {
  int n;
  int count=0;
  cin >> n;
  
  vector<int> data(n);
  for(int i=0;i<n;i++){
    cin >> data.at(i);
  }
  
  for(int i=1;i<n-1;i++){
    if((data.at(i)>data.at(i-1)&&data.at(i)<data.at(i+1))
       ||(data.at(i)<data.at(i-1)&&data.at(i)>data.at(i+1)))
      count++;
  }
  
  cout << count;
}
    
  


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

int main(){
    ll N; cin >> N;
    ll ans = 0;
    if(N%2){
        ans = N*((N-1)/2);
    }else{
        ans = N*((N-1)/2) + (N-1)/2+1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include<stdio.h>
#include <math.h>

int main(){
 	int n,d;
    scanf("%d%d",&n,&d);
	int a[n][d];
    int i,j,h;
    int sum = 0;
    double k = 0;
    double r;
	for(i = 0; i < n; i++){
		for(j = 0; j < d; j++){
			scanf("%d", &a[i][j]);
		}
	}
    for(i = 0; i < n; i++){
        for(h = i+1; h < n; h++){
    		for(j = 0; j < d; j++){
                k = k + (a[i][j]-a[h][j])*(a[i][j]-a[h][j]);
        	}
            r = sqrt(k);
            k = 0;
            if(ceil(r) == floor(r)){
				sum++;
            }
        }
    }
    printf("%d", sum);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string S,T;
  cin >> S;
  int s=S.size();
  int a,b,c;
  c=1000;
  for(int i=0;i<s-1;i++){
    T=S.substr(i,3);
    a=atoi(T.c_str());
    b=abs(a-753);
    if(c>b){c=b;}
  }
  cout << c << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int main(){
  string s;
  cin>>s;
  long long k;
  cin>>k;
  int s_length=(int)s.length();
  int tmp=0;
  int buf=0;
  vector<int> array(s_length,0);
  long long ans=0;
  if(s[0]==s[s_length-1])buf=1;
  for(int i=1;i<s_length;i++){
    if(s[i]==s[i-1]){
      array[i]=array[i-1]+1;
    }
    if(array[i]%2==1)ans++;
  }
  if(buf!=1){
    ans=ans*k;
    cout<<ans<<endl;
  }
  long long ans2=0;
  long long ans3=0;
  long long pic=0;
  if(buf==1){
    char s2[s_length*2],s3[s_length*3];
    for(int i=0;i<s_length;i++){
      s3[i]=s[i];
      s3[i+s_length]=s[i];
      s3[i+s_length*2]=s[i];
    }
    vector<int> array3(s_length*3,0);
    for(int i=1;i<s_length*3;i++){
      if(s3[i]==s3[i-1]){
	array3[i]=array3[i-1]+1;
      }
      if(i<s_length*2 && array3[i]%2==1)ans2++;
      if(array3[i]%2==1)ans3++;;
    }
    long long res=ans3-ans;
    if(k==1)pic=ans;
    if(k==2)pic=ans2;
    if(k==3)pic=ans3;
    if(k>3){
      if(k%2==0){
	pic=ans2+res*(k/2-1);
      }
      else{
	pic=ans+res*(k-1)/2;
      }
    }
    cout<<pic<<endl;
  }
  //  cout<<s_length<<endl;
  return 0;
}


Measured memory_bytes: 256
// Shift-JIS（シフトジス）

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

int main()
{
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    if (e - a > k) {
        cout << ":(" << endl;
    } else {
        cout << "Yay!" << endl;
    }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

const long long INFL = 1e17+7;
const long long INFI = 1e9+7;
const long long MOD = 1e9+7;
const double EPS = 1e-8;
const double PI=acos(-1);

using namespace std;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n,k;
    cin >> n >> k;
    vector<long long> a(n);
    for(int i=0;i<n;i++){
      cin >> a[i];
    }
    
    for(int i=0;i<n-k;i++){
      if(a[i]<a[i+k])cout << "Yes" << endl;
      else cout << "No" << endl;
    }
  
	return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int n, m;
  cin >> n >> m;
  string ans = (m == n) ? "Yes" : "No";
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var num = Add.num;
        var ps = Add.ar;
        var r = new int[num];
        for (var i = 0; i < num; i++)
            r[ps[i] - 1] = i + 1;
        var a = Enumerable.Range(1, num).Select(v => v * 30000).ToArray();
        var b = Enumerable.Range(1, num).Select(v => (num - v) * 30000 + r[v - 1]).ToArray();
        WriteLine($"{string.Join(" ", a)}\n{string.Join(" ", b)}");
    }
}

public class Add
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public  static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
long gcd(long p, long q) {
	if (p > q) swap(p, q);
	if (p == 0) return q;
	else return gcd(q % p, p);
}

int main() {
	int K;
	cin >> K;
	long ans = 0;
	rep(i, K) {
		rep(j, K) {
			rep(k, K) ans += gcd(gcd(i + 1, j + 1), k + 1);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3636
//#include <tourist>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}
struct edge {
    int to, cost;
};
ll a, b;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a>>b;
    cout<<a*b/gcd(a,b)<<"\n";
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)  
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){

  int n,m;
  cin>>n>>m;
  vector<int> v[n+1];
  int p[m],y[m];
  REP(i,m){
    cin>>p[i]>>y[i];
    v[p[i]].pb(y[i]);
  }
  REP(i,n+1){
    VSORT(v[i]);
  }

  REP(i,m){
    printf("%06d",p[i]);
    int x;
    vector<int>::iterator lit = lower_bound(v[p[i]].begin(),v[p[i]].end(),y[i]);
    printf("%06d\n",(int)(lit-v[p[i]].begin())+1);
  }



  return 0;
}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
template<unsigned int mod_>
struct ModInt{
	using uint = unsigned int;
	using ll = long long;
	using ull = unsigned long long;

	constexpr static uint mod = mod_;

	uint v;
	ModInt():v(0){}
	ModInt(ll v):v(normS(v%mod+mod)){}
	explicit operator bool() const {return v!=0;}
	static uint normS(const uint &x){return (x<mod)?x:x-mod;}		// [0 , 2*mod-1] -> [0 , mod-1]
	static ModInt make(const uint &x){ModInt m; m.v=x; return m;}
	ModInt operator+(const ModInt& b) const { return make(normS(v+b.v));}
	ModInt operator-(const ModInt& b) const { return make(normS(v+mod-b.v));}
	ModInt operator-() const { return make(normS(mod-v)); }
	ModInt operator*(const ModInt& b) const { return make((ull)v*b.v%mod);}
	ModInt operator/(const ModInt& b) const { return *this*b.inv();}
	ModInt& operator+=(const ModInt& b){ return *this=*this+b;}
	ModInt& operator-=(const ModInt& b){ return *this=*this-b;}
	ModInt& operator*=(const ModInt& b){ return *this=*this*b;}
	ModInt& operator/=(const ModInt& b){ return *this=*this/b;}
	ll extgcd(ll a,ll b,ll &x,ll &y) const{
		ll u[]={a,1,0},v[]={b,0,1};
		while(*v){
			ll t=*u/ *v;
			rep(i,3) swap(u[i]-=t*v[i],v[i]);
		}
		if(u[0]<0) rep(i,3) u[i]=-u[i];
		x=u[1],y=u[2];
		return u[0];
	}
	ModInt inv() const{
		ll x,y;
		extgcd(v,mod,x,y);
		return make(normS(x+mod));
	}
	bool operator==(const ModInt& b) const { return v==b.v;}
	bool operator!=(const ModInt& b) const { return v!=b.v;}
	friend istream& operator>>(istream &o,ModInt& x){
		ll tmp;
		o>>tmp;
		x=ModInt(tmp);
		return o;
	}
	friend ostream& operator<<(ostream &o,const ModInt& x){ return o<<x.v;}
};
using mint = ModInt<1000000007>;

string s;
int N;

bool alternate(){
	rep(i,N-1) if(s[i]==s[i+1]) return false;
	return true;
}

vector<int> acm;
vector<int> a2vs[3];
vector<mint> dp;

int main(){
	cin>>s;
	N = s.size();
	if(alternate()){
		puts("1");
		return 0;
	}
	int X = 0;
	rep(i,N-1) if(s[i] != s[i+1]) X = i+1;

	acm.resize(N+1);
	rep(i,N) acm[i+1] = acm[i] + (s[i]=='a' ? 1 : 2);
	rep(i,N+1) acm[i] %= 3;
	rep(i,N+1) a2vs[acm[i]].pb(i);

	dp.resize(N+1);
	dp[0] = 1;
	rep(i,N){
		rep(c,2){	//a,b
			int tar = (acm[i] + 1 + c)%3;
			int id = lower_bound(all(a2vs[tar]),i) - a2vs[tar].begin();
			if(id == a2vs[tar].size()) continue;
			int ni = a2vs[tar][id];
			dp[ni] += dp[i];
		}
	}
	mint ans = 0;
	rep1(consume,N){
		if(acm[N] != acm[consume]) continue;
		ans += dp[consume];
	}
	cout<<ans<<endl;

}


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

int main(void){
	int i;
	int p = 700;
	char str[3];
	
	scanf("%s", str);
	
	if(strcmp(str, "ooo") == 0){
		p += 300;
	}else if(strcmp(str, "oxo") == 0){
		p += 200;
	}else if(strcmp(str, "oox") == 0){
		p += 200;
	}else if(strcmp(str, "xoo") == 0){
		p += 200;
	}else if(strcmp(str, "xxo") == 0){
		p += 100;
	}else if(strcmp(str, "oxx") == 0){
		p += 100;
	}else if(strcmp(str, "xox") == 0){
		p += 100;
	}else{
	}
	
	printf("%d\n", p);
	return 0;
}

Measured memory_bytes: 128
n, k = map(int, input().split())
an = []
for _ in range(n):
  an.append(int(input()))

an.sort()
dn = [-1 for _ in range(n - k + 1)]
for i in range(n - k + 1):
  dn[i] = an[i+k-1] - an[i]

print(min(dn))

  

Measured memory_bytes: 11288
#include<iostream>
#include<algorithm> 
#include<cstdio>
#include<cctype>
#include<string>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf = 0x3f3f3f3f;
const int maxn= 2e5+5;
const double pi = acos(-1.0);
const ll mod = 1e9+7;
int main(){
   
    int n;
    string s;
    cin>>n>>s;
    if(s.length()<=n){
    	cout<<s<<endl;
	}else {
		for(int i=0;i<n;i++){
			cout<<s[i];
		}
		cout<<"..."<<endl;
	}
     return 0;
 }

Measured memory_bytes: 3596
while True:
    H,W = map(int,input().split())
    if H == W == 0:
        break
    else:
        for i in range(H):
            for j in range(W):
                if i == 0 or i == H - 1 or j == 0 or j == W - 1:
                    print("#", end="")
                else:
                    print(".", end="")
            print()
        print()


Measured memory_bytes: 7008
#include <bits/stdc++.h>
//  OURL:  https://atcoder.jp/contests/abc127/tasks/abc127_b

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

// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){ return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){ for(auto &e:t) fill_v(e,v); }

int main(int argc, char *argv[]) {
  ll r,d,x;
  cin >> r >> d >> x;
  REP(i,10) {
    x = r*x - d;
    cout << x << endl;
  }
  return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("-O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define F first
#define S second
#define pb push_back
#define bit __builtin_popcount
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define mkp make_pair
#define ffs fflush(stdout)

using namespace std;
using namespace __gnu_pbds;

//order_of_key(k) : Number of items strictly smaller than k
//find_by_order(k) : K-th element in a set (counting from 0)

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

typedef long long ll;
typedef long double ld;
typedef vector <int> lnum;
typedef pair <int, int> pii;

const int N = (int)1e6 + 5;
const int MOD = (int)1e9 + 7;
const int inf = (int)1e18;
const int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};
const ld eps = 1e9 - 7;
const int pp[] = {29, 31, 53, 67, 71};
const double pi = acos(-1.0);

mt19937 gen(chrono::system_clock::now().time_since_epoch().count());

signed main() {
  ios_base :: sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  string s;
  cin >> s;
  if (s == "SUN")
    cout << 7;
  if (s == "MON")
    cout << 6;
  if (s == "TUE")
    cout << 5;
  if (s == "WED")
    cout << 4;
  if (s == "THU")
    cout << 3;
  if (s == "FRI")
    cout << 2;
  if (s == "SAT")
    cout << 1;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int num,ans,hmax,i,j,k;
    ans = 1;
    hmax = 0;
    scanf("%d",&num);
    int h[num];
    for (i=0;i<num;i++){
        scanf("%d",&h[i]);
    }
    for (j=1;j<num;j++){
        for(k=0;k<j;k++){
            if(h[k]> hmax){
                hmax = h[k];
            }
        }if(h[j]>=hmax){
            ans +=1;
            
        }
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 128
def f(n):
    table = [0] * (n + 1)
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1
    return table


def main():
    N = int(input())
    ans = 0
    for i,count in enumerate(f(N)):
        ans += i*count
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 151684
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int mod = 1000000007;

int main() {
  int N;
  cin >> N;
  if(N%2 == 0) cout << N/2 << endl;
  else cout << N/2+1 << endl;
  return 0;
}

Measured memory_bytes: 256
//BISMILLAHIR RAHMANIR RAHIM
#include <bits/stdc++.h>
#define mem(a, b) (memset(a, b, sizeof(a)))
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define INF 100000000
#define MOD 1000000007
#define MAX 100005
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<int, ii> pii;
typedef vector<ii> vii;
typedef priority_queue<int,vector<int>,greater<int> > PQ;

int Set(int mask, int pos){return mask = mask | (1<<pos);}
bool check(int mask, int pos){return (bool)(mask & (1<<pos));}

int dp[10005][1005];
int a[1005], b[1005], h;
int n;

int solve(int amnt, int pos)
{
    if(pos >= n && amnt < h)
        return INF;
    if(amnt >= h)
        return 0;
    if(dp[amnt][pos] != -1)
        return dp[amnt][pos];

    int ret = INF;
    ret = min(ret, b[pos] + solve(amnt + a[pos], pos));
    ret = min(ret, solve(amnt, pos + 1));
    ret = min(ret, b[pos] + solve(amnt + a[pos], pos + 1));

    return dp[amnt][pos] = ret;
}

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

    cin>>h>>n;

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

    memset(dp, -1, sizeof(dp));
    int res = solve(0, 0);

    cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 40192
def main():
  A, B = map(int,input().split())
  i1 = max(A * 12.5, B * 10.0)
  i2 = min((A + 1) * 12.5, (B + 1) * 10.0)
  i = int(i1)
  while i < i2:
    if i >= i1: return i
    i += 1
  return -1

ans = main()
print(ans)

Measured memory_bytes: 9180
m,i,j,k,c[16],p,d;main(n){for(;scanf("%d%d",&n,&m),n;printf("%d\n",j>m?-1:j)){for(k=3;k--;)for(scanf("%d",&i);i--;c[j]=k)scanf("%d",&j);for(j=k=0;k++<n;p=i%2*2+p&3)j+=pow(3,n-k)*abs(i=p-c[k]);j=fmin(j,pow(3,n)+~j);}}

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

int main(){
	int N, M;
	cin >> N >> M;
	char A[N][N], B[M][M];
	for(int i=0; i<N; i++){
		for(int j=0; j<N; j++){
			cin >> A[i][j];
		}
	}
	for(int i=0; i<M; i++){
		for(int j=0; j<M; j++){
			cin >> B[i][j];
		}
	}

	for(int y=0; y<N-M+1; y++){
		int flag=1;
		for(int x=0; x<N-M+1; x++){
			if(A[y][x]==B[0][0]){
				flag = 0;
				for(int i=1; i<M; i++){
					for(int j=1; j<M; j++){
						if(A[y+i][x+j]!=B[i][j]){
							flag=1;
							break;
						}
					}
					if(flag==1){
						break;
					}
				}
			}
		}
		if(flag==0){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  sort(a,a+n);
  int sum=0;
  for(int i=0;i<k;i++)
    sum+=a[i];
  cout<<sum<<endl;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll mod_div(ll a,ll b){
  ll tmp=MOD-2,c=b,ret=1;
  while(tmp>0){
    if(tmp&1){
      ret*=c;ret%=MOD;
    }
    c*=c;c%=MOD;tmp>>=1;
  }
  return a*ret%MOD;
}
 
#define MAX_K 2000100
vector<ll> kaijo(MAX_K);
ll combination(ll n, ll r){
  if(n<r||n<0||r<0)
    return 0;
  if(kaijo[0]!=1){
    kaijo[0]=1;
    for(ll i=1;i<MAX_K;i++)kaijo[i]=(kaijo[i-1]*i)%MOD;
  }
  ll ret=kaijo[n];
  long long tmp = (kaijo[r] * kaijo[n-r]) % MOD;
  return mod_div(ret,tmp);
}

void modadd(ll &a, ll b){
  a+=b;
  a%=MOD;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll x,y;cin>>x>>y;
  ll ans=0;
  for(ll i=0;i<=x;i++){
    //cout<<i<<" "<<i+(x-(i*2))*2<<endl;
    if(i+(x-(i*2))*2 == y){
      ans+=combination(i+(x-(i*2)),i);
      ans%=MOD;
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 15872
#include <cstdio>

int map[4][4];

int sum,tmp;


int main ()
{
	scanf ("%d%d%d",&map[1][1],&map[1][2],&map[2][2]);
	for (int i=1;i<=101;i++)
	{
		map[3][3]=i;
			sum=map[1][1]+map[2][2]+i;

			tmp=sum-map[1][1]-map[1][2];

				map[1][3]=tmp;
				tmp=sum-map[1][3]-map[2][2];

					map[3][1]=tmp;
					tmp=sum-map[1][1]-map[3][1];

						map[2][1]=tmp;
						tmp=sum-map[2][2]-map[2][1];

/*	printf ("%d\n",i);
	for (int j=1;j<=3;j++)
										printf ("%d %d %d\n",map[j][1],map[j][2],map[j][3]);
*/								
							if (tmp+map[1][3]+map[3][3]==sum)
						{
							
								map[2][3]=tmp;
								tmp=sum-map[1][2]-map[2][2];

								if (sum==(tmp+map[3][1]+map[3][3]))
								{
									map[3][2]=tmp;
									for (int j=1;j<=3;j++)
										printf ("%d %d %d\n",map[j][1],map[j][2],map[j][3]);
									return 0;	
								}
						}
	}
	return 0;
}

Measured memory_bytes: 128
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<math.h>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
#include<chrono>
#include<unordered_map>
#include<list>
#include<fstream>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
const ll E=1e18+7;
#define F first
#define S second
#define MK make_pair
const ll MOD=1000000007;

vector<vector<ll>> e;
vector<bool> used;

vector<ll> dfs(ll w,vector<ll> path){
    used[w]=true;
    path.push_back(w+1);
    for(int i=0;i<e[w].size();i++){
        if(!used[e[w][i]]){return dfs(e[w][i],path);}
    }
    return path;
}


int main(){
    vector<vector<ll>> e;
    vector<bool> used;
    ll n,m;
    cin>>n>>m;
    e.resize(n);
    used.resize(n);
    for(int i=0;i<m;i++){
        ll a,b;
        cin>>a>>b;
        a--; b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    deque<ll> A;
    ll w=0;
    while(1){
        bool cont=false;
        used[w]=true;
        A.push_back(w+1);
        for(int i=0;i<e[w].size();i++){
            if(!used[e[w][i]]){w=e[w][i]; cont=true; break;}
        }
        if(!cont){break;}
    }
    w=0;
    while(1){
        bool cont=false;
        used[w]=true;
        if(w!=0){
            A.push_front(w+1);
        }
        for(int i=0;i<e[w].size();i++){
            if(!used[e[w][i]]){w=e[w][i]; cont=true; break;}
        }
        if(!cont){break;}
    }
    cout<<A.size()<<endl;
    for(int i=0;i<A.size();i++){
        cout<<A[i];
        if(i!=A.size()-1){cout<<" ";}
        else{cout<<endl;}
    }
    
    
    return 0;
}

Measured memory_bytes: 7168
n = int(input())
p = list(map(int,input().split()))
count = 0

if n <= 2:
    print(0)
else:

    for i in range(0,n-2):
        for h in range(i+1,n-1):
            for j in range(h+1,n):
                if (abs(p[i]-p[h]) < p[j] < p[i]+p[h]) and (p[i] != p[h] and p[h] != p[j] and p[j] != p[i]):

                    count += 1

    print(count)


Measured memory_bytes: 9092
#include <cstdint>
#include <iostream>

using namespace std;

int32_t main()
{
  uint64_t N;
  cin >> N;

  uint64_t total = 0;
  for (uint64_t i = 0; i < N; i++) {
    uint64_t x, y;
    cin >> x >> y;
    total += y - x + 1;
  }

  cout << total << endl;

  return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
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.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.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)
mod = 1000000007

def solve():
    x,y = LI()
    ans = 1
    while x*2 <= y:
        x <<= 1
        ans += 1
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 38384
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <bitset>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include<iomanip>

#define i64 int64_t
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define ffrvs(ii,nn,mm) for(int ii=nn;ii>=mm;ii--)
#define srt(vvv) sort(vvv.begin(),vvv.end())
#define srtrvs(vvv) reverse(vvv.begin(),vvv.end())
#define Graph vector<vector<int>>

i64 inf = 1000000007;
i64 giant = 4000000000000000037;

using namespace std;



//メモリ置き場


//inputします
void input() {
	
}

//ライブラリ置き場


//main
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);
	input();
	string s;
	cin >> s;
	if (s.size() % 2 != 0) {
		cout << "No" << endl;
		return 0;
	}
	ff(i, 0, s.size()) {
		if (i % 2 == 1) {
			if (s[i] != 'i' || s[i - 1] != 'h') {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

using namespace std;

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

const double pi = 3.14159265358979323846;

// #define fio() cin.tie(0); ios::sync_with_stdio(false);
// template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
// template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define TG0 get< 0 >
#define TG1 get< 1 >
#define TG2 get< 2 >
#define F first
#define S second
#define VL vector< ll >

// to_string(123)
// atoi("123"); atoi(s.c_str());
// "abc".size()
// s.find('+') == string::npos
// 1e18

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

  string S;
  cin >> S;

  if (S == "SUN")
    cout << 7 << endl;
  else if (S == "MON")
    cout << 6 << endl;
  else if (S == "TUE")
    cout << 5 << endl;
  else if (S == "WED")
    cout << 4 << endl;
  else if (S == "THU")
    cout << 3 << endl;
  else if (S == "FRI")
    cout << 2 << endl;
  else if (S == "SAT")
    cout << 1 << endl;

  return 0;
}


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

int main(){
    int n,k;
    string s;

    cin >> n >> k;
    cin >> s;

    if(s[k-1]=='A') s[k-1] = 'a';
    else if(s[k-1]=='B') s[k-1] = 'b';
    else if(s[k-1]=='C') s[k-1] = 'c';

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,d;
void solve()
{
    long long x=n%(2*d+1),u=n/(2*d+1);
    if (x) u++;
    cout<<u<<endl;
}
int main()
{
    while(cin>>n>>d)
        solve();
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{  string s1,s2;
   cin>>s1>>s2;
 int cnt=0;
 for(int i=0;i<s1.length();i++)
 {  if(s1[i]!=s2[i])
     cnt++;
 }
 cout<<cnt;
}

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

typedef long long ll;

int main(){
  int n,m,c;
  cin >> n >> m >> c;
  int b[m];
  for(int i=0;i<m;i++){
    cin >> b[i];
  }
  int a[n][m];
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin >> a[i][j];
    }
  }
  int ans=0;
  for(int i=0;i<n;i++){
    int count=c;
    for(int j=0;j<m;j++){
      count+=a[i][j]*b[j];
    }
    if(count>0){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
a, b, k = map(int, input().split())

if b - a < 2 * k:
    for i in range(a, b + 1):
        print(i)

else:
    ans = []
    for i in range(k):
        ans.append(a + i)
    for i in range(k-1, -1, -1):
        ans.append(b - i)

    for i in ans:
        print(i)

Measured memory_bytes: 3060
# p = 1 / N
# a * 2^b >= K
#
# b >= log2(K / a)
#
# [b]回表になる確率
# sum p * (1/2)^[b]

import numpy as np

N, K = map(int, input().split())

a = np.arange(N) + 1
b = np.log2(K / a)
b_ = np.ceil(b)
b_[b_ < 0] = 0

s = np.sum(0.5 ** b_) / N
print(s)


Measured memory_bytes: 20868
if __name__ == "__main__":
    h, w = map(int, input().split())
    s = list()
    s.append('.' * (w+2))
    for i in range(h):
        s.append('.' + input() + '.')
    s.append('.' * (w+2))

    pos = ((-1, -1),
           (-1, 0),
           (-1, 1),
           (0, -1),
           (0, 1),
           (1, -1),
           (1, 0),
           (1, 1))
    ans = list()
    for i in range(h):
        tmp = ''
        for j in range(w):
            if s[i+1][j+1] == '#':
                tmp += '#'
            else:
                count = 0
                for p in pos:
                    if s[i + p[0] + 1][j + p[1] + 1] == '#':
                        count += 1
                tmp += str(count)
        ans.append(tmp)

    for a in ans:
        print(a)


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
using namespace std;
long long n,k;
long long a[200000];
long long sum[200000];
long long sumz[200000];
long long mx = -(long long)1e20;
long long mymax(long long a,long long b){
	return a>b?a:b;
}
int main(){
	scanf("%lld%lld",&n,&k);
	for(long long i = 1; i <= n;i ++){
		scanf("%lld",&a[i]);
		sum[i] = sum[i-1] + a[i];
		if(a[i] > 0){
			sumz[i] = sumz[i-1] + a[i];
		}
		else{
			sumz[i] = sumz[i-1];
		}
	}
	if(n == k){
		printf("%lld",mymax(sum[n],0));
		return 0;
	}
	for(long long i = 1;i <= n-k+1 ;i ++){
		long long t = sumz[i-1] + sumz[n] - sumz[i+k-1] + sum[i+k-1] - sum[i-1];
		mx = mymax(mx,t);
	}
	for(long long i = 1;i <= n-k+1 ;i ++){
		long long t = sumz[i-1] + sumz[n] - sumz[i+k-1];
		mx = mymax(mx,t);
	}
	printf("%lld",mx);
	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long A, long long B){
	if (A != 1 && B != 1) cout << "1" << endl;
	if (A != 2 && B != 2) cout << "2" << endl;
	if (A != 3 && B != 3) cout << "3" << endl;
}

int main(){	
	long long A;
	long long B;
	scanf("%lld",&A);
	scanf("%lld",&B);
	solve(A, B);
	return 0;
}



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

int main(){
    int N;
    cin >> N;
    vector<int> vec(N);
    rep(i,N){
        cin >> vec.at(i);
    }
    bool app = true;
    rep(i,N){
        if(vec.at(i)%2==0){
            if(vec.at(i)%3!=0&&vec.at(i)%5!=0){
                app = false;
            }
        }
    }
    if(app){
        cout << "APPROVED" <<endl;
    }else{
        cout << "DENIED" <<endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        sc.close();

        double sq = r * r * 3.141592653589;
        double ci = r * 2 * 3.141592653589;

        System.out.println(String.format("%.6f", sq) + " " + String.format("%.6f", ci));

    }
}



Measured memory_bytes: 28352
#include<bits/stdc++.h>
#define M 1000000007
#define pb push_back
#define ll long long int
using namespace std;

int main()
{
	int n;
	cin>>n;
	int i;
	vector<int> g[n];
	for(i=0;i<n-1;i++)
	{
		int x,y;
		cin>>x>>y;
		x--;y--;
		g[x].pb(y);
		g[y].pb(x);
	}
	queue<int> q;
	int parent[n];
	int visited[n]={0};
	parent[0] = 0;
	q.push(0);
	visited[0] = 1;
	vector<int> order;
	while(!q.empty())
	{
		int x = q.front();
		q.pop();
		for(auto it : g[x])
		{
			if(visited[it])
				continue;
			visited[it] = 1;
			parent[it] = x;
			q.push(it);
		}
		order.pb(x);
	}

	ll dp[n][2] = {0};
	for(i=n-1;i>=0;i--)
	{
		int v = order[i];
//		cout<<"V = "<<v<<"\n";
		dp[v][0] = dp[v][1] = 1;
		for(auto it : g[v])
		{
			if(it==parent[v])
				continue;
			dp[v][0] *= (dp[it][0]+dp[it][1])%M;
			dp[v][0] %= M;
			dp[v][1] *= (dp[it][0]);
			dp[v][1] %= M;
		}

		// if(dp[v][0] == 0)
		// 	dp[v][0] = 1;
		// if(dp[v][1]==0)
		// 	dp[v][1] = 1;
	}
	cout<<(dp[0][0]+dp[0][1])%M;

	return 0;

}


Measured memory_bytes: 12440
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <list>
using namespace std;
 
static const int MAX=100000;
static const int INFTY=(1<<29);
 
vector<int> G[MAX];
list <int> out;
bool V[MAX];
int N;
int indeg[MAX];
 
void bfs(int s){
    queue<int> q;
    q.push(s);
    V[s]=true;
    while(q.size()){
        int u=q.front();
        q.pop();
        out.push_back(u);
        for(int i=0;i<G[u].size();i++){
            int v=G[u][i];
            indeg[v]--;
            if(indeg[v]==0 && !V[v]){
                V[v]=true;
                q.push(v);
            }
        }
    }
}
 
void tsort(){
    memset(indeg,0,sizeof(indeg));
    for(int u=0;u<N;u++){
        for(int i=0;i<G[u].size();i++){
            int v=G[u][i];
            indeg[v]++;
        }
    }
    for(int u=0;u<N;u++){
        if(indeg[u]==0 && !V[u])bfs(u);
    }
    for(list<int>::iterator it=out.begin();it!=out.end();it++){
        cout << *it << endl;
    }
}
 
int main(void){
    int s,t,M;
    scanf("%d %d",&N,&M);
    memset(V,false,sizeof(V));
    for(int i=0;i<M;i++){
        scanf("%d %d",&s,&t);
        G[s].push_back(t);
    }
    tsort();
    return 0;
     
}


Measured memory_bytes: 6744
/*! at_abc139b.cc
 *  2020-04-28
 *  GCC+17
 *  Type (opt): ad-hoc
 *  Notes (opt): Tricky condition when b==1, we don't need any extensions
 */

#include <stdio.h>

int main(void) {
    int a, b;
    scanf("%i %i", &a, &b);
    if (b == 1)
        printf("0\n");
    else if (a > b)
        printf("1\n");
    else
        printf("%d\n", (b - a) % (a - 1) ? (b - a) / (a - 1) + 2
                                         : (b - a) / (a - 1) + 1);
}


Measured memory_bytes: 128
#include <stdio.h>

int main(){
    int man[10] = {0};
    int i;
    int a = 0;
    int max = 0;
    for (i = 0; i < 10; i++) {
        scanf("%d",&man[i]);
        if (man[i] > max) {
            max = man[i];
        }
    }
    for (i = 0; i < 10; i++) {
        if(man[i] == max)
            break;
    }
    a = man[i];
    man[i] = man[0];
    man[0] = a;
    
    max = 0;
    for (i = 1; i < 10; i++) {
        if (man[i] > max) {
            max = man[i];
        }
    }
    for (i = 1; i < 10; i++) {
        if(man[i] == max) {
            break;
        }
    }
    a = man[i];
    man[i] = man[1];
    man[1] = a;
    
    max = 0;
    for (i = 2; i < 10; i++) {
        if (man[i] > max) {
            max = man[i];
        }
    }
    for (i = 2; i < 10; i++) {
        if(man[i] == max) {
            break;
        }
    }
    
    a = man[i];
    man[i] = man[2];
    man[2] = a;

    for (i = 0; i < 3; i++) {
        printf("%d\n",man[i]);
    }
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,b; cin>>n>>a>>b;
    vll x(n);
    rep(i,n) cin>>x[i];
    ll c = b/a;
    int cnt=0;
    ll cur = x[0];
    ll ans=0;
    rep(i,n-1){
        if (x[i+1]-x[i]>c){
            ans += a*(x[i]-cur);
            cur = x[i+1];
            cnt++;
        }
    }
    ans += a*(x[n-1]-cur);
    ans += b*cnt;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line ="";
		int array[] = {512,256,128,64,32,16,8,4,2,1};
		
		while((line = br.readLine())!=null){
			int n = Integer.parseInt(line);
			ArrayList<Integer> list = new ArrayList<Integer>();
			for(int i = 0; i < array.length;i++){
				if(n >= array[i]){
					n = n-array[i];
					list.add(array[i]);
				}
			}
			Collections.reverse(list);
			for(int i = 0; i < list.size();i++){
				System.out.print(list.get(i));
				if(i!=list.size()-1){
					System.out.print(" ");
				}
			}
			System.out.println("");
		}

	}

}

Measured memory_bytes: 24284
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int a,b,c;
  cin>>a>>b>>c;
  if(a+b+c>=22){
    cout<<"bust"<<endl;
  }else{
    cout<<"win"<<endl;
  }



  return 0;
}

Measured memory_bytes: 888
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000000;
// clang-format on

ll H;
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> H;

  ll total = 1, a = 1;
  while (total < H) {
    a <<= 1;
    total += a;
  }
  cout << total << endl;

  return 0;
}


Measured memory_bytes: 256
play :: (String, String, String) -> Char -> String
play ([], _, _) 'a' = "A"
play (_, [], _) 'b' = "B"
play (_, _, []) 'c' = "C"
play ((x:xs), ys, zs) 'a' = play (xs, ys, zs) x
play (xs, (y:ys), zs) 'b' = play (xs, ys, zs) y
play (xs, ys, (z:zs)) 'c' = play (xs, ys, zs) z

main :: IO ()
main = do
  (x:xs) <- getLine
  ys <- getLine
  zs <- getLine
  putStrLn $ play (xs, ys, zs) x


Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
const long long INF = 1e18+100;
int main() {
	long long n,k;
	cin>>n>>k;
	vector<long long> h(n);
	for(long long &i:h) {
		cin>>i;
	}
	vector<long long> dp(n,INF);
	dp[0] = 0;
	for(long long i=0;i<n;i++) {
		for(long long j=max((long long)0,i-k);j<i;j++) {
			dp[i] = min(dp[i], dp[j] + abs(h[i]-h[j]));
		}
	}
	debug()<<imie(dp);
	cout<<dp[n-1];
}



Measured memory_bytes: 4728
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <bitset>
#include <vector>
#include <set>
using namespace std;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

int main(){
    int N, cnt = 0, flag = 0;
    cin >> N;

    vector<int> A(N);

    for(int i = 0; i < N; i++){
        cin >> A.at(i);
    }

    int i = 0;
    while(1){
        sort(A.begin(), A.end());

        for(int j = 1; j < A.size(); j++){
            A.at(j) = A.at(j) % A.at(0);
            if(A.at(j) <= 0){
                cnt++;
                remove(A, j);
                if(cnt == (N-1)){
                    flag++;
                }
            }
        }
        if(flag == 1){
            break;
        }
        i++;
    }

    sort(A.begin(), A.end());
    cout << A.at(0);
}

Measured memory_bytes: 640