akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
int N;
ll A,B,inf = 1e9+7;

int main(){
	cin >> N >> A >> B;
	vector<ll> S(N+1,0),dp(N+1,0);
	if(A>B) swap(A,B);
	bool judge = true;
	for(int i=1;i<=N;i++){
		cin >> S[i];
		if(i>2 && S[i]-S[i-2]<A) judge = false;
	}
	S[0] = -1;
	if(!judge){
		cout << 0 << endl;
		return 0;
	}
	dp[0] = 1;
	int id = 0;//S[i]-S[i+1]<Aとなるi
	for(int i=1;i<=N;i++){
		(dp[i] += dp[i-1])%=inf;
		int s = lower_bound(S.begin(),S.end(),S[i]-B)-S.begin();
		if(S[i]-B>=0 && S[s]>S[i]-B) s--;
		if(s>=id){
			if(id>=1) (dp[i] += dp[s]-dp[id-1]+inf)%=inf;
			else (dp[i] += dp[s])%=inf;
		}
		if(S[i]-S[i-1]<A) id = i-1;
	}
	if(id>=1) cout << (dp[N]-dp[id-1]+inf)%inf << endl;
	else cout << dp[N] << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>
#include <cmath>


using namespace std;
using Graph = vector<vector <bool>>;

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (1){
       c -= b;
       if(c<=0){
            cout << "Yes" << endl;
            return 0;
       }
       a-= d;
       if(a<=0){
          cout << "No" << endl;
          return 0;
       }
    }
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long int64;
const int INF = 1e9;

template<class T>
void WarshallFloyd(vector<vector<T>> &G, T INF) {
    for(int i = 0; i < G.size(); ++i) G[i][i] = 0;
    for(int k = 0; k < G.size(); ++k) {
        for(int i = 0; i < G.size(); ++i) {
            for(int j = 0; j < G.size(); ++j) {
                if(G[i][k] == INF || G[k][j] == INF) continue;
                G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
            }
        }
    }
}

int main() {
    int N, M, R;
    cin >> N >> M >> R;
    vector<int> r(R);
    rep(i, R) cin >> r[i], r[i]--;
    vector<vector<int>> dist(N, vector<int>(N, INF));
    rep(i, M) {
        int a, b, c;
        cin >> a >> b >> c;
        --a, --b;
        dist[a][b] = dist[b][a] = c;
    }
    WarshallFloyd(dist, INF);
    sort(r.begin(), r.end());
    int ans = INF;
    do {
        int tmp = 0;
        rep(i, R - 1) {
            tmp += dist[r[i]][r[i + 1]];
        }
        ans = min(ans, tmp);
    } while(next_permutation(r.begin(), r.end()));
    cout << ans << '\n';
    return 0;
}


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

using namespace std;
#define ll long long
const int N = 2e5 + 5;
int vis[N];
vector<int> g[N];

void dfs(int node, int &cnt) {
    if (vis[node]) return;
    vis[node] = 1;
    ++cnt;
    for (auto u:g[node]) dfs(u, cnt);
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (vis[i])continue;
        int cnt = 0;
        dfs(i, cnt);
        ans = max(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 21608
// Created by sz
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;

const int N = 1e5 + 5;


int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int H,W,h,w;
    cin>>H>>W>>h>>w;
    cout<<H*W - h*W - H*w + h*w<<endl;
    return 0;
}


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

string s;
ll int k;

int main(void)
{
	cin >>s>>k;

	ll int cnt=0;
	for(int i=0; i<k; i++) {
		if(s[i]!='1') {
			cout <<s[i];
			return 0;
		}
	}

	printf("%d\n", 1);

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	long long int n,a,b,x=0,y=0;
	scanf("%lld %lld %lld",&n,&a,&b);
	x=n/(a+b)*a;
	y=n%(a+b);
	if(y>a)	y=a;
	printf("%lld\n",x+y);
	return 0;
}


Measured memory_bytes: 1712
#include <stdio.h>
char S[5];
int A[3]={0};
int main(int argc, char *argv[]){
	int i;
	scanf("%s", S);
	for(i=0; i<3; i++){
		A[S[i]-'a']++;
	}
	if(A[0]==1 && A[1]==1 && A[2]==1) printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 128
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()
import math

def resolve():
    import sys
    input = sys.stdin.readline
    a, b = [int(x) for x in input().rstrip().split(" ")]

    for i in range(int(100.0 / 0.08) + 1):
        if int(i * 0.08) == a and int(i * 0.1) == b:
            print(i)
            return
    print(-1)



if __name__ == "__main__":
    resolve()


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

int main(int argc, char **argv)
{
	int N; cin >> N;
	vector<int> h(N); for (int i = 0; i < N; ++i) cin >> h[i];

	int res{0};
	while (true)
	{
		if (*max_element(h.begin(), h.end()) == 0) break;
		int i{0};
		while (i < N)
		{
			if (h[i] == 0)
			{
				++i;
				continue;
			}

			while (i < N && h[i] != 0)
			{
				--h[i];
				++i;
			}
			++res;
		}
	}
	
	std::cout << res << std::endl;
}

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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = INF + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

const int N = 400 + 7;

int n;
int a[N];

bool read () {
	if (scanf("%d", &n) != 1)
		return false;
	forn(i, n)
		scanf("%d", &a[i]);
	return true;
}

li dp[N][N];
li pr[N];

void solve() {	
	pr[0] = 0;
	forn(i, n)
		pr[i + 1] = pr[i] + a[i];
	forn(i, n) forn(j, n) dp[i][j] = INF64;
	forn(i, n) dp[i][i] = 0;
	fore(len, 2, n + 1) forn(l, n - len + 1){
		int r = l + len - 1;
		fore(i, l, r)
			dp[l][r] = min(dp[l][r], dp[l][i] + dp[i + 1][r] + pr[r + 1] - pr[l]);
	}
	printf("%lld\n", dp[0][n - 1]);
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	
	int tt = clock();
	
#endif
	
	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

	while(read()) {	
		solve();
		
#ifdef _DEBUG
	cerr << "TIME = " << clock() - tt << endl;
	tt = clock();
#endif

	}
}	

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = ((B)-1); I >= (A); --I)
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

// http://sesenosannko.hatenablog.com/entry/2017/09/01/214852
struct Bellman_Ford{
	struct edge{ll from, to, cost;};
	ll inf = 100000000005LL;
	vector<edge> es;
	vector<ll> d;
	ll V,E;
	void init(ll v,ll e){
		V = v; E = e;
		d.resize(V);
	}
	void shortest_path(ll s){
		FOR(i,0,V) d[i] = inf;
		d[s] = 0;
		FOR(i,0,V){
			FOR(j,0,E){
				edge e = es[j];
				if(d[e.from]!=inf && d[e.to]>d[e.from] + e.cost){
					d[e.to] = d[e.from] + e.cost;
				}
			}
		}
	}
	bool find_negative_loop(){
		FOR(i,0,V)d[i] = 0;
		FOR(i,0,V){
			FOR(j,0,E){
				edge e = es[j];
				if(d[e.to]>d[e.from] + e.cost){
					d[e.to] = d[e.from] + e.cost;
					if(i == V-1) return true;
				}
			}
		}
		return false;
	}
	bool shortest_path(int s, int t){ // t: destination
		FOR(i,0,V)d[i] = inf;
		d[s] = 0;
		FOR(i,0,2*V){
			FOR(j,0,E){
				edge e = es[j];
				if(d[e.from]!=inf && d[e.to]>d[e.from] + e.cost){
					d[e.to] = d[e.from] + e.cost;
					if(i>=V-1 && e.to==t) return true;
				}
			}
		}	
		return false;
	}
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	Bellman_Ford bf;
	ll N,M,p;
	cin >> N >> M >> p;
	bf.init(N,M);
	FOR(i,0,M){
		ll a,b,c;
		cin >> a >> b >> c;
		bf.es.push_back({a-1,b-1,-c+p});
	}
	if(bf.shortest_path(0,N-1)){
		cout << -1 << endl;
	}else{
		cout << max(-bf.d[N-1],0LL) << endl;
	}
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  //b,a
  int n;
  cin >> n;
  vector<pll> ba(n);
  
  REP(i,n)
    cin >> ba[i].SE >> ba[i].FI;
  
  sort(ba.begin(), ba.end());
  ll timesum = 0;
  REP(i,n){
    timesum += ba[i].SE;
    //cout << timesum << endl;
    if(timesum > ba[i].FI){
      cout << "No" << "\n";
      return 0;
    }
  }
  
  cout << "Yes" << "\n";
}

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


int main() {
  int  a , b ;
  cin >> a >> b ;
  
  cout << a/b << endl;
  
  cout << a%b << endl;
  
  double c=a;
  double d=b;
  
  cout << fixed << setprecision(7);
  cout << c/d <<endl;
  
}


Measured memory_bytes: 3276
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using P = pair<int, int>;

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

    int n;
    cin >> n;
    map<int, int> mp;
    for (int i = 0; i < n; i++)
    {
        int s;
        cin >> s;
        mp[s]++;
    }
    int q;
    cin >> q;
    int ret = 0;
    while (q--)
    {
        int t;
        cin >> t;
        if (mp[t])
            ret++;
    }
    cout << ret << endl;
}



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

typedef long long ll;
#define vec vector<int>
#define vecll vector<ll>
#define vpair vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define rep(i,n)   for(int i=(int)0; i<(int)n; i++)
#define llrep(i,n)   for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n) for(int i=(int)m; i<(int)n; i++)
#define all(var)     (var).begin(), (var).end()
#define prt(var)     cout << var << endl
#define prt_dbl(i,var) cout<<fixed<<setprecision(i)<<var<<endl;
template <typename Val>
Val gcd(Val a, Val b) {
//use ll or int for gcd
    if (b==0) return a;
    else return gcd(b, a%b);
}
template <typename Val>
Val vec_max(vector<Val> v){
  return *max_element(v.begin(),v.end());
}
template <typename Val>
Val vec_min(vector<Val> v){
  return *min_element(v.begin(),v.end());
}
//---------------------------------------------------------------
int main(){
  string S,T,ans;
  cin>>S>>T;
  ans = "Yes";
  rep(i,S.size()){
    if(S.at(i)!=T.at(i)){
        ans = "No";
    }
  }

  cout<<ans<<endl;




}


Measured memory_bytes: 3628
n,k,c = map(int, input().split())
s = input()
ok = []
for i,x in enumerate(s):
    if x == "o":
        ok.append(i)

fast = []
pre = -10**10
for i,x in enumerate(s):
    if x == "o" and pre + c < i:
        fast.append(i+1)
        pre = i
    if len(fast) == k:
        break
late = []
pre = -10**10
for i,x in enumerate(s[::-1]):
    if x == "o" and pre + c < i:
        late.append(n-i)
        pre = i
    if len(late) == k:
        break
late = late[::-1]
for i in range(k):
    if fast[i] == late[i]:
        print(fast[i])


Measured memory_bytes: 63096
#coding:utf-8
n,k = map(int,input().split())
ls = []
for i in range(n):
    ls.append(int(input()))
#ls = [100000-i for i in range(100000)]
#n = 100000
#k = 1000
ls = sorted(ls)
ans = 1000000000
for i in range(n-k+1):
    mx = ls[i+k-1]
    mn = ls[i]
    ans = min(ans,mx - mn)
print (ans)

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  int R=0;
  bool cont = false;
  for(int i=0;i<3;i++){
    if(S.at(i) == 'R'){
      // cout << "in:"<< R;
      if(!cont){
        R = 0;
      }
      R++;
      cont = true;
    }
    else{
      cont = false;
    }
  }
  cout << R << endl;
}

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

