akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

struct S {
    int y, x;
    int d2() const {
        return y * y + x * x;
    }
    S(int y, int x) : y(y), x(x) {}
    bool operator<(const S &b) const {
        S a = (*this);
        int da = a.d2();
        int db = b.d2();
        if (da == db) return a.y < b.y;
        return da < db;
    }
};


ostream& operator<<(ostream& os, S a) {
    os << a.y << " " << a.x;
    return os;
}

int main() {
    int h, w;
    while (cin >> h >> w, h || w) {
        S s(h, w);
        S ans = S(1000, 1000);
        for (int h1 = 1; h1 <= 150; h1++) {
            for (int w1 = 1; w1 <= 150; w1++) {
                if (h1 >= w1) continue;
                S c(h1, w1);
                if (s < c) {
                    ans = min(ans, c);
                }
            }
        }
        cout << ans << endl;
    }
}

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

typedef long long ll;
ll MOD = 1000000007;


int main()
{
    ll S, a, b;
    cin >> S;
    
    b = (S-1)/1000000000 + 1;
    a = (b*1000000000) - S;

    cout << 0 << " " << 0 << " " << 1000000000 << " " << 1 << " " << a << " " << b << endl;

    return 0;
}


Measured memory_bytes: 256
K = int(input())
ans = [10**16]
c = 10**15-1
s = 10**15

for i in range(12,0,-1):
    c = 10**i - 1
    for j in range(999,99,-1):
        C = j * (10**i) + c
        S = C/sum(list(map(int, str(C))))
        if S <= s:
            ans.append(C)
            s = S
for i in range(1,10):
    ans += [i,i*10+9,i*100+99]
ans.sort()    
if K > len(ans):
    K = len(ans)
for i in range(K):
    print(ans[i])

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

int n, d;
map <int, int> m;

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> d;
		m[d]++;
	}
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> d;
		if (m[d] == 0) 
		{
			cout << "NO";
			return 0;
		}
		m[d]--;
	}
	cout << "YES";
	return 0;
}

Measured memory_bytes: 9600
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)
from heapq import heappush, heappop

def input():
    return sys.stdin.readline().strip()

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def rangeI(it, l, r):
    for i, e in enumerate(it):
        if l <= i < r:
            yield e
        elif l >= r:
            break

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

INF = 999999999999999999999999
MOD = 10**9+7

n = int(input())
S = [ input() for _ in range(n)]

left = 0
right = 0

l_ok = [False] * n
r_ok = [False] * n
lmr = [0] * n
min_lmr = [INF] * n

for i,s in enumerate(S):
    l = 0
    r = 0
    lok = True
    for j,c in enumerate(s):
        if c == "(":
            l += 1
        else:
            r += 1
            if r > l:
                lok = False
            min_lmr[i] = min(min_lmr[i], l-r)
    lmr[i] = l - r
    l = 0
    r = 0
    rok = True
    for j in range(len(s)-1, -1, -1):
        if s[j] == "(":
            l += 1
            if l > r:
                rok = False
                break
        else:
            r += 1

    left += s.count("(")
    right += s.count(")")

    l_ok[i] = lok
    r_ok[i] = rok

# log(l_ok)
# log(r_ok)

if left != right:
    print("No")
    exit()

strs = []

# LeftOKを並べる
for i in range(n):
    if l_ok[i]:
        strs.append(S[i])

# LeftもRightもだめなやつをminL-Rが多い順に並べる
ngs = []
for i in range(n):
    if not l_ok[i] and not r_ok[i]:
        # ngs.append((-1 * min_lmr[i], -1 * lmr[i], i))
        ngs.append((-1 * (min_lmr[i] + lmr[i]), i))

ngs.sort()

for ng in ngs:
    strs.append(S[ng[1]])

# RightOKを並べる
for i in range(n):
    if r_ok[i] and not l_ok[i]:
        strs.append(S[i])

# log(ngs)
# log(min_lmr)
# log("".join(strs))

l = 0
r = 0
for s in strs:
    for j,c in enumerate(s):
        if c == "(":
            l += 1
        else:
            r += 1
            if r > l:
                print("No")
                exit()
print("Yes")


Measured memory_bytes: 207196
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;


//始点全て試す bfs 
vector<string> field(25);
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
ll H, W;

ll bfs(int h, int w){
  Vs fi = field;
  if(fi[h][w] == '#') return -1;
  int d[25][25];
  rep(i, 0, 25) rep(j, 0, 25) d[i][j] = -1;
  d[h][w] = 0;
  queue<pair<int, int>> qu;
  qu.push(make_pair(h, w));
  while(!qu.empty()){
    pair<int, int> u = qu.front(); qu.pop();
    fi[u.first][u.second] = '#';
    rep(i, 0, 4){
      int y = u.first+dy[i], x = u.second+dx[i];
      if(y<0 || y>=H || x<0 || x>=W) continue;
      if(fi[y][x] == '#') continue;
      d[y][x] = d[u.first][u.second] + 1;
      fi[y][x] = '#';
      qu.push(make_pair(y, x));
    }
  }
  int res = -1;
  rep(i, 0, H) rep(j, 0, W) res = max(res, d[i][j]);
  return res;
}

