akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <limits>

using ull = unsigned long long;

struct Magic
{
	int attack, mp;
};

int f(const std::vector<Magic>& M, int H)
{
	constexpr int MY_INT_MAX = std::numeric_limits<int>::max();
	std::vector<int> dp(H+1, MY_INT_MAX);

	dp[0] = 0;

	for (size_t h = 1; h < dp.size(); h++)
	{
		for (Magic m : M)
		{
			size_t ph = (h > m.attack) ? h - m.attack : 0;
			dp[h] = std::min(dp[h], dp[ph]+m.mp);
		}
	}

	return dp[H];
}

int main()
{
	int H, N;
	std::cin >> H >> N;
	std::vector<Magic> M(N);
	for (int i = 0; i < N; i++)
	{
		std::cin >> M[i].attack >> M[i].mp;
	}

	std::cout << f(M, H);
}


Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())

lst_A = []

if (sx < tx) and (sy < ty):
    for i in range(tx - sx):
        lst_A.append("R")
    for i in range(ty - sy):
        lst_A.append("U")
    for i in range(tx - sx):
        lst_A.append("L")
    for i in range(ty - sy):
        lst_A.append("D")
    lst_A.append("D")
    for i in range(tx - sx + 1):
        lst_A.append("R")
    for i in range(ty - sy + 1):
        lst_A.append("U")
    lst_A.append("L")
    lst_A.append("U")
    for i in range(tx - sx + 1):
        lst_A.append("L")
    for i in range(ty - sy + 1):
        lst_A.append("D")
    lst_A.append("R")


print("".join(lst_A))

Measured memory_bytes: 3188
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
using namespace std;
const int MAXN=55;
const int MAXM=110;
const int P=1E9+7;
struct Edge
{
	int from, to;
	Edge(int u, int v): from(u), to(v) {}
};
int n, m, k, cnt, top, tot;
int c[2*MAXM][MAXM];
int f[MAXM];
int dfn[MAXN], low[MAXN];
int sta[MAXM], sum[MAXM];
vector<Edge> edges;
vector<int> g[MAXN];
set<int> bl[MAXM];
int gcd(int a, int b)
{
	if (b==0) return a;
	return gcd(b, a%b);
}
int exgcd(int a, int b, int& x, int& y)
{
	if (b==0) x=1, y=0;
	else exgcd(b, a%b, y, x), y-=a/b*x;
}
int qpow(int a, int b)
{
	int r=1;
	while (b)
	{
		if (b&1) r=1ll*r*a%P;
		a=1ll*a*a%P; b>>=1;
	}
	return r;
}
int inv(int a)
{
	int x, y;
	exgcd(a, P, x, y);
	return (x%P+P)%P;
}
void init()
{
	memset(c, 0, sizeof c);
	c[0][0]=1;
	for (int i=1; i<=m+k; i++)
	{
		c[i][0]=1;
		for (int j=1; j<=i&&j<=m; j++)
			c[i][j]=(c[i-1][j-1]+c[i-1][j])%P;
	}
	memset(f, 0, sizeof f);
	for (int i=1; i<=m; i++)
	{
		for (int j=1; j<=i; j++)
			f[i]=(f[i]+qpow(k, gcd(i, j)))%P;
		f[i]=1ll*f[i]*inv(i)%P;
	}
	edges.clear();
	for (int i=1; i<=n; i++) g[i].clear();
	memset(dfn, 0, sizeof dfn);
	memset(sum, 0, sizeof sum);
	cnt=top=tot=0;
}
inline void addEdge(int u, int v)
{
	edges.push_back(Edge(u, v));
	edges.push_back(Edge(v, u));
	g[u].push_back(edges.size()-2);
	g[v].push_back(edges.size()-1);
}
void tarjan(int u, int f)
{
	low[u]=dfn[u]=++cnt;
	for (int i=0; i<g[u].size(); i++)
	{
		int v=edges[g[u][i]].to;
		if (!dfn[v])
		{
			sta[++top]=g[u][i]; tarjan(v, u);
			low[u]=min(low[u], low[v]);
			if (low[v]>=dfn[u])
			{
				bl[++tot].clear(); bl[tot].insert(u);
                do bl[tot].insert(edges[sta[top]].to);
                while (sta[top--]!=g[u][i]);
			}
		}
		else if (v!=f) low[u]=min(low[u], dfn[v]);
	}
}
int main()
{
//	freopen("A.in", "r", stdin);
//	freopen("A.out", "w", stdout);
	scanf("%d%d%d", &n, &m, &k);
	init();
	for (int i=1; i<=m; i++)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		addEdge(u, v);
	}
	for (int i=1; i<=n; i++)
		if (!dfn[i]) tarjan(i, 0);
	int ans=1;
	for (int i=0; i<edges.size(); i+=2)
		for (int j=1; j<=tot; j++)
			if (bl[j].count(edges[i].from)&&bl[j].count(edges[i].to))
				sum[j]++;
	for (int i=1; i<=tot; i++)
	{
		if (sum[i]==bl[i].size()) ans=1ll*ans*f[sum[i]]%P;
		else if (sum[i]>bl[i].size()) ans=1ll*ans*c[sum[i]+k-1][sum[i]]%P;
		else ans=1ll*ans*k%P;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define inf 999999999999
#define F first
#define S second
#define read(x)  freopen("input.txt","r",stdin);
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pi 2*acos(0.0)
#define ee exp(1)
#define mx 200009
using namespace std;
int main(){//read(x);
//fast;
ll a,b,c,d,e,f,g,h,i,j,k,l=0,n,t;

cin>>n;
ll m[n];l=inf;
for(i=0;i<n;i++)cin>>m[i];
for(i=-100;i<=100;i++){
    a=0;
    for(j=0;j<n;j++){
        b=m[j]-i;
        a+=b*b;
    }
    l=min(l,a);
}
cout<<l<<endl;
}














Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
const double pi=acos(-1);
int main(){
  rep(i,MOD){
    int a,b;
    char c;
    cin >> a >> c >> b;
    if(c=='+') cout << a+b << endl;
    if(c=='-') cout << a-b << endl;
    if(c=='*') cout << a*b << endl;
    if(c=='/') cout << a/b << endl;
    if(c=='?') return 0;
  }
}



Measured memory_bytes: 3116
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cstdlib>  // abs() for integer
#include <math.h>     // math.h をインクルードする！
#include <iomanip> // 小数点以下のやつ
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
   vector<int> a(5);
    rep(i, 5) {
        cin >> a[i];
        if (a[i] == 0) {
            cout << i + 1 << endl;
            return 0;
        }
    }
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int N;
  cin >> N;
  vector<int> a(N);
  REP(i,N){
    cin >> a[i];
    a[i]--;
  }
  int res = 0;
  REP(i,N) if(a[a[i]] == i) res++;
  res /= 2;
  cout << res << endl;
  return 0;
}



Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<bitset>
#include<queue>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;

