akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T>
pair<vector<T>, vector<T>> slide_minmax(const vector<T> &v, int k){

	deque<int> deq_min, deq_max;
	vector<T> ret_min, ret_max;
	for (int i = 0; i < v.size(); i++) {

		while (!deq_min.empty() && v[deq_min.back()] >= v[i]) deq_min.pop_back();
		while (!deq_max.empty() && v[deq_max.back()] <= v[i]) deq_max.pop_back();
		
		deq_min.push_back(i);
		deq_max.push_back(i);

		if (i - k + 1 >= 0) {
			ret_min.emplace_back(v[deq_min.front()]);
			ret_max.emplace_back(v[deq_max.front()]);
			if (deq_min.front() == i - k + 1) deq_min.pop_front();
			if (deq_max.front() == i - k + 1) deq_max.pop_front();
		}

	}
	return { ret_min, ret_max };
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, K;
	cin >> N >> K;

	vector<int> P(N);
	for (int i = 0; i < N; i++) {
		int p; cin >> p;
		P[i] = p;
	}

	//auto [smin, smax] = slide_minmax(P, K);
	vector<int> smin, smax;
	tie(smin, smax) = move(slide_minmax(P, K));
	DMP(smin, smax);

	int cnt1 = 0;
	for (int i = 0; i < N - K; i++) if (smin[i] == P[i] && smax[i + 1] == P[i + K]) cnt1++;

	int seq = 0, cnt2 = 0;
	for (int i = 0; i < N - 1; i++) {
		if (P[i] < P[i + 1]) seq++;
		else seq = 0;
		if (seq == K - 1) cnt2++;
	}

	DMP(N - K + 1, cnt1, cnt2);
	cout << N - K + 1 - cnt1 - max(cnt2 - 1, 0) << "\n";

	return 0;
}


Measured memory_bytes: 4332
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

void out(int n){
	printf("%02d:%02d:%02d\n",n/3600,n/60%60,n%60);
}

