akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  int N, M; cin >> N >> M;
  int sum = 0;
  for (int i = 0; i < M; i++){
    int A; cin >> A; sum += A;
  }
  cout << max(-1, N - sum) << endl;

  return 0;
}


Measured memory_bytes: 3636
package main

import "fmt"

func main(){
    var s, t string
    var cnt int

    cnt = 0

    fmt.Scanf("%s", &s)
    fmt.Scanf("%s", &t)

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

    fmt.Printf("%d\n", cnt)
}


Measured memory_bytes: 4588
#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<string> s(N);
  rep(i, N) cin >> s[i];
  int M; cin >> M;
  vector<string> t(M);
  rep(i, M) cin >> t[i];
  
  int ans = 0;
  rep(i, N) {
    int ao = 0;
    int aka = 0;
    rep(j, N) {
      if(s[i] == s[j]) ao++;
    }
    rep(j, M) {
      if(s[i] == t[j]) aka++;
    }
    if(ans < ao-aka) ans = ao-aka;
  }
  
  cout << ans <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
/*---------------------------------------------------*/

int main(){
  int m,mini,maxi,gap,ans;
  int data[200];
  while(cin>>m>>mini>>maxi){
    if(m==0&&mini==0&&maxi==0)break;
    rep(i,m)cin>>data[i];
    ans=mini;gap=0;
    for(int i=mini-1;i<=maxi-1;i++){
      if(abs(data[i]-data[i+1])>=gap){
	gap=abs(data[i]-data[i+1]);
	ans=i+1;
      }
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 2996
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
/*union-find*/
const int MAX_V =100010;
int parent[MAX_V];//parent[x]=xの時xが根である
int rank[MAX_V];
struct edge
{
	int u,v,cost;
	edge(int _u,int _v,int _cost){
		u =_u;
		v =_v;
		cost =_cost;
	}
};
void init(int V){
	for(int i= 0;i < V;i++){
		parent[i] = i;
		rank[i] =0;
	}
}

int find(int x){
	if(parent[x] == x)
		return x;
	else{
		return find(parent[x]);
	}
}

void unit(int x,int y){
	x = find(x);
	y = find(y);
	if(x == y)
		return;
	if(rank[x] < rank[y]){
		parent[x] = y;
	}
	else{
		parent[y] = x;
		if(rank[x] == rank[y])
			rank[x]++;
	}
}

bool same(int x,int y){
	return find(x) == find(y);
}
//コストが低い順にsortする
bool cmp(const edge &left,const edge &right){
	return left.cost <right.cost;
}
vector<edge> es;

int V,E;
int kruskal(){
	init(V);
	sort(es.begin(),es.end(),cmp);
	int res = 0;
	for(int i =0;i <E;i++){
		edge e =es[i];
		if(!same(e.u,e.v)){
			unit(e.u,e.v);
			res +=e.cost;
		}
	}
	return res;
}


int main(){
	cin>>V>>E;
	for(int i =0;i < E;i++){
		int u,v,cost;
		cin>>u>>v>>cost;
		es.push_back(edge(u,v,cost));
	}
	
	cout <<kruskal()<<endl;
	return 0;
}

Measured memory_bytes: 2704
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        a: i64,
        b: i64,
        c: i64,
        d: i64
    }

    let ab = [a, b];
    let cd = [c, d];

    let mut max_num = std::i64::MIN;
    for &x in &ab {
        for &y in &cd {
            max_num = max_num.max(x * y);
        }
    }
    println!("{}", max_num);
}


Measured memory_bytes: 2200
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
const ll inf = 1LL << 50;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////

//隣り合う二項はm-1通り存在する。期待値の線形性からm-1通り
//それぞれについて差の絶対値がdである確率を求めて足し上げればよい
//1からnまでのペア(a,b)の差の絶対値がdである確率を求める
//d=0である時、条件を満たすペアは(1,1),,,,(n,n)のn個
//よって確率はn/n*n=1/n
//d!=0である時条件を満たすペアは(1,d+1),,,,(n-d,n)と(d+1,1),,,(n,n-d)の
//2(n-d)個です。よって確率は2*(n-d)/n*nです
int main() {
	double n, m, d;
	cin >> n >> m >> d;
	if (d == 0) {
		cout << fixed<<setprecision(10)<<(m - 1)/n << endl;
	}
	else {
		cout << fixed << setprecision(10) <<(m-1)* 2 * (n - d) / (n*n) << endl;
	}

	return 0;
}

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

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

    double w, h;
    cin >> w >> h;
    double x, y;
    cin >> x >> y;

    double ans = w * h / 2;
    if (x == w / 2 && y == h / 2) printf("%.10f 1\n", ans);
    else printf("%.10f 0\n", ans);
    return 0;
}


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

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int x, a, b;
int main(void) {
    while(~scanf("%d%d%d", &x, &a, &b)) {
        int t1 = abs(x - a), t2 = abs(x - b);
        puts(t1 < t2 ? "A" : "B");
    }
}


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

long double n,a[3000],dp[3000][6001];

long double fun(int i,int k){
if(n-i+1<-k)return 0;
if(i>n)return 1;
if(dp[i][k+3000])return dp[i][k+3000];
return dp[i][k+3000]=a[i]*fun(i+1,k+1) + (1-a[i])*fun(i+1,k-1);
}

