akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, K;
  int ans = 0;
  cin >> N >> K;
  vector<int> h(N);
  for(int i = 0; i < h.size(); ++i){
    cin >> h[i];
    if(h[i] >= K){
      ++ans;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
m,d = map(int,input().split())
ans = 0

for i in range(1,m+1):
    for j in range(1,d+1):
        d_10 = j//10
        d_1 = j % 10
        if d_1 >= 2 and d_10 >= 2 and d_1 * d_10 == i:
            ans += 1

print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++)
  {
    cin>>v[i];
  }
  int i=1;
  if(n==2)
  {
    if(v[0]==v[1]) cout<<1<<endl;
    else cout<<0<<endl;
    return 0;
  }
  int count=0;
  while(i<n)
  { 
    if(v[i]==v[i-1])
      { count++;i=i+2;}
    else if((i+1<n) && v[i]==v[i+1])
      {count++;i=i+3;}
    else i=i+2;
   }
   cout<<count<<endl;
    return 0;
 }


Measured memory_bytes: 764
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] arr = new int[n];
        for(int i=0; i<n; i++)
            arr[i] = in.nextInt();
        int maxSoFar = arr[0];
        long ans = 0;
        for(int i : arr) {
            if(i > maxSoFar) {
                maxSoFar = i;
            } else {
                ans += (long) (maxSoFar - i);
            }
        }
        System.out.println(ans);
        in.close();
    }
}

Measured memory_bytes: 50104
#include<iostream>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<math.h>
#include<ctime>

using namespace std;
using ll = long long;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ti = clock();
  // start-----------------------------------------------
  int n; cin >> n;
  double ans = 0;
  vector<pair<int, int>> point(n);
  for(int i = 0; i < n; i++){
    cin >> point[i].first >> point[i].second;
  }
  for(int i = 0; i < n; i++){
    for(int j = i+1; j < n; j++){
      ans += sqrt(pow(point[i].first - point[j].first, 2) + pow(point[i].second - point[j].second, 2));
    }
  }
  cout << fixed << setprecision(16) << 2.0 * ans / n << endl;

  // end-----------------------------------------------
  cerr << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl;
}


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

#define mp          make_pair
#define pb          push_back
#define ff          first
#define ss          second
#define ii          pair<int,int>
#define mod         (int)1e9+7
#define inf         1e18
#define max_v       200005

typedef long long int lli;
typedef long double ld;

#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

int n,k;
int A[100005];
int dp[100005];

int rec(int i,int n)
{
    if(i==n)
        return 0;
    if(dp[i]!=-1)
        return dp[i];
    int cost=INT_MAX;
    for(int j=i+1;j<=min(n,i+k);j++)
    {
        cost=min(cost,abs(A[j]-A[i])+rec(j,n));
    }
    return dp[i]=cost;
}

void solve()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>A[i];

    memset(dp,-1,sizeof(dp));
    cout<<rec(1,n)<<endl;

    return ;
}