int main(){
  string Sa, Sb, Sc;
  cin >> Sa >> Sb >> Sc;

  queue<char> A;
  for (int i=0; i<(int)Sa.size(); i++){
    A.push(Sa.at(i));
  }

  queue<char> B;
  for (int i=0; i<(int)Sb.size(); i++){
    B.push(Sb.at(i));
  }

  queue<char> C;
  for (int i=0; i<(int)Sc.size(); i++){
    C.push(Sc.at(i));
  }

  char c = 'a';
  while (!A.empty() || !B.empty() || !C.empty()){
    if (c == 'a'){
      if (A.empty()){
        cout << 'A' << endl;
        return 0;
      }
      c = A.front();
      A.pop();
    }
    else if (c == 'b'){
      if (B.empty()){
        cout << 'B' << endl;
        return 0;
      }
      c = B.front();
      B.pop();
    }
    else {
      if (C.empty()){
        cout << 'C' << endl;
        return 0;
      }
      c = C.front();
      C.pop();
    }
  }
}


Measured memory_bytes: 3628
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }

void main() {
  ulong N, M; readf("%d %d\n", &N, &M);
  auto H = readln.split.to!(ulong[]).sort();

  void solve() {
    if (M >= N) {
      writeln(0);
      return;
    }

    ulong count;
    foreach(h; H[0..N-M]) {
      count += h;
    }
    writeln(count);
  }

  solve();
}


Measured memory_bytes: 11284
# -*- coding: utf-8 -*-

def main():

    A, B = map(int, input().split())

    ans = 0

    while True:
        num = (A - 1) * ans + 1
        if num >= B:
            break
        
        ans += 1

    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9044
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<algorithm>
#include<list>
#include<cmath>
#include<iomanip>
#include<queue>
#include<functional>
#include<climits>
#include<iterator>
#include<unordered_map>

using namespace std;

const double pi=4*atan(1.0);

int mod=1000000007;

int main() {
	int N;
	cin>>N;
	vector<int> arr(N);
	for(auto& val:arr)
		cin>>val;

	vector<int> dp(N);
	
	int ans=0;
	dp[0]=arr[0];
	for(int i=1;i<N;++i){
		if(arr[i]>dp[ans]){
			dp[++ans]=arr[i];
		}
		else{
			
			int min=0,max=ans;
			int mid;
			while(1){
				mid=(max-min)/2+min;

				if(dp[mid]>arr[i]){
					if(min==mid)break;
					max=mid;
				}
				else if(dp[mid]<arr[i]){
					if(min==mid){
						++mid;
						break;
					}
					min=mid;
				}
				else{
					break;
				}
			}

			dp[mid]=arr[i];

		}
	}

	cout<<ans+1<<endl;

	//system("pause");
	return 0;
}

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

int64_t power(int64_t x, int y){
    if(y == 0)return 1;
    if(y == 1)return x % 1000000007;
    int64_t z = power(x, y/2) % 1000000007;
    if(y % 2 == 0)return z * z % 1000000007;
    else return (z * z % 1000000007) * x % 1000000007;
}

int main(){
    int64_t X, Y, sum = 1, three, comb, i = 0;
    cin >> X >> Y;
    if(X < Y){
        X = X - Y;
        Y = X + Y;
        X = Y - X;
    }
    if((X + Y) % 3 != 0){
        cout << 0 << endl;
    }else{
        if(X * 2 < Y || Y * 2 < X){
            cout << 0 << endl;
        }else{
            three = (X + Y) / 3;
            comb = Y - three;

            while(comb != i){
                sum *= three--;
                sum %= 1000000007;
                sum *= power(++i, 1000000005);
                sum %= 1000000007;
            }
            cout << sum << endl;
        }
    }
}

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