int main(){
    cout.precision(10);cout<<fixed;
cin>>n;

//memset(dp,lb,sizeof dp);
for(int i=1;i<=n;i++){
    cin>>a[i];
}
cout<<fun(1,0);
}


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

int main(){
  int input[5], max = 0, maxi = 0, tmp[5];
  int sum = 0;
  for(int i = 0; i < 5; i++){
    cin >> input[i];
    tmp[i] = (input[i] % 10 == 0) ? 0 : 10 - input[i] % 10;
    if(max < tmp[i]){
      max = tmp[i];
      maxi = i;
    }
  }

  for(int i = 0; i < 5; i++){
    sum += input[i];
    if(i != maxi){
      sum += tmp[i];
    }
  }

  cout << sum << endl;

  return 0;
}

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

using namespace std;

int f(int i, int n, int *memo, int *a) {
    if (i < 0) return INT_MAX;
    if (i == 0) return 0;
    if (i == 1) return abs(a[0] - a[1]);
    if (memo[i] != -1)
        return memo[i];
    int c1 = f(i - 1, n, memo, a) + abs(a[i-1] - a[i]);
    int c2 = f(i - 2, n, memo, a) + abs(a[i-2] - a[i]);
    memo[i] = min(c1, c2);
    return memo[i];
}

int main() {
    int n;
    cin >> n;
    int b[n];

    for (int i = 0; i < n; ++i) {
        cin >> b[i];
    }
    int memo[n];
    memset(memo, -1, sizeof(memo));
    cout << f(n-1, n, memo, b) << endl;
    return 0;
}


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

int main(){
    long long n,k;
    cin >> n >> k;
    long long ans=0;
    for(long long i=k;i<=n+1;i++){
        long long min=(i-1)*i/2;
        long long max=(2*n-i+1)*i/2;
        ans+=max-min+1;
        ans%=1000000007;
    }
    cout << ans << endl;
    return 0;
}

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

bool compare1(pair<long long int, long long int> p1, pair<long long int, long long int> p2)
{
	return (p1.first < p2. first);
}

int main()
{
	long long int i, m, n, a, b, ans=0;
	cin >> n >> m;

	vector<pair<long long int, long long int>> v;

	for(i=0; i<n; i+=1)
	{
		cin >> a >> b;
		v.push_back(make_pair(a, b));
	}

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

	i=0;
	while(m>0)
	{
		if(m>v[i].second)
		{
			m-=v[i].second;
			ans+=(v[i].first)*(v[i].second);
		}
		else
		{
			ans+=(v[i].first)*m;
			m=0;
		}
		i+=1;
	}

	cout << ans << endl;
}