int main() {
	int t,m,s;
	while(cin>>t>>m>>s,t!=-1){
		int time=2*3600-t*3600-m*60-s;
		out(time);
		out(time*3);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    int n, x, t;
    cin >> n >> x >> t;
    cout << ((n + x - 1) / x) * t << endl;
    return 0;
}

Measured memory_bytes: 3636
fun main(args: Array<String>) {
    val (n, m) = readIntList()
    val ans = n * (n - 1) / 2 + m * (m - 1) / 2
    println(ans)
}


// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

Measured memory_bytes: 37920
eps = 10**-7

def check(a, b):
  if b < a:
    a, b = b, a
  if b - a <= 1:
    return 2 * a - 2
  c = int((a*b)**.5 - eps)
  return 2 * c - 1 - (c * (c + 1) >= a * b)

for _ in range(int(input())):
  print(check(*list(map(int, input().split()))))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD =  998244353;
const int  Inv2 = (MOD+1)/2;

     signed main(){
  string s;
  cin>>s;
  cout<<s[0]<<s.size()-2<<s[s.size()-1]<<endl;

   }
         


        


Measured memory_bytes: 256
import sys
n = int(sys.stdin.readline())
a = [int(sys.stdin.readline()) for i in range(n)]
a = [-1] + a

def cond(a):
    if 2 not in a:
        return -1

    visited = set()
    current = 1
    count = 0

    while True:
        if current == 2:
            return count
        if current in visited:
            return -1
        count += 1
        visited.update((current,))
        current = a[current]

print(cond(a))


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

using namespace std;
typedef long long ll;
ll mod = 1e9+7;

int main(void)
{
  ll A,B;cin>>A>>B;
  ll M = max(A,B);
  ll N = min(A,B);
  for(ll i=0;i<M;i++)cout<<N;
  cout<<""<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
int main(void){

    char a[7],b[4];
    double n=0,k;

    scanf("%s%s",a,b);
    strcat(a,b);

    for(int i=0;i<strlen(a);i++){
        n+=(a[i]-'0')*(pow(10,strlen(a)-i-1));
    }
    k=round(sqrt(n));
    
    if(n==k*k) printf("Yes\n");
    else printf("No\n");

    return 0;
}

Measured memory_bytes: 2468
/*********************
*  Author: xuziyuan  * 
*********************/
 
#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair
 
using namespace std;
 
const LL MOD=1e9+7;

int n,x,y,z,val,num[100010],all,good[70000],dp[70000],ans=0;
vector <int> g[100010];

int main()
{
	cin>>n;
	rep(i,n-1)
	{
		cin>>x>>y>>z;
		g[x].pb(z);
		g[y].pb(z);
	}
	rep(i,n)
	{
		val=0;
		rep(j,g[i].size()) val^=g[i][j];
		num[val]++;
	}
	repn(i,15)
	{
		ans+=num[i]/2;
		if(num[i]%2==1) all|=(1<<i);
	}
	rep(i,1<<16)
	{
		int tmp=0;
		rep(j,16) if((i&(1<<j))>0) tmp^=j;
		if(tmp==0) good[i]=true;
	}
	rep(i,1<<16)
	{
		if(!good[i]) continue;
		for(int j=i;j>0;j=(j-1)&i) if(good[j]) dp[i]=max(dp[i],dp[i^j]+1);
	}
	cout<<ans+__builtin_popcount(all)-dp[all]<<endl;
	return 0;
}

Measured memory_bytes: 6648
#define X r+=(m*p+n*q)%(m*m+n*n)==0&&(m*q-n*p)%(m*m+n*n)==0
#define Z if(X,n=-n)X,n=-n
main(T,p,q,m,n,r){for(scanf("%d",&T);T--;puts(r==8?"P":"C"))
for(scanf("%d%d",&p,&q),r=m=0;m*m<=p*p+q*q;m++)for(n=m?0:1;m*m+n*n<=p*p+q*q;n++){Z;if(m=-m){Z;m=-m;}}exit(0);}

Measured memory_bytes: 584
#include <stdio.h>
#include <math.h>

int main(void) {
	int d, n;
	
	scanf("%d %d", &d, &n);
	
	printf("%d\n", (int)pow(100, d) * n + (n == 100 ? (int)pow(100, d) : 0));
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
const int mod = 1000000007;
int n,r;
int main(){ //srand((unsigned)time(NULL));
  cin >> n >> r;
  cout << (n <= 10 ? r + 100*(10-n) : r) << endl;
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

// Returns a tuple of (l, u) s.t.
// - l is the minimum value s.t. is_upper_fn(l) is false.
// - r is the minimum value s.t. is_upper_fn(r) is true.
//
// Required:
// - is_upper_fn is a function s.t.
//   - There exists a constant c s.t. is_upper_fn(x) is true for x >= c and
//     is_upper_fn(x) is false for x < c.
// - is_upper_fn(min_value) is false.
// - is_upper_fn(max_value) is true.
//
// Verified: ABC144E
tuple<int64, int64> BinarySearch(function<bool(int64)> is_upper_fn, int64 l, int64 u) {
  while (u - l >= 2) {
    int64 m = (l + u) / 2;
    if (is_upper_fn(m)) u = m; else l = m;
  }
  return make_tuple(l, u);
}

// Returns a vector of cumulative sums.
// Let c_sums be the return value.
// - c_sums[k] is the sum of xs over [0, k).
// - c_sums[r] - c_sums[l] is the sum of xs over [l, r).
template<class T> vector<T> CumulativeSumVector(const vector<T>& xs) {
  int n = xs.size(); vector<T> c_sums(n + 1);
  for (int i = 0; i < n; i++) c_sums[i + 1] = c_sums[i] + xs[i];
  return c_sums;
}

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

  int n;
  int64 m;
  cin >> n >> m;
  vector<int64> xs(n);
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
  }
  sort(xs.begin(), xs.end());
  reverse(xs.begin(), xs.end());

  auto count_fn = [&](int64 t) -> int64 {
    int64 v = 0;
    for (int i = 0; i < n; i++) {
      if (xs[i] + xs[0] < t) continue;
      if (xs[i] + xs[n - 1] >= t) {
        v += n;
        continue;
      }
      auto is_upper_fn = [&](int k) -> bool {
        return xs[i] + xs[k] < t;
      };
      int l = 0;
      int u = n - 1;
      tie(l, u) = BinarySearch(is_upper_fn, l, u);
      v += u;
    }
    return v;
  };

  auto is_upper_fn = [&](int64 k) -> bool {
    return count_fn(k) <= m;
  };
  int64 l = 0;
  int64 u = 1E18;
  tie(l, u) = BinarySearch(is_upper_fn, l, u);
  // cout << l << " " << u << endl;
  
  int64 ans = l * (m - count_fn(u));
  // cout << ans << endl;
  auto c_xs = CumulativeSumVector(xs);
  for (int i = 0; i < n; i++) {
    auto is_upper_2_fn = [&](int k) -> bool {
      return xs[i] + xs[k] < u;
    };

    if (is_upper_2_fn(0)) {
      continue;
    }
    if (!is_upper_2_fn(n - 1)) {
      ans += c_xs[n];
      ans += xs[i] * n;
      continue;
    }
    
    int li = 0;
    int ui = n - 1;
    tie(li, ui) = BinarySearch(is_upper_2_fn, li, ui);
    // cout << "li: " << li << endl;
    ans += c_xs[li + 1];
    ans += xs[i] * (li + 1);
  }
  cout << ans << endl;
}

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

#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(x) scanf("%lld",&x)
#define pr(x) printf("%lld\n",x)
#define clr(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
typedef pair<ll, ll> pii;
typedef vector< ll > vl;
typedef vector< pii > vpii;
const ll N= 1e5+55,mod = 1e9+7;
// i think i love a girl but .....
int main() {
// 	freopen("Task.in","r",stdin);freopen("Task.out","w",stdout);
	ll a,b,c,d,x,y,ans;
	sc(a);sc(b);sc(c);sc(d);
	x=max(a,c);
	y=min(b,d);
	ans=y-x;
	if(ans>0){
		pr(ans);
		return 0;
	}
	printf("0\n");
}

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

#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define check(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end() 
//#define endl '\n'  
typedef long long ll; 
typedef unsigned long long ull; 
typedef long double ld;
typedef pair< ll , ll > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <ll, vector<ll>, greater<ll> > min_heap;
const ll mod=1e9+7;
const ll inf=1e17+10;
const ll N=1e5+10;


int main()
{
	boost;
	string s;
	cin>>s;
	std::map<char, ll> ma;
	for(auto i:s) ma[i]++;
	ll flag=1;
	for(auto &i:ma)
	{
		if(i.ss!=2) flag=0;
	}	
	if(flag) cout<<"Yes";
	else cout<<"No";

  	return 0;
}

Measured memory_bytes: 256
from collections import deque
n = int(raw_input())
edges = []
for i in range(n-1):
    edges.append(map(int, raw_input().split()))

edge_to_i = {}
graph = [[] for _ in range(n+1)]
ans = [0] * (n-1)

for i in range(len(edges)):
    s,e = edges[i]
    graph[s].append(e)
    graph[e].append(s)
    edge_to_i[(s, e)] = i
    edge_to_i[(e, s)] = i

visited = set([])
q = deque([1])
while q:
    node = q.popleft()
    visited.add(node)

    not_colored = []
    colors = set([])
    for next_node in graph[node]:
        i = edge_to_i[(next_node, node)]
        if ans[i] == 0:
            not_colored.append(i)
        else:
            colors.add(ans[i])
        if not next_node in visited:
            q.append(next_node)

    color = 1
    for i in not_colored:
        while color in colors:
            color += 1
        ans[i] = color
        color += 1

print len(set(ans))
for i in ans:
    print i



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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll N, x[100500], M, K, a[100050];
ll dp[100050][70];
ll ans_delta[100050];
int f(int index, ll time) {
    //cout << index << " " << time << endl;
    if(time == 0) {
        return index;
    }
    ll now = 1;
    ll dp_index = 0;
    while(now * 2 <= time) {
        now *= 2;
        dp_index++;
    }
    int NEW = dp[index][dp_index];
    return f(NEW, time - now);
}

int main() {
    cout.precision(10);
    cin >> N;
    for(int i = 1; i <= N; i++) {
        cin >> x[i];
    }
    cin >> M >> K;
    //cout << N << " " << M << " " << K << endl;
    for(int i = 1; i <= M; i++) {
        cin >> a[i];
    }
    for(int i = 1; i < N; i++) {
        dp[i][0] = i;
    }
    for(int i = 1; i <= M; i++) {
        swap(dp[a[i] - 1][0], dp[a[i]][0]);
    }
    for(int i = 1; i < N; i++) {
        //cout << i << " " << dp[i][0] << endl;
    }
    for(int i = 1; i < 70; i++) {
        for(int delta = 1; delta < N; delta++) {
            int before = dp[delta][i - 1];
            dp[delta][i] = dp[before][i - 1];
            //cout << i << " " << delta << " " << dp[delta][i] << endl;
        }
    }
    for(int i = 1; i < N; i++) {
        ans_delta[i] = f(i, K);
        //cout << i << " " << ans_delta[i] << endl;
    }
    ll sum = x[1];
    cout << sum << endl;
    for(int i = 1; i < N; i++) {
        ll delta = x[ans_delta[i] + 1] - x[ans_delta[i]];
        sum += delta;
        cout << sum << endl;
    }
    return 0;
}


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

using namespace std;

int main(int argc, char const *argv[])
{
	double D, T, S;
	cin >> D >> T >> S;

	if(ceil(D/S) <= T)
		cout << "Yes\n";
	else
		cout << "No\n";

	return 0;
}

Measured memory_bytes: 3692
#include <iostream>
#include <stdio.h>

using namespace std;

char str1[123],str2[123];

int ok(int s,int n) {
    int i=s;
    int j=0;
    while(str1[i]==str2[j] && i<n && j<n) {
        i++;
        j++;
    }
    if(i==n) return 1;
    else return 0;
}

int main() {
    int n;
    scanf("%d",&n);
    scanf("%s %s",str1,str2);
    for(int i=0;i<n;i++) {
        if(str1[i]==str2[0]) {
            if(ok(i,n)) {
                printf("%d\n",n+i);
                return 0;
            }
        }
    }
    printf("%d\n",2*n);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <chrono>
using namespace std;

int main(int argc, const char * argv[]) {
    
    string S;
    cin >> S;
    int N = (int)S.size();
    
    long long sum = 0;
    for (long long A = 0; A < (1 << (N - 1)); A++) {// determine where '+'s locate. E.g., "01001" for 123456 means 1+234+56
        int s = 0;// start point of sub-string
        for (int i = 0; i < N - 1; i++) {
            if ((A >> i) & 1) {// if ith degit is 1
                sum += stoll(S.substr(s, i + 1 - s));
                s = i + 1;
            }
        }
        sum += stoll(S.substr(s, N - s));
    }
    
    cout << sum <<endl;
    
    return 0;
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long A, long long B){
    int ans = 0;
    REP2(i, A, B+1) {
        bool a = i / 10000 == i % 10;
        bool b = i / 1000 % 10 == i / 10 % 10;
        ans += a && b;
    }

    cout << ans << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}



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

int main() {
	int N,K;
  string s;
  	cin >> N >> K;
  cin >>s;
  
  for(int i=0;i<N;i++){
	if(K-1==i){
    	  s.at(i) = s.at(i) - ('A' - 'a');
	   	 }
    cout << s.at(i);  
    }
  cout << endl;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

#define INF 1e9

using namespace std;

vector<vi> adj;
vi ans;
vi a;
vi dp;

void dfs(int v, int p){
    auto itr = lower_bound(all(dp),a[v]);
    int oi = itr-dp.begin();
    int old = *itr;
    *itr = a[v];

    ans[v] = lower_bound(all(dp),INF)-dp.begin();

    for(auto u:adj[v]){
        if (u==p) continue;
        dfs(u,v);
    }
    dp[oi] = old;
}

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    a.resize(n);
    ans.resize(n);
    rep(i,n) cin>>a[i];
    adj.resize(n);
    dp.resize(n+1,INF);

    rep(i,n-1){
        int u,v; cin>>u>>v; u--; v--;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    dfs(0,-1);
    rep(i,n) cout<<ans[i]<<"\n";
    return 0;
}


Measured memory_bytes: 27916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    int N;
    cin >> N;
    int c = 6000005;
    vector<int> ans(c, 0);
    for (int i = 1; i < 101; i++) {
        for (int j = 1; j < 101; j++) {
            for (int k = 1; k < 101; k++) {
                ans[i*i + j*j + k*k + i*j + j*k + k*i]++;
            }
        }
    }
    for (int i = 1; i < N+1; i++) {
        printf("%d\n", ans[i]);
    }

}

Measured memory_bytes: 26692
#include <stdio.h>

int main(void)
{
	int a,b,c,d,e;
	e = 0;
	
	scanf("%d %d %d",&a,&b,&c);
	
	for(d = a;d <= b;++d){
		if(c % d == 0){
			++e;
		}
	}
	
	printf("%d\n",e);
	
	return(0);
}

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

std::vector<int> BuildArrFromInput() {
  int length;
  std::cin >> length;
  std::vector<int> nums;
  for (int i = 0; i < length; ++i) {
    int n;
    std::cin >> n;
    nums.push_back(n);
  }
  return nums;
}

void ExecStep(std::vector<int>& nums, int phase) {
  auto key = nums[phase];

  auto i = phase - 1;
  for (; i >= 0; i--) {
    if (nums[i] <= key) {
      break;
    }
    std::swap(nums[i+1], nums[i]);
  }
  nums[i+1] = key;
}

void PrintNums(std::vector<int>& nums) {
  for (auto p = nums.begin(); p != nums.end(); p++) {
    std::cout << *p;
    if (p + 1 != nums.end()) {
      std::cout << ' ';
    }
  }
  std::cout << '\n';
}

int main(void) {
  auto nums = BuildArrFromInput();
  for (auto i = 1; i < nums.size(); i++) {
    PrintNums(nums);
    ExecStep(nums, i);
  }
  PrintNums(nums);
  return 0;
}

Measured memory_bytes: 3104
package com.example.alds1.six

import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = Integer.parseInt(sc.next())
    val a = IntArray(n).map { Integer.parseInt(sc.next()) }.toIntArray()
    val q = partition(a, 0, a.size - 1)
    a.forEachIndexed { index, i ->
        if (index == q) {
            print("[$i]")
        } else {
            print(i)
        }
        if (index != a.size - 1) {
            print(" ")
        }
    }
    println()
}

fun partition(a: IntArray, p: Int, r: Int): Int {
    val x = a[r]
    var i = p - 1
    for (j in p until r) {
        if (a[j] <= x) {
            i++
            val tmp = a[j]
            a[j] = a[i]
            a[i] = tmp
        }
    }
    val tmp = a[r]
    a[r] = a[i + 1]
    a[i + 1] = tmp
    return i + 1
}



Measured memory_bytes: 74828
#ifdef _MSC_VER
#include "stdc++.h"
#endif
#ifdef __GNUC__
#include<bits/stdc++.h>
#endif
using namespace std;

using ll = long long;

//vector
using vi = vector<int>;
using vii = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

//constant
const double EPS = 1e-10;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, s, e) for (ll i = s; i < e; i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(), (x).rend()

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl;

// vector
//template<typename T> vector<vector<T>> vv(ll H, ll W, T v) { return vector<vector<T>> vec(H, vector<T>(W, v)); }

// view vector
template<typename T> void view(T e) { cout << e << endl; }
template<typename T> void view(const vector<T>& v) { for (const auto& e : v) { cout << e << " "; } cout << endl; }
template<typename T> void view(const vector<vector<T> >& vv) { for (const auto& v : vv) { view(v); } }

// DP
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; }



int main(){
    vll A(10000001, 1);

    ll N;
    cin >> N;

    FOR(i, 2, N + 1){
        for(ll j = 1; i * j <= N; j++){
            A[i * j]++;
        }
    }

    ll ans = 0;
    FOR(i, 1, N + 1){
        ans += i * A[i];
    }

    cout << ans << endl;
}


Measured memory_bytes: 81224
#include <bits/stdc++.h>
#define repl(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    string s;
    cin >> s;
    if(s == "ABC")cout << "ARC\n";
    else cout << "ABC\n";
    return 0;
}