typedef long long ll;
typedef long double ld;
#define Cin(argument) cin >> argument
#define Cin2(argument1,augument2) cin >> argument1 >> argument2
#define Cin3(argument1,augument2,argument3) cin >> argument1 >> argument2 >> argument3
#define Cin4(argument1,augument2,argument3,argument4) cin >> argument1 >> argument2 >> argument3 >> argument4
#define Cout(argument) cout << argument << "\n"
#define Cout2(argument1,argument2) cout << argument1 << argument2 << "\n"
#define Cout3(argument1,argument2,argument3) cout << argument1 << argument2 << argument3 << "\n"
#define Cout4(argument1,argument2,argument3,argument4) cout << argument1 << argument2 << argument3 << argument4 << "\n"
#define Kaigyou cout << "\n"
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define Size(n) (n).size()
#define EPS (1e-7)
#define INF (1e9)

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

    ll n,x=0,max=0; Cin(n);
    string s; Cin(s);
    rep(i,n){
        if(s[i]=='I') x++;
        else x--;
        if(max < x) max = x;
    }
    Cout(max);
    return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
#define END system("PAUSE");return 0
int n;
int a[222222];
vector<int>v[222222];
vector<int>V[222222];
int dp[222222];
signed main() {	
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		v[a[i] - 1].push_back(i);
	}
	rep(i, 200000) {
		rep(j, v[i].size()) {
			if (j&&v[i][j]-v[i][j-1]!=1)V[v[i][j]].push_back(v[i][j-1]);
		}
	}
	dp[0] = 1;
	rep(i, 200000){
		if (!i)continue;
		int cnt = 0;
		rep(j, V[i].size()) {
			cnt += dp[V[i][j]];
		}
		dp[i] = dp[i - 1] + cnt;
		dp[i] %= MOD;
	}
	cout << dp[n - 1] << endl;
	END;
}


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

int main() {

    int a, b;
    cin >> a >> b;

    if ((a%2==0 and b%2==0) or (a%2==1 and b%2==1)) cout << (a+b)/2 << endl;
    else cout << "IMPOSSIBLE" << endl;

    return 0;
}

Measured memory_bytes: 3632
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;
int main()
{
    int n;
    cin >> n;

    int o = 0;
    for (int i = 0; i < n; i++)
    {
        int p;
        cin >> p;
        if (p != i + 1)
        {
            o++;
        }
    }

    if (o == 0 || o == 2)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,i;
    cin>>n;
    ll arr[n];
    for(i=0;i<n;i++)
        cin>>arr[i];
    sort(arr,arr+n);
    cout<<abs(arr[n-1]-arr[0])<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

const int DEBUG = 0;

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;

PI sqr(int e) {
  int k = 1;
  while (1) {
    if (k * k >= e) {
      break;
    }
    k *= 2;
  }
  if (k * k == e) return PI(k, 0);
  return PI(k / 2, 1);
}

bool filter(int x, int y, PI t) {
  if (t.second == 0) {
    int p1 = x / t.first, p2 = y / t.first;
    return (p1 + p2) % 2 == 0;
  }
  return (y / t.first) % 2 == 0;
}

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, d1, d2;
  cin >> n >> d1 >> d2;
  int e1 = d1 & -d1;
  int e2 = d2 & -d2;
  if (e1 < e2) swap(e1, e2);
  PI t1 = sqr(e1);
  PI t2 = sqr(e2);
  vector<PI> ans;
  REP(i, 0, 2 * n) {
    REP(j, 0, 2 * n) {
      if (filter(i, j, t1) && filter(i, j, t2)) {
        ans.push_back(PI(i, j));
      }
    }
  }
  assert ((int) ans.size() >= n * n);
  REP(i, 0, n * n) {
    cout << ans[i].first << " " << ans[i].second << endl;
  }
  if (DEBUG) {
    REP(i, 0, ans.size()) {
      REP(j, 0, ans.size()) {
        ll x = (ans[i].first - ans[j].first);
        ll y = (ans[i].second - ans[j].second);
        ll d = x * x + y * y;
        assert (d != d1);
        assert (d != d2);
      }
    }
  }
}


Measured memory_bytes: 2420
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string.h>
using namespace std;

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

  if(x%111!=0){
    printf("%d\n",x+(111-x%111));
  }else{
    printf("%d\n",x);
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)
#define RREP(i, n) for(int i = (n)-1; i >= 0; --i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define PI 3.1415926
#define coutdb cout<<fixed<<setprecision(15)

const int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
const long long MOD = 1e9+7;

// typedef int_fast64_t ll;
#define int int_fast64_t

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

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

  int N, A, B, C, D; cin >> N >> A >> B >> C >> D;
  REP(m, N){ // m ... -D <= diff <= -C kosuu
    int mn = C*(N-1-m)-D*m, mx = D*(N-1-m)-C*m;
    if(mn <= B-A and B-A <= mx){
      cout << "YES" << endl;
      return 0;
    } 
  }
  cout << "NO" << endl;
}

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

using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