Measured memory_bytes: 2420
#include<cstdio>
#include<cstring>
using namespace std;
int c[4005][5];
char s[4005];
int main()
{
	int n;
	scanf("%d\n",&n);
	scanf("%s",s+1);
	for(int i=1;i<=n;i++)
	{
		c[i][1]=c[i-1][1],
		c[i][2]=c[i-1][2],
		c[i][3]=c[i-1][3];
		if(s[i]=='R')
		{
			c[i][1]++;
		}
		if(s[i]=='G')
		{
			c[i][2]++;
		}
		if(s[i]=='B')
		{
			c[i][3]++;
		}
	}
	long long ans=0;
	for(int i=1;i<=n;i++)
	{
		for(int k=i+2;k<=n;k++)
		{
			if(s[k]==s[i])continue;
			if(s[i]=='R'&&s[k]=='G')
			{
				ans+=c[k-1][3]-c[i][3];
			}
			else
			if(s[i]=='G'&&s[k]=='R')
			{
				ans+=c[k-1][3]-c[i][3];
			}
			else
			if(s[i]=='R'&&s[k]=='B')
			{
				ans+=c[k-1][2]-c[i][2];
			}
			else
			if(s[i]=='B'&&s[k]=='R')
			{
				ans+=c[k-1][2]-c[i][2];
			}
			else
			if(s[i]=='G'&&s[k]=='B')
			{
				ans+=c[k-1][1]-c[i][1];
			}
			else
			if(s[i]=='B'&&s[k]=='G')
			{
				ans+=c[k-1][1]-c[i][1];
			}
			if((k-i)%2==0)
			{
				int j=(k+i)/2;
				if(s[j]!=s[k]&&s[j]!=s[i])
				ans--;
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1812
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
typedef vector<ll>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
//const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


bool dx[8080][2*8000], dy[8080][2*8000];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    int x, y;
    cin >> S >> x >> y;
    vector<vector<int>> a(2);
    int d = 0;
    REP(i,S.size()){
        int t=0;
        while(S[i]=='F'&&i<S.size()) t++,i++;
        a[d].push_back(t);
        d = 1-d;
    }
    int g = 8000;
    REP(i,8080) REP(j,2*g){
        dx[i][j] = false;
        dy[i][j] = false;
    }
    dx[0][g] = true, dy[0][g] = true;
    REP(i,a[0].size()){
        REP(j,2*g){
            if(dx[i][j]){
                dx[(i+1)][j+a[0][i]] = true;
                if(i > 0) dx[(i+1)][j-a[0][i]] = true;
                //dx[i][j] = false;
            }
        }
    }
    REP(i,a[1].size()){
        REP(j,2*g){
            if(dy[i][j]){
                dy[(i+1)][j+a[1][i]] = true;
                dy[(i+1)][j-a[1][i]] = true;
                //dy[i][j] = false;
            }
        }
    }
    int a0 = a[0].size(), a1 = a[1].size();
    if(dx[a0][g+x] && dy[a1][g+y]) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 252800
n = int(input())
a = list(map(int,input().split()))
ans1 = max(a)
diff = min(ans1//2, ans1//2 + 1)
ans2 = ans1
for x in a:
  if x == ans1:
    continue
  d = min(abs(ans1//2 - x), abs(ans1//2 + 1 - x))
  if d <= diff:
    diff = d
    ans2 = x
print('{} {}'.format(ans1, ans2))

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

using namespace std;
const int dx[]={1,0,-1,0,1,-1,-1,1,0};
const int dy[]={0,1,0,-1,1,1,-1,-1,0};
const int INF = 1e9+101;
const long long LINF = 1e18;
const double EPS = 1e-8;
#define pb push_back
#define mk make_pair
#define fr first
#define sc second
#define reps(i,j,k) for(ll i = (j); i < (k); ++i)
#define rep(i,j) reps(i,0,j)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> Pii;
typedef pair<Pii,int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
template<class T>
ostream& operator<<(ostream &out, const vector<T> &v){
	out << "{";
	rep(i,v.size()){
		out << v[i] <<", ";
	}
	return out << "}" << endl;
}

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

    int dp[1024][1024] = {{}};
    rep(i,a.size()) {
        rep(j,b.size()){
            dp[i][j] = INF;
        }
    }

    rep(i,a.size()+1) dp[i][0] = i;
    rep(j,b.size()+1) dp[0][j] = j;

    reps(i,1,a.size()+1) { 
        reps(j,1,b.size()+1) {
            dp[i][j] = min(dp[i][j-1] + 1, min(dp[i-1][j] + 1, dp[i-1][j-1] + (int)(a[i-1]!=b[j-1])));
        }
    }

    cout << dp[a.size()][b.size()] << endl;

    return 0;  
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
#define sara ios_base::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
int LCS[3100][3100];
string s, t, tmp = "";
void solve(int n, int m){
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= m; j++){
            if(!i || !j)
                LCS[i][j] = 0;
            else if(s[i-1] == t[j-1])
                LCS[i][j] = LCS[i-1][j-1] + 1;
            else LCS[i][j] = max(LCS[i][j-1], LCS[i-1][j]);
        }
    }
}
string printLCS(int i, int j){
    if(!i || !j) return tmp;
    if(s[i-1] == t[j-1]) return printLCS(i-1, j-1) + s[i-1];
    else if(LCS[i][j-1] > LCS[i-1][j]) return printLCS(i, j-1);
    else return printLCS(i-1, j);
}

int main(){
    sara
    cin>> s>> t;
    solve(s.size(), t.size());
    cout<< printLCS(s.size(), t.size());
    return 0;
}


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

int main() {
  int n, ans = 64, c[101] = {0};

  cin >> n;
  while (true) {
    if (n < ans) {
      ans /= 2;
    }
    else {
      cout << ans << endl;
      return 0;
    }
  }
}

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

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

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

int N;
long long play[100010][3]; // play[i][j] = i日目の遊びjで得られる幸福度

long long dp[100010][3];

int main() {
    int N; cin >> N;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> play[i][j];
        }
    }

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (j == k) continue;
                chmax(dp[i+1][k], dp[i][j] + play[i][k]);
            }
        }
    }

    long long res = 0;
    for (int j = 0; j < 3; j++) {
        chmax(res, dp[N][j]);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4992
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;

int main() {
	int N;
	bool flag=false;
	cin >> N;
	vector<ll> A(300);
	REP(i,N){
		cin >> A[i];
		if(A[i]%2!=0) flag = true;
	}
	int cnt=0;
	while(!flag){
		REP(i,N) A[i] /= 2;
		REP(i,N) if(A[i] % 2 != 0) flag = true;
		cnt++;
	}
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 256
x = int(input())
if x < 4:
  print(1)
  exit()
import math
result = 1
for i in range(2,x+1):
  if math.floor(math.log(x,i)+1/100000) > 1:
    result = max(result, i ** math.floor(math.log(x,i)+1/100000))
  
print(result)


Measured memory_bytes: 3060
// practice with kaiboy
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	void main() {
		int x = sc.nextInt();
		int y = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		c += b += a;
		int[] aa = new int[c];
		for (int i = 0; i < c; i++)
			aa[i] = sc.nextInt();
		Arrays.sort(aa, 0, a);
		Arrays.sort(aa, a, b);
		for (int i = a - 1, j = b - y - 1; i >= a - x; i--, j--)
			aa[j] = aa[i];
		Arrays.sort(aa, b - x - y, c);
		long ans = 0;
		for (int i = c - 1; i >= c - x - y; i--)
			ans += aa[i];
		println(ans);
	}
}


Measured memory_bytes: 62540
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;

void main(){
	string s = readln.chomp;
	int n = s.length.to!int;
	
	int ans = 0;
	foreach(i; 0 .. n){
		if(i % 2){ // 自分はp
			if(s[i] == 'p') ans += 0; // pp
			else ans += 1; // pg
			}
		else{ // 自分はg
			if(s[i] == 'p') ans += -1; // gp
			else ans += 0; // gg
			}
		}
	
	ans.writeln;
	}

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

using namespace std;

const int MaxN = 300005;

struct SegmentTree
{
    vector<int> Val, Low, High, Leaf;
    void Build(int x, int Left, int Right)
    {
        Low[x] = Left;
        High[x] = Right;
        if (Left == Right)
        {
            Leaf[Left] = x;
            return;
        }
        int Mid = (Left + Right) / 2;
        Build(x * 2, Left, Mid);
        Build(x * 2 + 1, Mid + 1, Right);
    }
    void Update(int x, int Left, int Right, int val)
    {
        if(Low[x] > Right || High[x] < Left)
        {
            return;
        }
        if (Low[x] >= Left && High[x] <= Right)
        {
            Val[x] += val;
            return;
        }
        Update(x * 2, Left, Right, val);
        Update(x * 2 + 1, Left, Right, val);
    }
    int Get(int x)
    {
        x = Leaf[x];
        int Resuft = 0;
        while (x > 0)
        {
            Resuft += Val[x];
            x /= 2;
        }
        return Resuft;
    }
    void Init(int n)
    {
        Val.assign(n * 4 + 5, 0);
        Low.assign(n * 4 + 5, 0);
        High.assign(n * 4 + 5, 0);
        Leaf.assign(n + 5, 0);
        Build(1, 1, n);
    }
};

int n, m;
pair<int, int> a[MaxN];
int Resuft[MaxN];
SegmentTree ST;

bool cmp(pair<int, int> x, pair<int, int> y)
{
    return (x.second - x.first) > (y.second - y.first);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i].first >> a[i].second;
    }
    ST.Init(m);
    sort(a + 1, a + n + 1, cmp);
    int j = n;
    Resuft[1] = n;
    for (int i = 2; i <= m; i++)
    {
        while (a[j].second - a[j].first + 1 < i && j >= 1)
        {
            ST.Update(1, a[j].first, a[j].second, 1);
            j--;
        }
        Resuft[i] = j;
        for (int k = i; k <= m; k += i)
        {
            Resuft[i] += ST.Get(k);
        }
    }
    for (int i = 1; i <= m; i++)
    {
        cout << Resuft[i] << '\n';
    }
    
    return 0;
}