Measured memory_bytes: 3624
#include<stdio.h>
void insertionSort(int*, int);

int main()
{
	int A[101], N, n;
	scanf("%d", &N);
	for (n = 0; n <= N - 1; n++) scanf("%d", &A[n]);
	insertionSort(A, N);
	return 0;
}

void insertionSort(int*a, int n)
{
	int x;
	for (x = 0; x <= n - 2; x++)
		printf("%d ", a[x]);
	printf("%d\n", a[n - 1]);
	int i, j, k;
	for (i = 1; i <= n - 1; i++)
	{
		j = 0;
		while (j <= i - 1)
		{
			k = a[i];
			if (a[i]<a[j])
			{
				a[i] = a[j];
				a[j] = k;
			}
			j++;
		}

		for (x = 0; x <= n - 2; x++) printf("%d ", a[x]);
		printf("%d\n", a[n - 1]);
	}

}

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

int main() {
    int A;
    cin >> A;
    int B;
    cin >> B;
    int C;
    cin >> C;

    if (A > B) {
        swap(A, B);
    }
    if (B > C) {
        swap(B, C);
    }

    cout << (C * 10 + A + B) << endl;

    return 0;
}


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

using pii = pair<int,int>;


int main(){
  int N;
  cin >> N;
  vector<pii> vec(N);
  for(int i = 0; i < N; i++){
  	int buff; cin >> buff;
    vec[i] = {buff, i+1};
  }
  sort(vec.begin(), vec.end());
  for(auto a: vec){
  	cout << a.second << " ";
  }
  cout << endl;
}

Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define st first
#define nd second
#define turbo ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define vi vector<int>
#define vvi vector<vi>
#define qi queue<int>
#define ld long double

