akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// Welcome to my source code!

int main() {
    int n;
    cin >> n;
    int h[n];
    for (int i = 0; i < n; i++) cin >> h[i];
    bool flag = true, rt = false;
    for (int i = n - 2; i >= 0; i--) {
        if (h[i + 1] < h[i]) {
            if (h[i + 1] == h[i] - 1) {
                h[i]--;
                rt = true;
            } else {
                rt = false;
                flag = false;
            }
        } else rt = false;
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 640
function main(input) {
	const args = input.split(' ');
	const s = parseInt(args[0], 10);
	var List = [s]
  
	f(s,List)	
}

function f(a,list){
  if(a%2==0) {
    g(a/2,list)
  }else{
    g(3*a+1,list)
  }
}

function g(b,list){
	list.push(b)
 	for(var j = 0;j<list.length;j++){
      if(j == list.length-1) return f(b,list)
      else if(b == list[j]) return console.log(list.length)
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int n;
pair<int,int>a[100005];

int main() {
	cin>>n;
	for (int i=0;i<n;i++) cin>>a[i].first>>a[i].second;
	sort(a,a+n);
	for (int i=0;i<n;i++) cout<<a[i].first<<' '<<a[i].second<<'\n';
}


Measured memory_bytes: 3888
#include <iostream>
#include <cmath>
#include <cassert>

int n_digit(long x){
    int ret = 0;
    while(x > 0){
        x = x / 10;
        ret++;
    }
    return ret;
}

int F(long a, long b){
    return std::max(n_digit(a), n_digit(b));
}

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

    long N;
    std::cin >> N;

    long NN = (long)(sqrt(N) + 1);
    assert(NN <= 1000000); // <= 10^5 < 10^6

    int ans = 100;
    for(long i = 1; i < NN; i++){
        long a = i;
        long b = N / i;
        if(a * b == N){
            ans = std::min(F(a, b), ans);
        }
    }
    
    std::cout << ans << std::endl;
}


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

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    long long S[N];

    long long sum=0;
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    for(int i=0;i<N;i++){
        sum+=A[i];
        S[i] = sum;
    }
    long long mi = LONG_LONG_MAX;
    for(int i=0;i<N-1;i++){
        mi = min(mi,abs(S[N-1]-S[i]-S[i]));
    }

    cout << mi;

    return 0;
}

Measured memory_bytes: 2560
#include<iostream>

using namespace std;

int main() {
	int n;
	int p[20];
	cin >> n;
	int count = 0;
	for (int i = 0;i < n;i++) {
		cin >> p[i];
	}
	for (int i = 1;i < n - 1;i++) {
		/*cout << count << endl;*/
		if ((p[i - 1] > p[i]&&p[i]>p[i+1])||(p[i-1]<p[i]&&p[i]<p[i+1])){
			count += 1;
		}
	}
	cout << count << endl;
	return 0;
}

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

#define ll long long
#define ar array

void solve() {
}

void addEdge(vector<int> adj[], int u, int v) {
  adj[u].push_back(v);
  adj[v].push_back(u);
}

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

  int N, M;
  cin >> N;
  cin >> M;
  vector<int> adj[N+1];

  for (int i=0; i<M; i++) {
    int node1, node2;
    cin >> node1;
    cin >> node2;
    addEdge(adj, node1, node2);
  }

  // for (int i=1; i<N+1; i++) {
  //   for (auto node : adj[i]) {
  //     cout << "[" << i << " ," << node << "]";
  //   }
  //   cout << "\n";
  // }
  // cout << "\n";

  // perform BFS

  queue<int> q;
  bool visited[N+1] = {false};
  int parent[N+1] = {0};

  visited[0] = true;
  visited[1] = true;
  parent[1] = 1;
  q.push(1);
  while (!q.empty()) {
    int s = q.front();
    q.pop();

    for (auto u : adj[s]) {
      if (visited[u]) {
        continue;
      }
      visited[u] = true;
      if (parent[u] == 0) {
        parent[u] = s;
      }
      q.push(u);
    }
  }

  bool allVisited = true;
  for (int i=1; i<N+1; i++) {
    allVisited = allVisited && visited[i];
  }

  if (!allVisited) {
    cout << "No" << "\n";
    return 0;
  }

  cout << "Yes" << "\n";
  for (int i=2; i<N+1; i++) {
    cout << parent[i] << "\n";
  }
  




  return 0;

}


Measured memory_bytes: 10624
#include<cstdio>

int main(void){
	while(1){
		int n;
		scanf("%d",&n);
		if(n==0)break;
		int cnt=0;
		for(int i=1;i<=n/2;i++){
			int j=i,sum=i;
			while(sum<n){
				j++;
				sum+=j;
			}
			if(sum==n)cnt++;
		}
		printf("%d\n",cnt);
	}
	return 0;
}

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

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

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

	int a,b,c,d; cin >> a >> b >> c >> d;

	cout << a*b - a*d - b*c + c*d << endl;

	return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

vector<vector<long long int>> f(int b, int e, const vector<long long int>& v, const vector<long long int>& pre) {
	vector<vector<long long int>> res;
	long long int s = pre[e];
	if (b > 0) s -= pre[b - 1];
	int bb = b, ee = e;
	while (b < e) {
		int m = (b + e) / 2;
		long long int c1 = pre[m];
		if (bb > 0) c1 -= pre[bb - 1];
		long long int c2 = s - c1;
		if (c1 < c2) {
			b = m + 1;
		} else {
			e = m;
		}
	}
	if (b == ee) {
		res.push_back({min(v[e], s - v[e]), max(v[e], s - v[e])});
		return res;
	}
	long long int s1 = pre[e];
	if (bb > 0) s1 -= pre[bb - 1];
	res.push_back({min(s1, s - s1), max(s1, s - s1)});
	if (e > bb) {
		s1 -= v[e];
		res.push_back({min(s1, s - s1), max(s1, s - s1)});
	}
	return res;
}

int main() {
    int n;
    cin >> n;
    vector<long long int> v(n, 0);
    vector<long long int> pre(n, 0);
    long long int c = 0;
    for (int i = 0; i < n; i++) {
    	cin >> v[i];
    	c += v[i];
    	pre[i] = c;
    }
    long long int res = 0x3f3f3f3f;
    for (int i = 1; i < n - 2; i++) {
    	vector<vector<long long int>> ret1 = f(0, i, v, pre), ret2 = f(i + 1, n - 1, v, pre);
    	for (int j = 0; j < ret1.size(); j++) {
    		for (int k = 0; k < ret2.size(); k++) {
    			res = min(res, max(ret1[j][1], ret2[k][1]) - min(ret1[j][0], ret2[k][0]));
    		}
    	}
    }
    cout << res << endl;
}


Measured memory_bytes: 6384
s = list(input())
n = len(s)
m = n // 2

a = [] + s[:m]
b = [] + s[m+1:]

for i in range(m):
    if a[i] != a[m-1-i] or b[i] != b[m-1-i] or a[i] != b[i]:
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n)repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
typedef pair<int,int> P;
typedef pair<int, P> PP;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define pb(x) push_back(x)
#define fi first
#define se second
const int inf = 1e9+7;
const int INF = 1e18+7;
int mod = 1e9+7;