Measured memory_bytes: 8832
import java.util.*;

public class Main {
    public static void main(String[] args){
        //ArrayList<Integer> array = new ArrayList<Integer>();
        Scanner sc = new Scanner(System.in);
        while(true){
            int H = sc.nextInt();
            int W = sc.nextInt();
            if(H==0 && W==0){
                break;
            }
            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                    System.out.print("#");
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}



Measured memory_bytes: 36640
/*
Arthor : Ender_zzm
E-mail zzm_ender_wiggin@outlook.com
Blog ender-zzm.enbar.cn
*/
#include <bits/stdc++.h>
using namespace std;

inline int read(){
    register int x = 0, flag = 1;
    register char ch;
    while (!isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (x = x * 10 + (ch & 15), isdigit(ch = getchar()));
	return x * flag;
}

template <class T>
inline void write(T x){
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10); 
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define For(i, x, y) for (int i = (x); i <= (y); i++) 
#define Rep(i, x, y) for (int i = (x); i >= (y); i--) 

#define int long long
int n, k;
int a[202020],p[202020];
int Sum[202020];
signed main() {
	n = read();	 k = read();
	for (int i = 1; i <= n; i++) {
		a[i] = read();
	}
	for (int i = k + 1; i <= n; i++) {
		if (a[i] > a[i - k]) {
			puts("Yes");
		}
		else puts("No");
	}
	return 0;
}


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

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

using namespace std;

int main(){
	int n; cin>>n;
	int m;
	for(m=1;m*m<=n;m++);
	cout<<(m-1)*(m-1)<<'\n';

	return 0;
}


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

using namespace std;

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

int main(){
	ios::sync_with_stdio(false);
	double v;
	while (cin>>v){
		int N;
		for (N=2;;N++){
			double t;
			t=sqrt((5*N-5)/4.9);
			if (9.8*t>=v){
				break;
			}
		}
		cout<<N<<endl;
	}
	return 0;
}

Measured memory_bytes: 1228
require 'prime'
class Integer
  def divisor
    return [1] if self == 1
    pd=Prime.prime_division(self)
    first, *rest = pd.map do |p, k|
      (0..k).map{|i| p**i}
    end
    first.product(*rest).map do |a|
      a.inject(:*)
    end.sort
  end
end
io = STDIN
n=io.gets.to_i
div=n.divisor
size=div.size
if size.even?
  puts div[size/2-1]+div[size/2]-2
else
  puts div[size/2]*2-2
end


Measured memory_bytes: 2940
#include<iostream>
#include<cmath>

using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int at_t, at_a;
	at_t = ceil((float)c / b);
	at_a = ceil((float)a / d);
	if (at_t > at_a) {
		cout << "No\n";
	}
	else {
		cout << "Yes\n";
	}
}

Measured memory_bytes: 3192
s = input()
t = input()
set_ = set()
for i in s:
    set_.add(i)
for i in t:
    if i not in set_:print(-1);exit()
dic = [[0]*26 for _ in range(len(s))]
tmp = [[] for _ in range(26)]
for i in range(len(s)):
    tmp[ord(s[i])-ord('a')].append(i)
import bisect
for i in range(len(s)):
    for nxt in set_:
        idx = bisect.bisect_right(tmp[ord(nxt)-ord('a')],i)

        if idx==len(tmp[ord(nxt)-ord('a')]):
            dic[i][ord(nxt)-ord('a')] = tmp[ord(nxt)-ord('a')][0] + len(s)-i
            # idx = tmp[ord(nxt)-ord('a')][0]+len(s)
        else:
            dic[i][ord(nxt)-ord('a')] = tmp[ord(nxt)-ord('a')][idx]-i
cnt = tmp[ord(t[0])-ord('a')][0]
for i in range(1,len(t)):
    cnt += dic[cnt%len(s)][ord(t[i])-ord('a')]
print(cnt+1)

Measured memory_bytes: 104252
//diverta2019_c.cpp
//Sat May 11 20:39:46 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int n;
	cin >> n;
//	string s[n];
	int lasta = 0;
	int firstb = 0;
	int both = 0;
	int ans = 0;
	for (int i=0;i<n;i++){
		string s;
		cin >> s;
		for (int j=0;j<s.length()-1;j++){
			if (s[j]=='A' && s[j+1]=='B'){
				ans++;
			}
		}
		if (s[0] == 'B' && s[s.length()-1] == 'A'){
			both++;
		}else if (s[0] == 'B'){
			firstb++;
		}else if (s[s.length()-1] == 'A'){
			lasta++;
		}
	}
//	cout << ans << endl;
//	cout << firstb << " " << lasta << " " << both<< endl;

	int aandb = min(firstb,lasta);
	ans += 2*min(aandb,both);

	if (aandb>both){
		ans += aandb-both;
	}else {
		int temp = max(firstb,lasta)-aandb;
		ans += min(temp,both-aandb);
		if (both-aandb-temp>0){
			ans += both-aandb-temp;
			if (firstb == 0 && lasta == 0){
				ans--;
			}
		}
	}


	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define all(x) (x.begin()),(x.end())
#define sz(x)  ((ll)x.size())
#define FAST_IO ios_base :: sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
using namespace std;
#ifdef LOCAL
#include "uj.h"
#endif
void tokenize(string str,const char delim,vector<string> & res){
	stringstream p(str);
	string token;
	while(getline(p,token,delim)){
		res.push_back(token);
	}
	return;
}

// Your workSpace ...
const ll inf = 1e10;
const int maxn = 1e6;

void min_self(ll & a,ll b){
	a = min(a,b);
}
int N,W;
void test_case(){
	cin >> N >> W;
	
	// now the problem constraint has changed as weight is that much large that it can't be used as dimensions of dp
	// but we can change the defination of dp[i] so suite the problem now if we say that dp[i] represents min weight 
	// required to get value ith then note that the meaning is same in reverse way.. 
	
	// the transition remains same as case of weight... as we will be adding value instead of weight...
	
	vector<int> value(N),weight(N);
	ll tot_val = 0;
	for(int i = 0;i<N;++i){
		cin >> weight[i] >> value[i];
		tot_val += value[i];
	}
	
	vector<ll> dp(tot_val+1,inf);
	dp[0] = 0; // Base Case
	for(int items = 0;items < N;++items)
		for(int val = tot_val - value[items]; val >= 0; --val)
			min_self(dp[val+value[items]],dp[val] + weight[items]);
	
	ll ans = -1;
	for(int i = 0;i<=tot_val;++i)	
		if(dp[i] <= W) ans = max((ll)i,ans);
	
	//debug() << owo(value) << owo(weight) << owo(dp) << owo(tot_val);
	cout << ans;
	return;
}
	
	


	





int main(){
	FAST_IO;
	int tt;
	//cin>>tt;
	tt = 1;
	while(tt--){
		test_case();
	}
#ifndef ONLINE_JUDGE
 	cerr << "Running Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 3996
import math

X, K, D = list(map(int, input().split()))
X = abs(X)

if X - K*D >= 0:
    print(X - K*D)
    exit()

z_cnt = math.ceil(X/D)
if K%2 == z_cnt%2:
    print(math.ceil(X/D)*D-X)
else:
    print(X - (math.ceil(X / D)-1) * D)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string op;
  cin >> N;
  for (int i = 0; i < N; i++) {
  cin >> op;
  if (op == "Y") {
    cout << "Four" << endl;
    break;
  }
  }
 if (op != "Y") {
   cout << "Three" << endl;
 }
}

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

#define mem(arr,x) memset(arr,x,sizeof(arr))
#define pb push_back
#define ll long long
#define mp make_pair
#define rep(i,n)  for(ll i=0;i<n;i++)
#define repi(i,n)  for(ll i=1;i<=n;i++)
#define all(x)   (x.begin(),x.end())

const double PI = 3.1415926535897932;
const int mod = 1e9 + 7;  
const int inf = 1e9 + 5;

int max(int a,int b)
{
	if(a>b)
	return a;
	return b;
}
char c[1005][1005];
int dp[1005][1005];
int main()
{
	
ios_base::sync_with_stdio(false);
cin.tie(0);
int n,m;
cin>>n>>m;
//char c[n][m];
for(int i=1;i<=n;i++)
{
	for(int j=1;j<=m;j++)
		cin>>c[i][j];
}
for(int i=1;i<=n;i++)
{
	for(int j=1;j<=m;j++)
	{    if(i==1 && j==1)
		 {  dp[i][j]=1;
		 }
			else if(c[i][j]=='.')
			dp[i][j]=(dp[i][j-1]+dp[i-1][j])%mod;
	}
}
cout<<dp[n][m]<<'\n';
}

Measured memory_bytes: 8456
#include <stdio.h>
long long resi (long long h)
{
	if(h<2) return h;
	return resi(h/2)*2+1;
}
int main()
{
	long long h;
	scanf("%lld",&h);
	printf("%lld",resi(h));
	/*long long h;
	scanf("%lld",&h);
	long long dp[h+1];
	dp[0]=0;
	dp[1]=1;
	for(int i=2;i<=h;i++)
	{
		dp[i]=dp[i/2]*2+1;
	}
	printf("%lld",dp[h]);*/
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
typedef long double LD;
typedef pair<int, int> P;

const int MOD = 1e9 + 7;
const int INF = 1 << 30;
const int MAXN = 50;

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

	int N, M;
	cin >> N >> M;

	bool n[MAXN][MAXN], m[MAXN][MAXN];
	string S;
	for (int i = 0; i < N; i++) {
		cin >> S;
		for (int j = 0; j < S.length(); j++) n[i][j] = (S[j] == '#');
	}
	for (int i = 0; i < M; i++) {
		cin >> S;
		for (int j = 0; j < S.length(); j++) m[i][j] = (S[j] == '#');
	}

	bool res = false;
	for (int i = 0; i <= N - M; i++) {
		for (int j = 0; j <= N - M; j++) {
			res = true;
			for (int k = 0; k < M; k++) {
				for (int l = 0; l < M; l++) {
					if (n[i+k][j+l] != m[k][l]) {
						res = false;
						break;
					}
				}
				if (!res) break;
			}
			if (res) break;
		}
		if (res) break;
	}

	cout << (res?"Yes":"No") << endl;
	return 0;
}

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

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

  int n = s.size() + 1;
  int a[n];
  for (int j = 0; j < n; j++){
    a[j] = 0;
  }
  int i = 0;

  while (i < n - 1){
    if (s.at(i) == '<'){
      a[i] = 0;
      int j = 0;
      while (i + j < n - 1){
        if (s.at(i + j) == '<'){
          a[i + j + 1] = j + 1;
          j++;
        }else break;
      }
      i += j;
    }else{
      int j = 0;
      while (i + j < n - 1){
        if (s.at(i + j) == '>'){
          j++;
        }else break;
      }
      a[i] = max(a[i], j);
      for (int k = 1; k <= j; k++){
        a[i + k] = j - k;
      }
      i += j;
    }
  }

  long long ans = 0;
  for (int j = 0; j < n; j++){
    ans += a[j];
  }
  cout << ans << endl;
}

Measured memory_bytes: 2820
A=input()
S=[]
for i in A:
    S.append(int(i))

ans_1=0
ans_2=0
for i in range(1,len(S)+1):
    if i%2!=0:
        if S[i-1]!=0:
            ans_1+=1
    else:
        if S[i-1]==0:
            ans_1+=1
        

for i in range(1,len(S)+1):
    if i%2!=0:
        if S[i-1]!=1:
            ans_2+=1
    else:
        if S[i-1]==1:
            ans_2+=1

print(min(ans_1,ans_2))

Measured memory_bytes: 3956
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


class DisjointSet{
    public:
        vector<int> rank,p;