int main() {
  cin >> H >> W;
  rep(i, 0, H){
    cin >> field[i];
  }

  ll ans = -1;
  rep(i, 0, H){
    rep(j, 0, W){
      ans = max(ans, bfs(i, j));
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
//pbds
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

using ll = long long;
using pii = pair<int,int>;
 
#define NL '\n'
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define sz(x) x.size()
#define pi  acos(-1.0)
#define INF 0x3f3f3f3f
#define LINF 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(), (x).end()
#define mem(a, b) memset(a, b, sizeof(a))
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;++i)
#define fastIO() ios_base::sync_with_stdio(0),cin.tie(NULL)
 

#define faye_valentine 
void dbg(){cerr<<NL;}template<typename H,typename... T> void dbg(H h,T... t){cerr<<' '<<h;dbg(t... );}
#ifdef  faye_valentine
#define debug(...) cerr<<"("<<#__VA_ARGS__<<"):",dbg(__VA_ARGS__)
#else
#define debug(...) 
#endif
 
 
 
void absinthe(){
	int x, n; cin >> x >> n;
	set<int> os; 
	int mx, mn;
	rep(i,0,n) {
		int k; 
		cin >> k; 
		os.insert(k);
	}
	for(int l = x; l <= 200; l++) {
		if(os.find(l) == os.end()) {
			mx = l;
			break;
		}
	}
	for(int l = x; l >= -100; l--) {
		if(os.find(l) == os.end()) {
			mn = l;
			break;
		}	
	}
	if(abs(x-mn) <= abs(x-mx)) cout << mn <<  NL;
	else cout << mx << NL;
}
 
int main(){
	int Tx = 1; //read(Tx);  
	fastIO(); // cin >> Tx;
	while(Tx--) absinthe();
}

Measured memory_bytes: 3664
while 1:
    a, op, b = input().split()
    if op == '?':
        break
    a = int(a)
    b = int(b)
    if op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)    
    elif op == '*':
        print(a * b)
    elif op == '/':
        print(a // b)

Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

const ll mod=1e9+7;
ll mu(ll a,ll b){
  return (ll)a*b%mod;
}
ll ad(ll a,ll b){
  if((a+=b)>=mod)a-=mod;
  return a;
}
ll pw(ll a,ll b,ll c=1LL){
  for(;b;b>>=1,a=mu(a,a))if(b&1)c=mu(c,a);
  return c;
}
ll dv(ll a,ll b){
  return mu(a,pw(b,mod-2));
}


map<ll, int> prime_factor(ll n){
  map<ll, int> ret;
  for(ll i=2; i*i<= n; i++){
    while(n%i==0){
      ret[i]++;
      n/=i;
      //      cout << i << endl;
    }
  }
  if(n!=1) ret[n]=1;
  return ret;
}

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

  ll n,m;
  cin >> n >> m;
  auto mp=prime_factor(m);
  const ll nmax=1e5+1e2;
  ll kai[nmax];
  kai[0]=1;
  rep1(i,nmax-1) kai[i]=mu(kai[i-1],i);
  ll inv[nmax];
  rep(i,nmax) inv[i] = dv(1,kai[i]);
  ll ans=1;
  for(auto i:mp){
    ll num=i.first;
    ll cou=i.second;
    // しきりn-1 ボールcou個 n-1+cou C cou
    ans = mu(ans, mu(mu(kai[n-1+cou],inv[cou]),inv[n-1]));
  }

  cout << ans << endl;
  
  return 0;
    

}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <algorithm>
#include <cassert>

using namespace std;

const int N = 30;
int n, m;
int a[N];
int b[N];

void solve()
{
	memset(a, 0, sizeof a);
	a[0] = n;
	int c;
	for(c = 0; a[m] == 0; ++ c) {
		memset(b, 0, sizeof b);
		for(int i = 0; i <= m; ++ i) {
			b[0] += a[i] / 2;
			b[i + 1] += a[i] / 2;
			b[i] += a[i] & 1;
		}
		for(int i = 0; i <= m; ++ i) {
			a[i] = b[i];
		}
	}
	cout << c << endl;
}

int main()
{
	int test = 0;
	for( ; cin >> n >> m && (n || m); ) {
		printf("Case %d: ", ++ test);
		solve();
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    int n;

	cin >> n;

	if (n < 1200) Out("ABC");
	else if (n < 2800) Out("ARC");
	else Out("AGC");
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N;
    cin>>N;
    ll ans=100000;
    rep(i,1,N){
        ll res=0;
        ll j=i,k=N-i;
        while(j>0){
            res+=j%10;
            j/=10;
        }
        while(k>0){
            res+=k%10;
            k/=10;
        }
        ans=min(ans,res);
    }
    cout <<ans<<"\n";
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 200005
#define INF 2147483647

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

int n;
int dat[1<<19];

//配列、木:0オリジン
//n_:元の数列の要素数
//n:修正後の配列要素数 木のサイズ:2*n-1
void init(int n_){
	n=1;
	while(n<n_)n*=2;
	for(int i=0;i<2*n-1;i++)dat[i]=INF;
}

void update(int i,ll x){
	i += n-1;
	dat[i] = x;
	while(i>0){
		i = (i-1)/2;
		dat[i] = min(dat[i*2+1],dat[i*2+2]);
	}
}

//[a,b)のmin 節点k[l,r)について調べる
int find(int a,int b,int k,int l,int r){
	if(r<=a || b<=l){
		return INF;
	}else if(a<=l && r<=b){
		return dat[k];
	}else{
		ll v1 = find(a,b,2*k+1,l,(l+r)/2);
		ll v2 = find(a,b,2*k+2,(l+r)/2,r);
		return min(v1,v2);
	}
}

int main()
{
	int q,m;
	scanf("%d %d",&m,&q);
	init(m);
	int com,x;
	ll y;
	for(int i=0;i<q;i++){
		scanf("%d%d%d",&com,&x,&y);
		if(com==0){
			update(x,y);
		}else{
			printf("%d\n",find(x,y+1,0,0,n));
		}
	}
	return 0;
}



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

int main() {
  int n; cin >> n;
  int num = n%10;
  if(num == 3) cout << "bon" << endl;
  else if(num == 0 || num == 1 || num == 6 || num == 8) cout << "pon" << endl;
  else cout << "hon" << endl;
}

Measured memory_bytes: 3508
#include<iostream>
using namespace std;
 
int main(){
	char b;
	cin >> b;
	char A,T,G,C,ans;
	if(b == 'A')ans = 'T';
	if(b == 'T')ans = 'A';
	if(b == 'C')ans = 'G';
	if(b == 'G')ans = 'C';
	cout << ans;
	return 0;
}


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

int main()
{
    string s;
    int k;
    cin >> k;
    cin >> s;
    if(s.length()>k)
    {
        for(int i=0 ; i<k ; i++)
        {
            cout << s[i];
        }
        cout << "...";
    }
    else
        cout << s;
    return 0;
}


Measured memory_bytes: 3624
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000
typedef long long ll;

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

map<vector<string>, int> m; // すでに探索済みかを確かめる

// カードをremoveした後シフトする
vector<string> shift(vector<string> s) {
    string ss;
    for (int y = 0; y < 5; y++) {
        for (int x = 0; x < 4; x++) {
            if (s[y][x] != '*') ss += s[y].substr(x, 1);
        }
    }
    for (int y = 0; y < 5; y++) {
        for (int x = 0; x < 4; x++) {
            if (4*y + x < ss.size()) {
                s[y][x] = ss[4*y+x];
            } else {
                s[y][x] = '*';
            }
        }
    }
    return s;
}

// sはカードの並び
int dfs(vector<string> s) {
    if (m.find(s) != m.end()) return m[s];
    int ret = 0;
    // 今のカードの枚数をチェック
    // これがretの最高値
    for (int y = 0; y < 5; y++) {
        for (int x = 0; x < 4; x++) {
            if (s[y][x] != '*') ret++;
        }
    }
//    cout << "ret:" << ret << endl;
    for (int y = 0; y < 5; y++) {
        for (int x = 0; x < 4; x++) {
            if (s[y][x] == '*') continue;
            for (int i = 0; i < 8; i++) {
                int nx = x + dx[i];
                int ny = y + dy[i];
                if (0 <= nx && nx < 4 && 0 <= ny && ny < 5 && s[y][x] == s[ny][nx]) {
                    vector<string> ss;
                    ss = s;
                    ss[y][x] = ss[ny][nx] = '*';
                    ss = shift(ss);
                    ret = min(ret, dfs(ss));
                }
            }
        }
    }
    m.insert(map<vector<string>, int>::value_type(s, ret));
    return ret;
}

int main(void) {
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        m.clear();
        vector<string> s;
        for (int y = 0; y < 5; y++) {
            string c;
            for (int x = 0; x < 4; x++) {
                char ch;
                cin >> ch;
                c.push_back(ch);
            }
            s.push_back(c);
        }
        cout << dfs(s) << endl;
    }
    return 0;
}

Measured memory_bytes: 1496
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include <numeric>
using namespace std;
const long long int mod=1000000007;
int main(void) {
	long long int i,N,go=1,ans=1;
	long long int x[100005];
	scanf("%lld", &N);
	for (i = 0; i < N; i++) {
		scanf("%lld", &x[i]);
	}
	//i番目がゴールする必要十分条件
	//i-1までのjについて2j+1<=x[j]
	//2i<=x[i]
	for (i = 0; i < N; i++) {
		while (go<N&&(2*(go-1-i)<x[go-1])&& (2 * (go- i)<=x[go])) {
			go++;
		}

		ans *= go - i;
		ans %= mod;
	}
	printf("%lld", ans);
	return 0;
}

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

struct Card {
  char suit;
  int value;
};

void trace(const vector<Card>& a) {
  for (int i = 0; i < a.size(); i++) {
    cout << a[i].suit << a[i].value << ((i != a.size() - 1)? " " : "");
  }
  cout << endl;
}

bool is_stable(const vector<Card>& in, const vector<Card>& out) {
  for (int i = 0; i < in.size(); i++) {
    if (in[i].value != out[i].value || in[i].suit != out[i].suit) return false;
  }
  return true;
}

vector<Card> bubble_sort(vector<Card> c, int n) {
  for (int i = 0; i < n; i++) {
    for (int j = n - 1; j > i; j--) {
      if (c[j].value < c[j - 1].value) swap(c[j], c[j - 1]);
    }
  }
  return c;
}

vector<Card> selection_sort(vector<Card> c, int n) {
  for (int i = 0; i < n; i++) {
    int minj = i;
    for (int j = i; j < n; j++) {
      if (c[j].value < c[minj].value) minj = j;
    }
    swap(c[i], c[minj]);
  }
  return c;
}

int main() {
  int n;
  cin >> n;
  vector<Card> v(n);
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    v[i].suit = s[0];
    v[i].value = s[1] - '0';
  }
  auto v1 = bubble_sort(v, n);
  trace(v1);
  cout << "Stable" << endl;
  auto v2 = selection_sort(v, n);
  trace(v2);
  if (is_stable(v1, v2)) cout << "Stable" << endl;
  else cout << "Not stable" << endl;
}



Measured memory_bytes: 3208
def main():
    n, m = map(int, input().split())
    h = list(map(int, input().split()))
    ab = [list(map(int, input().split())) for _ in [0]*m]
    g = [[] for _ in [0]*n]
    [g[a-1].append(b-1) for a, b in ab]
    [g[b-1].append(a-1) for a, b in ab]

    cnt = 0
    for i in range(n):
        hh = h[i]
        for j in g[i]:
            if h[j] >= hh:
                break
        else:
            cnt += 1
    print(cnt)


main()

Measured memory_bytes: 111172
n = int(input())
queries = [list(map(int, input().split())) for i in range(n)]

s, t = 1, 0
for q in queries:
    if q[0] == 1:
        s *= q[1]
        t *= q[1]
    elif q[0] == 2:
        t += q[1]
    else:
        t -= q[1]
print(-t, s)


Measured memory_bytes: 5604
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

int main()
{
    int n, l;
    cin >> n >> l;

    string str;
    map <string, int> mp;
    for(int i = 0; i < n; i ++)
    {
    	cin >> str;
    	mp[str] ++;
    }

    for(auto it = mp.begin(); it != mp.end(); it ++)
    {
    	while(it -> second > 0)
    	{
    		cout << it -> first;
    		it -> second --;
    	}
    }
}

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

NUM = 1/(4*M)
count = 0
A_s = sum(A)
NUM = NUM * A_s
for i in range(0,N):
  if(A[i] >= NUM):
    count+= 1
if(count >= M):
  print("Yes")
else:
  print("No")

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

int main() {
    ll x;
    cin >> x;
    double z=2*x;
    z = sqrt(z);
    ll y=z;
    for(ll i =y-1 ; i < y+2; i++) {
        if(i*(i+1)/2>=x){
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999999999999
#define rep(i,m,n) for(lli i = m;i < n;i++)
#define rrep(i,m,n) for(lli i=m-1;i>=n;i--)
#define pb(n) push_back(n)
#define UE(N) N.erase(unique(N.begin(),N.end()),N.end());
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(25) << S << endl
#define Vec(K,L,N,S) vector<L> K(N,S)
#define DV(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define TV(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define MAX 5100000
#define ALL(a)  a.begin(),a.end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli A,B,C,D,E,F,N,M,K,L,R,X,Y,Z,W,H,sum=0,num=0,flag=0;string S,T;
  cin >> N;
  vector<lli> G={3,5,7};
  queue<lli> que;
  que.push(3);
  que.push(5);
  que.push(7);
  while(!que.empty()){
    auto v=que.front();que.pop();
    if(v*10+3<=N){
      G.pb(v*10+3);
      que.push(v*10+3);
    }
    if(v*10+5<=N){
      G.pb(v*10+5);
      que.push(v*10+5);
    }
    if(v*10+7<=N){
      G.pb(v*10+7);
      que.push(v*10+7);
    }
  }
  for(auto v:G){
    S=to_string(v);
    if(S.find('3')!=string::npos&&S.find('5')!=string::npos&&S.find('7')!=string::npos)sum++;
  }
  Out(sum);
}

Measured memory_bytes: 896
#include <stdio.h>

int main(void)
{
    int h, w;
    int count, delrow=0, flag = 0;
    char table[100][100], buf[100];

    scanf("%d %d", &h, &w);
    getchar();
    for(int i=0; i<h; i++)
    {
        scanf("%s", buf);
        for(int j=0; j<w; j++)
            table[i][j] = buf[j];
    }

    for(int i=0; i<h; i++)
    {
        count = 0;
        for(int j=0; j<w; j++)
        {
            if(table[i][j] == '.')
                count++;
        }
        if(count == w)
        {
            delrow++;
            for(int j=0; j<w; j++)
                table[i][j] = 'x';
        }
    }
    for(int j=0; j<w; j++)
    {
        count = 0;
        for(int i=0; i<h; i++)
        {
            if(table[i][j] == '.')
                count++;
        }
        if(count == h-delrow)
            for(int i=0; i<h; i++)
                table[i][j] = 'x';
    }
    for(int i=0; i<h; i++)
    {
        count = 0;
        for(int j=0; j<w; j++)
        {
            if(table[i][j] != 'x')
                printf("%c", table[i][j]);
            else
                count++;
        }
        if(count != w)
            putchar('\n');
    }

    return 0;
}

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

int main(){
  int N;
  cin >> N;
  
  vector<int> H(N);
  for (int i = 0; i < N; i++) {
    cin >> H.at(i);
  }
  
  int ans = 0;
  
  if (N == 1) {
    ans = 1;
  }
  
  else {
    for (int i = N - 1; i > 0; i--) {
      if (H.at(i) < H.at(i - 1)) {
        if (H.at(i - 1) - H.at(i) != 1){
          break;
        }
        else {
          H.at(i - 1) = H.at(i - 1) - 1;
        }
      }
    
      if (i == 1) {
        ans = 1;
      }
    
    }
  }
  
  if (ans == 0) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

// ツ各ツ可。ツ棒ツづ個陳シツ古」ツづ可債カツ右ツづ個縦ツ棒ツづ可つュツづゥツづ個づ債債カツつゥツづァツ可スツ氾板姪堋づ個禿シツ療債つゥツづーツ計ツ算ツつキツづゥツ。
int main() {
  int n,m,h,k;
  while(cin>>n>>m>>h>>k,n) {
    long long s[n];
    REP(i,n)cin>>s[i];
    bool bar[n][h];
    memset(bar,0,sizeof(bar));
    pair<int,int> barp[m];
    REP(i, m) {
      int a,b;
      cin>>a>>b;
      bar[a-1][b] = 1;
      barp[i] = make_pair(a-1,b);
    }
    int barval[n][h];
    REP(i,n)
      barval[i][0] = i;
    REP(i, h-1) {
      REP(j, n) {
        if (bar[j][i+1])
          barval[j+1][i+1] = barval[j][i];
        else if (j>0&&bar[j-1][i+1]) 
          barval[j-1][i+1] = barval[j][i];
        else
          barval[j][i+1] = barval[j][i];
      }
    }
    int mi = 0;
    REP(i, n)
      if (barval[i][h-1] < k) mi += s[i];
    REP(j, m) {
      int left = barval[barp[j].first][barp[j].second];
      int right = barval[barp[j].first+1][barp[j].second];
      int mii = 0;
      REP(i, n) {
        int hoge = barval[i][h-1];
        if (hoge == left) hoge = right;
        else if (hoge == right) hoge = left;
        if (hoge < k) mii += s[i];
      }
      mi = min(mi, mii);
    }
    cout << mi << endl;
  }
}

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

int main() {
  string S;
  cin>>S ;
  int l=S.size();
  int temp=1000;
  int num;
  for(int i=0;i<l-2;i++){
    num=(S[i]-'0')*100+(S[i+1]-'0')*10+(S[i+2]-'0');
    temp=min(temp,abs(num-753));
  }

    cout<<temp<<endl;

}


Measured memory_bytes: 256
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h[ohara], w, x, y, sum, k, q;

bool check(ll x) {
  ll aa[n + 10];
  rep(i, n) aa[i] = h[i] - x * b;
  cnt = 0;
  rep(i, n) {
    if (aa[i] <= 0) continue;
    cnt += (aa[i] + a - b - 1) / (a - b);
  }
  if (cnt <= x)
    return true;
  else
    return false;
}

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

  cin >> n >> a >> b;
  rep(i, n) cin >> h[i];
  ll le = 0, ri = INF + 10, mid;
  while (ri - le > 1) {
    mid = (le + ri) / 2;
    if (check(mid))
      ri = mid;
    else
      le = mid;
  }
  Cout(ri);
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define pii pair < int, int >
typedef vector<int> vi;
typedef   long long ll;
const int mod =1e9+7;

void solve(){
	int a,b,c,d,k;
	cin>>a>>b>>c>>d>>k;
	cout<<c*60+d-a*60-b-k;	


}


int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

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

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

  int a[5];
  int b[5];
  a[0]=0;
  for(int i=0; i<3; i++) b[i]=c[0][i]-a[0];
  a[1]=c[1][0]-b[0]; a[2]=c[2][0]-b[0];

  bool OK=true;
  for(int i=1; i<3; i++)
    for(int j=1; j<3; j++)
      if(a[i]+b[j]!=c[i][j]) OK=false;
  if(OK) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int M;
  cin>>M;
  ll d, c;
  ll ans = 0;
  ll sum = 0;
  for(int i=0;i<M;++i) {
    cin>>d>>c;
    ans += c;
    sum += d*c;
  }
  ans--;
  if(sum%9==0) ans += sum/9-1;
  else ans += sum/9;
  cout<<ans<<endl;
}



Measured memory_bytes: 3636
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main(){
    int n;
    cin>>n;
    int h[n];
    rep(i,n)cin>>h[i];

    bool state;
    int ans=0;
    int mizuyari;
    while(true){
        mizuyari = 0;
        if(h[0]==0)state = false;
        else{
            state = true;
            ++mizuyari;
        }
        //printf("%d ",state);
        for(int i=1;i<n;++i){
            if(state == true && h[i] == 0){
                state = false;
            }
            else if(state == false && h[i] > 0){
                state = true;
                ++mizuyari;
            }
            //printf("%d ",state);
        }
        //printf("| ");
        if(mizuyari > 0){
            ans += mizuyari;
            rep(i,n) if(h[i] != 0)--h[i];
            //rep(i,n) printf("%d ",h[i]);
            //cout<<ans<<endl;
        }
        else break;
    }
    cout<<ans;
}

Measured memory_bytes: 256
X = [int(input()) for _ in range(5)]
m = 10
mi = 10
rX = []
for i, x in enumerate(X):
    y = int(str(x)[-1])
    if y != 0 and y < m:
        m = y
        mi = i
    if len(str(x)) == 1:
        rX.append(10)
    else:
        z = int(''.join(str(x)[:-1]))
        if y == 0:
            rX.append(z * 10)
        else:
            rX.append((z + 1) * 10)
if m == 10:
    print(sum(rX))
else:
    print(sum([x if i != mi else X[mi] for i, x in enumerate(rX)]))

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

int main() {
  string s;
  cin >> s;
  s[1] = 'R'^'B'^s[1];
  cout << s << endl;
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  int ans =0;
  vector<int> p(n,0);
  for(int i=0;i<n;i++){
    cin >> p[i];
  }
  
  for(int i=0;i<n-2;i++){
    if((p[i]<p[i+1]&&p[i+1]<p[i+2])||(p[i]>p[i+1]&&p[i+1]>p[i+2])){
      ans++;
    }
  }
    
    cout << ans << endl;
  }
  

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f=true){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f=true){cout<<(f?"YES":"NO")<<endl;}
#define ANS(a) cout<<a<<endl

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int A,B; cin >>A>>B;
    string S; cin >>S;
    bool f = true;;
    rep(i, S.length()) {
        if ((i==A && S[i] != '-') || (i!=A && !isdigit(S[i]))) {
            f = false;
            break;
        }
    }
    Yes(f);
}


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

#define int long long 
#define dou  double 
#define endl "\n"

const int mod=1e9+7;

int mulmod(int a,int b) // (a*b)%mod = (a%mod)*(b%mod)%mod
{
	return ((a%mod)*(b%mod))%mod;
}

void solve()
{
	int n,i,j,sum=0,ans=0;
	cin >> n;
	vector<int> v(n);
	for(i=0;i<n;i++)
	{
		cin >> v[i];
		sum = (sum%mod + v[i]%mod)%mod;
	}
	for(i=0;i<n;i++)
	{
		sum = (sum%mod-(v[i]%mod)+mod)%mod;
		ans = (ans%mod + mulmod(v[i],sum))%mod;
	}
	cout << ans << endl;
}

main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	solve();
}