using namespace std;

/*---------------------------------------------------------///CODE///---------------------------------------------------------*/

const int N = 1e5;
const int MOD = 1e9 + 7;
ll dp[N + 10][2];
vi graph[N + 10];

void count_dp(int v, int f)
{
    if(graph[v].size() == 1 && graph[v][0] == f)
    {
        dp[v][0] = 1, dp[v][1] = 1;
        return;
    }

    ll ans1 = 1;
    ll ans2 = 1;

    for(int& i : graph[v])
        if(i != f)
        {
            count_dp(i, v);
            (ans1 *= dp[i][0]) %= MOD;
            (ans2 *= ((dp[i][1] + dp[i][0]) % MOD)) %= MOD;
        }

    dp[v][1] = ans1; 
    dp[v][0] = ans2;
}
int main()
{
    turbo

    int n; cin >> n;

    for(int i = 1; i < n; i++)
    {
        int a, b; cin >> a >> b;
        graph[a].pb(b);
        graph[b].pb(a);
    }
    count_dp(1, 1);

    cout << (dp[1][0] + dp[1][1]) % MOD;

    return 0;
}

Measured memory_bytes: 14208
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int sum[100000];

int main(){
    int H, W, D;
    cin >> H >> W >> D;
    vector<vector<int>> A(H, vector<int>(W));
    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){
            cin >> A[i][j];
        }
    }
    int Q;
    cin >> Q;
    vector<int> L(Q), R(Q);
    for(int i = 0; i < Q; ++i){
        cin >> L[i] >> R[i];
    }
    
    // キーに対応する座標を格納するコンテナ
    map<int, P> coord;
    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){
            coord[A[i][j]] = P(i + 1, j + 1);
        }
    }
    
    for(int i = H * W - D + 1; i <= H * W; ++i){
        int now = i;
        while(now > D){
            int temp = sum[now];
            P p1 = coord[now];
            now -= D;
            P p2 = coord[now];
            
            sum[now] = temp + abs(p2.first - p1.first) + abs(p2.second - p1.second);
        }
    }
    
    for(int i = 0; i < Q; ++i){
        cout << sum[L[i]] - sum[R[i]] << endl;
    }
}