        DisjointSet(){}
        DisjointSet(int size){
            rank.resize(size,0);
            p.resize(size,0);
            rep(i,size) makeSet(i);
        }

        void makeSet(int x){
            p[x] = x;
            rank[x] = 0;
        }

        bool same(int x, int y){
            return findSet(x) == findSet(y);
        }

        void unite(int x, int y){
            link(findSet(x),findSet(y));
        }

        void link(int x, int y){
            if(rank[x] > rank[y]){
                p[y] = x;
            }
            else{
                p[x] = y;
                if(rank[x] == rank[y]) rank[y]++;
            } 
        }
        int findSet(int x){
            if(x != p[x]){
                p[x] = findSet(p[x]);
            }
            return p[x];
        }

};

int main(){
  int N,M; cin >> N >> M;
  DisjointSet T(N);
  rep(i,M){
    int x,y,z;
    cin >> x >> y >> z;
    x--; y--;
    T.unite(x,y);
  }
  int ans = 0;
  rep(i,N){
    if(T.findSet(i) == i) ans++;
  }
  cout << ans << endl;
}


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

typedef long long ll;
using namespace std;

template<typename T>
struct BinaryIndexedTree {
    vector<T> data;

    BinaryIndexedTree(int sz) {
        data.assign(++sz, 0);
    }