int main()
{
    fio

    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
 
    int t;
    t=1;
//    cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

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

int main(){

    string card;
    int m,h;

    while(1){
        cin>>card;
        if(card=="-")break;
        cin>>m;

        for(int i=0;i<m;i++){
            cin>>h;
            for(int j=0;j<h;j++){
                card += card[0];
                card.erase(0,1);
//                cout<<card<<endl;
            }
        }
        cout<<card<<endl;
    }


    return 0;
}


Measured memory_bytes: 3224
M=99;main(n,i,j,k,a,b,c){
    double p=atan(1)*4,X[100],Y[100],x,y;
    for(;scanf("%d",&n),n;printf("%d\n",a)){
        for(i=0;i<n;i++)scanf("%lf,%lf",X+i,Y+i);
        for(a=i=0;i<n;i++){
            for(b=k=0;k<M;k++){
                x=X[i]+cos(p*k/M),y=Y[i]+sin(p*k/M);
                for(c=0,j=i;j<n;j++){
                    if((X[j]-x)*(X[j]-x)+(Y[j]-y)*(Y[j]-y)<1+1e-7)c++;
                }
                if(b<c)b=c;
            }
            if(a<b)a=b;
        }
    }
exit(0);}

Measured memory_bytes: 644
#include <cstdio>
#include <algorithm>

int main() {
  int W, a, b;
  scanf("%d %d %d", &W, &a, &b);

  if (a > b) std::swap(a, b);

  if (a+W >= b) return puts("0"), 0;
  printf("%d\n", b-(a+W));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
#include <numeric>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


// const double PI = acos(-1);
// int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
// int a[12][12];



void solve() {
  int n; 
  string s;
  cin >> n >> s;
  vector<char> x;
  for (int i = 0; i < n; i++){
    if (s[i] != s[i+1]) {
      x.push_back(s[i]);
    }
  }
  cout << x.size() << endl;
  
}


int main() {
  solve();
  return 0;
}

Measured memory_bytes: 640
#include <iostream>


bool count_alphabet(int counts[27]) {
  char string[1200];
  int ascii_code;

  if (std::cin.getline(string, sizeof(string))) {
    for (int i = 0; string[i] != '\0'; i ++) {
      ascii_code = (int)string[i];
      if (65 <= ascii_code && ascii_code <= 90) {
        ascii_code -= 65;
        counts[ascii_code] += 1;
      } else if (97 <= ascii_code && ascii_code <= 122) {
        ascii_code -= 97;
        counts[ascii_code] += 1;
      }
    }
    return true;
  } else {
    return false;
  }
}

int main() {
  int counts[27] = {0};

  while(count_alphabet(counts));

  for (int i = 0; i < 26; i ++) {
    std::cout << (char)(i + 97) << " : " << counts[i] << std::endl;
  }

  return 0;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  string S;
  cin >> S;
  bool is_ok = false;
  rep(i, S.size())
  {
    rep(j, S.size())
    {
      string temp = S.substr(0, i - 1);
      temp += S.substr(j, S.size());
      if (temp == "keyence")
        is_ok = true;
    }
  }

  if (is_ok)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <cassert>
using namespace std;
typedef long long ll;

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define FOREQ(i, k, n) for (int i = (k); i <= (int)(n); ++i)
#define DEC(i, k) for (int i = (k); i >= 0; --i)
#define FORIT(i, c) for (__tyoeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define SZ(v) (int)((v).size())
#define MEMSET(v, h) memset((v), (h), sizeof(v))
#define FIND(m, w) ((m).find(w) != (m).end())
#define ALL(c) (c).begin(), (c).end()

ll n, w;
const ll MOD = 1000000007;
ll weight[210];
ll sum[210];
ll dp[210][10010];
ll combi[210][210];

int main()
{
    MEMSET(weight, -1);
    MEMSET(combi, 0);
    combi[0][0] = 1;
    REP(i, 205) {
        REP(j, 205) {
            combi[i + 1][j]  = (combi[i + 1][j] + combi[i][j]) % MOD;
            combi[i + 1][j + 1] = (combi[i + 1][j + 1] + combi[i][j]) % MOD;
        }
    }
    scanf("%lld %lld", &n, &w);
    REP(i, n) {
        scanf("%lld", &weight[i]);
    }
    sort(weight, weight + n);
    sum[0] = weight[0];
    REP(i, n) {
        sum[i + 1] = sum[i] + weight[i + 1];
    }
    if (sum[n] <= w || weight[0] > w) {
        puts("1");
        return 0;
    }
    MEMSET(dp, 0);
    dp[n][0] = 1;
    for (int i = n; i > 0; i--) {
        int next = i - 1;
        for (int j = 0; j <= w; j++) {
            dp[next][j] = (dp[next][j] + dp[i][j]) % MOD;
            if (j + weight[next] > w) { continue; }
            dp[next][j + weight[next]] = (dp[next][j + weight[next]] + dp[i][j]) % MOD;
        }
    }
    ll ans = 0;
    int index = 0;
    while (index < n) {
        int start = index;
        int cnt = 1;
        while (weight[index] == weight[index + 1]) { cnt++; index++; }
        FOREQ(i, 0, w) {
            ll rest = w - (i + sum[start] - weight[start]);
            int k = rest / weight[index];
            if (rest < 0 || cnt <= k) { continue; }
            ans = (ans + combi[cnt][k] * dp[index + 1][i]) % MOD;
        }
        index++;
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 17000
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>
#include<stack>
#include<iomanip>

using namespace std;

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPL(i,a,n) for(ll i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SORTVG(v) sort(v.begin(),v.end(),greater<>())
#define SORTV(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef pair<int,int> Pii;
typedef vector<int> Vi;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}

vector<string> split(string s, string delim) {
    vector<string> res;
    int pos = 0;
    while(true) {
        int found = (int)s.find(delim, pos);
        if(found >= 0) {
            res.push_back(s.substr(pos, found - pos));
        }
        else {
            res.push_back(s.substr(pos));
            break;
        }
        pos = found + (int)delim.size();
    }
    return res;
}

int atcoder(){
    string s,t="",tr;
    cin>>s;
    vector<string> sub=split(s,"x");
    REP(i,0,sub.size()) t+= sub[i];
    int ans=0;
    
    tr = t;
    reverse(ALL(tr));
    if(t!=tr){cout<<-1<<ENT;return 0;}

    int i=0,j=(int)s.size()-1;
    while(j>i){
        int t1=0,t2=0;
        while(s[i]=='x'){
            i++;
            t1++;
        }
        while(s[j]=='x'){
            j--;
            t2++;
        }
        ans += abs(t1-t2);
        i++;
        j--;
    }
    cout<<ans<<ENT;
    return 0;
}


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




Measured memory_bytes: 2380
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<vector<int>> gr(n, vector<int>(n));
  rep(i, n){
    rep(j, n){
      int in;
      cin >> in;
      gr.at(i).at(j) = in;
    }
  }
  vector<bool> chk(n, false);
  int ans = 0;
  priority_queue<pair<int, int>> pq;
  pq.push(make_pair(0, 0));
  int co = 0;
  while(!pq.empty()){
    auto p = pq.top(); pq.pop();
    if(chk.at(p.second) == true) continue;
    chk.at(p.second) = true;
    ans += p.first;
    // cerr << ans << endl;
    co++;
    if(co == n) break;

    rep(i, n){
      if(gr.at(p.second).at(i) == -1) continue;
      if(chk.at(i) == true) continue;
      pq.push(make_pair(-1*gr.at(p.second).at(i), i));
    }
  }
  cout << -1*ans << endl;
  return 0;
}


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

int N;

int main() {
   cin >> N;
   int ot = 0, ox = 0, oy = 0;
   bool ok = true;
   while (N--) {
      int t, x, y;
      cin >> t >> x >> y;
      int dist = abs(x-ox) + abs(y-oy);
      int tt = t - ot;
      if (dist > tt || (dist+tt)%2) {
         ok = false;
      }
      ot = t, ox = x, oy = y;
   }

   puts(ok?"Yes":"No");

   return 0;
}

Measured memory_bytes: 256
N = int(input())
H = list(map(int,input().split()))
ans = 0
tmp = 0
for i in range(N-1):
    if H[i]<H[i+1]:
        ans = max(ans,tmp)
        tmp = 0
    else:
        tmp += 1
ans = max(ans,tmp)
print(ans)

Measured memory_bytes: 14224
import numpy as np

N, M, C = map(int, input().split())
B = np.array(list(map(int, input().split())))
A = []
for i in range(N):
    A_i = list(map(int, input().split()))
    A.append(A_i)
A = np.array(A)

#ans = list((A@B) > -C).count(True)
ans = list((A.dot(B)) > -C).count(True)

print(ans)


Measured memory_bytes: 12504
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3500;
int n, mod, ans;
int c[maxn + 10][maxn + 10], s[maxn + 10][maxn + 10];
int a[maxn + 10], b[maxn * maxn + 10];

int fpow(int x, int y, int mod) {
	int ans = 1;
	while (y) {
		if (y & 1) ans = 1ll * ans * x % mod;
		y >>= 1; x = 1ll * x * x % mod;
	}
	return ans;
}

int main() {
	scanf("%d%d", &n, &mod);
	c[0][0] = s[0][0] = 1;
	for (int i = 1; i <= maxn; ++i) {
		c[i][0] = 1;
		for (int j = 1; j <= i; ++j) {
			c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % mod;
			s[i][j] = (1ll * s[i - 1][j] * j + s[i - 1][j - 1]) % mod;
		}
	}
	for (int i = 0; i <= n; ++i)
		a[i] = fpow(2, fpow(2, i, mod - 1), mod);
	b[0] = 1;
	for (int i = 1; i <= maxn * maxn; ++i)
		b[i] = b[i - 1] * 2 % mod;
	for (int i = 0; i <= n; ++i)
		for (int j = 0; j <= i; ++j) {
			int w = 1ll * c[n][i] * s[i + 1][j + 1] % mod;
			w = 1ll * w * b[(n - i) * j] % mod;
			w = 1ll * w * a[n - i] % mod;
			if (i & 1) ans = (ans - w + mod) % mod;
			else ans = (ans + w) % mod;
		}
	printf("%d", ans);
}



Measured memory_bytes: 144256
n, m = map(int, input().split())
a = [""] * n
b = [""] * m

for i in range(n):
    a[i] = input()

for i in range(m):
    b[i] = input()

for i in range(n):
    for j in range(n):
        if i + m > n or j + m > n:
            continue
        flag = True
        for k in range(m):
            for l in range(m):
                if a[i + k][j + l] != b[k][l]:
                    flag = False
        if flag is True:
            print("Yes")
            exit(0)

print("No")


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

int main() {
	int N;
	ll A,s=0;
	cin >> N;
	map<ll, ll> mp;
	mp[0]++;
	REP(i,N){
		cin >> A;
		s+=A;
		mp[s]++;
	}
	ll ans=0;
	map<ll, ll>::iterator itr;
	for(itr=mp.begin();itr!=mp.end();itr++){
      	ll sec=itr->second;
		ans += sec*(sec-1)/2;
	}
	cout << fixed << ans << endl;
	
	return 0;
}

Measured memory_bytes: 12800
#include<iostream>
#include<cstdio>
int main()
{
    int a,b,c;
    while(~scanf("%d %d %d",&a,&b,&c))
    {
     if(a==b)
        printf("%d\n",c);
    if(a==c)
        printf("%d\n",b);
    if(b==c)
        printf("%d\n",a);
    }
    return 0;
}


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

int main() {
    int64_t N;
    cin >> N;

    if (N % 2 == 1) {
        cout << 0 << endl;
        return 0;
    }

    int64_t ans = N / 10;

    int64_t t = N / 10;
    int64_t div = 5;
    while (div <= t) {
        ans += t / div;
        div *= 5;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
#define P putchar
using namespace std;
int n;
signed main()
{
	scanf("%d",&n),P(48),P(10);string s("Vacant"),t,tm;cin>>t;int l(0),r(n-1);
	if(s==t){goto endreturn;}
	while(l!=r)
	{
		int mid((l+r+1)>>1);printf("%d",mid),P(10);
		cin>>tm;if(s==tm){goto endreturn;}
		((((t==tm)&&(mid&1))||((t!=tm)&&(!(mid&1))))?(r=mid-1):(l=mid));
	}
	endreturn:return 0;
}

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

#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int ans=a+b-(c+d);
  if(ans==0){
    cout<<"Balanced"<<endl;
    return 0;
  }
  cout<<(ans>0? "Left":"Right")<<endl;
  return 0;
}


Measured memory_bytes: 256
import math
N, D = (int(_) for _ in input().split())  
x = []
for i in range(N):
    x.append([int(_) for _ in input().split()]) 

cnt = 0
for i in range(N):
    for j in range(N):
        if i < j :
            comb = [(x - y) * (x - y) for (x, y) in zip(x[i], x[j])]
            d = int(math.sqrt(sum(comb)))
            if d * d == sum(comb):
                cnt +=1

print(cnt)


Measured memory_bytes: 38256
#include <stdio.h>
#include <vector>
 
using namespace std;
 
struct Node{
    Node(){
        parent = -1;
        depth = num_of_children = 0;
    }
    int parent;
    int depth;
    vector<int> children;
    int num_of_children;
};
 
void calcDepth(Node nodes[],int root_id){
    for(int i = 0;i < nodes[root_id].num_of_children;i++){
        nodes[nodes[root_id].children[i]].depth = nodes[root_id].depth+1;
        calcDepth(nodes,nodes[root_id].children[i]);
    }
}
 
int main(){
    int n,id,k,child_id,root_id;
    scanf("%d",&n);
    Node nodes[n];
 
    for(int i = 0; i < n; i++){
        scanf("%d %d",&id,&k);
        for(int j = 0; j < k; j++){
            scanf("%d",&child_id);
            nodes[id].children.push_back(child_id);
            nodes[id].num_of_children++;
            nodes[child_id].parent = id;
        }
    }
 
    for(root_id = 0; root_id < n; root_id++){
        if(nodes[root_id].parent == -1) break;
    }




 
    calcDepth(nodes,root_id);
 
    for(int i = 0; i < n; i++){
        if(nodes[i].parent == -1){
            printf("node %d: parent = -1, depth = 0, root, ",i);
        }else if(nodes[i].num_of_children == 0){
            printf("node %d: parent = %d, depth = %d, leaf, ",i,nodes[i].parent,nodes[i].depth);
        }else{
            printf("node %d: parent = %d, depth = %d, internal node, ",i,nodes[i].parent,nodes[i].depth);
        }
        printf("[");
        for(int j = 0; j < nodes[i].num_of_children-1; j++){
            printf("%d, ",nodes[i].children[j]);
        }
        if(nodes[i].num_of_children > 0){
            printf("%d",nodes[i].children[nodes[i].num_of_children-1]);
        }
        printf("]\n");
    }
}


Measured memory_bytes: 7428
def main():
    n, m, x = map(int, input().split())
    ca = []
    for _ in range(n):
        ca.append(list(map(int, input().split())))
    result = 10**9
    for i in range(1, 2**n+1):
        work = 0
        j = 0
        temp = [0] * m
        for flag in bin(i)[2:].zfill(n):
            if flag == "1":
                work += ca[j][0]
                for k in range(1, m+1):
                    temp[k-1] += ca[j][k]
            j += 1
        flag = True
        for t in temp:
            if t < x:
                flag = False
                break
        if flag:
            result = min(result, work)
    if result == 10**9:
        print(-1)
    else:
        print(result)
main()

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

namespace ConsoleApp1
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var inputArray = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();

            long sum = inputArray[0] + inputArray[1];
            long minus = inputArray[0] - inputArray[1];
            long multi = inputArray[0] * inputArray[1];

            long answer = Math.Max(Math.Max(sum, minus), multi);

            System.Console.WriteLine(answer);
        }
    }
}

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

using namespace std;

int main() {
    unsigned int n;
    cin >> n;

    vector<int> vt(2 * n);
    for (int i = 0; i < 2 * n; ++i) {
        cin >> vt[i];
    }
    sort(vt.begin(), vt.end());

    int ans = 0;
    for (int i = 0; i < 2 * n; i += 2) {
        ans += vt[i];
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
using namespace std;

ll Mo = 1e9 + 7;
int main()
{
    int N, M;
    ll ans=1;

    cin >> N >> M;

    if (abs(N - M) >= 2) cout << 0 << endl;
    else if (N + 1 == M) {
        for (int i = 1; i <= N; i++) {
            ans *= i;
            ans %= Mo;
        }
        for (int i = 1; i <= M; i++) {
            ans *= i;
            ans %= Mo;
        }
        cout << ans << endl;
    }
    else if (M + 1 == N){
        for (int i = 1; i <= N; i++) {
            ans *= i;
            ans %= Mo;
        }
        for (int i = 1; i <= M; i++) {
            ans *= i;
            ans %= Mo;
        }
        cout << ans << endl;
    }
    else {
        for (int i = 1; i <= N; i++) {
            ans *= i;
            ans %= Mo;
        }
        for (int i = 1; i <= M; i++) {
            ans *= i;
            ans %= Mo;
        }
        cout << 2*ans%Mo << endl;
    }

    return 0;
}


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

#define rep(i,a,b) for(ll i=(a);i<=(b);i++)
#define END(x) do{cout<<(x)<<endl;exit(0);}while(0)
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: (x))cerr<<e<<" ";cerr<<"\n";}while(0)
#define exp2(x)  (1LL<<(x))

using namespace std;
using ll=long long;


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

int n, a,b;  
  cin >> n >> a >> b;
  END(min(n*a, b));
  //sort(s.begin(), s.end());
  //if (s[0]==s[1] and s[2]==s[3] a}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

string s, t;

void rott(string& a)
{
    char tmp = a[0];
    int tlen = a.length() - 1;
    for (int i = 0; i <= tlen - 1; i++)
        a[i] = a[i+1];
    a[tlen] = tmp;
    return;
}

int main()
{
    getline(cin, t);
    getline(cin, s);
    if (s == t)
        return cout << "Yes\n", 0;
    int len = s.length();
    for (int i = 1; i <= len; i++)
    {
        rott(s);
        if (s == t)
            return cout << "Yes\n", 0;
    }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n; cin >> n;
    vll a(n); for(auto& e : a) cin >> e;

    vll inc = {0};
    vi idxs = {-1};
    vll diffs = {-1};
    vi nums = {-1};
    int idx = 0;
    rep(i, n){
        int e = a[i];
        if(e > inc.back()){
            inc.emplace_back(e);
            idxs.emplace_back(i);
            diffs.emplace_back(0);
            nums.emplace_back(0);
            idx++;
        }
        else {
            int to = (int)(lower_bound(_all(inc), e) - begin(inc));
            diffs[to] += e - inc[to - 1];
            nums[to]++;
        }
    }

    int m = inc.size();
    ll cnt = 0;
    vll res(n);
    rrep(i, m, 1){
        cnt++;
        res[idxs[i]] += diffs[i] + cnt * (inc[i] - inc[i - 1]);
        cnt += nums[i];
    }

    rep(i, n){
        cout << res[i] << endl;
    }

    return 0;
}


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

class MaxFlow {
public:
  struct edge { ll to, cap, rev; };

  const ll INF = 1LL << 60;
  ll N;
  vector< vector<edge> > E;
  vector<bool> used;

  MaxFlow(ll n): N(n), E(n), used(n) {};

  void add_directed_edge(ll from, ll to, ll cap) {
    E[from].push_back((edge) { to, cap, (ll) E[to].size() });
    E[to].push_back((edge) { from, 0, (ll) E[from].size() - 1 });
  }

  void add_undirected_edge(ll from, ll to, ll cap) {
    E[from].push_back((edge) { to, cap, (ll) E[to].size() });
    E[to].push_back((edge) { from, cap, (ll) E[from].size() - 1 });
  }

  ll dfs(ll v, ll t, ll f) {
    if(v == t) return f;
    used[v] = true;
    REP(i, 0, E[v].size()) {
      edge &e = E[v][i];
      if(!used[e.to] && e.cap > 0) {
        ll d = dfs(e.to, t, min(f, e.cap));
        if(d > 0) {
          e.cap -= d;
          E[e.to][e.rev].cap += d;
          return d;
        }
      }
    }
    return 0;
  }

  ll max_flow(ll s, ll t) {
    ll flow = 0;
    while(1) {
      REP(i, 0, N) used[i] = false;
      ll f = dfs(s, t, INF);
      if(f == 0 || f == INF) break;
      flow += f;
    }
    return flow;
  }
};

int main(void) {
  ll N, A, B;
  cin >> N >> A >> B;
  vector<ll> a(N), b(N);
  REP(i, 0, N) cin >> a[i] >> b[i];

  ll ans = 0;
  vector<bool> used(N, false);
  REP(i, 0, N) {
    ll d = abs(a[i] - b[i]);
    if(d <= A || (B <= d && d <= 2 * A)) {
      used[i] = true;
      ans++;
    }
  }

  const ll s = N, t = N + 1;
  MaxFlow flow(N + 2);
  REP(i, 0, N) if(!used[i]) {
    ll d = a[i] - b[i];
    if(d > 0) flow.add_directed_edge(s, i, 1);
    if(d < 0) flow.add_directed_edge(i, t, 1);
  }
  REP(i, 0, N) REP(j, 0, N) if(!used[i] && !used[j]) {
    ll di = a[i] - b[i];
    ll dj = a[j] - b[j];
    ll d = abs(di + dj);
    if(d <= A || (B <= d && d <= 2 * A)) {
      if(di > 0 && dj < 0) flow.add_directed_edge(i, j, 1);
      if(di < 0 && dj > 0) flow.add_directed_edge(j, i, 1);
    }
  }
  ans += flow.max_flow(s, t);

  cout << ans << endl;
}



Measured memory_bytes: 8060
#include <bits/stdc++.h>
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define fr first
#define sc second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define int long long
using namespace std;

string s,t;
int L[3005][3005];

void Write(int i, int j)
{
    if(L[i][j])
    {
        if(s[i-1] == t[j-1])
        {
            Write(i - 1, j - 1);
            cout << s[i-1]  ;
        }
        else
        {
            if(L[i - 1][j] > L[i][j - 1])
                Write(i - 1, j);
            else
                Write(i, j - 1);
        }
    }
}

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin >> s >> t;
    for(int i=1;i<=s.size();i++){
        for(int j=1;j<=t.size();j++){
            if (s[i-1] == t[j-1]) L[i][j] = 1 + L[i - 1][j - 1];
			else L[i][j] = max(L[i][j - 1], L[i - 1][j]);
        }
    }
    Write(s.size(),t.size());
}


Measured memory_bytes: 70784
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}
struct edge {
    ll to,cost;
};