Measured memory_bytes: 4780
#include <bits/stdc++.h>
using namespace std;
#define int               long long
#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define uniq(v)           (v).erase(unique(all(v)),(v).end())
#define sz(x)             (int)((x).size())
#define fr                first
#define sc                second
#define pii               pair<int,int>
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define ppc               __builtin_popcount
#define ppcll             __builtin_popcountll

template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.fr>>a.sc;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.fr<<" "<<a.sc;return out;}
template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}

const long long INF=1e18;
const int32_t M=1e9+7;
const int32_t MM=998244353;

const int N=0;



void solve(){
	int h1,m1,h2,m2,k;
	cin>>h1>>m1>>h2>>m2>>k;
	int t = (60*h2+m2) - (60*h1+m1);
	cout<<t-k;
}
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	#ifdef SIEVE
		sieve();
	#endif
	#ifdef NCR
		init();
	#endif
	int t=1;
	//cin>>t;
	while(t--) solve();
	return 0;
}


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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    lint n, d, x;
    cin >> n >> d >> x;
    lint ans = x;
    rep(i, n){
        lint a;
        cin >> a;
        ans += (d + a - 1) / a;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
*/

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

#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll INF = 1LL<<60;
const ll mod = 1e9 + 7;
const int MAX_N = 5e5 + 5;
int dx[] = { -1,0,1,0 }, dy[] = { 0,1,0,-1 };
vector<ll> prime;

ll inv[MAX_N], fac[MAX_N];

template <class T = ll> T in() { T x; cin >> x; return (x); }
inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1; while (b > 0) { if (b & 1) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; }
inline void _nCr() { fac[0] = 1; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; }
inline void PRI(ll n) { bool a[n + 1]; for (int i = 0; i < n + 1; i++) { a[i] = 1; }for (int i = 2; i < n + 1; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } }

typedef pair<int, pair<int, int>> edge;

class UnionFind {
private:
	vector<int> par;
public:
	UnionFind(int N) { par = vector<int>(N, -1LL); }
	int find(int x);
	ll size(int x);
	void unite(int x, int y);
	bool same(int x, int y);
};



class Kruskal {
private:
	UnionFind *uf;
	vector<edge> e;
public:
	vector<edge> mst;
	Kruskal(int N) { uf = new UnionFind(N); }
	void add(int x, int y, ll z);
	void run();
};



//----UnionFind-------------------------------
int UnionFind::find(int x) {
	if (par[x] < 0) return x;
	else return par[x] = find(par[x]);
}

ll UnionFind::size(int x) {
	return -par[find(x)];
}

void UnionFind::unite(int x, int y) {
	x = find(x);
	y = find(y);

	//大きい方に小さい方をくっ付ける
	if (size(x) < size(y)) swap(x, y);
	par[x] += par[y];
	par[y] = x;
}

bool UnionFind::same(int x, int y) {
	x = find(x);
	y = find(y);
	return x == y;
}



//----Kruskal-------------------------------
void Kruskal::add(int x, int y, ll z) {
	//x < y
	if (x > y) swap(x, y);
	e.push_back({ z,{x,y} });
}

void Kruskal::run() {
	sort(e.begin(), e.end());
	e.erase(unique(e.begin(), e.end()), e.end());
	for (auto x : e) {
		if (uf->same(x.second.first, x.second.second)) {
			continue;
		}
		else {
			mst.push_back(x);
			uf->unite(x.second.first, x.second.second);
		}
	}
}

signed main() {
	int a,b;
	string s;
	int n;cin >> n;
	cin >> s;
	a = b = 0;
	REP (i,s.size()) {
		if (s[i] == 'R') a++;
		else b++;
	}
	if (a > b) cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

const int N = 210;

char s[N];

bool check(char *s, int n){
	if (n & 1){
		return false;
	}
	for (int i = 0; i < n >> 1; ++ i){
		if (s[i] != s[i + (n >> 1)]){
			return false;
		}
	}
	return true;
}

int main(){
	scanf("%s", s);
	int len = strlen(s);
	for (int i = 1; ; ++ i){
		if (check(s, len - i)){
			return printf("%d\n", len - i), 0;
		}
	}
}

Measured memory_bytes: 256
local mfl = math.floor

local n = io.read("*n", "*l")
local s = io.read()
local m_cnt = {}
local d_pos = {}
local c_pos = {}
local ss = ""
local mc = 0LL
for i = 1, n do
  ss = s:sub(i, i)
  if ss == "D" then
    table.insert(d_pos, i)
  elseif ss == "C" then
    table.insert(c_pos, i)
  elseif ss == "M" then
    mc = mc + 1LL
  end
  m_cnt[i] = mc
end
local m_sum_per_c = {}
for i = 1, #c_pos do
  local ic = c_pos[i]
  if i == 1 then
    m_sum_per_c[i] = m_cnt[ic]
  else
    m_sum_per_c[i] = m_sum_per_c[i - 1] + m_cnt[ic]
  end
end

local function llprint(llnumber)
  local str = tostring(llnumber):gsub("LL", "")
  print(str)
end

local cposall = {}
local tmp = 1
for i = 1, n + 1 do
  while c_pos[tmp] and c_pos[tmp] < i do
    tmp = tmp + 1
  end
  cposall[i] = tmp
end
local mmi = math.min
local q = io.read("*n")
for i = 1, q do
  local k = io.read("*n")
  local ret = 0LL
  for id = 1, #d_pos do
    local dp = d_pos[id]
    local c_from = cposall[dp]
    local c_to = cposall[mmi(n + 1, dp + k)] - 1
    if 1 <= c_to then
      ret = ret + m_sum_per_c[c_to] - (c_to - c_from + 1) * m_cnt[dp]
      if 1 < c_from then
        ret = ret - m_sum_per_c[c_from - 1]
      end
    end
  end
  llprint(ret)
end


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

const int nmax = 8;
bool graph[nmax][nmax];

int dfs(int v, int N, bool visited[nmax]) {
  bool all_visited = true;
  for (int i = 0; i < N; ++i) {
    if (!visited[i]) all_visited = false;
  }
  if(all_visited) return 1;
  
  int ret=0;
  for (int i = 0; i < N; ++i) {
    if(!graph[v][i]) continue;
    if(visited[i]) continue;
    visited[i] = true;
    ret += dfs(i, N, visited);
    visited[i] = false;
  }
  return ret;
}

int main() {
  int N, M;
  cin >> N >> M;
  for (int i = 0; i < M; ++i) {
    int A, B;
    cin >> A >> B;
    graph[A - 1][B - 1] = graph[B - 1][A - 1] = true;
  }
  bool visited[nmax];
  for (int i = 0; i < N; ++i) {
    visited[i]=false;
  }
  visited[0] = true;
  cout << dfs(0, N, visited) << endl;
}


Measured memory_bytes: 256
package main

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

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	t, _ := strconv.Atoi(sc.Text())
	return t
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	N := nextInt(sc)
	A := make([]int, N+2)
	C := make([]int, N+2)
	for i := 0; i <= N; i++ {
		if i < N {
			A[i+1] = nextInt(sc)
		}
		C[i+1] = C[i] + abs(A[i+1]-A[i])
	}
	// 最初の観光スポットからi番目(1-indexed)の観光スポットまでの累積の旅費をC[i]とする
	wtr := bufio.NewWriter(os.Stdout)
	for i := 1; i <= N; i++ {
		// i番目の観光スポットをスキップした場合のコストは、
		// スタート -> A[i-1]までのコスト + A[i-1] -> A[i+1]のコスト + A[i+1] -> A[N+1]のコストとなる
		fmt.Fprintln(wtr, C[i-1]+abs(A[i+1]-A[i-1])+(C[N+1]-C[i+1]))

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


Measured memory_bytes: 4608
using System;
using System.Linq;

namespace AOJ000
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = int.Parse(Console.ReadLine());
            var h = Math.Floor(S / 3600.0);
            var m = Math.Floor((S % 3600.0) / 60);
            var _s = Math.Floor((S % 3600.0) % 60);

            Console.WriteLine("{0}:{1}:{2}", h, m, _s);
        }
    }
}