struct pair_hash {
    template <class T1, class T2>
    std::size_t operator()(const std::pair<T1, T2> &pair) const {
        return std::hash<T1>()(pair.first) ^ std::hash<T2>()(pair.second);
    }
};
unordered_map<ll, ll> memo;
ll mypow2(ll y) {
    if (y == 0)
        return 1;
    else if (y == 1)
        return 2;
    else {
        auto it = memo.find(y);
        if (it != memo.end())
            return it->second;
        else {
            if (y % 2 == 1)
                return memo[y] = 2 * mypow2(y - 1) % MOD;
            else {
                auto ans = mypow2(y / 2);
                return memo[y] = ans * ans % MOD;
            }
        }
    }
}

int main() {
    int N;
    cin >> N;
    // unordered_map<pair<ll, ll>, ll, pair_hash> slopeCount;
    map<pair<ll, ll>, ll> slopeCount;
    ll zeroCount = 0;
    for (int i = 0; i < N; ++i) {
        ll A, B;
        cin >> A >> B;
        if (A == 0 && B == 0) {
            ++zeroCount;
        } else {
            auto gcdAB = __gcd(abs(A), abs(B));
            if (B < 0)
                ++slopeCount[{-A / gcdAB, -B / gcdAB}];
            else
                ++slopeCount[{A / gcdAB, B / gcdAB}];
        }
    }
    // unordered_set<pair<ll, ll>, pair_hash> seen;
    set<pair<ll, ll>> seen;
    ll ans = 1;
    for (const auto &p : slopeCount) {
        const auto &slope = p.first;
        // cout << slope.first << " " << slope.second << " " << p.second
        //      << endl;
        if (seen.find(slope) == seen.end()) {
            pair<ll, ll> vertical;
            if (slope.first == 0) {
                vertical = {1, 0};
            } else if (slope.second == 0) {
                vertical = {0, 1};
            } else if (slope.first < 0) {
                vertical = {slope.second, -slope.first};
            } else {
                vertical = {-slope.second, slope.first};
            }
            auto it = slopeCount.find(vertical);
            if (it != slopeCount.end()) {
                ans *= (mypow2(it->second) + mypow2(p.second) - 1);
                ans %= MOD;
                seen.insert(vertical);
            } else {
                ans *= mypow2(p.second);
                ans %= MOD;
            }
        }
    }
    ans -= 1;
    if (ans < 0)
        ans += MOD;
    ans += zeroCount;
    ans %= MOD;

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

Measured memory_bytes: 16092
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n,suma=0;
	cin>>n;
	long long c[n*2];
	for(int i=0;i<2*n;i++){
		cin>>c[i];
		}
	for(int i=0;i<n;i++){
		if(c[i]-c[i+n]>0){
			suma=suma+(c[i]-c[i+n]);
		}
	}
	cout<<suma;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const ll MOD = 1000000007;
const double EPS = 1e-9;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;

ll div(ll n){
    ll res=0;
    while(n%2==0){
        res++;
        n/=2;
    }
    return res;
}

// gcdも呼ぶ！！！
// lcmも呼ぶ！！！
// gcdも呼ぶ！！！
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a,   b) * b;}

int main(void) {
    
    

    ll n,m;
    scanf("%lld %lld",&n,&m);
    vll v(n);
    rep(i,n){
        scanf("%lld",&v[i]);
        if(v[i]%2==1){fin(0);return 0;}
        v[i]/=2;
    }

    ll t=div(v[0]);
    rep(i,n){
        if(t!=div(v[i])){
            fin(0);
            return 0;
        }
        v[i] >>= t;
    }

    m >>= t;

    ll l=v[0];
    for (int i = 1; i < n; i++) {
        l = lcm(l, v[i]);
        if(l>m){
            fin(0);
            return 0;
        }
    }
    m/=l;

    fin((m+1)/2);
    
}


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

#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()
#define INF 999999999
using namespace std;

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

bool shortestPath(const Graph g, int s,
    vector<Weight> &dist, vector<int> &prev) {
  int n = g.size();
  dist.assign(n, INF+INF); dist[s] = 0;
  prev.assign(n, -2);
  bool negative_cycle = false;
  REP(k, n) REP(i, n) if(dist[i]<INF) FOR(e,g[i]) {
    if (dist[e->dst] > dist[e->src] + e->weight) {
      dist[e->dst] = dist[e->src] + e->weight;
      prev[e->dst] = e->src;
      if (k == n-1) {
        dist[e->dst] = -INF;
        negative_cycle = true;
      }
    }
  }
  return !negative_cycle;
}

int main(){
	int r,T,V,E,s,t,e,i;
	//for(scanf("%d",&T);T;putchar(--T?' ':'\n')){
		scanf("%d%d%d",&V,&E,&r);
		Graph g(V);
		vector<Weight> dist;
		vector<int> prev;
		for(;E--;)scanf("%d%d%d",&s,&t,&e),g[s].push_back(Edge(s,t,e));
		if(!shortestPath(g,r,dist,prev))puts("NEGATIVE CYCLE");
		else for(i=0;i<V;i++){
			if(dist[i]>=INF)puts("INF");
			else printf("%d\n",dist[i]);
		}
	//}
}

Measured memory_bytes: 1168
x,y,a,b,c = map(int,input().split())
n = a+b+c
ar = list(map(int,input().split()))
br = list(map(int,input().split()))
cr = list(map(int,input().split()))
ls = []
for i in ar:
  ls.append([i,1])
for i in br:
  ls.append([i,2])
for i in cr:
  ls.append([i,3])
