akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	VI a(5);
	REP(i, 5) {
		cin >> a[i];
	}
	int k;
	cin >> k;
	rSORT(a);
	REP(i, 5) {
		FOR(j, i, 5) {
			if (a[i] - a[j] > k) {
				cout << ":(" << endl;
				return 0;
			}
		}
	}

	cout << "Yay!" << endl;

	return 0;
}



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

long long mod = 1000000007;

class UnionFind
{
public:
   vector<int> parent;
   UnionFind(int N)
   {
      for (int i = 0; i < N; i++)
      {
         parent.push_back(-1);
      }
   }
   int root(int A)
   {
      if (parent[A] < 0)
         return A;
      return parent[A] = root(parent[A]);
   }
   int size(int A)
   {
      return -parent[root(A)];
   }

   bool unite(int A, int B)
   {
      A = root(A);
      B = root(B);
      if (A == B)
         return false;
      if (size(A) < size(B))
         swap(A, B);
      parent[A] += parent[B];
      parent[B] = A;
      return true;
   }
};
vector<pair<long long, long long>> prime(long long N)
{
   vector<pair<long long, long long>> res;
   for (long long i = 2; i * i <= N; i++)
   {
      if (N % i != 0)
         continue;
      long long ex = 0;
      while (N % i == 0)
      {
         ex++;
         N = N / i;
      }
      res.push_back({i, ex});
   }
   if (N != 1)
      res.push_back({N, 1});
   return res;
}
int main(void)
{
   long long A, B;
   cin >> A >> B;
   vector<pair<long long, long long>> PA = prime(A);
   vector<pair<long long, long long>> PB = prime(B);
   map<long long, long long> result;
   for (int i = 0; i < PA.size(); i++)
   {
      result[PA[i].first]++;
   }
   for (int i = 0; i < PB.size(); i++)
   {
      result[PB[i].first]++;
   }
   long long count = 1;
   for (auto ans : result)
   {
      if (ans.second == 2)
         count++;
   }
   cout << count << endl;
   return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

struct Edge{
  int to, cost;
  Edge(int to, int cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;

vector<ll> dist;
vector<int> par;
bool bellman_ford(int n, int s){ // n: number of edges, s: source
  dist = vector<ll>(n, longinf);
  par = vector<int>(n);
  par[s] = -1;
  dist[s] = 0;
  rep(i, n) {
    rep(v, n) {
      for(auto e: graph[v]) {
        if(dist[v] != longinf && dist[e.to] > dist[v] + e.cost) {
          dist[e.to] = dist[v] + e.cost;
          par[e.to] = v;
          if(i == n-1) return true;
        }
      }
    }
  }
  return false;
}

set<pair<int, int> > s;
vector<int> buildPath(int t) {
  vector<int> path;
  for(int u=t; u>=0; u=par[u]) {
    path.push_back(u);
    if(s.count(make_pair(min(u, par[u]), max(u, par[u]))))
      s.erase(make_pair(min(u, par[u]), max(u, par[u])));
  }
  reverse(path.begin(), path.end());
  return path;
}

int main() {
  int N, M;
  cin >> N >> M;
  graph = AdjList(N, vector<Edge>());
  rep(i, M) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    s.insert(make_pair(min(a, b), max(a, b)));
    graph[a].push_back(Edge(b, c));
    graph[b].push_back(Edge(a, c));
  }
  rep(i, N) {
    bellman_ford(N, i);
    rep(j, N)
      if(i != j)
        buildPath(j);
  }
  cout << s.size() << endl;
  return 0;
}



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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    string s; cin >> s;
    cout << s[0] << s[1] << s[2] << endl;
    return 0;
}


Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<cmath>
#include<sstream>
#include<iomanip>
#include <map>
#include <stack>
 
const int64_t cc = pow( 10, 9 );
 
bool sort_pair( std::pair< char, int64_t > origin, std::pair< char, int64_t > another )
{
    return origin.first < another.first;
}
/*
int main()
{
    int64_t a,b,c,d,e;
    std::vector< int64_t > list;
    std::cin>> a;
    std::cin>> b;

    for( int i = 0; i < a; i++ )
    {
        std::cin>> c;
        list.push_back( c + 1 );
    }

    double max = 0;

    std::vector< double > add_list( a + 1, 0 );
    
    for( int i = 0; i < a; i++ )
    {
        add_list[i+1] = add_list[i] + list[i];
    }

    for( int i = 0; i + b <= a; i++ )
    {
        max = std::max( max, add_list[i+b] - add_list[i] );
    }

    std::cout<< max / 2;
}
*/
using namespace std;
int main() {
    int N, K; cin >> N >> K;
    vector<long long> p(N);
    for (int i = 0; i < N; ++i) cin >> p[i], ++p[i]; // 1 足しておく

    // 累積和
    vector<long long> s(N+1, 0);
    for (int i = 0; i < N; ++i) s[i+1] = s[i] + p[i];

    // K 差を見ていく
    long long res = 0;
    for (int i = 0; i+K <= N; ++i) res = max(res, s[i+K] - s[i]);
    cout << fixed << setprecision(10) << (double)(res)/2 << endl;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,count=0,i,temp,sum;
	cin>>a>>b;

	for(i=a;i<=b;i++)
	{
		sum=0;
		temp = i;
		while(temp)
		{
			sum*=10;
			sum+=(temp%10);
			temp/=10;
		}

		if(sum==i)
			count++;
	}

	cout<<count<<endl;

	return 0;
}


Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
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; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k,n;cin >> k >> n;
    vector<int> a(n),b(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<n-1;i++){
        b[i]=a[i+1]-a[i];
    }
    b[n-1]=a[0]+(k-a[n-1]);
    int ans=k+1;
    for(int i=0;i<n;i++){
        chmin(ans,k-b[i]);
    }
    cout << ans << endl;
}

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