Measured memory_bytes: 8192
// *
// *
// *  Created By : Pritish Thakkar 
// *  Hackerrank : ma5terdrag0n
// *  CodeChef : solo_loser
// *  Hackerearth : pritish9
// *------------------------------------
// *  OS : Ubuntu 16.04
// *  Language : CPP14
// *  Editor : Sublime Text 3
// *  C++ compiler : g++
// *
// *
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define inf 1000000007
#define fr first
#define sc second
#define eps 1e-9
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define sni(x) scanf("%d",&x)
#define snl(x) scanf("%lld", &x)
#define snc(x) scanf("%c", &c);
#define rep(n) for(int i = 0 ; i < n ;i ++)
#define repc(i, n) for(int i = 0 ; i < n ; i ++)
#define FOR(i, x, y) for(int i = x ; i < y ; i ++)
#define DEC(i, x, y) for(int i = x ; i >= y ; i --)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b,c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a+n
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

bool isUpper(char c) {return (c >= 'A' && c <= 'Z');}
bool isLower(char c) {return (c >= 'a' && c <= 'z');}
bool iplpha(char c) {return (c >= 'A' && c <= 'Z')||(c >= 'a' && c <= 'z');}
bool isnum(char c){return (c >= '0' and c <= '9');}
bool isalnum(char c) {return (c >= 'A' && c <= 'Z')||(c >= 'a' && c <= 'z')||(c >= '0' && c <= '9');}
char toUpper(char c){return isUpper(c)?c:c-'a'+'A';}
char toLower(char c){return isLower(c)?c:c+'a'-'A';}
bool isvowel(char c){c = toLower(c); return (c == 'a' or c == 'e' or c == 'i' or c == 'i' or c == 'o' or c == 'u');}
template<typename t> t gcd(t a, t b){return ((b == 0) ? a : gcd(b, a%b));} 
template<typename t> t lcm(t a, t b){return (a * (b / gcd(a, b)));}
template <typename T> T modpow(T base, T exp, T modulus) {base %= modulus;T result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
string toLowerCase(string s){rep(s.size()){if(!isLower(s[i])){s[i] = toLower(s[i]);}}return s;}
string toUpperCase(string s){rep(s.size()){s[i] = toUpper(s[i]);}return s;}
template<typename T> void cumulative(T *a, T *b, T n){rep(n){i ? b[i] = b[i-1] + a[i] : b[i] = a[i];}}
bool ispal(string s){ll lo, hi;lo = 0;hi = s.length()-1;while(lo <= hi){if(s[lo] != s[hi]){return 0;}lo++;--hi;}return 1;}
template<class T >string toString(T n){string v = "";while(n){v.pb(n % 10 + '0');n /= 10;}reverse(all(v));return v;}

//--------------------------------------------------------------------

void solve(){
    string s;
    cin >> s;
    ll ans = sz(s);
    rep(sz(s)-1){
        if(s[i] != s[i+1]){
            ans = min(ans, max((ll)sz(s) - i - 1, (ll)i+1));
        }
    }
    cout << ans << endl;
}

int main(){
    std::ios::sync_with_stdio(0);
    // int start = clock();
    #ifdef ONLINE_JUDGE
    #else
      //freopen("input.in" , "r" , stdin);
      // freopen("output.txt", "w", stdout);
    #endif
    solve();
    // cout << n;
    // int stop = clock();
    // cout << (stop - start) / 1000.0000<< endl;
}












Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>   
using namespace std;
using namespace __gnu_pbds;
typedef long long ll; 
#define int long long
typedef unsigned long long lu;
typedef vector<ll> v;
typedef vector<vector<ll> > vv;
typedef vector<string>  vs;
typedef vector<pair<ll,ll>> vpr;
typedef long double ld;
#define f(i,n) for(ll i = 0; i < n; i++)
#define ff(i,n) for(ll i=1;i<=n;i++)
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define amax(x,y) if(y>x) x=y;
#define amin(x,y) if(y<x)x=y;
#define bg(x) x.begin()
#define sz(x) (ll)x.size()
#define in(x,n) for(ll i=0;i<n;i++)cin>>x[i]
#define out(x,n) for(ll i=0;i<n;i++)cout<<x[i]<<" " 
#define mxt(a) *(max_element(a.begin(),a.end()))
#define mnt(a) *(min_element(a.begin(),a.end())
#define tc ll t;cin>>t;while(t--)
typedef pair<ll,ll> pi;
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define yesno(f) if(f) yes else no
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
const ld PI = 2 * acos(0.0);
ll cel(ll x1,ll y1){if((x1%y1)==0)return x1/y1;else return x1/y1+1;}
ll power(ll a,ll b,ll m)
{
    if(b==0)
        return 1;
    ll d=power(a,b/2,m);
    d=(d*d)%m;
    if(b&1)
        d=(d*a)%m;
    return d;
}
const ll mod=1e9+7;
int MOD(int a)
{
    if(a<0)
        a+=mod;
    if(a>=mod)
        a%=mod;
    return a;
}
// set_name.find_by_order(k) It returns to an iterator to the kth element (counting from zero) in the set in O(logn) time
// set_name.order_of_key(k) It returns to the number of items that are strictly smaller than our item k in O(logn) time.
/*string operations :
str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
str.substr (x) : returns a substring str[x],... end of string
str.find(qtr) : returns the first occurenece of qtr in str */
v b;
void fun(int i,int j)
{
    int l=i-j,r=i+j+1;
    l=max(l,0ll);
    b[l]++;
    if(r < sz(b))
        b[r]--;
}
bool check(v &a)
{
    int n=sz(a);
    for(auto it:a)
    {
        if(it!=n)
            return false;
    }
    return true;
}
int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int n,k;cin>>n>>k;
    v a(n);in(a,n);
    b.resize(n,0);
    for(int i=0;i<k;i++)
    {
        fill(all(b),0);
        for(int i=0;i<n;i++)
        {
            fun(i,a[i]);
        }
        for(int i=1;i<n;i++)b[i]+=b[i-1];
        a=b;
        if(check(a))
            break;
    }
    out(a,n);
    return 0;
}

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