ls.sort(reverse = True)
nx = 0
ny = 0
cnt = 0
res = 0
for item in ls:
  if item[1]==1:
    if nx==x: continue
    nx+=1
  if item[1]==2:
    if ny==y: continue
    ny+=1
  res+=item[0]
  cnt+=1
  if cnt==x+y:
    break
print(res)

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

int main() {
  string s;
  cin >> s;
  int counter = 0;
  if (s[0] == 'o') ++counter;
  if (s[1] == 'o') ++counter;
  if (s[2] == 'o') ++counter;
  int a = counter*100;
  cout << 700 + a << endl;
}

Measured memory_bytes: 256
// #include C/C++ {
#include <bits/stdc++.h>
// }
using namespace std;
// #typedef {
typedef long long int64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
// }

// #parameter{
#ifdef DEBUG_MODE

#define TYPE decltype
#define RF(filename) {freopen((filename), "r", stdin);}
#define WF(filename) {freopen((filename), "w", stdout);}
#define DF(filename) {freopen((filename), "w", stderr);}
#define eprintf printf

#else

#define TYPE __typeof
#define RF(filename) {;}
#define WF(filename) {;}
#define DF(filename) {;}
#define eprintf(...)
#define fprintf(...)

#endif

// #define {
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define MP make_pair
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define ALL(it) (it).begin(), (it).end()
#define FILL(__space, __val) memset(__space, __val, sizeof(__space))
#define MOVE(__spaceTo, __spaceFrom) memmove(__spaceTo, __spaceFrom, sizeof(__spaceTo))
#define UNIQUE(__vector) sort(ALL(__vector)), __vector.resize(unique(ALL(__vector)) - __vector.begin())
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = acos(-1.0);
const double EPS = 1e-6;

#define MAX_N 100005
#define MAX_M 5005
#define MOD (int)(1e9+7)
#define INF ((1 << 30) - 1)
#define BINF ((1LL << 62) - 1LL)
#define NONE -1
#define NIL 0
// }

/////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////
int main() {
	RF("input.txt");
	//  WF("output.txt");
	DF("err.txt");

	int N, M, C;
	scanf("%d %d %d", &N, &M, &C);
	int B[MAX_N];
	for(int i = 0; i < M; i++) scanf("%d", B + i);

	int res = 0;
	while(N--){
		int A[MAX_N];
		for(int i = 0; i < M; i++) scanf("%d", A + i);
		int sum = 0;
		for(int i = 0; i < M; i++){
			sum += A[i] * B[i];
		}
		sum += C;
		if(sum > 0) res++;
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 256
import math
import sys
import numpy as np
from collections import defaultdict, deque, Counter 
from itertools import accumulate, product, permutations,combinations, combinations_with_replacement
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd

max_value = 1000000000
min_value = -1000000000
sys.setrecursionlimit(max_value)

N = int(input())
As = list(map(int,input().split()))
Bs = list(map(int,input().split()))

v = 0
for i in range(N):
    if As[i] >= Bs[i]:
        v += Bs[i]
        As[i] -= Bs[i]
        Bs[i] = 0
        continue
    else:
        v += As[i]
        Bs[i] -= As[i]
        As[i] = 0
        if As[i+1] >= Bs[i]:
            v += Bs[i]
            As[i+1] -= Bs[i]
            Bs[i] = 0
        else:
            v += As[i+1]
            Bs[i] -= As[i+1]
            As[i+1] = 0
print(v)


Measured memory_bytes: 29124
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;

int main(){
    string s;

    cin >> s;

    int cnt = s.size()-2;
    string ans;
    ans = s[0]+to_string(cnt)+s[s.size()-1];

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18+10;
const int mod = 1e9+7;
const int N = 401;
using ll = long long;
ll n,dp[N][N], arr[N], cum[N];
void add_self(int &a, int b) {
    a = (a + b) % mod;
    if(a < 0) a += mod;
}
ll f(int i, int j) {
    return cum[j]-cum[i-1] + dp[i][j];
}

map<pair<int, int>,int> M;
int main()
{
    scanf("%lld", &n);
    for(int i =1; i <= n; i++) scanf("%lld", &arr[i]);
    for(int i = 1; i <= n; i++) cum[i] = cum[i-1] + arr[i];
    for(int i =1; i <= n; i++) {
        for(int j = 1; j <= n; j++) {
            dp[i][j]=inf;
        }
    }
    for(int sz = 1; sz <= n; sz++) {
        for(int i = 1; i <= n; i++) {
            int j = i+sz-1;
            if(j > n) break;
            if(sz==1) dp[i][j]=0;
            else {
                for(int k = i; k < j; k++) {
                    dp[i][j] = min(dp[i][j], f(i, k) + f(k+1, j));
                    //dp[i][j] = min(dp[i][j], f(i, k)+f(k+1,j));
                }
            }
        }
    }
    printf("%lld\n", dp[1][n]);
    return 0;
}

//dp[2][1] += (dp[1][2])

Measured memory_bytes: 5088
void main(){
	int[] val = inln();
	val.sort();
	writeln( val[2]==val[0]+val[1]? "Yes":"No" );
}
     
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range;
const long mod = 10^^9+7;      
// 1要素のみの入力
T inelm(T= int)(){
	return to!(T)( readln().chomp() );
}
     
// 1行に同一型の複数入力
T[] inln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split())ln ~= elm.to!T();
	return ln;
}


Measured memory_bytes: 2752
using System;
using System.Collections.Generic;

public static class Program
{
	public class Process
	{
		public string name;
		public int time;
	}

	public static void Main()
	{
		var lineList = Console.ReadLine().Split(' ');
		int n = int.Parse(lineList[0]);
		int q = int.Parse(lineList[1]);
		var queue = new Queue<Process>();
		for (int i = 0; i < n; i++)
		{
			lineList = Console.ReadLine().Split(' ');
			var process = new Process()
			{
				name = lineList[0],
				time = int.Parse(lineList[1])
			};
			queue.Enqueue(process);
		}
		int time = 0;
		while (queue.Count > 0)
		{
			var process = queue.Dequeue();
			if (process.time <= q)
			{
				time += process.time;
				Console.WriteLine(string.Format("{0} {1}", process.name, time));
			}
			else
			{
				time += q;
				process.time -= q;
				queue.Enqueue(process);
			}
		}
	}
}



Measured memory_bytes: 17612
#include<stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
 
int asc(const void *a, const void *b) {
    char *left_char = (char *)a;
    char *right_char = (char *)b;
    return strcmp( left_char, right_char );
}

int main(){
    int n,i,j,c=1;
    scanf("%d",&n);
    char s[200001][12];
    for(i=0;i<n;i++){
        scanf("%11s",s[i]);
    }
    //for(i=0;i<n;i++){ printf("%s\n",s[i]); }
    qsort(s, n, sizeof(*s), asc);
    //for(i=0;i<n;i++){ printf("%s\n",s[i]); }
    for(i=0;i<n-1;i++){
        if(strcmp(s[i],s[i+1])!=0){ c++; }
    }
    printf("%d",c);
    return 0;
}


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

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

using namespace std;
using lint=long long;

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

	lint ans;
	if(a>0) ans=b/x-(a-1)/x;
	else    ans=b/x+1;
	cout<<ans<<'\n';

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) \
    for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) \
    for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(), v.end()
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 1e9 + 7LL;
template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
    for (int i = 0; i < v.size(); ++i) {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (int i = 0; i < v.size() - 1; ++i) {
        os << v[i] << " ";
    }
    if (v.size() > 0) {
        os << v[v.size() - 1] << endl;
    }
    return os;
}