N, M = map(int, input().split())
hsh = {}
for i in range(M):
    hsh[int(input())] = True

acc = [0 for _ in range(N+1)]
acc[0] = 1

for i in range(1,N+1):
    if i > 1 and i-2 in hsh:  # 2段前が穴
        if i-1 in hsh: # 1段前が穴
            d = 0
        else:
            d = acc[i-1]
    else:  # 2段前が穴ではない
        s = acc[i-2] if i > 1 else 0
        if i-1 in hsh:  # 1段前が穴
            d = s
        else: 
            d = acc[i-1] + s
    acc[i] = d

# print(hsh)
# print(acc)
print(acc[-1]%1000000007)


Measured memory_bytes: 460056
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
    int n; cin >> n;
    vector<ll> a(n);

    REP(i, n) cin >> a[i];

    vector<ll> l(n, 0), r(n, 0);
    l[0] = a[0]; r[n-1] = a[n-1];

    REP(i, n-1) {
        l[i+1] = l[i] + a[i+1];
        r[n-2-i] = r[n-1-i] + a[n-2-i];
    }

    reverse(r.begin(), r.end());

    ll ans = numeric_limits<ll>::max();
    REP(i, n-1) {
        ans = min(ans, abs(l[i] - r[n-2-i]));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
const int mod=1000000007;

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> box(n+1,1);
  for(int i=0;i<m;i++) {
    int temp;
    cin >> temp;
    box.at(temp)=0;
  }
  
  vector<int> dp(n+1,1);
  dp.at(1)=dp.at(0)*box.at(1);
  for(int i=0;i<n-1;i++) {
    dp.at(i+2)=(dp.at(i+1)+dp.at(i))%mod;
    dp.at(i+2)*=box.at(i+2);
    //cout << dp.at(i+2) << endl;
  }
  cout << dp.at(n) << endl;
}


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