long long gcd(long long a, long long b){
	return b==0?a:gcd(b,a%b);
}

long long nondivisorNum(long long a, long long b, long long c){
	return a - (a/b + a/c - a/(b*c/gcd(b,c)));
}

int main(){
	long long a,b,c,d;
	cin >> a >> b >> c >> d;
	
	cout << nondivisorNum(b,c,d)-nondivisorNum(a-1,c,d);
	return 0;
}

Measured memory_bytes: 256
/*
  NAME : RISHABH SINGH
  INSTITUTION : DELHI TECHNOLOGICAL UNIVERSITY
*/
#include "bits/stdc++.h"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define int long long
#define pii pair<int, int>
#define bi __builtin_inf()
#define ll long long
#define mp make_pair
#define ss second
#define pb push_back
#define ff first
#define speed_cubing ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define um unordered_map
#define us unordered_set
#define bp __builtin_popcount
#define ld long double
#define rep(n) for (int i = 0; i < n; i++)
#define pll pair<ll, ll>
#define mx = 1e18;
#define lb(v, val) (lower_bound(v.begin(), v.end(), val) - v.begin())
#define ub(v, val) (upper_bound(v.begin(), v.end(), val) - v.begin())
#define PI 3.1415926535
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
#define sz(v) (int)v.size()
#define endl '\n'
const int N = 1e4;
const int mod = 998244353;
ll mul_inv(ll a,ll b = mod) {ll t1=a,t2=b,t3,v1=1,v2=0,v3;while(t2!=1){ll x=t1/t2;t3=t1-x*t2;v3=v1-x*v2;t1=t2,t2=t3;v1=v2,v2=v3;}return(v2+b)%b;}


int32_t main(){
   
   speed_cubing 
   
   int n,m;
   cin>>n>>m;

   int h[n+1];

   for(int i=1;i<=n;i++)
      cin>>h[i];

   vector<int> arr[n+1];

   for(int i=0;i<m;i++){
      int x,y;
      cin>>x>>y;
      arr[x].pb(y),arr[y].pb(x);
   }   

   int cnt = 0;

   for(int i=1;i<=n;i++){
      int temp = h[i];
      bool flag = 0;
      for(auto x:arr[i]){
         if(h[x]>=temp){
           flag = 1;
           break;
         }
      } 
      if(!flag)
        cnt++;
   }

   cout<<cnt;
   
    
   return 0;
}