/*
const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_MAX; i++){
        fac[i] = fac[i-1]*i%MOD;
        inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
        finv[i] = finv[i-1]*inv[i]%MOD;
    }
}
long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
*/


int main(){
    int N; cin >> N;
    if (N % 2 == 0){
        cout << 0.50000000000 << endl;
    } else {
        cout << fixed << setprecision(10) << (double)((N-1)/2+1)/N << endl;
    }
}


Measured memory_bytes: 256
S = input()

mm = ['0' + str(x) for x in range(1,10)] + ['10','11','12']

mmyy = (S[:2] in mm)
yymm = (S[2:] in mm)

answer = 'NA'
if yymm and mmyy:
  answer = 'AMBIGUOUS'
elif yymm:
  answer = 'YYMM'
elif mmyy:
  answer = 'MMYY'
  
print(answer)

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

int main() {
    int a,b,c,d;
    cin >> a >> b >> c;
    if(a > b)d = a, a = b, b = d;
    if(b > c)d = b, b = c, c = d;
    if(a > b)d = a, a = b, b = d;
    cout << a << " " << b << " " << c << endl;
}


Measured memory_bytes: 3112
K, S=map(int, input().split())
KK=2*K
counter=0
for x in range(K+1):
  yz=S-x
  if yz<0:
    pass
  else:
    if yz<=K:
      counter+=(yz+1)
    elif yz>KK:
      pass
    else:
      counter+=(KK-yz+1)
    