int dfs(int i, int sum);

int qq[10][11];	//[i][j] i*j
int nmax[11][11] = {0};
int used[10] = {0};
int n, s;

int main() {
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 11; j++) {
			qq[i][j] = i*j;
		}
	}
	for (int i = 0; i < 11; i++) {
		for (int j = i-1; j >= 0; j--) {
			nmax[i][j] += nmax[i][j+1] + (9-(i-1-j))*(i-(i-1-j));
		}
	}

	while ((cin >> n >> s) != NULL) {
		cout << dfs(0, 0) << endl;
		for (int i = 0; i < 10; i++)
			used[i] = 0;
	}
	return 0;
}

int dfs(int d, int sum) {
	int count = 0;
	
	if (d == n) {
		if (sum == s)
			return 1;
		else
			return 0;
	}
	if (sum > s)
		return 0;
	if (sum + nmax[n][d] < s) {
		return 0;
	};

	for (int i = 0; i < 10; i++) {
		if (!used[i]) {
			used[i] = d + 1;
			count += dfs(d + 1, sum + qq[i][used[i]]);
			used[i] = 0;
		}
	}

	return count;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int A, B;
    cin >> A >> B;
    for (double i = 1; i < 1e6; i++)
    {
        if (floor(i * 0.08) == A and floor(i * 0.1) == B)
        {
            cout << (int)i;
            return 0;
        }
    }
    cout << -1;
    return 0;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
arr = []
ans = [0 for i in range(m+1)]
for i in range(n):
    arr.append(list(map(int,input().split())))
for i in arr:
    for j in i[1:]:
        ans[j-1] +=1
val = 0
for i in ans:
    if i == n:
        val +=1
print(val)

Measured memory_bytes: 38256
import queue
import copy
import math
from collections import deque
import bisect

# 2つの入力を空白で分割し、数値化
n, k = map(int, input().split())

# 空白区切りの数値をリスト化
pn = list(map(int, input().split()))

expects = []
max_e = 0
prev_e = 0

for p, i in zip(pn, range(0, n)):
    e = (((1 + p) * p) // 2) / p
    expects.append(e)
    if i + 1 == k:
        max_e = sum(expects)
        prev_e = max_e
    elif i + 1 > k:
        current_e = prev_e + expects[-1] - expects[i-k]
        max_e = max(max_e, current_e)
        prev_e = current_e
    else:
        continue

print(max_e)



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

struct QueueOfInt {
	int max;
	int *value;
	int front;
	int rear;
	int count;
	QueueOfInt() {
		max = 100;
		count = 0;
		value = new int[max];
		front = 1;
		rear = 0;
	}
	void push(int x) {
		if (count > 0.9 * max) {
			int *temp = value;
			value = new int[max * 2];
			int i, j;
			for (i = 1, j = front; i <= count; i++, j = (j + 1) % max)
				value[i] = temp[j];
			front = 1;
			rear = count;
			max = max * 2;
			delete[] temp;
		}
		rear = (rear + 1) % max;
		count++;
		value[rear] = x;
	}
	int top() {
		return value[front];
	}
	void pop() {
		if (max != 100 && count < 0.1) {
			int *temp = value;
			value = new int[max / 2];
			int i, j;
			for (i = 1, j = front; i < count; i++, j = (j + 1) % max)
				value[i] = temp[j];
			max = max / 2;
			front = 1;
			rear = count;
			delete[] temp;
		}
		front = (front + 1) % max;
		count--;
	}
	bool empty() {
		return count == 0;
	}
};

struct ArrayOfQueue {
	QueueOfInt *value;
	int n;
	ArrayOfQueue(int x) {
		n = x;
		value = new QueueOfInt[n];
	}
	void enqueue(int t, int x) {
		value[t].push(x);
	}
	int front(int t) {
		return value[t].top();
	}
	void dequeue(int t) {
		value[t].pop();
	}
	bool empty(int t) {
		return value[t].empty();
	}
};

int main(void) {
	int n, q, com, t, x;
	cin >> n >> q;
	ArrayOfQueue ar(n);
	while (q--) {
		cin >> com >> t;
		if (com == 0) {
			cin >> x;
			ar.enqueue(t, x);
		} else if (com == 1) {
			if (!ar.empty(t))
				cout << ar.front(t) << endl;
		} else {
			if (!ar.empty(t))
				ar.dequeue(t);
		}
	}
}


Measured memory_bytes: 4880
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std; using ll=long long; using P=pair<ll,ll>; const int INF=1e9; const ll LNF=1e18;

int main(){
  string s; cin>>s; s+='T';
  int x,y; cin>>x>>y;
  vector<int> v[2];
  
  int tt=0, nw=0; bool fs=true;
  for(char ch : s) {
    if (ch == 'F') nw++;
    else if (fs) {
      x -= nw; nw=0; tt^=1; fs=false;
    } else {
      if (nw > 0) v[tt].push_back(nw);
      nw=0; tt^=1;
    }
  }/*
  for(int z:v[0]) {
    cout<<z<<" ";
  } cout<<endl;
  for(int z:v[1]) {
    cout<<z<<" ";
  } cout<<endl;*/

  set<int> val[2];

  int n0 = v[0].size(), n1 = v[1].size();
  val[0].insert(0);
  for(int i=0;i<n0;i++) {
    int now = i%2, nex = (i+1)%2;
    val[nex].clear();

    for(int z:val[now]) {
      val[nex].insert(z+v[0][i]);
      val[nex].insert(z-v[0][i]);
    }
    /*
    for(int z:val[nex]) {
      cout<<z<<" ";
    } cout<<endl;*/
  }
  if (val[n0%2].find(x) == val[n0%2].end()) {
    cout<<"No"<<endl;
    return 0;
  }

  val[0].clear(); val[1].clear();
  val[0].insert(0);
  for(int i=0;i<n1;i++) {
    int now = i%2, nex = (i+1)%2;
    val[nex].clear();

    for(int z:val[now]) {
      val[nex].insert(z+v[1][i]);
      val[nex].insert(z-v[1][i]);
    }/*
    for(int z:val[nex]) {
      cout<<z<<" ";
    } cout<<endl;*/
  }
  if (val[n1%2].find(y) == val[n1%2].end()) {
    cout<<"No"<<endl;
    return 0;
  }

  cout<<"Yes"<<endl;
}

Measured memory_bytes: 640
fun main(args:Array<String>):Unit {
    readLine()!!.toInt()
    val array = readLine()!!.split(' ').map(String::toInt).toIntArray()
    repeat(readLine()!!.toInt()){
        val (b, e, t) = readLine()!!.split(' ').map(String::toInt)
        for (k in 0 until (e - b)){
            swap(array, b + k, t + k)
        }
    }
    println(array.joinToString(" "))
}

fun swap(array:IntArray, a:Int, b:Int):Unit {
    val (f, t) = Pair(array[a], array[b])
    array[a] = t
    array[b] = f
}


Measured memory_bytes: 37232
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, [ $t:tt ]) => {{
    let len = read_value!($iter, usize);
    (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  }};

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    x: usize,
  }
  let mut dp = vec![false; x + 1];
  dp[0] = true;
  for i in 100 .. 106 {
    for p in 1 .. x + 1 {
      if let Some(prev) = p.checked_sub(i) {
        dp[p] = dp[p] || dp[prev];
      }
    }
  }

  puts!("{}\n", if dp[x] { 1 } else { 0 });
}