int main() {
    vint x(5);
    cin >> x;
    REP(i,5){
        if (x[i] == 0){
            cout << i + 1 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3624
#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>;

bool check(vector<P> s) {
  int h = 0;
  for (P p : s) {
    int b = h+p.first;
    if (b < 0) return false;
    h += p.second;
  }
  return true;
}

int main() {
  int n;
  cin >> n;
  vector<P> ls, rs;
  int total = 0;
  rep(i,n) {
    string s;
    cin >> s;
    int h = 0, b = 0;
    for (char c : s) {
      if (c == '(') ++h; else --h;
      b = min(b, h);
    }
    if (h > 0) ls.emplace_back(b, h);
    else rs.emplace_back(b-h, -h);
    total += h;
  }
  sort(ls.rbegin(), ls.rend());
  sort(rs.rbegin(), rs.rend());
  if (check(ls) && check(rs) && total == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 18744
N, T = (int(x) for x in input().split())
cost_min = 1001
for i in range(N) :
    cost, time = (int(x) for x in input().split())
    if time <= T and cost < cost_min :
        cost_min = cost
if cost_min > 1000 :
    print("TLE")
else :
    print(cost_min)

Measured memory_bytes: 3060
#include <stdio.h>
int main (void)
{
   int n,i;
   long ans = 0;
   scanf("%d",&n);
   for(i=1;i<=n;i++){
      if(i%3!=0 && i%5!=0)ans+=i;
   }
   printf("%ld\n",ans);
   return 0;
}


Measured memory_bytes: 1736
package main

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

////////////////////////////////////////
///        templates                 ///
////////////////////////////////////////

var sc = bufio.NewScanner(os.Stdin)

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

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
        buf := make([]byte, 0, 1000000)
        for {
                l, p, e := rdr.ReadLine()
                if e != nil {
                        panic(e)
                }
                buf = append(buf, l...)
                if !p {
                        break
                }
        }
        return string(buf)
}

func strSprit(str string) []string {
        cols := strings.Split(str, " ")
        return cols
}

func parseInt(str string) int {
        n, _ := strconv.Atoi(str)
        return n
}

func intSprit(str string) []int {
        strs := strSprit(str)
        cols := make([]int, len(strs))
        for i, v := range strs {
                cols[i] = parseInt(v)
        }
        return cols
}

type SortSlice []int

func (s SortSlice) Len() int {
        return len(s)
}

func (s SortSlice) Swap(i, j int) {
        s[i], s[j] = s[j], s[i]
}

func (s SortSlice) Less(i, j int) bool {
        return s[i] < s[j]
}

func reverseString(str string) string {
        buf := []rune(str)
        for i, j := 0, len(buf)-1; i < j; i, j = i+1, j-1 {
                buf[i], buf[j] = buf[j], buf[i]
        }
        return string(buf)
}

////////////////////////////////////////
///        end templates             ///
////////////////////////////////////////

func countLen(i int, a []int) int {
        r := 1
        for t := i; t < len(a)-1; t++ {
                if a[t] != a[t+1] {
                        break
                }
                r++
        }
        return r
}

func main() {
        line := nextLine()
        N := parseInt(line)

        line = nextLine()
        spl := strSprit(line)

        a := make([]int, N)

        for i := 0; i < N; i++ {
                a[i] = parseInt(spl[i])
        }

        idx := 0
        c := 0
        for idx < N-1 {
                if a[idx] == a[idx+1] {
                        d := countLen(idx, a)
                        idx += d - 1
                        c += d / 2
                }
                idx++
        }
        fmt.Println(c)

}



Measured memory_bytes: 640
import java.util.*;
public class Main {
	String[] tile;
	boolean[][] board;
	String error;
	int nowx = 0, nowy = 0;

	void dfs() {
		if(nowx < 0 || nowx >= tile[0].length() || nowy < 0 || nowy >= tile.length || tile[nowy].charAt(nowx) == '.' || error != null) return;
		switch(tile[nowy].charAt(nowx)) {
		case '>':nowx++;break;
		case '<':nowx--;break;
		case 'v':nowy++;break;
		case '^':nowy--;break;
		case '.':return;
		}
		if(board[nowy][nowx]) {
			error = "LOOP"; //既に訪れたら、ループ状態に突入してしまう。
			return;
		}
		board[nowy][nowx] = true; //調査済み
		dfs();
	}

	void doIt() {
		Scanner stdIn = new Scanner(System.in);
		while(true) {
			int height = stdIn.nextInt();
			int width = stdIn.nextInt();
			if(width + height == 0) break;
			tile = new String[height];
			board = new boolean[height][width];
			error = null;
			nowx = nowy = 0;
			
			for(int r =0; r < tile.length; r++) {
				tile[r] = stdIn.next();
			}
			board[0][0] = true;
			dfs();

			System.out.println(((error == null) ? (nowx + " " + nowy) : error));
		}
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		new Main().doIt();
	}

}

Measured memory_bytes: 21812
import sys
from collections import deque

input = sys.stdin.readline


def dfs(N):
    alphabet = "abcdefghij"
    stack = deque(["a"])
    ans = []
    while stack:
        s = stack.pop()
        if len(s) == N:
            ans.append(s)
            continue
        for suffix in reversed(alphabet[:len(set(s)) + 1]):
            stack.append("".join((s, suffix)))
    return ans


def main():
    N = int(input())

    ans = dfs(N)
    print("\n".join(ans))


if __name__ == "__main__":
    main()


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>A[i], A[i]--;
	int ret=0;
	FOR(i,N) if(A[i]==i) swap(A[i],A[i+1]), ret++;
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 640
MOD = 10**9+7
n = int(input())
a = list(map(int, input().split()))
ans = 0
for b in range(61):
	zero, one = 0, 0
	for x in a:
		if (x>>b)&1:
			one += 1
		else:
			zero += 1
	ans += zero*one*(1<<b)
	ans %= MOD
print(ans)

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

#define int long long

signed main() {
  string s;
  map<string, bool> m;
  cin >> s;
  int k;
  cin >> k;
  char b;

  int l = s.size();
  for ( int i = 0; i < l; i++ ) {
    b = min(b, s[i]);    
  }
  for ( int i = 0; i < l; i++ ) {
    string a = "";
    for ( int j = i; j < min(l, i+10); j++ ) {      
      a.push_back(s[j]);
      m[a] = true;
    }
  }

  auto it = m.begin();
  for ( int i = 0; i < k-1; i++ ) it++; 
  cout << it->first << endl;  
  
  return 0;
}


Measured memory_bytes: 4736
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sys/time.h>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>

using namespace std;

void solve(long long N, long long M){
    if (N == 1 || M == 1) {
        if (N == 1 && M == 1) {
            std::cout << 1 << std::endl;
            return;
        } else {
            std::cout << max(N, M) - 2 << std::endl;
        }
    } else {
        std::cout << (N-2) * (M-2) << std::endl;
    }
}

int main(){	
    struct timeval start,end;
    long long span;
    gettimeofday(&start,NULL);

    long long M;
    long long N;
    scanf("%lld",&N);
    scanf("%lld",&M);
    solve(N, M);

    gettimeofday(&end,NULL);
    span = (end.tv_sec -start.tv_sec)*1000000LL + (end.tv_usec - start.tv_usec);
    std::cerr << "--Total Time: " << span/1000 << "ms" << endl;
    return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long ll;

int main(){
	int n, a, b;
	string s;
	cin >> n >> a >> b >> s;
	int cnt = 0, bcnt = 0;
	for (int i = 0; i < s.size(); ++i)
	{
		// cout << i << endl;
		if(s[i]=='a'){
			// cout << 'a';
			if(cnt < a+b){
				cout << "Yes" << endl;
				cnt++;
			}
			else cout << "No" << endl;
		}
		if(s[i]=='b'){
			// cout << 'b';
			if(cnt < a+b and bcnt+1 <= b){
				cout << "Yes" << endl;
				cnt++;
				bcnt++;
			}
			else cout << "No" << endl;
		}
		if(s[i]=='c') cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 896
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 65;
const int mod = 1000000007;

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  string s;
  cin>>s;
  if(s=="AAA"||s=="BBB")cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return 0;
}


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

string T,TT[10000];
int sum;

string Rev(string S)
{
  reverse(S.begin(),S.end());
  return S;
}

int Con(string S)
{
  for(int i=0;i<sum;i++){
    if(TT[i]==S)return 0;
  }
  return 1;
}

int main()
{
  int m,len;
  string left,right;
  cin>>m;
  for(int i=0;i<m;i++){
    cin>>T;
    len=T.length();
    sum=0;
    TT[sum++]=T;
    for(int j=1;j<len;j++){
      left=T.substr(0,j);
      right=T.substr(j,len);
      if(Con(left+Rev(right)))TT[sum++]=left+Rev(right);
      if(Con(Rev(left)+right))TT[sum++]=Rev(left)+right;
      if(Con(Rev(left)+Rev(right)))TT[sum++]=Rev(left)+Rev(right);
      if(Con(right+left))TT[sum++]=right+left;
      if(Con(right+Rev(left)))TT[sum++]=right+Rev(left);
      if(Con(Rev(right)+left))TT[sum++]=Rev(right)+left;
      if(Con(Rev(right)+Rev(left)))TT[sum++]=Rev(right)+Rev(left);
    }
    cout<<sum<<endl;
  }
  return 0;
}

Measured memory_bytes: 1360
N,M = map(int,input().split())
ls_1 = []
ls_2 = []
ls_3 = []
for i in range(M):
    s,c = map(int,input().split())
    if s == 1:
        ls_1.append(c)
    elif s == 2:
        ls_2.append(c)
    else:
        ls_3.append(c)
if len(set(ls_1)) > 1 or len(set(ls_2)) > 1 or len(set(ls_3)) > 1 or (N > 1 and len(ls_1) > 0 and sum(ls_1)==0):
    print(-1)
else:
    if len(ls_1) == 0:
        if N > 1:
            ls_1.append(1)
        else:
            ls_1.append(0)
    if len(ls_2) == 0:
        ls_2.append(0)
    if len(ls_3) == 0:
        ls_3.append(0)
    
    ans = (10 **(N-1)) * ls_1[0] + (10**((N-2)*(N-1)// 2)) * ls_2[0] + ((N-2)*(N-1) // 2) * ls_3[0]
    print(ans)

Measured memory_bytes: 3064
function Main(input) {
  input=input.split("\n");
  var X=input[0]-0;

  console.log(Math.ceil((2*Math.abs(X)+1/4)**(1/2)-1/2));
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  
  


Measured memory_bytes: 29560
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
using graph = vector<vector<int>>;
int main(){
    int n, m; cin >> n >> m;
    int ans = 0;
    if(n>0){
        ans += n * (n-1) / 2;
    }
    if(m>1){
        ans += m * (m-1) / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
const ll mod=1e9+7;

int main(){
  int n;
  cin>>n;
  ll a[n];
  rep(i,0,n) cin>>a[i];
  ll b[n+1];
  b[0]=0;
  rep(i,0,n){
    b[i+1]=b[i]+a[i];
    b[i+1]%=mod;
  }
  ll sum=0;
  rep(i,0,n-1){
    ll c=b[n]-b[i+1];
    if(c<0) c+=mod;
    sum+=a[i]*c%mod;
    sum%=mod;
  }
  cout<<sum<<endl;
}

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

int main(void) {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  sort(a.begin(), a.end());
  cout << a[a.size() - 1] - a[0] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <bitset>
#include <functional>
using namespace std;
const constexpr int INF = 1e9;
//typedef std::pair<std::string,double> P;

typedef long long ll;
typedef vector<int> VI;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

//グラフの隣接リスト
VI g[200010];
//頂点の入次数を管理
int h[100010];

map<int, int> mp[220000];
signed main(void) {
    int N, M; cin >> N >> M;
    for(int i=0; i<M; ++i){
        int a, b; cin >> a >> b;
        a--; b--;
        mp[a][b]=1;
        mp[b][a]=1;
    }
    bool ok = false;
    for(int i=0; i<N; ++i){
        if(mp[0][i]&&mp[i][N-1]) ok = true;
    }
    if(ok) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
	return 0;
}


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

int main(){
  int H,W,N;
  cin >> H >> W >> N;
  int sr,sc; cin >> sr >> sc;
  sr--; sc--;
  string S,T;
  cin >> S >> T;
  
  //高橋は方向を1つに絞ってやればよい
  //（取り除ける列が存在したとき、取り除いた方向以外は、縦横が違うか、それを打ち消してるか）
  //青木がそれに対抗できるか（逆に動かし続けられるか）
  int tr,tc;
  bool f=false;
  
  //L
  tc=sc;
  for(int i=0; i<N; i++){
    if(S[i]=='L') tc--;
    if(tc<0) f=true;
    if(T[i]=='R') tc=min(tc+1,W-1);
  }
  
  //R
  tc=sc;
  for(int i=0; i<N; i++){
    if(S[i]=='R') tc++;
    if(tc>=W) f=true;
    if(T[i]=='L') tc=max(tc-1,0);
  }
  
  //U
  tr=sr;
  for(int i=0; i<N; i++){
    if(S[i]=='U') tr--;
    if(tr<0) f=true;
    if(T[i]=='D') tr=min(tr+1,H-1);
  }
  
  //D
  tr=sr;
  for(int i=0; i<N; i++){
    if(S[i]=='D') tr++;
    if(tr>=H) f=true;
    if(T[i]=='U') tr=max(tr-1,0);
  }
  
  cout << (f?"NO":"YES") << endl;
}

Measured memory_bytes: 776