print(counter)

Measured memory_bytes: 3060
#pragma comment (linker, "/STACK:256000000")

#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_DEPRECATE
#define _CRT_NONSTDC_NO_DEPRECATE
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <fstream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <memory.h>
#include <sstream>
#include <cassert>
#include <ctime>
#include <complex>
#include <random>
#include <bitset>

using namespace std;

typedef unsigned int uint32;
typedef long long int64;
typedef unsigned long long uint64;
typedef long double ldouble;
typedef pair<int, int> pii;
typedef pair<int64, int64> pll;
typedef pair<uint64, uint64> puu;
typedef pair<pii, pii> piiii;

#define pb push_back
#define sq(x) ((x)*(x))
#define tmin(x,y,z) (min(min((x),(y)),(z)))
#define rand32() (((unsigned int)(rand()) << 16) | (unsigned int)(rand()))
#define rand64() (((unsigned int64)(rand32()) << 16) | (unsigned int64)(rand32()))
#define bit(mask, b) ((mask >> b) & 1)
#define biton(mask, bit) (mask | (((uint32)(1)) << bit))
#define bitoff(mask, bit) (mask & (~(((uint32)(1)) << bit)))
#define bitputon(mask, bit) (mask |= (((uint32)(1)) << bit))
#define bitputoff(mask, bit) (mask &= (~(((uint32)(1)) << bit)))
#define FAIL() (*((int*)(0)))++
#define INF ((int)(1e9) + 1337)
#define LINF ((int64)(1e18))
#define EPS 1e-13
#define PI (3.1415926535897932384626433832795)
#define y1 yy1
#define y0 yy0
#define j0 jj0
//#define MOD 1000000007LL
#define HMOD 1234567913LL
#define HMOD2 1000000007LL
#define HBASE 1000003
#define REV2 500000004