signed main(){
	int a, b;char c;
	scanf("%lld %c%lld", &a, &c, &b);
	if(c == '+')printf("%lld\n", a+b);
	else printf("%lld\n",a-b);
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<stack>
#include<queue>
using namespace std;
typedef long long ll;

const int maxn = 1000010;

int n,ans;
string s;

ll read(){ ll s=0,f=1; char ch=getchar(); while(ch<'0' || ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0' && ch<='9'){ s=s*10+ch-'0'; ch=getchar(); } return s*f; }

int main(){
	cin>>s;
	n = s.size();
	for(int i=1;i<n/2;i++){
		for(int j=i;j<=i+i-1;j++){
			int tr=1;
			for(int k=0;k<i;k++){
				if(s[k]!=s[k+i]){
					tr=0; break;
				}
			}
			if(tr) ans=i;
		}
	}
	
	printf("%d\n",ans*2);
	
	return 0;
}

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

#define mp make_pair
#define X first
#define Y second
#define pb push_back
#define CL(x) (x << 1)
#define CR(x) ((x << 1) + 1)
#define sqr(x) ((x) * (x))
#define Task ""

const bool OnLineJudge = 1;

typedef long long cc;
typedef long double ld;
typedef pair <int, int> pii;
int n, k;
const int N = 100005;
pii a[N];
bool g[N];

int main() {
    std :: ios_base :: sync_with_stdio(false); cin.tie(NULL);
    //-------------------------------------------------------------------------------------------------------
    cin >> n >> k;
    cc sum = 0;
    for (int i = 1; i <= n; i++) {
        cin >> a[i].X >> a[i].Y;
        if (a[i].X <= k) {
            g[i] = true;
            sum += a[i].Y;
        }
    }
    cc res = 0;
    for (cc i = 30; i >= 0; i--) {
        int curBit = (k >> i) & 1;
        if (curBit == 0) {
            for (int j = 1; j <= n; j++)
                if (g[j] && ((a[j].X >> i) & 1)) {
                    sum -= a[j].Y;
                    g[j] = false;
                }
        } else {
            cc sub = 0;
            for (int j = 1; j <= n; j++)
                if (g[j] && ((a[j].X >> i) & 1)) {
                    sub += a[j].Y;
                }
            res = max(res, sum - sub);
        }
    }
    res = max(res, sum);
    cout << res << "\n";
    //-------------------------------------------------------------------------------------------------------
    return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair<int, int> pii;  // pair<int, int> に pii という別名を付ける
typedef long long ll;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long double L;
  cin >> L;
  cout << fixed << setprecision(10) << (L/3)*(L/3)*(L/3) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
int main()
{
  int A, B;
  cin >> A >> B;
  if (A == B)
  {
    cout << A + B << endl;
  }
  else if (A > B)
  {
    int ans = max(A - 1, B) + A;
    cout << ans << endl;
  }
  else
  {
    int ans = max(A, B - 1) + B;
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR(x, z, y) for(int x = (z); y; x++)
#define rep(x, y) for(int x = 0; x < (y); x++)
#define REP(x, z, y) for(int x = (z); x < (y); x++)
#define all(x) x.begin(), x.end()
#define len(x) (sizeof(x) / sizeof(x[0]))
#define split_str(str, sp_word) istringstream stream(str); string res; FOR(cnt, 0, getline(stream,res,sp_word))
#define scanln(x) fgets(x, sizeof x, stdin)
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define i_str(x) atoi(x.c_str())
#define digit(x) ((int)log10((double)(x)) + 1)
const int MOD = 1000000007; 
typedef long long ll;
using namespace std;

 
int main() {
  ll S,C,ans = 0;
  scanf("%lld%lld",&S,&C);

  if(S >= C / 2) ans = C / 2;
  else{
    C -= 2 * S;
    ans += S;
    ans += C / 4;
  }

  printf("%lld",ans);
 
  return 0;
}

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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'
#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
// #define int long long

typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9;
const int MOD = 1e9+7;
const int K = 1e5 + 4;
int n, k, r, s, p;
string t;

int dp[K][3]; //0: end with r, 1: end with s, 2: end with p
void xuat(){
	for(int i=0; i<k; i++){
		for(int j=0; j<3; j++) cerr << dp[i][j] << ' ';
		cerr << endl;
	}
	cerr << endl;
}
int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n >> k >> r >> s >> p >> t;
	for(int i=0; i<n; i++){
		int prev[3];
		for(int j=0; j<3; j++) prev[j] = dp[i%k][j];

		dp[i%k][0] = max(prev[1], prev[2]); 
		if (t[i] == 's') dp[i%k][0] += r;
		dp[i%k][1] = max(prev[0], prev[2]);
		if (t[i] == 'p') dp[i%k][1] += s;
		dp[i%k][2] = max(prev[0], prev[1]);
		if (t[i] == 'r') dp[i%k][2] += p;
	}
	int ans = 0;
	for(int i=0; i<k; i++) ans += max({dp[i][0], dp[i][1], dp[i][2]});
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1488
#include<bits/stdc++.h>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
int main()
{ 
    cool;
    int a,p,s=0;
    cin>>a>>p;
    s=a*3+p;
    cout<<(s/2)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    ll k;
    cin >> s >> k;
    ll n = s.size();
    vector<pair<char, ll>> cnt;
    cnt.emplace_back(s[0], 0);
    rep(i, n) {
        if (s[i] == cnt.back().first) cnt.back().second++;
        else cnt.emplace_back(s[i], 1);
    }
    int m = cnt.size();
    ll ans = 0;
    if (m == 1) ans = (k*n)/2;
    else {
        rep(i, m) {
            ans += k * (cnt[i].second/2);
        }
        if (s[0] == s[n-1]) {
            ans -= (k-1) * (cnt[0].second/2);
            ans -= (k-1) * (cnt[m-1].second/2);
            ans += (k-1) * ((cnt[0].second+cnt[m-1].second)/2);
        }
    }
    cout << ans << endl; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,sum=0,ans=0;
	cin>>n;
	int a[n];
	for(int i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	for(int i=0;i<n;i++)
	{
		if(a[i]%2==0)
		{
			ans++;
			if(a[i]%3==0||a[i]%5==0)
				sum++;
		}
	}
	if(ans==sum)
		cout<<"APPROVED";
	else
		cout<<"DENIED";
	return 0;
	}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

  int G[N][N];
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      G[i][j] = -1;
    }
  }

  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    G[a][b] = 1;
    G[b][a] = 1;
  }

  int res = 0;
  for (int i = 0; i < N; ++i) {
    int counter = 0;
    int loc;
    int j = 0;
    for (; j < N; ++j) {
      if (G[i][j] == 1) {
        ++counter;
        loc = j;
      }
    }

    if (counter == 1) {
      ++res;
      G[i][loc] = -1;
      G[loc][i] = -1;
      i = -1;
    }
  }

  cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int hp(long long n) 
{ 
    int a= log2(n);
    return a;
} 
int main(){
    long long h;
    cin>>h;
    int a=hp(h);
    long long b=0;
    for(int i=0;i<=a;i++)
    {
        b=b+pow(2,i);
    }
    cout<<b;
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll c=0;
    string s;
    cin >> s;
    for (ll i=0;i<s.size();i++){
        if (s[i]=='x')c++;
    }
    if (c>7){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
    return 0;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
typedef long long ll;
const int INF = 1001001001;


int main() {

    int n;
    cin >> n;

    vector<int> values (n);
    rep(i, n) cin >> values[i];
    sort(values.begin(), values.end());

    double sum = values[0];
    for(int i = 1 ; i < n - 1 ; i ++) {
        sum = (sum + values[i]) / 2;
    }
    sum = (sum + values[n -1]) / 2;
    printf("%.10f", sum);


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	if(b>a)return 0;
	if(a==b)return 1;
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int g(int x){
	x=modpow(x,MOD-2);
	return x;
}
int h,w,a,b;
int x[1010][1010];
signed main(){
	cin>>h>>w>>a>>b;
	rep(i,b){
		rep(j,a){
			x[i][j]=1;
		}
	}
	for(int i=b;i<h;i++){
		for(int j=a;j<w;j++){
			x[i][j]=1;
		}
	}
	rep(i,h){
		rep(j,w){
			cout<<x[i][j];
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 9344
N = int(input().strip())

sum_all = N * (N+1) / 2

threeU = N // 3
threeU = threeU * 3

fiveU = N // 5
fiveU = fiveU * 5

fifU = N // 15
fifU = fifU * 15


sum_five = (5 + fiveU) * (N//5) / 2

sum_three = (3 + threeU) * (N//3) / 2

sum_fif = (15 + fifU) * (N//15) / 2

print(int(sum_all - sum_three - sum_five + sum_fif))





Measured memory_bytes: 9192
#include<iostream>
#include<vector>
#include<list>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }
// pair 型
template<class S,class T>
std::ostream& operator<<(std::ostream& os, const pair<T,S>& p){
  cout << "(" << p.first << "," << p.second << ")";
  return os;
}


// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}

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



int main(){
  int h,w,k; cin >>h >>w >>k;
  int x1,y1,x2,y2; cin >>x1>>y1>>x2>>y2;
  vector<vector<int>> ike(h+2,vector<int>(w+2,-1));
  rep(i,h){
    rep(j,w){
      char c; cin >>c;
      ike[i+1][j+1]=(c=='@')*(-1);
    }
  }
  if(df)rep(i,h+2)print(ike[i]);
  list<pair<int,pair<int,int>>> que;
  que.push_back({0,{x1,y1}});
  ike[x1][y1]=-1;
  if(df)print(que);
  while(que.size()!=0){
    pair<int,pair<int,int>> p=que.front();
    que.pop_front();
    int step=p.first;
    pair<int,int> pos=p.second;
    if(df)print(pos);
    step++;
    rep(d,4){
      rep(j,k){
        int i=j+1;
        pair<int,int> pos2={pos.first+dx[d]*i,pos.second+dy[d]*i};
        if(df)print(pos2);
        int flag=ike[pos2.first][pos2.second];
        if(df)print(flag);
        if(flag==-1) break;
        if(flag){
          if(flag<ike[pos.first][pos.second]) break;
          continue;
        }
        ike[pos2.first][pos2.second]=step;
        que.push_back({step,pos2});
        if(pos2==make_pair(x2,y2)){
          print(step);
          return 0;
        }
      }
    }
    if(df)print(que);
    if(df)rep(i,h+2) print(ike[i]);
  }
  print(-1);
}


Measured memory_bytes: 18740
import java.util.Scanner;

class Main {

	
          
    public static void main(String[] str) {
    	Scanner sc= new Scanner(System.in);
    	String num=sc.next();
    	System.out.println(solution(num));
    	sc.close();
    }
    
 public static int solution(String num) {
	 
	 if(num.length()<=1) {
		 
		 return Integer.valueOf(num);
	 }
	 
	 int op1= (num.charAt(0)-'1')+(num.length()-1)*9;
	 int op2=0;
	 for(int i=0;i<num.length();i++) {
		 op2+=num.charAt(i)-'0';
	 }
	return Math.max(op1, op2);
 }
}

Measured memory_bytes: 21844
# -*- coding: utf-8 -*-
#ABC138B
import copy
import sys
import math

n = int(input())
tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))

total=1
for i in range(0,n):
	total*=hoge[i]

ret=0
for i in range(0,n):
	ret+=total/hoge[i]

print(total/ret)

Measured memory_bytes: 3444
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int n, a[300][300];
ll d[300][300], flag[300][300];
ll ans = 0;

void warshall_floyd() {
	for (int k = 0; k < n; k++){
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
				if (d[i][j] == d[i][k] + d[k][j] && i != k && j != k) {
					flag[i][j] = 1;
				}
			}
		}
	}
}

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

	warshall_floyd();

	for (int i = 0; i < n; i++) {
		for (int j = i; j < n; j++) {
			if (d[i][j] == a[i][j]) {
				if (!flag[i][j]) {
					ans += a[i][j];
				}
			}
			else {
				ans = -1;
				break;
			}
		}
		if (ans < 0)break;
	}

	cout << ans << endl;
}

Measured memory_bytes: 2048
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
char in[110];
int main(){
	int a;
	int b;
	scanf("%d%s%d",&a,in,&b);
	for(int i=0;i<a;i++){
		if(in[b-1]!=in[i])in[i]='*';
	}
	printf("%s\n",in);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

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

int bingo[3][3];
bool flag[3][3];
int cnt[2][105];
int h, w;
int choco[1010][1010];
int s[11][11];

int main() {
	ll n, T;
	cin >> n >> T;
	vector<ll>t(n);
	ll ans = T;
	rep(i, n) {
		cin >> t[i];
	}
	for (int i = 1;i < n;++i) {
		ll zero = 0;
		ans += T - max(zero, t[i - 1] + T - t[i]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>
#include <string.h>
int main(void) {
	
	int N;
	int count = 0;
	scanf("%d", &N);
	for (int i = 2; i <= 9; i++) {
		if (N <= 9) {
			count++;
			printf("Yes");
			break;
		}

		if (N%i == 0 && N / i <= 9) {
			count++;
			printf("Yes");
			break;
		}
	}

	if(count==0)printf("No");



	return 0;

}

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

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

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

  string ans = "No";
  for (int i = 0; i < n.size(); ++i) {
    if (n[i] == '7') ans = "Yes";
  }
  cout << ans << endl;
}

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

long long int n, ans=0;
vector<int> a(500000);
vector<int> b(500000);
vector<int> c(500000);

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> a.at(i);
    for (int i = 0; i < n; ++i) cin >> b.at(i);
    for (int i = 0; i < n; ++i) cin >> c.at(i);

    sort(a.begin(), a.begin()+n);
    sort(b.begin(), b.begin()+n);
    sort(c.begin(), c.begin()+n);

    for (int i = 0; i < n; ++i)
    {
        ans += (lower_bound(a.begin(), a.begin()+n, b.at(i)) - a.begin()) * (c.begin()+n - upper_bound(c.begin(), c.begin()+n, b.at(i)));
    }

    cout << ans << endl;
}

Measured memory_bytes: 6144
import java.util.*;
import java.util.Map;
import java.util.TreeMap;
import java.util.HashMap;

public class Main{
    static long fix = 998244353L;

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        long ans = 1;

//        long fix = 998244353;

        int n = sc.nextInt();

        int[] d = new int[n];

        for (int i=0; i<n; i++) d[i] = sc.nextInt();

//        Arrays.sort(d);

        if (d[0]!=0){
            System.out.println(0);
            return;
        }

        if (n==1 && d[0]==0){
            System.out.println(0);
            return;
        }

        Map<Integer, Integer> map = new TreeMap<>();

        for (int i=0; i<n; i++){
            if(map.containsKey(d[i])){
                int v = map.get(d[i]);
                v++;
                map.put(d[i], v);
            }else {
                map.put(d[i], 1);
            }
        }

        Object[] mapkey = map.keySet().toArray();
//        Arrays.sort(mapkey);

        if(map.get(0)!=1){
            System.out.println(0);
            return;
        }
//        System.out.println(map);

        List<Integer> l = new ArrayList<>();

        for (Integer val: map.values()){
            l.add(val);
        }
//        System.out.println(l);

        int tmp = -1;
        for (Integer val: map.keySet()){
            if (val!=tmp+1){
                System.out.println(0);
                return;
            }else {
                tmp++;
            }
        }





        for (int i=1; i<l.size()-1; i++){
            ans *= (((power((long)l.get(i), (long)l.get(i+1)))%fix));
            ans %= fix;
            if (ans<0) ans += fix;
        }
        System.out.println(ans);
//        System.out.println(power(10, 9));
//        System.out.println(power(10000, 10000));
    }

    public static long power(long x, long n){
        long sum = 1;
        while (n>0){
            if ((n&1)==1){
                sum *= x;
                sum %= fix;
            }
            x *= x;
            x %= fix;
            if (sum < 0) sum += fix;
            if (x < 0) x += fix;
            n>>=1;
        }
//        return sum;
        return sum%fix;
    }

}


Measured memory_bytes: 54620
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n1 = sc.nextInt();
		int n2 = sc.nextInt();
		int n3 = sc.nextInt();
		int n4 = sc.nextInt();
		List<Integer> list = new ArrayList<Integer>();
		list.add(n1);
		list.add(n2);
		list.add(n3);
		list.add(n4);
		
		if(list.contains(1)) {
			if(list.contains(9)) {
				if(list.contains(7)) {
					if(list.contains(4)){
						System.out.println("YES");
					} else {
						System.out.println("NO");
					}
				} else {
				 System.out.println("NO");
				}
			} else {
				System.out.println("NO");
			}
		} else {
			System.out.println("NO");
		}
	}

}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
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 unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

const ll mod = 1e9+7;
const ld PI = 3.14159265358979323846;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    ll n;
	cin >> n;
	n = n % 10;
	if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) cout << "hon"<< endl;
	else if (n == 3) cout << "bon" << endl;
	else cout << "pon" << endl;
} 

Measured memory_bytes: 3648
H = []
W = []
while True:
    h, w = map(int, input().split())
    if h == 0 and w == 0:
        break
    else:
        H.append(h)
        W.append(w)
for i in range(len(H)):
    for j in range(H[i]):
        for k in range(W[i]):
            if j == 0 or j == H[i]-1 or k == 0 or k == W[i]-1:
                print('#',end="")
            else:    
                print('.',end="")
        print("")
    print("",end="\n")


Measured memory_bytes: 7020
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int64_t h;
  cin >> h;
  int64_t ans=0;
  int64_t i=1;
  int64_t p=1;
  while(p<=h){
    ans+=p;
    p=p*2;
  }
  cout << ans;
}
    

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//.\a.exe

int main(void){ios::sync_with_stdio(false);cin.tie(0);
///////////////////////////////////////////////////////
int n,m,x,a=0,b=0;
cin >> n >> m >> x;
int A[m];
for(int i=0;i<m;i++){
	cin >> A[i];
}
for(int i=0;i<m;i++){
	if(A[i]<x){
		a++;
	}
	else{
		b++;
	}
}

if(a>=b){
	cout << b << endl;
}

else{
	cout << a << endl;
}
///////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<queue>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
#include<cstdlib>
#include<stack>
#include<ctime>
#include<map>
#include<list>
using namespace std;

int main()
{
	int a;
	scanf("%d",&a);
	int tmp=pow(a,2)+pow(a,3)+a;
	printf("%d\n",tmp);
	return 0;
}


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

int r, D, x2000;

int put_xi(int i) {
    if(i > 2000) {
        int xi = put_xi(i - 1);
        cout << xi << endl;
        return r * xi - D;
    } else {
        return r * x2000 - D;
    }
}

int main() {
    cin >> r >> D >> x2000;
    cout << put_xi(2009) << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

A = sorted(A)

set_A = set(A)
if len(set_A) == 1:
    print(len(A))
    exit()
    
tmp_slime = A[0]
tmp_flag = True
for i in range(1, len(A)):
    if tmp_slime*2 >= A[i]:
        tmp_slime += A[i]
    else:
        tmp_flag = False
        break
if tmp_flag:
    print(len(A))
    exit()

low = 0
high = len(A)-1
mid = (low + high) // 2
while True:
    tmp = mid
    slime = sum(A[0:mid+1])
    flag = True
    for i in range(mid+1, len(A)):
        if slime*2 >= A[i]:
            slime += A[i]
        else:
            flag = False
            break
    if flag:
        high = mid
        mid = (low + high) // 2
    else:
        low = mid
        mid = (low + high) // 2
    if mid == tmp:
        break
    
print(len(A) - len(A[0:mid+1]))


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

int main(){
    string n;
    int k;
    cin >> n >> k;
    
    vector<char> d(k);
    for(int i = 0; i < k; i++){
        cin >> d.at(i);
    }

    int result;
    int tmp;
    int flag = 0;

    while(1){
        for(int i = 0; i < k; i++){
            for(int j = 0; j < n.size(); j++){
                if(n.at(j) == d.at(i)){
                    flag = 1;
                    break;
                }
            }
        }
        if(flag == 0){
            break;
        }
        tmp = stoi(n);
        tmp++;
        n = to_string(tmp);
        flag = 0;
    }

    result = stoi(n);
    cout << result << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define n 500000
#define mem(arr) memset(arr, 0, sizeof(arr))
using namespace std;
typedef long long lli;
typedef double llf;
typedef pair<int, int> P;
void solve();
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int times = 1;
//	cin >> times;
	for(int i=0; i<times; i++)
	{
		solve();
		cout << '\n';
	}
	return 0;
}

int a, b, c, d, e, f, g, h;
int arr[n + 50], arr1[n + 50], arr2[n + 50];

//type here

void solve()
{
	int a; cin >> a;
	set<int> S;
	for(int i=0; i<a; i++)
	{
		int tmp; cin >> tmp;
		if(S.count(tmp))
		{
			cout << "NO";
			return;
		}
		S.insert(tmp);
	}
	cout << "YES";
}

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

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

// ref. https://atcoder.jp/contests/abc144/submissions/8133816

const int MAX_N = 600;

int n, m;
vector<int> edges[MAX_N];
double dp[MAX_N];
double answer = MAX_N + 1;

void solve(int block) {
    dp[n - 1] = 0;
    for (int i = n - 2; i >= 0; i--) {
        double sum = 0.0;
        double max_cost = 0.0;
        double num = (double) edges[i].size();
        for (auto to : edges[i]) {
            sum += dp[to - 1];
            chmax(max_cost, dp[to - 1]);
        }
        if (i == block && num >= 2) {
            sum -= max_cost;
            num--;
        }
        dp[i] = 1.0 + sum / num;
    }

    chmin(answer, dp[0]);
}

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

    for (int i = 0; i < m ; i++) {
        int s, t;
        cin >> s >> t;
        edges[s-1].push_back(t);
    }

    for (int i = 0; i < n-1; i++) {
        solve(i);
    }

    printf("%3.7f\n", answer);

    return 0;
}


Measured memory_bytes: 1408
N, M = [int(_) for _ in input().split()]
X = [[int(_) for _ in input().split()] for _ in range(M)]

if N == 1:
    L = range(10)
elif N == 2:
    L = range(10, 100)
else:
    L = range(100, 1000)

for i in L:
    v = str(i)
    f = True
    for s, c in X:
        if f and int(v[s-1]) != c:
            f = False
    if f:
        print(v)
        exit(0)
print(-1)


Measured memory_bytes: 3064
fn main() {
    let stdin = std::io::stdin();
    let mut buf = String::new();
 
    stdin.read_line(&mut buf).unwrap();
    let mut it = buf.trim().split_whitespace();
    let c = it.next().unwrap();

    let byte = *(c.as_bytes().first().unwrap()) + 1;
    println!("{}", char::from(byte));
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    string S;
    cin >> S;
    int ans = 0;
    char c = S[0];
    rep(i, S.size()) {
        if (c != S[i]) {
            c = S[i];
            ans++;
        }
    }

    cout << ans << endl;
}

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

#define N_MAX 500001

struct node{
    int key;
    struct node *right;
    struct node *left;
    struct node *parent;
};

typedef struct node *Node;
Node root = NULL;

int find(int k,Node u)
{
    if( u == NULL ){
        return 0;
    }
    
    if( u->key == k ){
        return 1;
    }else if( u->key < k ){
        return find(k,u->right);
    }else{
        return find(k,u->left);
    }
}

void insert(int k){
    Node y = NULL;
    Node x = root;
    Node z;
    
    z = malloc(sizeof(struct node));
    z->key = k;
    z->right = NULL;
    z->left = NULL;
    while(x != NULL){
        y = x;
        if(z->key < x->key){
            x = x->left;
        }else{
            x = x->right;
        }
    }
    z->parent = y;

    if(y == NULL){
        root = z;
    }else if(z->key < y->key){
        y->left = z;
    }else{
        y->right = z;
    }
}

/* 中間順アルゴリズム */
void inorder(Node u){
    if(u == NULL){
        return;
    }
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}

/* 先行順アルゴリズム */
void preorder(Node u){
    if(u == NULL){
        return;
    }
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(){
    int n, i, x;
    char com[20];
    scanf("%d", &n);
    for( i = 0; i < n; i++ ){
        scanf("%s", com);
        if( com[0] == 'i' ){
            scanf("%d", &x);
            insert(x);
        }else if( com[0] == 'p' ){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }else if( com[0] == 'f' ){
            scanf("%d", &x);
            if(find(x,root)){
                printf("yes\n");
            }else{
                printf("no\n");
            }
        }
    }
    return 0;
}




Measured memory_bytes: 20560
# coding: utf-8
# Your code here!
import math

while True:
    m, f, r = list(map(int,input().split()))
    if m == -1 and f == -1 and r ==-1 :
        break
    if m == -1 or f == -1:
        print("F")
    elif m+f >= 80:
        print("A")
    elif m+f >= 65:
        print("B")
    elif m+f >= 50:
        print("C")
    elif m+f >= 30:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")


Measured memory_bytes: 5660
#include<bits/stdc++.h>
using namespace std;
int n,l,h,mid,m,a,r;
int ask(int x)
{
	char s[20];
	printf("%d\n",x);
	fflush(stdout);
	scanf("%s",s);
	if(s[0]=='V') exit(0);
	return s[0]=='M';
}
int main()
{
	scanf("%d",&n);
	l=0; h=n;
	a=ask(0);
	r=a;
	while(l<h)
	{
		mid=(l+h)/2;
		m=ask(mid);
		if((mid-l)%2!=(m^a))
		{
			h=mid;
			r=m;
		}
		else
		{
			l=mid;
			a=m;
		}
	}
	return 0;
}

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

int main(){
  
    long long int N,M;
    cin>>N>>M;
    long long int ans=0;
    if(N*2>=M){
        ans=M/2;
        cout<<ans<<endl;
    }
    else{
        ans+=N;
        M=M-2*N;
        ans=ans+M/4;
        cout<<ans<<endl;
    }
}


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


int main()
{


        long long n,m,a,b,c,e,f,g,p,q,r,fr,sc,tr,sz,tz,sz1,sz2,i,j,k,mx=-9,mn=999999999999; string str,ttr,ntr;
        long long x=1,y=1,cnt=0,res=0,ttl=0,ans=0,sum=0; long long flg=0,flag=1,na=0,as=1;
        vector<long long>u,v,w; vector< pair<long long,long long> >vct,tct; vector<string>vst;
        set<long long>st,nt,tt; map<long long,long long>mp,nq,qr,mp1,mp2;

        cin>>n;

        while(n!=0)
        {
            n=n/2;
            ans=ans+x;
            x=x*2;
        }

        cout<<ans<<endl;









    return 0;
}




Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int sx = sc.nextInt();
      int sy = sc.nextInt();
      int tx = sc.nextInt();
      int ty = sc.nextInt();
      for(int i = 0;i < tx-sx;i++)System.out.print("R");
      for(int i = 0;i < ty-sy;i++)System.out.print("U");
      for(int i = 0;i < tx-sx;i++)System.out.print("L");
      for(int i = 0;i < ty-sy;i++)System.out.print("D");
      System.out.print("D");
      for(int i = 0;i <= tx-sx;i++)System.out.print("R");
      for(int i = 0;i <= ty-sy;i++)System.out.print("U");
      System.out.print("L");
      System.out.print("U");
      for(int i = 0;i <= tx-sx;i++)System.out.print("L");
      for(int i = 0;i <= ty-sy;i++)System.out.print("D");
      System.out.println("R");
    }
}

Measured memory_bytes: 25536
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
sum = 0
for i in range(N):
    if A[i] > B[i]:
        sum += B[i]
    else:
        sum += A[i]
        if A[i+1] > B[i]-A[i]:
            sum += B[i]-A[i]
            A[i+1] -= B[i]-A[i]
        else:
            sum += A[i+1]
            A[i+1] = 0
print(sum)

Measured memory_bytes: 18476
// AOJ 0114: Electro-Fly
// 2017.8.23 bal4u@uu
// 1017.11.14

#include <stdio.h>

long long gcd(long long a, long long b)
{
	long long r;
	if (a < b) r = a, a = b, b = r;
	while (b != 0) r = a % b, a = b, b = r; return a;
}

int carmichael(int a, int m)
{
    int n, b;
	for (n = 1, b = a; b != 1; n++) b = (b * a) % m;
	return n;
}

char buf[40], *p;
int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int a1, a2, a3, m1, m2, m3, b1, b2, b3;
	long long ans;
	
	while (fgets(p=buf, 40, stdin) && *p != '0') {
		a1 = getint(), p++, m1 = getint(), p++;
		a2 = getint(), p++, m2 = getint(), p++;
		a3 = getint(), p++, m3 = getint(), p++;		

		b1 = carmichael(a1, m1);
		b2 = carmichael(a2, m2);
		b3 = carmichael(a3, m3);
		
		ans = (long long)b1 / gcd(b1,  b2) * b2;
		ans =           ans / gcd(ans, b3) * b3;
		printf("%lld\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1744
# 2020/01/23
# AtCoder Beginner Contest 144 - B

# Input
n = int(input())

ans = "No"
for i in range(1, 10):
    for j in range(1, 10):
        wk = i * j
        if wk == n:
            ans = "Yes"
            break

# Output
print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1e9+7,maxn=200005;
int sum1,sum2,n,m,k,ans,f[maxn];
int calsum() {
	int sum=0;
	for(register int i=1; i<n; i++) {
		sum=(sum+(n-i)*i)%mod;
	}
	sum=sum*m%mod*m%mod;
	return sum;
}
int ksm(int x,int y) {
	int sum=1;
	while(y) {
		if(y&1) {
			sum=sum*x%mod;
		}
		x=x*x%mod;
		y>>=1;
	}
	return sum;
}
void fact() {
	f[0]=1;
	for(register int i=1; i<maxn; i++) {
		f[i]=f[i-1]*i%mod;
	}
}
int C(int x,int y) {
	return f[y]*ksm(f[x],mod-2)%mod*ksm(f[y-x],mod-2)%mod;
}
signed main() {
	scanf("%lld%lld%lld",&n,&m,&k);
	sum1=calsum();
	swap(n,m);
	sum2=calsum();
	ans=(sum1+sum2)%mod;
	fact();
	ans=ans*C(k-2,n*m-2)%mod;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 5388
#include <bits/stdc++.h>
using namespace std;
double dp[4000][4000];
double P[4000];
int main(){
    int N; cin >> N;
    for(int i=0; i<N; ++i){
        double p;
        cin >> p;
        P[i] = p;
    }
    dp[0][0] = 1-P[0];
    dp[0][1] = P[0];
    for(int i=1; i<N; ++i){
       dp[i][0] = dp[i-1][0]*(1-P[i]); 
    }
    for(int i=1; i<N; ++i){
        //cout << dp[i][0] << " ";
        for(int j=1; j<=i+1; ++j){
            dp[i][j] = P[i]*dp[i-1][j-1] + (1-P[i])*dp[i-1][j]; 
            //cout << dp[i][j] << " ";
        }
        //cout << endl;
    }
    double res = 0;
    for(int j=N/2+1; j<=N; ++j){
        res += dp[N-1][j];
    }
    cout << setprecision(9) << res << endl;
    return 0;
}

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

#define pout(n)  printf ("%d\n", n)

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());

const int d4x[4] = {1, 0, -1, 0};
const int d4y[4] = {0, 1, 0, -1};
const int d8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const int d8y[8] = { 0,1,1,1,0,-1,-1,-1 };

#define MAX_N (int)2e5+20
#define INF 1e12+20

typedef long long ll;
using namespace std;
int f[101][11],p[101][11],b[11];
int main(){
	ios::sync_with_stdio(false);
	int n,ans=-1000000000;
	cin >> n;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=10;j++)
			cin>>f[i][j];
	for(int i=1;i<=n;i++)
		for(int j=0;j<=10;j++)
			cin>>p[i][j];
	b[10]=1;
	while(1){
		int x=10;
		while(b[x]==1) b[x]=0,x--;
		b[x]=1;
		if(x==0) break;
		x=0;
		for(int i=1;i<=n;i++)
		{
			int s=0;
			for(int j=1;j<=10;j++)
				if(f[i][j]==1&&b[j]==1) s++;
			x+=p[i][s];
		}
		ans=max(ans,x);
	}
	pout(ans);
	return 0;
}


Measured memory_bytes: 256
from sys import stdin
from sys import setrecursionlimit
from itertools import combinations_with_replacement


n,m,q = map(int,stdin.readline().rstrip().split())

abcd = [list(map(int,stdin.readline().rstrip().split())) for _ in range(q)]
abcd.sort()

maxes = 0

kazu = [i for i in range(1,m+1)]

li = list(combinations_with_replacement(kazu,n))

for i in li:
    i = list(i)
    ma = 0
    for j in abcd:
        a,b,c,d = j
        a -= 1;b -= 1
        if i[b]-i[a] == c:
            ma += d
    maxes = max(ma,maxes)
print(maxes)

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

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

    for(int i=0;i<n;i++){
        int s,f;
        cin >> s >> f;

        if(a>=s && a<f){
            cout << 1 << endl;
            return 0;
        }
        if(b>s && b<=f){
            cout << 1 << endl;
            return 0;
        }
        if(a<=s && b>=f){
            cout << 1 << endl;
            return 0;
        }
    }

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


Measured memory_bytes: 3132