Measured memory_bytes: 10208
N = int(input())
X = list(map(int, input().split()))

y = [0] * (N + 1)
for i in reversed(range(1, N + 1)):
    cnt = 0
    for j in range(2 * i, N + 1, i):
        cnt += y[j]
    if cnt % 2 != X[i - 1]:
        y[i] = 1

print(sum(y))
if sum(y):
    print(*[i for i in range(N + 1) if y[i]])


Measured memory_bytes: 98392
import java.util.Scanner;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        if(N%2 == 0){
            System.out.println(N/2);
        } else {
            System.out.println((N/2)+1);
        }
    }
}

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

template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x; return is;
}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;

#define rep(i,n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()
#define dump(x) cout << #x << " = " << (x) << endl

int main(){
    int n;
    cin >> n;
    vi a(n);
    cin >> a;

    vi m(n);

    // B(1/2)*m=a -> m=B\a : O(n^2)?
    /*
    rep(i,n){
        m[i] = 0;
        rep(j,n){
            if(i<=j){
                if((j-i)%2 == 0) m[i] += a[j];
                else m[i] -= a[j];
            }
            else{
                if((i-j)%2 == 0) m[i] -= a[j];
                else m[i] += a[j];
            }
        }
        cout << m[i] << " ";
    }
    */

   // m[0] = a[0] - a[1] + a[2] - ... +a[n-1]
   // m[i+1] = 2*a[i] - m[i] : O(n)?
    m[0] = 0;
    rep(i,n){
        if(i%2) m[0] -= a[i];
        else m[0] += a[i];
    }
    cout << m[0];
    rep(i,n-1){
        m[i+1] = 2*a[i] - m[i];
        cout << " " << m[i+1];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include<cmath>
#include<vector>
#include<climits>
#include<algorithm>
#include<numeric>
#include<iomanip>
#include<map>
#include<random>
#include<cassert>
using namespace std;
#define ll long long int
#define ld long double
const ll Mod = 1000000007;
ll CaseN=1;
const ld PI = 22/7.0;

bool mycmp(string s,string t)
{
if(s.size()<t.size())
{
return true;	
}		
return false;
}


void solve()
{
	ll n;
	cin>>n;
	cout<<n*(n+1)/2<<endl;
 // cout<<"Case #"<<CaseN<<": ";
   CaseN++;
	// print your ans below;
    
return ;
}


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//cin>>t;
	while(t--)
	{
	solve();	
	}
}


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

long long sortfnc(const void *a,const void *b){
    if(*(long long*)a == *(long long*)b){return 0;}
    if(*(long long*)a < *(long long*)b){return -1;}
    return 1;
}

int main(void){
	long long n,a[131072],i,r,ts;
	scanf("%lld",&n);
	for(i = 0;i < n;i++){scanf("%lld",&a[i]);}
	qsort(a,n,sizeof(long long),sortfnc);
	ts = a[0];
	r = 1;
	for(i = 1;i < n;i++){
		if(ts*2 < a[i]){
			r = 1;
		}
		else{
			r++;
		}
		ts+=a[i];
	}
	printf("%d",r);
	return 0;
}

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		String s = sc.next();
		int b = 0;
		int all =0;
		for (int i=0;i<s.length();i++) {
			if (s.charAt(i)=='c') {
				System.out.println("No");
			} else if (s.charAt(i)=='b') {
				b ++;
				if (b<=B&&all<A+B) {
					all++;
					System.out.println("Yes");
				} else {
					System.out.println("No");
				}
			} else {
				all ++;
				if (all<=B+A) {
					System.out.println("Yes");
				} else {
					System.out.println("No");
				}
			}
		}
	}
}

Measured memory_bytes: 50940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

struct union_find{
    vector<ll> parent;
    union_find(ll n){
        parent.resize(n);
        rep(i, 0, n) parent[i] = i;
    }

    ll root(ll x){
        if(parent[x] == x) return x;
        parent[x] = root(parent[x]);
        return parent[x];
    }

    void unite(ll x, ll y){
        ll rx = root(x);
        ll ry = root(y);
        if(rx != ry) parent[rx] = ry;
    }

    bool same(ll x, ll y){
        ll rx = root(x);
        ll ry = root(y);
        if(rx == ry) return true;
        return false;
    }
};

int main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> p(n+1);
    rep(i, 1, n+1){
        ll t;
        cin >> t;
        p[t] = i;
    }

    union_find tree(n+1);
    rep(i, 0, m){
        ll x, y;
        cin >> x >> y;
        tree.unite(x, y);
    }

    ll ans = 0;
    rep(i, 1, n+1){
        if(tree.same(i, p[i])) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
use std::cmp::*;
fn main(){
    let a=read::<i32>();
    let b=read::<i32>();
    let c=read::<i32>();
    let d=read::<i32>();
    println!("{}",max(0,min(b,d)-max(a,c)))
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
struct masu{
	int a, i, j;

	bool operator<(const masu& right)const {
		return a < right.a;
	}
};

ll ans = 0, sum[90000];
int h, w, d, q;
int a[300][300];
int l[100000], r[100000];


int main() {
	cin >> h >> w >> d;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a[i][j];
			a[i][j] -= 1;
		}
	}
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> l[i] >> r[i];
		l[i] -= 1;
		r[i] -= 1;
	}

	vector<masu>m;
	for (int j = 0; j < h; j++) {
		for (int k = 0; k < w; k++) {
			m.push_back(masu{ a[j][k], j, k });
		}
	}
	sort(m.begin(), m.end());

	//0~h*w-1
	for (int i = d; i < h*w; i++) {
		sum[i] = sum[i - d] + abs(m[i].i - m[i - d].i) + abs(m[i].j - m[i - d].j);
	}

	for (int i = 0; i < q; i++) {
		ans = sum[r[i]] - sum[l[i]];
		//if (l[i] > d-1)ans -= sum[l[i]];
		cout << ans << endl;
	}

}