//#ifdef _MY_DEBUG
//    #define HMOD 1000000007
//    #define HBASE (1000003LL)
//#else
//    #define HMOD ((int64)(1e18) + 3LL)
//    #define HBASE (1000037LL)
//#endif
#define MAX 2000000000
mt19937 ggen;

int n, k;
vector<vector<int> > g;
int u[100010];
int ans = 0;

int dfs(int a, int p)
{
    int res = 0;
    for (int i = 0; i < (int)g[a].size(); i++)
    {
        res = max(res, dfs(g[a][i], a));
    }
    if (res == k - 1 && p != 0)
    {
        ans++;
        res = -1;
    }
    return res + 1;
}

void solve()
{
    cin >> n >> k;
    g.resize(n);
    for (int i = 0; i < n; i++)
    {
        int to;
        cin >> to;
        to--;
        if (i == 0)
        {
            if (to != 0)
                ans++;
        }
        else
        {
            g[to].push_back(i);
        }
    }
    dfs(0, 0);
    cout << ans;
}

#define TASK "substr"
int main()
{
    //testgen(100000, 100000);// return 0;
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _MY_DEBUG
    freopen("input.txt", "rt", stdin); freopen("output.txt", "wt", stdout);
#else
    //freopen(TASK ".in", "rt", stdin); freopen(TASK ".out", "wt", stdout);
#endif
    //stresstest(5, 7, 100); return 0;
    ggen = mt19937(13);

    //int start = clock();
    solve();

    return 0;
}