    T sum(int k) {
        T ret = 0;
        for (++k; k > 0; k -= k & -k) ret += data[k];
        return (ret);
    }

    void add(int k, T x) {
        for (++k; k < data.size(); k += k & -k) data[k] += x;
    }

    int search_small(int index) {
        int x = sum(index);

        int ok = -1;
        int ng = index;
        while (abs(ok - ng) > 1) {
            int mid = ok + (ng - ok) / 2;

            if (sum(mid) < x)ok = mid;
            else ng = mid;
        }

        return ok;
    }

    int search_big(int index) {
        int x = sum(index);

        int ok = data.size() - 1;
        int ng = index;
        while (abs(ok - ng) > 1) {
            int mid = ok + (ng - ok) / 2;
            int count = sum(mid);
            if (count > x)ok = mid;
            else ng = mid;
        }

        return ok;
    }

    void print() {
        for (int i = 0; i < data.size(); i++) {
            if (i > 0)cout << " ";
            cout << sum(i);
        }
        cout << endl;
    }
};

int main() {
    int n;
    cin >> n;
    vector<int> pos(n + 1);
    for (int i = 1; i <= n; i++) {
        int tmp;
        cin >> tmp;
        pos[tmp] = i;
    }

    BinaryIndexedTree<int> bit(n + 1);
    ll ret = 0;
    for (int i = n; i >= 1; i--) {
        int nowpos = pos[i];
        ll s1 = bit.search_small(nowpos);
        ll s2 = bit.search_small(s1);
        ll b1 = bit.search_big(nowpos);
        ll b2 = bit.search_big(b1);

        ll cases = 0;
        if (s1 != -1)cases += (s1 - s2) * (b1 - nowpos);
        if (b1 != n + 1)cases += (nowpos - (s1 + 1)) * (b2 - b1);
        ret += i * cases;
        bit.add(nowpos, 1);
    }

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

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top,S[1000];

void push(int x){
  S[++top] = x;
}

int pop(){
  top--;
  return S[top+1];
}

int main(){
  int a,b;
  top = 0;
  char s[100];
  while(scanf("%s",s) != EOF){
    if(s[0] == '+'){
      a = pop();
      b = pop();
      push(a+b);
    }else if(s[0] == '-'){
      b = pop();
      a = pop();
      push(a-b);
    }else if(s[0] == '*'){
      a = pop();
      b = pop();
      push(a*b);
    }else{
      push(atoi(s));
    }
  }
  printf("%d\n",pop());
  return 0;
}



Measured memory_bytes: 2120
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	S := getString()
	Q := getInt()
	s := make([]byte, len(S)+2*Q)
	for i := 0; i < len(S); i++ {
		s[i+Q] = S[i]
	}
	l := Q - 1
	r := len(S) + Q
	flg := false
	for i := 0; i < Q; i++ {
		t := getInt()
		if t == 1 {
			flg = !flg
		} else {
			f, c := getInt(), getString()[0]
			if f == 1 {
				if !flg {
					s[l] = byte(c)
					l--
				} else {
					s[r] = byte(c)
					r++
				}
			} else {
				if flg {
					s[l] = byte(c)
					l--
				} else {
					s[r] = byte(c)
					r++
				}

			}
		}
	}

	l++
	r--

	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	if !flg {
		for i := l; i <= r; i++ {
			fmt.Fprint(w, string(s[i]))
		}
		fmt.Fprintln(w)
	} else {
		for i := r; i >= l; i-- {
			fmt.Fprint(w, string(s[i]))
		}
		fmt.Fprintln(w)
	}
}


Measured memory_bytes: 5632
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp5
{
    class Program
    {

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int G = N / 100;
            int A = N % 100;
            int B;
            if(A % 5 == 0)
            {
                B = A / 5;
            }
            else
            {
                B = A / 5 + 1;
            }

            if(B <= G)
            {
                Console.WriteLine("1");
            }
            else
            {
                Console.WriteLine("0");
            }
            
            

        }
    }
}