#define ll long long
#define int long long
#define loop(i,s,e) for(int i=s;i<e;i++)
#define rloop(i,s,e) for(int i=e;i>=s;i--)
#define fr first
#define sc second
#define pb push_back
#define  vii vector<int>
#define vll vector<ll>
#define vpii vector<pair<int ,int >>
#define vpll vector<pair<ll, ll> >
#define  pii pair<int,int>
#define lb(v,x) lower_bound(v.begin(),v.end(),x);
#define ub(v,x) upper_bound(v.begin(),v.end(),x);
const long mod =1e8;
const int N = 5e6+5;
const long long inf= 1e18;

ll gcd(ll a ,ll b){if(b==0) return a;return gcd(b,a%b);}
ll mul(ll a ,ll b){return (a%mod * b%mod )%mod;}
ll mpower(ll a, ll b){if(b==0) return 1;ll temp=mpower(a,b/2);if(b%2==0){return mul(temp,temp);}else{	return mul(mul(temp,temp) , a);}}
ll inv(ll a){return mpower(a,mod-2);}
ll ncr(ll n, ll r){if(r==0)return 1;ll ans=n%mod;ans=mul(ans,ncr(n-1,r-1));ans=mul(ans,inv(r));	return ans;}
ll power(ll a, ll b){if(b==0) return 1;ll temp=power(a,b/2);if(b%2==0)return temp*temp;else return temp*temp*a;}
ll add(ll a, ll b){return (a%mod + b%mod)%mod;}


void solve()
{
     
 double n;cin>>n;
 double l = n/3;
 
 double ans = (double)l * (double)l * (double)l;
 cout<<setprecision(12)<<ans<<endl;
   
}

int32_t main()
{
	ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1;//cin>>t;
	while(t--){
        solve();
	}
}

Measured memory_bytes: 256
class RobotMove
  def run
    loop do
      @arr = Array.new(21).map! { Array.new(21,0) }

      number = gets.to_i
      break if number == 0
      
      set(number)
      
      move
      
      puts (@arr.select { |x| x.include?(1) == true }.size == 0)? "Yes": "No"
    end
  end
  
  def set(number)
    number.times do line = gets.split.map(&:to_i); @arr[line[0]][line[1]] = 1 end
  end
  
  def move
    x = 10
    y = 10
    gets.to_i.times do line = gets.split
      line[1].to_i.times do
        case line[0]
          when "N"; y+=1
          when "E"; x+=1
          when "S"; y-=1
          when "W"; x-=1
        end
        @arr[x][y] = 0
      end
    end  
  end
end

RobotMove::new.run()

Measured memory_bytes: 6140
#include <bits/stdc++.h>
//#include "atcoder/all"
using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
using pii = pair<int, int>;
const ll mod = 1e9 + 7;

vector<bool> flag;

void dfs(const vector<vector<int>>& G, int now) {
  if (flag[now]) return;
  flag[now] = true;

  for (int nv : G[now]) {
    if (flag[nv] == false) {
      dfs(G, nv);
    }
  }

  return;
}
int main() {
  int n, m;
  cin >> n >> m;

  vector<pair<int, int>> coord(m);

  for (int i = 0; i < m; i++) {
    cin >> coord[i].first >> coord[i].second;
    coord[i].first--;
    coord[i].second--;
  }

  int ans = 0;

  for (int i = 0; i < m; i++) {
    vector<vector<int>> G(n);
    for (int j = 0; j < m; j++) {
      if (i == j) {
        continue;
      } else {
        G[coord[j].first].push_back(coord[j].second);
        G[coord[j].second].push_back(coord[j].first);
      }
    }

    flag.assign(n, false);
    dfs(G, 0);

    auto it = find(flag.begin(), flag.end(), false);

    if (it != flag.end()) {  // falseがあるなら、橋
      ans++;
      // cout << coord[i].first + 1 << "  " << coord[i].second + 1 << endl;
    }
  }

  cout << ans << endl;
}


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