Measured memory_bytes: 10368
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>

using namespace std;

int n, k;

int main() {
    cin >> n >> k;
    
    long long ans = 1e11, cal;
    for (int i = 0; i <= n; ++i) {
        cal = 1;
        for (int j = 0; j < i; ++j)
            cal *= 2;
        for (int j = 0; j < n - i; ++j)
            cal += k;
        ans = min(ans, cal);
        
        cal = 1;
        for (int j = 0; j < i; ++j)
            cal += k;
        for (int j = 0; j < n - i; ++j)
            cal *= 2;
        ans = min(ans, cal);
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#define ll long long
using namespace std;
ll f[100005][2],n,a,b;
ll MOD= (ll) 1e9+7;
vector< vector<ll> > child;
void solve(ll x,ll parent){
	for(ll i=0;i<child[x].size();i++){
		if(child[x][i]!=parent){
			solve(child[x][i],x);
			f[x][0]=f[x][0]*(f[child[x][i]][0]+f[child[x][i]][1])%MOD;
			f[x][1]=f[x][1]*f[child[x][i]][0]%MOD;
		}
	}
}
int main(){
	scanf("%lld", &n);
	child.clear();
	child.resize(n+1);
	for(ll i=1;i<n;i++){
		scanf("%lld %lld", &a,&b);
		child[a].push_back(b);
		child[b].push_back(a);
	}
	for(ll i=1;i<=n;i++){
		f[i][1]=f[i][0]=1;
	}
	solve(1,0);
	printf("%lld", (f[1][1]+f[1][0])%MOD);
}


Measured memory_bytes: 12800
a,b,k=map(int,input().split())

ans=[]

for i in range(k):
    if a <= a+i <= b:
        ans.append(a+i)
    if a <= b-i <= b:    
        ans.append(b-i)

ans=sorted(list(set(ans)))

for aa in ans:
    print(aa)


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

typedef long long ll;

using namespace std;

int main() {
  int N;
  cin >> N;
  ll n = 1;
  for (int i = 1; i <= N; ++i) {
    n = (n * i) % (1'000'000'007);
  }
  printf("%lld\n", n);
}

Measured memory_bytes: 3260
#include <iostream>

#define rep(i, first, to) for(int i = first; i < to; ++i)

using namespace std;
typedef long long ll;

int h, w;
char a[102][102];

int main() {
	cin >> h >> w;
	fill(a[0], a[0] + 102, '#');
	rep(i, 1, 102) {
		a[i][0] = '#';
		a[i][w + 1] = '#';
	}
	rep(i, 1, 102) {
		a[h + 1][i] = '#';
	}
	rep(i, 1, h + 1) {
		rep(j, 1, w + 1) {
			cin >> a[i][j];
		}
	}
	rep(i, 0, h + 2) {
		rep(j, 0, w + 2) {
			cout << a[i][j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, arr[N];
int mem[N];
int solve(int i){
   if(i <= 0)
      return 0;
   else if(mem[i] != -1){
      return mem[i];
   }
   int op1 = abs(arr[i] - arr[i-1]) + solve(i-1);
   int op2 = abs(arr[i] - arr[i-2]) + solve(i-2);
   //cout<<op1<<" "<<op2<<endl;
   return mem[i] = min(op1, op2);  
}
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   memset(mem, -1, sizeof mem);
   cin>> n;
   for(int i = 0; i < n; i++){
      cin>>arr[i];
   }
   mem[0] = 0;
   mem[1] = abs(arr[1] - arr[0]);
   cout<<solve(n-1)<<endl;
   return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
void chmin(int &a,int b) {if(a > b) a=b;}

int N,A,B,C;
vector<int> l;

int rec(int i,int a,int b,int c){
  if(i == N){
    if(!a || !b || !c) return 1e9;
    else return abs(a-A) + abs(b-B) + abs(c-C);
  }
  
  int res=rec(i+1,a,b,c);
  
  chmin(res,rec(i+1,a+l[i],b,c)+(a ? 10 : 0));
  chmin(res,rec(i+1,a,b+l[i],c)+(b ? 10 :0 ));
  chmin(res,rec(i+1,a,b,c+l[i])+(c ? 10 : 0));
  
  return res;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> A >> B >> C;
  l.resize(N);
  rep(i,N) cin >> l[i];
  
  cout << rec(0,0,0,0) << endl;
}
  


Measured memory_bytes: 256
#include <stdio.h>
#include <set>
#include <algorithm>

using namespace std;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)

int n,m;
pii ranges[353531];   // sort by first, [left, right]
pii ranges2[353531];  // sort by second, [right, id]

int ans[125252];

const int B = 830;
const int C = 125;

// pointer struct
struct data{
  // id, position, in-iterator, out-iterator
  int id,pos,in,out;
};
data pts[C];
int cnt[353531];

int main(){
  // input
  scanf("%d%d",&n,&m);
  REP(i,n){
    int l,r;
    scanf("%d%d",&l,&r);
    ranges[i] = pii(l,r);
  }
  
  // d small
  FOR(d,1,min(B,m+1)){
    int tmp = 0;
    REP(i,n){
      int x = (ranges[i].first+d-1)/d;
      if(x*d<=ranges[i].second)tmp++;
    }
    ans[d]=tmp;
  }

  // d large
  // sort
  sort(ranges,ranges+n);
  REP(i,n)ranges2[i]=pii(ranges[i].second, i);
  sort(ranges2,ranges2+n);

  // pointer init
  data yo;
  yo.id=0; yo.pos=0; yo.in=0; yo.out=0;
  set<int> S;
  int tmp = 0;
  FOR(i,1,m+1){
    yo.pos++;
    while(yo.in<n && ranges[yo.in].first==yo.pos){
      S.insert(yo.in);
      yo.in++;
    }
    while(yo.out<n && ranges2[yo.out].first<yo.pos){
      S.erase(S.find(ranges2[yo.out].second));
      yo.out++;
    }
    if(i%B==0){
      // pts
      pts[yo.id] = yo;
      yo.id++;
      for(int x : S){
        if(cnt[x]==0)tmp++;
        cnt[x]++;
      }
    }
  }

  int pts_len = yo.id;
  FOR(d,min(B,m+1),m+1){
    ans[d] = tmp;
    if(d==m)break;
    REP(i,pts_len){
      if(pts[i].pos > m)break;
      // step pts[i]
      pts[i].pos += i+1;
      while(pts[i].in<n && ranges[pts[i].in].first<=pts[i].pos){
        if(cnt[pts[i].in]==0)tmp++;
        cnt[pts[i].in]++;
        pts[i].in++;
      }
      while(pts[i].out<n && ranges2[pts[i].out].first<pts[i].pos){
        int id = ranges2[pts[i].out].second;
        cnt[id]--;
        if(cnt[id]==0)tmp--;
        pts[i].out++;
      }
    }
  }
  FOR(d,1,m+1)printf("%d\n",ans[d]);
  return 0;
}


Measured memory_bytes: 21248
#include<iostream>
using namespace std;
typedef long long ll;
#define fr(i,n) for(int i=0;i<n;i++)

int main(){
  ll n,l,a[100010],k;
  cin>>n>>l;
  fr(i,n) cin>>a[i];
  bool f=0;
  fr(i,n-1){
    if(a[i]+a[i+1]>=l){
      k=i;
      f=1;
      break;
    }
  }
  if(!f) cout<<"Impossible"<<endl;
  else{
    cout<<"Possible"<<endl;
    fr(i,k) cout<<i+1<<endl;
    fr(i,n-k-1) cout<<n-1-i<<endl;
  }
}

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

# define fr first
# define sc second
# define ll unsigned long long
# define mk make_pair
# define pb emplace_back
# define sz(s) (int)s.size()
# define all(s) s.begin(), s.end()

using namespace std;

const int N = 2e5+10;
const int inf = 1e9+7;

int a, b, n;

int main () {
    cin >> n >> a >> b;
    cout << min(a * n, b) << endl;
}


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

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

  int ans = t.length();
  for (int i = 0; i <= (s.length()-t.length()); i++) {
    int count = t.length();
    for (int j = 0; j < t.length(); j++) {
      if (s[i+j] == t[j]) count--;
    }
    if (count < ans) ans = count;
  }

  cout << ans << endl;
}

Measured memory_bytes: 3624
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args)throws Exception{
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int d[]=new int[N];
		int z=0;
		while(z<N){
			d[z]=stdIn.nextInt();
			z++;
		}z=0;
		Arrays.sort(d);
		System.out.println(d[N/2]-d[N/2-1]);
	}
}

Measured memory_bytes: 52168
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a<b)
    {
        for(int i=1;i<=b;i++)
         cout<<a;
    }
    else
    {
        
        for(int i=1;i<=a;i++)
         cout<<b;   
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int main()
{
	int n,m,q,i,k;
	int x[100005];
	cin>>n>>m>>q;
	for(i=1;i<=n;i++)
		x[i]=m-q;
	for(i=0;i<q;i++)
	{
		cin>>k;
		x[k]++;
	}
	for(i=1;i<=n;i++)
		if(x[i]<=0)
			printf("No\n");
		else
			printf("Yes\n");
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int n, *a;
    cin >> n;
    a = new int[3*n];
    int i;
    for (i = 0; i < 3*n; i++)
        cin >> a[i];

    long long ans = 0;

    sort(a, a+n*3);

    for (i = 0; i/2 < n; i += 2)
        ans += a[n+i];
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>

#define MAX 1001


int main(){

  int n;
  scanf("%d%*c", &n);

  int a[MAX], b[MAX];
  int i,j,k;
  for(i = 0; i < n; i++){
    scanf("%d%*c", &a[i]);
  }

  for(i = 0; i < n; i++){
    b[i] = a[i];
  }

  for(k = 0; k < n-1; k++){
    printf("%d ", b[k]);
  }
  printf("%d\n", b[n-1]);
  
  for(i = 1; i < n; i++){
    for(j = 0; j < i; j++){
      if(b[j] > a[i]){

	for(k = i; k > j; k--){
	  b[k] = b[k-1];
	}
	b[j] = a[i];
	break;
      }	
    }

    for(k = 0; k < n-1; k++){
      printf("%d ", b[k]);
    }
    printf("%d\n", b[n-1]);
  }
  
  return 0;
}

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

X_max = X
X_min = X

while True:
    if N == 0 or (X in p) == False:
        print(X)
        break
        break
    X_max += 1
    X_min -= 1
    if (X_min in p) == False:
        print(X_min)
        break
        break
    if (X_max in p) == False:
        print(X_max)
        break
        break

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pb push_back
#define pii pair<ll,ll>
#define ll long long
#define tii tuple<ll,ll,ll>
#define all(v) (v).begin(),(v).end()
#define deb(x) cout << #x << "=" << x << endl;
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define ld long double
#define mod 998244353
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-9
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;      


const int N = 2e5+5; 
int n; 
ll seg[2 * N];

void build() {  
  for (int i = n - 1; i > 0; --i) 
    seg[i] = seg[2*i] + seg[2*i+1];
}

void update(int p, int value) {  
  for (seg[p += n] += value; p > 1; p >>= 1) seg[p>>1] = (seg[p] + seg[p^1])%mod;
}

//represents the range [l, r]
ll query(int l, int r) {  
    if(l>r) return 0;
  ll res = 0;
  r += 1;
  for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
    if (l&1) (res += seg[l++])%=mod;
    if (r&1) (res += seg[--r])%=mod;
  }
  return res%mod;
}

int main() {
    fastio
    ll k;
    cin>>n>>k;

    vector<pii> vec(k);
    for(auto& it: vec) cin>>it.first>>it.second;
    for(int i = 1; i<=n; ++i) {
        if(i!=1 && query(0, i-1)==0) continue;
        for(int j = 0; j<k; ++j) {
            int x = vec[j].first;
            int y = vec[j].second;

            if(i+x-1<n)
            update(i+x-1, (i==1?1:query(0, i-1)));
            if(i+y<n)
            update(i+y, -(i==1?1:query(0, i-1)));
        }
    }

    /*for(int i = 0; i<n; ++i) {
        cout<<query(0, i)<<endl;
    }*/
    cout<<query(0, n-1)%mod<<endl;
}

Measured memory_bytes: 6772
#include<stdio.h>
int main(){
  int i,j;
  int a[5001],n,s,t;
  a[0]=0;
  for(;;){
    scanf("%d",&n);
    if(n==0){
      break;
    }
    for(i=0;i<n;i++){
      scanf("%d",&a[i+1]);
      a[i+1]+=a[i];
    }
    s=-100000;
    for(i=0;i<n;i++)
      for(j=i+1;j<n+1;j++)
	if(a[j]-a[i]>s)
	  s=a[j]-a[i];
    printf("%d\n",s);
    /*
    t=0;
    for(i=1;i<=n;i++)
      for(j=0;j<=n-i;j++){
	s=0;
	for(k=0;k<i;k++)
	  s+=a[j+k];
	if(s>t)
	  t=s;
      }
    */
    //printf("%d\n",t);
  }
  return 0;
}

Measured memory_bytes: 0
import java.io.*;
import java.util.*;
import java.math.*;
 
class Main
{
    public static void main(String[] args)throws IOException
    {
        BufferedReader br =  new BufferedReader(new InputStreamReader(System.in));
        Scanner sc = new Scanner(System.in);
        int t = 1;
        while(t-->0)
        {
        	   int r = sc.nextInt();
                  double pie=3.141592653589793238;
                  double d = 2.0*pie*r;
                  System.out.println(d);
       

        	 
        }
     


        
        	
    }




   

}

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


int main(){
    int N,K; cin >> N >> K;
    set<int> st;
    rep(i,K){
        int d; cin >> d;
        st.insert(d);
    }

    for(int i=N;i<100000;i++){
        string s = to_string(i);
        bool ng = false;
        rep(j,s.size()){
            for(auto it : st){
                if(s[j]==it+'0'){
                    ng = true;
                    break;
                }
            }
            if(ng) break;
        }
        if(!ng){
            cout << s << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3676
X = int(input())

if X == 2:
    print(2)
    quit()

if X % 2 == 0:
    f = X+1
else:
    f = X

#fが素数かどうかをしらべていく。
while True:
    flag = True
    for i in range(2, int(f**0.5)+1):
        #fが素数ではないことを確認したら
        if f % i == 0:
            ｆ += 2
            flag = False
            break
    if flag:
        print(f)
        break


Measured memory_bytes: 3188