Measured memory_bytes: 4352
#include <stdio.h>
#include<iostream>
#include <string.h>
using namespace std;
int main(void) {
    int count=0,len;
    char n[100000];
    cin >>n;
    len=(int)strlen(n);
    for(int i=0;i<len+1;i++){
        if(count==2){
            printf("Yes\n");break;
        }
        if(n[i]==n[i-1]){
            count+=1;
        }
        else{
            count=0;
        }
        if(i+1==len+1){
            printf("No\n");
        }
    }
    return 0;
}



Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

typedef int64_t  ll;
typedef uint64_t ull;

long double v[1000];
int main(void) {
    int n, i;
    double sum=0.0;
    cin >> n;
    for (i = 0; i < n; i++) {
        cin >> v[i];
    }
    sort(v, v+n);
    sum += v[0];
    for (i = 1; i < n; i++) {
        sum += v[i];
        sum /= 2.0;
    }
    printf("%.13lf\n", sum);
    
    return 0;
}


Measured memory_bytes: 256
N, K, Q = map(int, input().split())
A =[0]*N
P = [K]*N
for i in range(Q):
    p = int(input())
    A[p-1]+=1

for i in range(N):
    if K - (Q-A[i]) > 0:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 51672
#include <iostream>
#include <sstream>
#include <fstream>