Measured memory_bytes: 4084
import java.util.*;
import java.util.stream.*;
import java.io.*;

public class Main {
    
  public static void main(String[] args) throws IOException {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] in1 = br.readLine().split(" ");
    int H = Integer.parseInt(in1[0]);
    int W = Integer.parseInt(in1[1]);

    String[] glid = new String[H]; 
    for(int i = 0; i < H; i++){
      glid[i] = br.readLine();
    }
    br.close();

    String someString = "ksksk111";
    int a = (int)someString.chars().filter(ch -> ch == 'k').count();

    
    int hashNum = 0;
    for(int i = 0; i < H; i++){
      hashNum += (int)glid[i].chars().filter(ch -> ch == '#').count();
    }

    hashNum--;
    int y = 0, x = 0;
    while(!(y == H-1 && x == W-1)){
      if(y != H-1 && glid[y+1].charAt(x) == '#'){
        y++;
        hashNum--;
      }else if(x != W-1 && glid[y].charAt(x+1) == '#'){
        x++;
        hashNum--;
      }else{
        break;
      }
    }
    
    if(y == H-1 && x == W-1 && hashNum == 0)
      System.out.println("Possible");
    else
      System.out.println("Impossible");
  }
}

Measured memory_bytes: 28628
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #include <ext/pb_ds/detail/standard_policies.hpp>
    using namespace std;
    using namespace __gnu_pbds;
    #define endl "\n"
    #define fi first
    #define se second
    #define pb push_back
    #define ll long long
    #define ld long double
    #define pii pair<ll,ll>
    #define read(t) ll t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define For(i,n) for(ll i=0;i<n;i++)
    #define what(x) cerr << #x << " is " << x << endl;
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;
    typedef tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> ordered_mset;
    typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
    typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
/*.....................................................................................................................*/

    const ll mod=(ll)1e9+7;
    ll add(ll x,ll y) {return (x+y)%mod;}
    ll mult(ll x, ll y){return ((x%mod )* (y%mod)) % mod;}
    long long binpow(long long x, long long p) 
    {
        if (p == 0) {return 1;}
    	if (p == 2 || (p & 1)) {return mult(x, binpow(x, p - 1));}
    	return binpow(binpow(x, p / 2), 2);
    }
    ll modinv(ll a) {return binpow(a,mod-2);}
    double pi=3.141592653589793238462641;
    ll dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};
    const ll man=(ll)1e5+5;
/*........................................................................................................................*/


signed main()
{
    fast;
    string a,b; cin>>a>>b;
    cout  <<b+a<<endl;
    
}   


Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    int n,x;
    cin>>n>>x;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    ll ans =  0;
    rep(i,n-1){
        if(a[i]+a[i+1]>x){
            ans += a[i]+a[i+1]-x;
            if(a[i]+a[i+1]-x>a[i+1]){
                a[i+1]=0;
            }else {
                a[i+1]=a[i+1]-(a[i]+a[i+1]-x);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>

int main(){
	int a,l,r;
	scanf("%d",&a);
	l=a/100;/*上二桁*/
	r=a%100;/*下二桁*/
	int L,R;
	/*0は00またわ13~99,1は1~12,*/
	if(l==0)
		L=0;
	else if(l<13)
		L=1;
	else 
		L=0;
	
	if(r==0)
		R=0;
	else if(r<13)
		R=1;
	else
		R=0;
	
	if(L==1&&R==1)
		printf("AMBIGUOUS");
	if(L==1&&R==0)
		printf("MMYY");
	if(L==0&&R==1)
	    printf("YYMM");
    if(L==0&&R==0){
	printf("NA");
	}
		printf("\n");
	
}
		

Measured memory_bytes: 128
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

const long long MOD = 1000000007;

int main(){
  int n;
  cin>>n;
  vector<string> v(n);
  rep(i,n){
    cin>>v[i];
    sort(v[i].begin(), v[i].end());
  }
  sort(v.begin(), v.end());

  string prev = v[0];
  int i=1;
  ll tmp = 1;
  ll ans = 0;
  for(int i=1; i<n; i++) {
    if(prev==v[i]) {
      tmp++;
    } else {
      ans +=tmp*(tmp-1)/2;
      tmp = 1;
      prev = v[i];
    }
  }
  ans += tmp*(tmp-1)/2;
  std::cout << ans << std::endl;
  
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(), (x).end())
#define Reverse(x) reverse((x).begin(), (x).end())
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define INF INT_MAX
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15) //15桁まで表示
#define str string
typedef std::pair<int,int> pii;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<ui,ui> puu;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<str> vs;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a * b / gcd(a, b);};
int floor(int a,int b){return (a+b-1)/b;};
int month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
template<class T>inline bool chmax(T& a,T b){if(a < b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a > b){a=b;return true;}return false;};

int main() {
    vi a(3);
    cin >> a[0]>>a[1]>>a[2];
    cout << max({a[0],a[1],a[2]})-min({a[0],a[1],a[2]}) << endl;
}


Measured memory_bytes: 256