int main(int argc, char *argv[]) {
  long long n, k;
  std::cin >> n >> k;
  std::vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> a.at(i);
  }

  std::vector<int> s, visited(n + 1, -1);
  int v = 1;
  while (visited.at(v) == -1) {
    visited.at(v) = s.size();
    s.push_back(v);
    v = a.at(v - 1);
  }

  int c = s.size() - visited.at(v);
  int l = visited.at(v);

  if (l >= k)
    std::cout << s.at(k) << std::endl;
  else {
    k -= l;
    k %= c;
    std::cout << s.at(l + k) << std::endl;
  }
}


Measured memory_bytes: 5388
// inputに入力データ全体が入る
function Main(input) {
    input = input.split(" ");
    var N = parseInt(input[0],10);
    var L = parseInt(input[1],10);
    var aziSouwa = [];
    for(var i = 1; i < N+1; i++){
        aziSouwa.push(L + i - 1);
    }    
    var value = 0;
    var diff = [];
    var index = 0;

    aziSouwa.forEach(function(val,i){
    diff[i] = Math.abs(value - val);
    index = (diff[index] < diff[i]) ? index : i;
    });
    aziSouwa.splice(index,1);
    var souwa = aziSouwa.reduce(function(total, data){return total + data});
    console.log(souwa);
};
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