#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cctype>

#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>

using namespace std;

template<typename T> ostream& operator<<(ostream& os, const vector<T>& v){
    os << "{ ";
    for (typename vector<T>::const_iterator it = v.begin(); it != v.end(); ++it)
        os << '\"' << *it << '\"' << (it + 1 == v.end() ? "" : ", ");
    os << " }";
    return os;
}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define vv(type,w,h,init) vector<vector<type>>(h,vector<type>(w,init))
typedef vector<string> vs;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long ul;
typedef unsigned long long ull;

#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define mp make_pair

void solve(int n, int k){
    vi s(k);
    rep(i, k) cin >> s[i];
    rep(i, n)rep(j, k){
        int b; cin >> b;
        s[j] -= b;
    }
    bool ok = true;
    rep(i, k){
        if (s[i] < 0) ok = false;
    }
    cout << (ok ? "Yes" : "No" ) << endl;
}

int main(){
    int n, k;
    while (cin >> n >> k, n, k){
        solve(n, k);
    }
}

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


int main() {
	string s;
	cin >> s;
	int ans = s.size();
	for (int i = 1; i < s.size();i++) {
		if (s[i - 1] != s[i]) {
			ans = min(ans, max(i, (int)s.size() - i));
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h> 
using namespace std;
int main(){
  int h,a,e=0;
  cin>>h>>a;
  if(h%a==0) cout<<h/a;
  else
  {
      while(h>=0){
    
   h=h-a;
    e++;
    
  }
  
  cout<<e;
  
  }
 return 0; 
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

/*
void print_vec(vector<ll>& v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
	return;
}
*/

ll solve(ll N, ll C, vector<ll>& x, vector<ll>& v){
	vector<ll> clock(N), anti(N), v_cum(N, 0);
	v_cum[0] = v[0];
	REP(i, N-1){
		v_cum[i+1] = v_cum[i] + v[i+1]; 
	}

	REP(i, N){
		clock[i] = v_cum[i] - x[i];
	}

	ll v_rev_cum = 0;
	REP(i, N){
		v_rev_cum += v[N-1-i];
		anti[i] = v_rev_cum - (C - x[N-1-i]);
	}

	vector<ll> anti_max(N);
	anti_max[0] = anti[0];
	for(int i=1;i<N;i++){
		anti_max[i] = max(anti[i], anti_max[i-1]);
	}

	ll res = 0;
	REP(i, N){
		res = max(res, clock[i]);
	}
	REP(i, N-1){
		res = max(res, v_cum[i] - 2 * x[i] + anti_max[N-2-i]);
	}
	return res;
}

int main(){
	ll N, C;
	cin >> N >> C;
	vector<ll> x(N), v(N);
	REP(i, N) cin >> x[i] >> v[i];
	vector<ll> x_rev(N), v_rev(N);
	REP(i, N){
		x_rev[i] = C - x[N-1-i];
		v_rev[i] = v[N-1-i];
	}
	cout << max(solve(N, C, x, v), solve(N, C, x_rev, v_rev)) << endl;
    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;
#define MOD 1000000007

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;}
template<class T> inline T gcd(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T lcm(T a,T b){return a*b/gcd(a,b);}

const int INF=1e9;
const double eps=0.0000000001;

int main(){
  string s;
  cin >> s;
  ll k;
  cin >> k;
  FOR(i,s.size()){
    if(s[i]!='1'){
      cout << s[i] << endl;
      return 0;
    }
    if(i+1==k){
      cout << 1 << endl;
      return 0;
    }
  }
  cout << 1 << endl;
  
  
}

Measured memory_bytes: 384
import java.util.Scanner;
import java.util.Stack;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ


		Scanner scan = new Scanner(System.in);

		while(scan.hasNextLine()){
			Stack<Double> stk = new Stack<Double>();
			String[] lt = scan.nextLine().split(" ");

			for(int i=0;i<lt.length;i++){
				try{
					stk.push(Double.parseDouble(lt[i]));
				}
				catch(Exception e){
					double b = stk.pop();
					double a = stk.pop();

					switch(lt[i].charAt(0)){
					case '+': stk.push(a+b); break;
					case '-': stk.push(a-b); break;
					case '*': stk.push(a*b); break;
					case '/': stk.push(a/b); break;
					}
				}
			}

			System.out.println(stk.pop());
		}
	}

}

Measured memory_bytes: 12000
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(8);
    double T, D; cin >> T >> D;
    double t1, t2; cin >> t1 >> t2;
    double d1, d2; cin >> d1 >> d2;
    double ans = INF;
    for(int i = 0; i <= D; i++)
    {
        for(int j = 0; j <= D; j++)
        {
            if(i == 0 and j == 0) continue;
            if(d1 * i + d2 * j > D) continue;;
            double a = (d1 * i) / 1000, b = (d2 * j) / 1000;
            double k = (t1 * a + t2 * b) / (a + b);
            ans = min(ans, abs(k - T));
        }
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 3284
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int n, x, max;
	int a, b, c;
	int ans;

	while (1) {
		scanf("%d%d", &n, &x);
		if (n == 0 && x == 0) break;

		ans = 0;
		max = x; if (max > n) max = n;
		for (a = 1; a <= max; a++) {
			for (b = a + 1; b <= max; b++) {
				c = x - a - b;
				if (c > b && c <= n) ans++;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}





Measured memory_bytes: 2088
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  ll ans = 0, mn = 1e9, cnt = 0;
  rep(i, n) {
    ll a;
    cin >> a;
    if(a < 0) cnt++;
    mn = min(mn, abs(a));
    ans += abs(a);
  }
  if(cnt % 2) ans -= mn * 2;
  cout << ans << endl;
}

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

int main(){
    int H, W, K;
    cin >> H >> W >> K;

    char C[H][W];
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            cin >> C[i][j];
        }
    }

    int ans=0;
    int count;

    for (int ibit = 0; ibit < (1 << H); ++ibit){
        for (int jbit = 0; jbit < (1 << W); ++jbit){
            count = 0;
            for(int i=0; i<H; i++){
                for(int j=0; j<W; j++){
                    if( ( ibit & (1<<i) ) || ( jbit & (1<<j) ) ) continue;
                    if( C[i][j]=='#' ) count++;
                }
            }
            if( count == K ) ans++;
        }    
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<int,int>
#define F first
#define S second
#define mod 1000000007
#define INF 9000000000000000000
signed main(void){
    int n,m;cin>>n>>m;
    vector<int>S(n),T(m);rep(i,n)cin>>S[i];
    rep(i,m)cin>>T[i];
    vector<vector<int>>dp(n+1,vector<int>(m+1,1));
    rep(i,n)rep(j,m){
        if(S[i]==T[j])dp[i+1][j+1]=(dp[i+1][j]+dp[i][j+1])%mod;
        else dp[i+1][j+1]=(dp[i+1][j]+dp[i][j+1]-dp[i][j])%mod;
    }
    cout<<(dp[n][m]+mod)%mod<<endl;
}


Measured memory_bytes: 31616
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (a)-1; i >= (b); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll h, w, a, b;
    cin >> h >> w >> a >> b;
    rep(i, h){
        rep(j, w){
            int f1 = (j < a);
            int f2 = (i < b);
            cout << (f1^f2);
        }
        cout << "\n";
    }
    return 0;
}

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

int main()
{
	long N,A,B,result;
	int temp;
	cin>>N>>A>>B;

	if (A>B)
	{
		temp=0;
		cout<<temp<<endl;
	}

	else if(N==1 && A<B)
	{
		temp=0;
		cout<<temp<<endl;
	}


	else
	{
		result= (A+(N-1)*B)-((N-1)*A+B)+1;
		cout<<result<<endl;
	}
	
	return 0;
}

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

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

    bool f = true;

    rep(i, S.size()) {
        if (i%2 == 0 && S[i] == 'L') f = false;
        if (i%2 == 1 && S[i] == 'R') f = false;
    }

    cout << (f ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <list>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <numeric>
#include <unordered_set>
#include <unordered_map>
#include <chrono>
#include <random>
#include <bits/stdc++.h>
 
using namespace std;
template <typename T> T max(T a, T b) {return a>b?a:b;}
 
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
 
#define ll long long
#define PI 3.14159265358979323846
#define min(a,b) ((a<b)?(a):(b))
#define max(a,b) ((a<b)?(b):(a))
#define abs(a) ((a>0)?a:-(a))

const double eps = (double)1e-6;
const int maxn = 2e5+5;
const ll mod = 1e9+7;



    

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

    // int n, t; cin >> n;
    // vector<int> a,b;
    // for (int i = 0; i < n; i++) {
    //     cin >> t; a.push_back(t);
    // }
    // for (int i = 0; i < n; i++) {
    //     cin >> t; b.push_back(t);
    // }

    // for (int i = 0; i < n; i++) {
    //     if (a[i] > b[i]) {
    //         swap(a,b);
    //         break;
    //     }
    // }
    // int cnt = 0;
    // while (a != b) {
    //     next_permutation(a.begin(),a.end());
    //     cnt++;
    // }
    // cout << cnt << endl;
    int k,n; cin >> k >> n;
    if (k*500 >= n) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = ((1LL << 60) + (1LL << 29));
const int MOD = 1000000007;

//=============================
int N, M, K;
string S, T;
vector<int> A;
vector<int> B;
string ss, tt;
//=============================
void input()
{
    cin >> ss;
    cin >> tt;
}
//=============================
void func() {}
// vector<vector<int>> ns(S.size(), vector<int>(26,INF));
// vector<vector<int>> nt(T.size(), vector<int>(26,INF));
vector<vector<int>> ns;
vector<vector<int>> nt;
//=============================
void solve()
{
    string S = ss + ss;
    int n = ss.size();
    int N = S.size();
    vector<vector<int>> ns(N+1, vector<int>(26, -1));

    rrep(i, N - 1, 0)
    {
        char cur = S[i];
        int cur_id = cur - 'a';
        rep(j, 0, 26 - 1)
        {
            if (cur_id == j)
            {
                ns[i][j] = i + 1;
            }
            else
            {
                ns[i][j] = ns[i + 1][j];
            }
        }
    }

    int ans = 0;
    int sind = 0;
    int prv = 0;
    rep(i, 0, tt.size()-1){
        int dst = tt[i]-'a';
        sind %= n;
        if (ns[sind][dst] == -1) {
            ans = -1;
            break;
        }
        else {
            ans += ns[sind][dst] - sind;
            sind = ns[sind][dst];
        }
    }
    cout<<ans<<endl;
}
//=============================
signed main()
{
    input();
    solve();
    return 0;
}

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

int main() {
  int n, a;
	cin >> n >> a;
	int x = n % 500;

	if ((x - a) <=0) {
		cout << "Yes" << endl;
	}
	else  {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
//4-adjacent

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) int n;cin>>n;vector<int>a(n);rep(i,0,n)cin>>a[i]
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
#define cout15(a) printf("%.15f\n",a)
template<class T>inline bool chmin(T& a,T b,bool f){
if(f==1){if(a>b){a=b;return true;}return false;}
else if(f==0){if(a<b){a=b;return true;}return false;}return false;}
typedef pair<ll,string> p;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

int main (){
    nvarep(n,a);
    int fou=0,twe=0,one=0;
    rep(i,0,n){
        if(a[i]%4==0)fou++;
        else if(a[i]%2==0)twe++;
        else one++;
    }
    if(twe>0)one++;
    if(one-1<=fou)cout<<"Yes"<<nnn;
    else cout<<"No"<<nnn;
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
int main(void){
    
    int A[3][10], B[3][10], C[3][10], D[3][10];
    int i, t;
    int n, b, f, r, v;
    for(i = 0; i < 3; i++){
        for(t = 0; t < 10; t++){
        A[i][t] = 0;
        B[i][t] = 0;
        C[i][t] = 0;
        D[i][t] = 0;
        }
    }
    
    scanf("%d\n", &n);
    
    for(n; n > 0; n--){
        scanf("%d %d %d %d\n", &b, &f, &r, &v);
        switch(b){
            case 1:
                if(0 <= (A[f -1][r -1] + v) && (A[f -1][r -1] + v) <= 9){
                A[f -1][r -1] += v;
                }
                break;
            case 2:
                if(0 <= (B[f -1][r -1] + v) && (B[f -1][r -1] + v) <= 9){
                B[f -1][r -1] += v;
                }
                break;
            case 3:
                if(0 <= (C[f -1][r -1] + v) && (C[f -1][r -1] + v) <= 9){
                C[f -1][r -1] += v;
                }
                break;
            case 4:
                if(0 <= (D[f -1][r -1] + v) && (D[f -1][r -1] + v) <= 9){
                D[f -1][r -1] += v;
                }
                break;
        }

    }
    
    for(i = 0; i < 3; i++){
        for(t = 0; t < 10; t++){
        printf(" %d", A[i][t]);
        }
        printf("\n");
    }
    
    printf("####################\n");
    
    for(i = 0; i < 3; i++){
        for(t = 0; t < 10; t++){
        printf(" %d", B[i][t]);
        }
        printf("\n");
    }
    
    printf("####################\n");
    
    for(i = 0; i < 3; i++){
        for(t = 0; t < 10; t++){
        printf(" %d", C[i][t]);
        }
        printf("\n");
    }
    
    printf("####################\n");
    
    for(i = 0; i < 3; i++){
        for(t = 0; t < 10; t++){
        printf(" %d", D[i][t]);
        }
        printf("\n");
    }
    
    return 0;
}

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

namespace ABC070A
{
    class Program
    {
        static void Main(string[] args)
        {
            String n;

            n = Console.ReadLine();

            if (n[0] == n[2])
            {
                Console.WriteLine("Yes");
            }

            else
            {
                Console.WriteLine("No");
            }

            Console.ReadKey();

        }
    }
}

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

typedef long long ll;

#define BORDER 1000000LL

int main() {
	map<int, ll> dat;
	vector<int> ord;
	int n, id, c; ll e, s;
	while(1) {
		cin >> n;
		if(!n) break;
		dat.clear(); ord.clear();
		for(int i=0; i<n; ++i) {
			cin >> id >> e >> s;
			if(!dat.count(id)) {
				ord.push_back(id);
				dat[id] = e*s;
			}else dat[id] += e*s;
		}
		c = 0;
		for(int i=0; i<(signed)ord.size(); ++i) {
			id = ord[i];
			if(dat[id]>=BORDER) {
				cout << ord[i] << endl;
				++c;
			}
		}
		if(!c) cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 1288
#include <algorithm>
#include <iostream>
#include <iomanip>
using namespace std;
long double p[100],kq ,a[100000];
int cd;
int main()
{
		cin >> cd;
		for (int i = 1 ; i <= cd ; i++)
		{
				cin >> a[i];
		}
		p[0] = 1;
		for (int i  = 1 ; i <= cd ; i++)
		{
				p[i] = p[i-1] * 2;
		}
		sort(a + 1 , a + 1 + cd);
		int t = 1;
		for (int i = cd ; i >= 3 ; i--)
		{
				kq += a[i] / p[t];
				t++;
		}
		kq += a[1]/p[t] + a[2]/p[t];
		cout <<fixed<<setprecision(9);
		cout <<kq;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];

    vector<ll> s(N+1);
    for(int i = 0; i < N; i++) s[i+1] = s[i] + a[i];
    for(int i = 1; i <= N; i++) s[i] = (s[i] - i) % K;

    ll res = 0;
    map<ll, ll> mp;
    for (int i = 0; i <= N; i++) {
        if (i >= K) mp[s[i-K]]--;
        res += mp[s[i]]++;
    }
    cout << res << '\n';
}


Measured memory_bytes: 18768
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <bitset>
#include <numeric>
#include <cassert>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define FOR(x, b, e) for(int x=(b); x<=(e); ++x)
#define FORD(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define REP(x, n) for(int x=0; x<(n); ++x)
#define ALL(c) c.begin(),c.end()
#define sz(x) ((int)((x).size()))
#define pb push_back
#define st first
#define nd second
#define mp(x,y) make_pair(x,y)
typedef short int sint;

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it) {
	*this << ((it != d.b) ? ", " : "") << *it;
  }
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main() {
	ios_base::sync_with_stdio(false);

	int n;
	cin >> n;
	vi x(n);
	REP(i, n) {
		cin >> x[i];
	}
	int bestSum = -1;
	FOR(i, 1, 100) {
		int sum = 0;
		REP(j, n) {
			sum = (sum + (i - x[j])*(i - x[j]));
		}
		if (bestSum == -1 || sum < bestSum) {
			bestSum = sum;
		}
	}
	cout << bestSum << endl;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define int long long
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c;
  cin>>a>>b>>c;
  if(a+b>=c) cout<<"Yes\n";
  else cout<<"No\n";
}

Measured memory_bytes: 256