Measured memory_bytes: 20000
N,M = map(int,input().split())
A = sorted([list(map(int,input().split())) for _ in range(N)],key=lambda x:x[0])
cnt = 0
ind = N-1
for i in range(N):
    if cnt+A[i][1]>M:
        ind = i-1
        break
    cnt += A[i][1]
yen = 0
for i in range(ind+1):
    yen += A[i][0]*A[i][1]
if ind+1<N:
    yen += A[ind+1][0]*(M-cnt)
print(yen)

Measured memory_bytes: 65368
n = int( input() )
l = [[]] * n
for i in range( n ):
  a = int( input() )
  k = [ -1 ] * n
  for _ in range( a ):
    x, y = map( int, input().split() )
    k[ x - 1 ] = y
  l[ i ] = k

ret = 0
for i in range( 2 ** n - 1, 0, -1 ):
  o = [int(i) for i in str( "{:b}".format(i).zfill(n) )]
  is_right = True
  for j in range( n ):
    for m in range( n ):
      if o[j] == 1:
        is_right &= ( l[j][m] in [-1, o[m]] )
    if not is_right:
      break
        
  if is_right:
    ret = sum(o)
    break
          
print( ret )


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
int INF = 100100101;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int a,b;
  cin >> a>>b;
  int ans;
  if(a <=5) ans = 0;
  else if(a >=6 && a <= 12) ans = b/2;
  else ans = b;
  cout << ans << endl;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