int main()
{
  ll n;
  cin>>n;
  ll ans=0;
  for (int i = 1; i <= n; ++i)
  {
    if(i%3==0 && i%5==0) ;
    else if(i%3==0) ;
    else if(i%5==0) ;
    else ans+=i;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3624
import java.util.Scanner;


public class Main {

	static Scanner sc = new Scanner(System.in);
	static String str;

	public static void main(String[] args) {
		while(read()){
			solve();
		}
	}

	public static Boolean read(){
		if(!sc.hasNext())  return false;

		str = sc.next();
		return true;
	}


	public static void solve(){
		for(int i=str.length()-1; i>=0; i--){
			System.out.print(str.charAt(i));
		}
		System.out.println();
	}

}

Measured memory_bytes: 11000
#include <iostream>
#include <string>
#include <math.h>
#include <stdio.h>
using namespace std;

int main() {
  double n, sum, m, a;
  int s[1000];

  while (1) {
    sum = 0;
    a = 0;
    cin >> n;

    if (n == 0) break;

    for (int i = 0; i < n; i++) {
      cin >> s[i];
      sum += s[i];
    }
    m = sum / n;

    for (int i = 0; i < n; i++) {
      a += (s[i] - m) * (s[i] - m);
    }

    printf("%f\n", sqrt(a / n));
  }

  return 0;
}

Measured memory_bytes: 1240
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
using ll = long long;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define rep(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288

int main(){
    int n;
    cin>>n;
    vector<int>h(n);
    rep(i,n)cin>>h[i];
    vector<int>dp(n);
    dp[0]=0;
    dp[1]=abs(h[1]-h[0]);
    for(int i=2;i<n;i++){
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>

#define MAX_SIZE 100000000
typedef unsigned long long ull;
using namespace std;

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

  string ans = "No";
  const int len = s.size();
  for(int i = 0; i < len; i++) {
    if(s == t) {
      ans = "Yes";
      break;
    }
    s = s.back() + s.substr(0,len-1);
  }

  cout << ans << endl;
}


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

int main(){
	ios_base::sync_with_stdio(0);
	string s;
	cin>>s;
	for (int i = 0; i < s.size()-1; ++i)
		{
			if(s[i]=='A' and s[i+1]=='C'){
				cout<<"Yes"<<endl;
				return 0;
			}
		}	
		cout<<"No"<<endl;

	return 0;	
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<string>
#include<time.h>
#include<list>
#include<random>
#include<bitset>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;

ll sum;

void f(ll sm, string str) {
    for (ll i = 0; i < str.size() - 1; ++i) {
        sum += sm + stoll(str.substr(0, i + 1)) + stoll(str.substr(i + 1, str.size() - i - 1));
        f(sm + stoll(str.substr(0, i + 1)), str.substr(i + 1, str.size() - i - 1));
    }
}

int main() {
    string s;
    cin >> s;
    sum = stoll(s);
    f(0, s);
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <queue>

using namespace std;

int main () {
	string input;
	cin >> input;
	if(input.length() == 2){
		cout << input << endl;
	}
	else{
		cout << input[2] << input[1] << input[0] << endl;	
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
int a[3],b,c,d,e;
int flag=1;
for(b=0;b<3;b++){
scanf("%d",&a[b]);
}
while(flag){
flag=0;
for(c=0;c<2;c++){
if(a[c]>a[c+1]){
d=a[c];
a[c]=a[c+1];
a[c+1]=d;
flag=1;
}
}
}
for(e=0;e<3;e++){
printf("%d",a[e]);
if(e==2){
printf("\n");
}else{
printf(" ");
}
}
return 0;
}


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

int main(){
    int n;
    cin >> n;
    if(n%2 == 1) cout << n/2+1;
    else cout << n/2;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
int f(int n){
	int sum = 0;
	while (n){
		sum += n % 10;
		n /= 10;
	}
	return sum;
}
int main(){
	int N,A,B;
	int count = 0;
	scanf("%d %d %d", &N, &A, &B);
	for (int i = 1; i <= N; i++){
		if (A <= f(i) && f(i) <= B){
			count += i;
		}
	}
	printf("%d\n", count);
	return 0;
} 

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,W,H,K;
	string s;
	while(cin>>N) {
		VI A(N+1);
		ll rm=0;
		REP(i, N) {cin>>K;if(K<N+1)A[K]++;else rm++;}
		ll ans=N;
		REP(i, N+1) {
			rm += i<=A[i] ? A[i]-i : A[i];
		}
		cout<<rm<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 1024
"use strict";
function Main(input) {
    let lines = input.split("\n");
    const nums = lines.shift().split(/\s/).map((v) => v - 0);
    const N = nums[0], Q = nums[1];
    let S = lines.shift().split(/\s/)[0];
    let T = new Array(N+1).fill(0);
    for (let m = 0; m < S.length; m++) {
        T[m + 1] = T[m] + ((m + 1 < N) && (S.substr(m, 2) == 'AC') ? 1 : 0);
    }
    for (let n = 0; n < Q; n++) {
        let lr = lines.shift().split(/\s/).map((v) => v - 0 - 1);
        const l = lr[0], r = lr[1];
        console.log(T[r] - T[l]);
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 32596
#include<iostream>
#include<string>
#include<vector>
#define rep(i,n) for(int i=0;i<(int) (n);i++)
using namespace std;
int main(){
  int n,k,r,s,p;
  string t;
  cin>>n>>k;
  cin>>r>>s>>p;
  cin>>t;

  int val=0;
  vector<int>f(n);
  f[0]=1;
  rep(i,n){
    char c,ch;
    c=t.at(i);
    if(i>=k){
      ch=t.at(i-k);
      if(c!=ch||f[i-k]==1){
          if(c=='r')val+=p;
          if(c=='s')val+=r;
          if(c=='p')val+=s;
          f[i]=0;
        }else{
          f[i]=1;
        }
      }else{
        if(c=='r')val+=p;
        if(c=='s')val+=r;
        if(c=='p')val+=s;
        f[i]=0;
      }
  }

  cout<<val;
}

Measured memory_bytes: 896
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let m: usize = sc.cin();
    let x: i32 = sc.cin();
    let y: i32 = sc.cin();
    let xs: Vec<i32> = (0..n).map(|_| sc.cin()).collect();
    let ys: Vec<i32> = (0..m).map(|_| sc.cin()).collect();
    let z = min!(y, *min!(..ys).unwrap());
    if x < z && *max!(..xs).unwrap() < z {
        put!("No War");
    } else {
        put!("War");
    }
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 4352
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	wfp := os.Stdout

	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
		if len(os.Args) > 2 {
			wfp, _ = os.Create(os.Args[2])
		}
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(wfp)

	v := getNextInt(scanner)
	e := getNextInt(scanner)

	ee := make([][]int, v)
	seg := Segment{}
	seg.init(v)

	for i := 0; i < v; i++ {
		ee[i] = make([]int, 0)
	}

	for i := 0; i < e; i++ {
		s := getNextInt(scanner)
		t := getNextInt(scanner)
		ee[s] = append(ee[s], t)
		seg.minimize(t, seg.bucket[0][t]+1)
	}

	for i := 0; i < v; i++ {
		t := seg.top()
		fmt.Fprintln(writer, t)
		for j := 0; j < len(ee[t]); j++ {
			seg.minimize(ee[t][j], seg.bucket[0][ee[t][j]]-1)
		}
		seg.minimize(t, math.MaxInt32)
	}

	writer.Flush()
}

// Segment ...
type Segment struct {
	n, h, i, chunk, inf int
	unit                []int
	bucket              [][]int
}

func (seg *Segment) init(n int) {
	seg.n = n
	seg.unit = make([]int, 1)
	seg.unit[0] = 1
	seg.bucket = make([][]int, 1)
	seg.bucket[0] = make([]int, n)

	chunk := 8
	for i := 0; n > 1; i++ {
		n = (n-1)/chunk + 1
		seg.bucket = append(seg.bucket, make([]int, n))
		seg.unit = append(seg.unit, seg.unit[i]*chunk)
	}
	seg.h = len(seg.unit)
	seg.chunk = chunk
	seg.inf = math.MaxInt32
}

func (seg *Segment) minimize(index, value int) {
	seg.bucket[0][index] = value
	for seg.i = 0; seg.i < seg.h-1; seg.i++ {
		s := index - index%seg.chunk
		t := s + seg.chunk
		if t > len(seg.bucket[seg.i]) {
			t = len(seg.bucket[seg.i])
		}
		parent := index / seg.chunk
		min := seg.inf
		for i := s; i < t; i++ {
			if min > seg.bucket[seg.i][i] {
				min = seg.bucket[seg.i][i]
			}
		}
		seg.bucket[seg.i+1][parent] = min
		index /= seg.chunk
	}
}

func (seg *Segment) top() int {
	index := 0
	for seg.i = seg.h - 2; seg.i >= 0; seg.i-- {
		s := index * seg.chunk
		t := s + seg.chunk
		if t > len(seg.bucket[seg.i]) {
			t = len(seg.bucket[seg.i])
		}
		for i := s; i < t; i++ {
			if seg.bucket[seg.i][i] == seg.bucket[seg.i+1][index] {
				index = i
				break
			}
		}
	}

	return index
}



Measured memory_bytes: 3264
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a <= b) {
			System.out.println(a);
		} else {
			System.out.println(a - 1);
		}

	}

}


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

int main() {
  int R;
  cin >> R;
  
  	if (R < 1200) {
      cout << "ABC" << endl;
    }
  	else if (R >= 1200 && R < 2800) {
      cout << "ARC" << endl;
    }
  	else {
      cout << "AGC" << endl;
    }
}

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

using namespace std;

int main()
{
    string S;
    cin >> S;
    if(S[0] == 'S'){
        cout<<"Cloudy"<<endl;
    }else if(S[0] == 'C'){
        cout<<"Rainy"<<endl;
    }else if(S[0] == 'R'){
        cout<<"Sunny"<<endl;
    }
            return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 5;
const int P = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int fac[MAXN], inv[MAXN];
int power(int x, int y) {
	if (y == 0) return 1;
	int tmp = power(x, y / 2);
	if (y % 2 == 0) return 1ll * tmp * tmp % P;
	else return 1ll * tmp * tmp % P * x % P;
}
int binom(int x, int y) {
	if (y > x) return 0;
	else return 1ll * fac[x] * inv[y] % P * inv[x - y] % P;
}
void update(int &x, int y) {
	x += y;
	if (x >= P) x -= P;
}
void init(int n) {
	fac[0] = 1;
	for (int i = 1; i <= n; i++)
		fac[i] = 1ll * fac[i - 1] * i % P;
	inv[n] = power(fac[n], P - 2);
	for (int i = n - 1; i >= 0; i--)
		inv[i] = inv[i + 1] * (i + 1ll) % P;
}
int sbinom(int cnt, int sum) {
	assert(cnt != 0);
	if (sum < 0) return 0;
	else return binom(sum + cnt - 1, cnt - 1);
}
int main() {
	int n, ans = 0;
	read(n), init(n);
	update(ans, fac[n - 1]);
	for (int i = 1; i <= n - 1; i++) {
		int cnt = binom(n - 1, i), lft = n - 1 - i;
		update(cnt, P - sbinom(lft + 1, n - 1 - 2 * lft));
		if (lft) update(cnt, sbinom(lft, n - 1 - 2 * lft));
		update(ans, 1ll * cnt * fac[i] % P * fac[n - 1 - i] % P);
	}
	writeln(ans);
	return 0;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

/*
18 26
*/
int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int q;
    cin >> q;

    vector<set<int>> a(26);
    for (int i = 0; i < n; i++) {
        a[s[i] - 'a'].insert(i);
    }

    for (int i = 0; i < q; i++) {
        int type;
        cin >> type;
        if (type == 1) {
            int index;
            char new_c;
            cin >> index >> new_c;
            index--;
            a[s[index] - 'a'].erase(index);
            s[index] = new_c;
            a[s[index] - 'a'].insert(index);
        } else {
            int l, r;
            cin >> l >> r;
            l--, r--;
            int cnt = 0;
            for (int j = 0; j < 26; j++) {
                auto lower_it = a[j].lower_bound(l);
                // auto upper_it = a[j].upper_bound(r);
                // if (lower_it != upper_it)
                if (lower_it != a[j].end() && *lower_it <= r)
                    cnt++;
            }
            cout << cnt << endl;
        }
    }
}

Measured memory_bytes: 24196
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <new>

using namespace std;

typedef long long ll;

#define rep(i, N) for (ll i = 0; i < (ll)(N); ++i)

int main(){
    ll N;
    ll ans = 1;
    cin >> N;

    vector<ll> P(N,0);
    vector<ll> DP(N,0);

    rep(i,N){
        cin >> P[i];
    }

    DP[0] = P[0];

    for(ll i = 1;i < N;i++){
        if(DP[i - 1] >= P[i]){
            ans += 1;
            DP[i] = P[i];
        }else{
            DP[i] = DP[i - 1];
        }
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 3328
/*
Stay away from
               ,----..                                                         ,---.-,
  ,----..     /   /   \                 ,---,    ,---,                 ,---,  '   ,'  '.
 /   /   \   /   .     :        ,---.,`--.' |  .'  .' `\            ,`--.' | /   /      \
|   :     : .   /   ;.  \      /__./||   :  :,---.'     \          /    /  :.   ;  ,/.  :
.   |  ;. /.   ;   /  ` ; ,---.;  ; |:   |  '|   |  .`\  |        :    |.' ''   |  | :  ;
.   ; /--` ;   |  ; \ ; |/___/ \  | ||   :  |:   : |  '  |        `----':  |'   |  ./   :
;   | ;    |   :  | ; | '\   ;  \ ' |'   '  ;|   ' '  ;  :           '   ' ;|   :       ,
|   : |    .   |  ' ' ' : \   \  \: ||   |  |'   | ;  .  |  ---      |   | | \   \      |
.   | '___ '   ;  \; /  |  ;   \  ' .'   :  ;|   | :  |  '           '   : ;  `---`---  ;
'   ; : .'| \   \  ',  /    \   \   '|   |  ''   : | /  ;            |   | '     |   |  |
'   | '/  :  ;   :    /      \   `  ;'   :  ||   | '` ,/             '   : |     '   :  ;
|   :    /    \   \ .'        :   \ |;   |.' ;   :  .'               ;   |.'     |   |  '
 \   \ .'      `---`           '---" '---'   |   ,.'                 '---'       ;   |.'
  `---`                                      '---'                               '---'

to save your life.
*/
#define   ll                long long
#define   pb                push_back
#define   ff                first
#define   ss                second
#define   srt(v)            sort(v.begin(),v.end())
#define   inf               2000000000000000
#define   mxn               109
#define   pi                acos(-1)
#define   MOD               1000000007
#define   db(x)             printf("### VALUE: (%lld) ###\n",(ll)x)
#include  <bits/stdc++.h>
using namespace std;

ll N,W;
ll cost[mxn];
ll value[mxn];
ll dp[mxn][100009];

ll solve(ll i,ll x)
{
    if(i > N){
        if(x == 0) return 0;
        else return 5*inf;
    }
    if(dp[i][x] != -1) return dp[i][x];
    ll ret = 2*inf;
    if(value[i] <= x){
       ret = min(ret,cost[i] + solve(i+1,x - value[i]));
    }
    ret = min(ret,solve(i+1,x));
    return dp[i][x] = ret;
}


int main()
{
    cin >> N >> W;
    memset(dp,-1,sizeof dp);
    for(ll i = 1;i <= N;i++){
        cin >> cost[i] >> value[i];
    }
    for(ll i = 100000;i >= 0;i--){
     ll keep = solve(1,i);
     if(keep <= W){
        cout << i << endl;
        return 0;
     }
    }
}
/*
".....but the truth is that you can increase it slightly."
Day 16.

*/




Measured memory_bytes: 85376
#include<stdio.h>

int main(void)
{
    char buffer[256];
    int h[30], w[30];
    int counter=0;
    while(1)
    {
        fgets(buffer, 256, stdin);
        sscanf(buffer, "%d %d", &h[counter], &w[counter]);
        if(h[counter]==0 && w[counter]==0) break;
        counter++;
    }
    
    int i, j, k;
    for(i=0;i<counter;i++)
    {
        for(k=0;k<w[i];k++)
        {
            putchar('#');
        }
        putchar('\n');
        
        for(j=1;j<h[i]-1;j++)
        {
            putchar('#');
            for(k=1;k<w[i]-1;k++)
            {
                putchar('.');
            }
            putchar('#');
            putchar('\n');
        }
        
        for(k=0;k<w[i];k++)
        {
            putchar('#');
        }
        putchar('\n');
       putchar('\n');
    }
    
    return(0);
}


Measured memory_bytes: 2100
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>

using namespace std;
// https://stackoverflow.com/questions/10150468/how-to-redirect-cin-and-cout-to-files
long long not_divisible(long long n, vector<long long> a) {

  sort(a.begin(), a.end());
  const long long a_max = 1000001; 
  bool div[a_max];
  memset(div, false, sizeof div);
  long long count = 0;
  if(a.size() == 1) {
    return 1;
  }
  /*
  for(auto aa = a.begin();aa != a.end();aa++) {
    cout << *aa << endl;
  }
  cout << "=========" << endl;
  */
  for(long long i=0;i<n;i++) {
    if(i==0) {
      if(a[i] != a[i+1]) {
	// cout <<  a[i]<< "!!"  << endl;
	count++;
      }
      long long aa = a[i];
      while(aa < a_max) {
	div[aa] = true;
	aa += a[i];
      }
      continue;
    }
    if(i < n-1) {
      if(a[i] != a[i-1] && a[i+1] != a[i] && !div[a[i]]) {
	//cout << a[i]<< "!!" << div[a[i]] << endl;
	count++;
      }
      if(a[i] == a[i-1]) {
	continue;
      }
      long long aa = a[i];
      while(aa < a_max) {
	/*
	if(div[aa]) {
	  break;
	}
	*/
	div[aa] = true;
	aa += a[i];
      }
      continue;
    }
    // i == n-1
    if(a[i-1] != a[i] && !div[a[i]]) {
      //cout <<  a[i]<< "!!"  << endl;
      count++;
    }
  }

  return count;
}

int main() {
  long long n;
  cin >> n;
  vector<long long> a;
  for(long long i=0; i<n;i++) {
    long long aa;
    cin >> aa;
    a.push_back(aa);
  }
  cout << not_divisible(n, a);
}


Measured memory_bytes: 7452
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
//#include <chrono> //1e+9で割る auto end= chrono::system_clock::now()-st;  cout<<end.count()%1e+9<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> LP;
typedef long double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)

int N,W;
int v,w;
int dp[10001];
int main()
{
	cin>>N>>W;
	rep(i,N){
		cin>>v>>w;
		rep(j,W-w+1){
			dp[j+w]=max(dp[j+w],dp[j]+v);
		}
	}
	int ans=0;
	rep(i,W+1) ans=max(ans,dp[i]);
	cout<<ans<<endl;
}


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

const int mod =1000000007;
#define all(v) v.begin(),v.end()
#define mp make_pair
#define pb push_back

template<typename T, typename U>
inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U>
inline void amax(T &x, U y) { if(x < y) x = y; }

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;

int main(){
	int n;
	cin>>n;
	int a,b,c,x,y,z;
	a=b=c=0;
	while(n--){
		cin>>x >>y >>z;
		x+=max(b,c);
		y+=max(a,c);
		z+=max(a,b);
		a=x;
		b=y;
		c=z;
	}
	cout<<max(a,max(b,c))<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
const int MOD = 1e9+7;
const int MAX = 1e6+6;
int N, pd[MAX][2][2];

int solve(int i, int a, int b) {
	if(i == N && a && b) return 1;
	if(i == N) return 0;
	int &ans = pd[i][a][b];
	if(ans != -1) return ans;
	ans = 0;
	ans = (ans+solve(i+1, 1, b))%MOD;
	ans = (ans+solve(i+1, a, 1))%MOD;
	ans = (ans+8LL*solve(i+1, a, b))%MOD;
	return ans;
}

int main(int argc, char** argv) {
	scanf("%d", &N);
	memset(pd, -1, sizeof pd);
	PER(i, N, 0) {
		solve(i, 0, 0);
		solve(i, 0, 1);
		solve(i, 1, 0);
		solve(i, 1, 1);
	}
	printf("%d\n", solve(0, 0, 0));
	return 0;
}


Measured memory_bytes: 19388
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a[5],i,j,x,y,n;n=0;
    scanf("%d%d%d",&a[1],&a[2],&a[3]);
    sort(a+1,a+4);
    y=a[3]-a[1];
    x=a[3]-a[2];
    if(x%2==0&&y%2==0)
    {
        n=x+(y-x)/2;
    }
    else if(x%2==1&&y%2==1)
        n=x+(y-x)/2;
    else
        n=1+x+1+(y-x)/2;
   printf("%d",n);
    return 0;


}

Measured memory_bytes: 256
import fractions

n = int(input())
a = list(map(int, input().split()))
r = 0

ans = a[0]
for i in range(1, n):
    ans = ans * a[i] // fractions.gcd(ans, a[i])

for i in range(1, n):
    r += ans//a[i]

g = r+ans//a[0]
print(g % (1000000000+7))


Measured memory_bytes: 6200
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BRng10s solver = new BRng10s();
        solver.solve(1, in, out);
        out.close();
    }

    static class BRng10s {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int t = in.nextInt();
            outer:
            for (int i = 0; i < t; i++) {
                long a = in.nextLong(), b = in.nextLong(),
                        c = in.nextLong(), d = in.nextLong();
                if (a < b || b > d) {
                    out.println("No");
                    continue;
                } else if (b - c <= 1) {
                    out.println("Yes");
                    continue;
                }
                long mod = gcd(b, d);
                if (b - c > mod + 1) {
                    out.println("No");
                    continue;
                }
                long lb = (c + 1) % mod;
                long ub = (b - 1) % mod;
                a %= mod;
                if (lb <= ub) {
                    if (lb <= a && a <= ub) {
                        out.println("No");
                        continue;
                    }
                } else {
                    if (a <= ub || lb <= a) {
                        out.println("No");
                        continue;
                    }
                }
                out.println("Yes");//高須クリニック?
            }
        }

        private static long gcd(long u, long v) {
            long k, t;
            k = 0;
            while ((0 == (u & 1)) && (0 == (v & 1))) {
                k++;
                u /= 2;
                v /= 2;
            }
            if ((u & 1) == 0) {
                t = u / 2;
            } else {
                t = -v;
            }

            do {
                while ((t & 1) == 0) t /= 2;

                if (t > 0) {
                    u = t;
                } else {
                    v = -t;
                }

                t = u - v;
            } while (0 != t);
            return u * (1 << k);
        }

    }
}



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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#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 yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

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

struct BIT{
  vll tree;
  ll n;

  BIT(ll n_):tree(n_+1,0),n(n_){
  }

  ll cumulativeSum(ll i){
    ll s=0;
    while(i>0){
      s += tree[i];
      i -= i&-i;
    }
    return s;
  }

  //[l, r)
  ll sum(ll l, ll r){
    ll res = cumulativeSum(r) - cumulativeSum(l);
    return res;
  }

  void add(ll i, ll x){
    i++;
    while(i<=n){
      tree[i] += x;
      i += i&-i;
    }
  }
};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

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

  vll s(n+1);
  REP(i,n+1){
    if(i==0)
      s[i]=0;
    else if(i==1)
      s[i]=a[i-1]-k;
    else
      s[i]=s[i-1]+a[i-1]-k;
  }

  vll b=s;
  SORT_UNIQUE(b);
  map<ll,ll> table;
  REP(i,b.size())table[b[i]]=i;

  REP(i,n+1)s[i]=table[s[i]];
  BIT bit(n+1);

  ll ans=0;
  REP(i,n+1){
    ll now=bit.sum(0,s[i]+1);
    bit.add(s[i],1);
    ans+=now;
  }

  cout<<ans<<endl;
}



Measured memory_bytes: 21892
#include <iostream>

using namespace std;
const int kBalln = 10;
int main(){
  int n;
  int ball;
  int b, c;
  bool ans;
  cin >> n;
  for (int j = 0; j < n; ++j)
    {
      b = 0; c = 0;ans = true;
      for (int i = 0; i < kBalln; ++i)
        {
          cin >> ball;
          if (b < ball)
            {
              b = ball;
            }
          else if (c < ball)
            {
              c = ball;
            }
          else
            {
              ans = false;
              // cout << "NO" << endl;
              // break;
            }
        }
      cout << (ans ? "YES" : "NO") << endl;
    }
  return 0;
}

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

string S;
set<char> st;

int main(){
    cin >> S;
    for(int i = 0; i < S.size(); i++)
        st.insert(S[i]);

    if(S.size() == st.size()) cout << "yes";
    else cout << "no";

    return 0;
}

Measured memory_bytes: 256
while 1:
 m,f,r=map(int,input().split());s=m+f
 if m==f==r<0:break
 if m*f<0 or s<30:print('F')
 elif s>79:print('A')
 elif s>64:print('B')
 elif s>49 or r>49:print('C')
 else:print('D')

Measured memory_bytes: 5596
#dp[i][j]:i日目に活動j:0,1,2:A,B,Cをするときの幸福度の最大値

N = int(input())
abc = [list(map(int,input().split())) for i in range(N)]#abc:012

dp = [[0,0,0] for i in range(0,N,1)]
dp[0] = abc[0]

for i in range(1,N,1):
    for j in range(0,3,1):#012:abc
        dp[i][j] = abc[i][j]+max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3])

print(max(dp[N-1]))

Measured memory_bytes: 101700
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <sstream>
#include <limits.h>
using namespace std;
 
int main()
{
    int n;
    cin >> n;
    
    long long int last = 0;
    std::vector<long long int> v;
    std::vector<long long int> diff;
    for(int i=0; i<n; i++){
        long long int tmp;
        cin >> tmp;
        v.push_back(tmp);
        
        if(i==0){
            diff.push_back(0);
        }else{
            diff.push_back(tmp-v[i-1]);
            if(tmp-v[i-1] > 0) last = i;
        }
    }
    //cout << last << endl;
    
    long long int sum = 1000;
    long long int num = 0;
    for(int i=0; i<n-1; i++){

        sum += num * v[i];
        num = 0;
        if(v[i+1] > v[i]){ // 明日上がるなら
            num = sum / v[i];
            sum = sum % v[i];
        }else if(v[i+1] < v[i]){
            
            
        }

        //cout << sum << ":" << num <<  " ( " << v[i] << endl;
    }
    if(num > 0) sum += num * v[n-1];
    //cout << sum << ":" << num <<  " ( " << v[n-1] << endl;
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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 T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;


signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,d;
    cin>>n>>d;
    int cnt=0;
    for (int i = 0; i < n; i++)
    {
        int x,y;
        cin>>x>>y;
        if(x*x+y*y<=d*d) cnt++;
    }
    cout<<cnt<<endl;
    
    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long c,a,b,k,i,sum=0;
  cin>>a>>b>>c>>k;
    sum+=min(a,k);
    k=k-min(a,k);
    if(k>0){
     sum+=min(b,k)*0;
     k=k-min(b,k);
    }
    if(k>0){
     sum+=min(c,k)*(-1);
     k=k-min(c,k);
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 3532