Measured memory_bytes: 11092
#include <iostream>

using namespace std;

int main()
{
	int res[4]={};
	for(int a,b,c;cin>>a>>b>>c;){
		if(a>b) swap(a,b);
		if(b>c) swap(b,c);
		if(a>b) swap(a,b);
		
		if(a+b<=c) break;
		res[0]++;
		if(a*a+b*b==c*c) res[1]++;
		if(a*a+b*b>c*c)  res[2]++;
		if(a*a+b*b<c*c)  res[3]++;
	}
	for(int i=0;i<4;i++)
		cout<<res[i]<<(i<3?' ':'\n');
	
	return 0;
}

Measured memory_bytes: 1156
#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

using vll = vector<ll>;

void solve();

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

  solve();

  return 0;
}

#define ini(...)   \
  int __VA_ARGS__; \
  in(__VA_ARGS__)

#define inl(...)  \
  ll __VA_ARGS__; \
  in(__VA_ARGS__)

#define ins(...)      \
  string __VA_ARGS__; \
  in(__VA_ARGS__);

void in() {}
template <typename T, class... U>
void in(T& t, U&... u) {
  cin >> t;
  in(u...);
}

void out() {
  cout << endl;
}
template <typename T, class... U>
void out(const T& t, const U&... u) {
  cout << t;
  if (sizeof...(u))
    cout << " ";
  out(u...);
}

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