int main(){
  while(1){
    LL b;
    cin >> b;
    if(b==0) return 0;
    pair<LL,LL> ans={0,-1};
    repp(i,1,sqrt(2*b)+1){
      if(2*b%i==0){
        if((2*b/i-i-1)>=0&&(2*b/i-i-1)%2==0) ans=max(ans,{i,(2*b/i-i-1)/2});
      }
    }
    cout << ans.second+1 SP ans.first << endl;
  }
  return 0;
}



Measured memory_bytes: 3080
using System;

namespace ARC064A{
    public class Program{
        public static void Main(string[] args){
            var sr = new StreamReader();
            //---------------------------------
            var N = sr.Next<int>();
            var X = sr.Next<int>();
            var A = sr.Next<int>(N);

            var res = 0L;
            for(var i = 0; i < N; i++){
                var dif = Math.Max(0, A[i] - X);
                A[i] -= dif;
                res += dif;
            }
            for(var i = 1; i < N; i++){
                var dif = Math.Max(0, A[i - 1] + A[i] - X);
                A[i] -= dif;
                res += dif;
            }

            Console.WriteLine(res);
            //---------------------------------
        }
    }

    public class StreamReader{
        private readonly char[] _c = {' '};
        private int _index = -1;
        private string[] _input = new string[0];
        private readonly System.IO.StreamReader _sr = new System.IO.StreamReader(Console.OpenStandardInput());