void solve();
#ifndef ONLINE_JUDGE
#include "./lib.hpp"
#endif

void solve() {
    ini(N, M);
    vector<string> A(N), B(M);
    rep(i, N) cin >> A[i];
    rep(i, M) cin >> B[i];

    rep(i, N - M + 1) {
        rep(j, N - M + 1) {
            bool same = true;
            rep(k, M)
                same = same && A[i + k].substr(j, M) == B[k];
            if (same) {
                out("Yes");
                return;
            }
        }
    }

    out("No");
}


Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define MOD 1e9 + 7
#define INF 1e9
#define SENTINEsL 2e9
#define PIE 3.1415a926535

template <class T>
inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}
template <class T>
inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template <class T>
inline T GCD(T a, T b){if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) {return (a * b) / GCD(a, b);}

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> v(n);
    int sum = 0;
    int ac = 0;
    rep(i, n) cin >> v[i], sum += v[i];
    rep(i, n) {
        if (v[i] < (double)sum / (4 * m)) continue;
        else
            ac++;
    }
    if (ac >= m)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define rep(i,n) for(int (i)=0; (i) < (n); (i)++)
#define rep2(i,j,n) for(int (i)=(j); (i) < (n); (i)++)
int h, x[10][5];
void input(){
    rep(i,h) rep(j,5){
        scanf("%d",&x[i][j]);
    }
}
int cal(){
    int chain, flag, score=0;
    while(1){
        flag=0;
        for(int i=h-1; i>-1; i--){//i列目の連鎖
            for(int j=0; j<3; j++){
                chain=1;
                for(int k=j+1; k<5; k++){
                    if(x[i][j]!=-1 && x[i][j]==x[i][k]) chain++;
                    else break;
                }
                if(chain>2){
                    flag=1; score+=x[i][j]*chain;
                    for(int k=j; k<j+chain; k++){
                        x[i][k]=-1;
                    }
                    break;
                }
            }
        }
        if(flag==0)break;
        
        for(int i=h-1; i>0; i--){
            for(int j=0; j<5; j++){
                for(int k=i-1; k>=0; k--){
                    if(x[i][j]==-1 ) {if(x[k][j]!=-1){
                        x[i][j]=x[k][j];
                        x[k][j]=-1;
                    }}
                    else break;
                }
            }
        }
        
        /*rep(i,h) {
            rep(j,5){
                printf("%2d ",x[i][j]);
            }
            puts("");
        }puts("");*/
    }
    return score;
}
int main(void){
    int score=0;
    while(1){
        scanf("%d",&h);
        if(h==0) break;
        input();
        /*printf("入力\n");
        rep(i,h) {
            rep(j,5){
                printf("%2d ",x[i][j]);
            }
            puts("");
        }puts("");*/
        printf("%d\n",cal());
    }
    return 0;
}



Measured memory_bytes: 2028
def price_list(number, tax)
  (1..1000).map do |i|
    i if (tax * i).floor == number
  end.compact
end

a, b = gets.split(' ').map(&:to_i)

a_result = price_list(a, 0.08)
b_result = price_list(b, 0.10)

result = a_result & b_result

if result.empty? then
  puts '-1'
else
  puts result.min
end

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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PI acos(-1.0)
#define sq(n) ((n)*(n))

using namespace std;
typedef long long ll;

int main() {
    FAST;

    int n, i;
    cin >> n;

    vector<int> h(n), dp(n);
    for (i = 0; i < n; ++i) cin >> h[i];

    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);

    for (i = 2; i < n; ++i) {
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
    }

    cout << dp[n-1] << "\n";

    return 0;
}


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

int main(int argc, const char * argv[]) {
    // insert code here...
    string s;
    cin >> s;
    string res;
    for (int i = 0; i < s.size(); i ++) {
        if (i % 2 == 0) {
            res += s.at(i);
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


int main(void) {
  ll i, j, k;
  
  ll H, W;
  cin >> H >> W;
  
  if(H==1||W==1) {
    pt(1);
  }else {
    pt(H*W-H*W/2);
  }
  
  
  
  
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);
            int iT = int.Parse(sS[1]);
            List<int> lstC = new List<int>();
            for (int i = 0; i < iN; i++)
            {
                sS = System.Console.ReadLine().Trim().Split(' ');
                if (int.Parse(sS[1]) <= iT) { lstC.Add(int.Parse(sS[0])); }     // 指定時間内
            }

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

            // 解析
            string sOut = "TLE";
            if (lstC.Count > 0) { lstC.Sort(); sOut = lstC[0].ToString(); }

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

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

}


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

int main() {
    int k, a, b;
    scanf("%d%d%d", &k, &a, &b);
    int i = 0;
    while (i < 2000) {
        i += k;
        if (a <= i && i <= b) {
            puts("OK");
            return 0;
        }
    }
    puts("NG");
}


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

int main()
{
    int n, k, s;
    cin >> n >> k >> s;
    rep(i, k) {
        cout << s << endl;
    }
    if(s != 1) {
        rep(i, n - k) {
            cout << s - 1 << endl;
        }
    }
    else {
        rep(i, n - k) {
            cout << s + 1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3576