        public T Next<T>(){
            if(_index == _input.Length - 1){
                _index = -1;
                while(true){
                    string rl = _sr.ReadLine();
                    if(rl == null){
                        if(typeof(T).IsClass) return default(T);
                        return (T)typeof(T).GetField("MinValue").GetValue(null);
                    }
                    if(rl != ""){
                        _input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
                        break;
                    }
                }
            }
            return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
        }

        public T[] Next<T>(int x){
            var ret = new T[x];
            for(var i = 0; i < x; ++i) ret[i] = Next<T>();
            return ret;
        }

        public T[][] Next<T>(int y, int x){
            var ret = new T[y][];
            for(var i = 0; i < y; ++i) ret[i] = Next<T>(x);
            return ret;
        }
    }
}

Measured memory_bytes: 16856
#,[,----------]>>--------->>--------->>--------->>--------->>--------->>--------->>
#,----------[[>->+<<-]>[[-]<<[-]+<[+>>]>[<---------<[-]+<[+>>>>]>
#[<---------<[-]+<[+>>>>>>]>[<---------<[-]+<[+>>>>>>>>]>
#[<---------<[-]+<[+>>>>>>>>>>]>[<---------<+<+>>>>>>>>>>>>>]]]]]]
#>[<+>-]<<,----------]>[-]<<[<<]>>[+++++++[<+++++++>-]<+.[-]>>>]++++++++++
bf Main.sh

Measured memory_bytes: 688
s=input()
n=len(s)
ans="Yes"
for i in range(n):
    if s[i]!=s[n-i-1]:
        ans="No"

for i in range((n-1)//2):
    if s[i]!=s[(n-1)//2-i-1]:
        ans="No"

for i in range((n+3)//2-1,n):
    if s[i]!=s[n-i+(n+3)//2-2]:
        ans="No"
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <string.h>

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

int main()
{
	int n, m;
	scanf("%d %d", &n, &m);

	int one = n - m;
	int execution = one * 100 + m * 1900;
	int mult = 1 << m;

	printf("%d", execution * mult);

	return 0;
}




Measured memory_bytes: 256