akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography.X509Certificates;

class Slimes
{
    static void Main(string[] args)
    {

        var number = int.Parse(Console.ReadLine());

        var words = Console.ReadLine();

        var check = words[0].ToString();


        int count = 1;

        for(var i = 0; i< number; i++)
        {
            if(words[i].ToString() != check)
            {
                count++;
            }
            check = words[i].ToString();
        }

        Console.WriteLine(count);
    }
}

Measured memory_bytes: 15328
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

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

const int mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;


int main()
{
    ll n,x,m; cin >> n >> x >> m;
    bool e = false;
    set<ll> s;
    ll p = -1;
    ll a = x;
    for(int i = 0; i < n; i++){
        if(s.find(a) != s.end()){
            p = a;
            break;
        }
        s.insert(a);
        a = (a*a) % m;
    }
    ll ans = 0;
    if(p == -1){
        a = x;
        for(int i = 0; i < n; i++){
            ans += a;
            a = (a*a) % m;
        }
    }else{
        a = x;
        ll sum1 = 0;
        ll cnt1 = 0;
        while(true){
            cnt1++;
            sum1 += a;
            a = (a*a) % m;
            if(a == p) break;
        }
        ll sum2 = 0;
        ll cnt2 = 0;
        while(true){
            cnt2++;
            sum2 += a;
            a = (a*a) % m;
            if(a == p) break;
        }
        ll cycle = (n-cnt1)/cnt2;
        ans = sum1 + cycle * sum2;
        ll res = n - cnt1 - cycle * cnt2;
        for(int i = 0; i < res; i++){
            ans += p;
            p = (p*p)%m;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5912
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 100;
int N;
ll T[MAX_N];


ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll m, ll n) {
    if ((0 == m) || (0 == n)) return 0;
    return ((m / gcd(m, n)) * n);
}

void solve() {
    ll ans = 1;
    REP(i, N) ans = lcm(ans, T[i]);
    cout << ans << endl;
}

int main() {
    cin >> N;
    REP(i, N) cin >> T[i];
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}

int main(void){
	char a=getchar();
	char b=getchar();
	char c=getchar();
	puts(a!=b||b!=c||c!=a?"Yes":"No");
}


Measured memory_bytes: 256
n, m = map(int, input().split())

V = [set() for _ in range(n)] # 隣接リスト
for a, b in [[*map(lambda x: int(x)-1, input().split())] for _ in range(m)]:
    V[a].add(b)
    V[b].add(a)

from collections import deque
G = [-1] * n # グループ色分け
for s in range(n): # BFS
    dq = deque([s])
    while dq:
        p = dq.popleft()
        if G[p] >= 0: continue
        G[p] = s # 色付け
        for c in V[p]: dq.append(c)

C = dict() # グループメンバ数集計
for g in G:
    if not g in C: C[g] = 0
    C[g] += 1

print(max(C.values())) # 最大メンバ数


Measured memory_bytes: 94016
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    string s;cin>>s;
    rep(i,s.size()){
        cout<<'x';
    }
    cout<<endl;

}

Measured memory_bytes: 3620
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>

using namespace std;
#define REP(i,a,n) for(int i = a; i < n; ++i)
#define REPM(i,n,a) for(int i = n - 1; i >= a; --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFD 1.0e+308
typedef long long LL;
typedef unsigned long long ULL;

typedef pair<LL, LL> PP;

const int MAX = 131072;
int N, T;
int A[100001];
int seg[MAX * 2];

void update(int index, int val) {
	int i = MAX + index;
	while (i > 0) {
		seg[i] = min(seg[i], val);
		i /= 2;
	}
}
// [0, t)
int range_min(int t) {
	int ret = INF;
	int offset = MAX;
	while (t != 0) {
		if (t & 1) {
			ret = min(ret, seg[offset + t - 1]);
		}
		offset /= 2;
		t /= 2;
	}
	return ret;
}

void init() {
	REP(i, 0, MAX * 2) {
		seg[i] = INF;
	}
	REP(i, 0, N) {
		update(i, A[i]);
	}
}

int main() {
	cin >> N >> T;
	REP(i, 0, N) {
		cin >> A[i];
	}
	init();

	int max_diff = 0;
	int max_cnt = 0;
	REP(i, 1, N) {
		int rmin = range_min(i);
		if (max_diff < A[i] - rmin) {
			max_diff = A[i] - rmin;
			max_cnt = 1;
		} else if (max_diff == A[i] - rmin) {
			++max_cnt;
		}
	}
	cout << max_cnt << endl;

	return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>

int x[100];

int main(){
  int i,j;
  int n;
  int cnt = 0;
  int flag;
  int tempo;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&x[i]);
}

    flag = 1;
    while(flag){
      flag = 0;
      for(j=n-1;j>0;j--){
        if(x[j] < x[j-1]){
          tempo = x[j];
          x[j] = x[j-1];
          x[j-1] = tempo;
          cnt++;
          flag = 1;
        }
      }
    }

      for(i=0;i<n;i++){
        printf("%d",x[i]);
        if(i<n-1){
          printf(" ");
        }
      }

          printf("\n%d\n",cnt);
        return 0;
      }


Measured memory_bytes: 2084
#include<bits/stdc++.h>
using namespace std;
int h,w,a,b;
void a1(int a){
	for(int i=1;i<=a;i++)
		cout<<1;
	for(int i=a+1;i<=w;i++)
		cout<<0;
	cout<<endl;
}
void a2(int a){
	for(int i=1;i<=a;i++)
		cout<<0;
	for(int i=a+1;i<=w;i++)
		cout<<1;
	cout<<endl;
}
int main(){
	while(cin>>h>>w>>a>>b){
		for(int i=1;i<=b;i++){
			a1(a);
		}
		for(int i=b+1;i<=h;i++){
			a2(a);
		}
	}
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
const int INT_INF = 1001001001;
//stoi(s) : string→int stoll(s) :string→longlong  int→string to_string(i)
const double PI = acos(-1.0);
//小数点の表し方 cout << fixed << setprecision(5);

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}

ll mypow(ll a,ll b){
    ll p = 1;
    for(ll i=0;i<b;i++){
        p *= a;
    }
    return p;
}
ll number(ll a){
    ll cnt = 0;
    bool ok = true;
    ll i=0;
    while((a/(10*mypow(5,i))) > 0){
        cnt += a / (10*mypow(5,i));
        i++;
    }
    return cnt;
}

int main(){
    ll n;
    cin >> n;
    if(n%2==1){
        cout << 0 << endl;
        return 0;
    }

    cout << number(n) << endl;

}

Measured memory_bytes: 256
module Main where

import Data.Functor
import Data.List

main :: IO ()
main = do
  { [w,h,x,y,r] <- getInts
  ; if x < r then putStrLn "No"
    else if y < r then putStrLn "No"
      else if x + r > w then putStrLn "No"
        else if y + r > h then putStrLn "No"
             else putStrLn "Yes"
  }

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

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

	int a, b, c;
	a = 0; b = 0; c = 0;

	for (int i = 0; i < N; i++) {
		int P;
		cin >> P;
		if (P <= A) a++;
		else if (P <= B) b++;
		else c++;
	}

	cout << min(min(a, b), c) << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define rep(i,a,b) for(auto i=(a); i<(b); ++i)
#define REP(i,n) rep(i,0,n)
#define all(v) (v).begin(), (v).end()
#define rs resize
#define DBG(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl

const ld PI = acos(-1.0);
template<class T> using min_queue =
priority_queue<T, vector<T>, greater<T>>;
template<class T> int sz(const T &x) {
    return (int) x.size(); // copy the ampersand(&)!
}

template<class T> ostream& operator<<(ostream &os, vector<T> &v) {
    os << "\n[";
    for(T &x : v) os << x << ',';
    return os << "]\n";
}

struct pairhash {
    public:
    template<typename T1, typename T2>
    size_t operator()(const pair<T1, T2> &p) const {
        size_t lhs = hash<T1>()(p.x);
        size_t rhs = hash<T2>()(p.y);
        return lhs ^ (rhs+0x9e3779b9+(lhs<<6)+(lhs>>2));
    }
};

void run() {
	string s;
	cin >> s;
	if (s.length()%2 == 1) {
		cout << "No" << endl;
	} else {
		bool pos = true;
		for (ll i = 0; i < s.length(); i++) {
			if (i%2 == 0 && s[i] != 'h') {
				pos = false;
			}
			if (i%2 == 1 && s[i] != 'i') {
				pos = false;
			}
		}
		if (pos) {
			cout << "Yes" << endl;
		} else {
			cout << "No" << endl;
		}
	}
}

signed main() {
    // DON'T MIX "scanf" and "cin"!
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << setprecision(20);
    run();
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    int M = scanner.nextInt();
    for(int i = 0;i < M;i++){
      N = N - scanner.nextInt();
    }
    if(N < 0) N = -1;
    System.out.println(N);
  }
}

Measured memory_bytes: 37812
n,k = map(int,input().split())
li = [i for i in range(0,n+1)]
#print(li)
#[0,1, 2, 3]
tmp = 0
def exc(n):
    return (n)*(n+1)//2

for i in range(k,n+2):
    #print(i,li[n-i+1:],li[:i],sum(li[n-i+1:]) - sum(li[:i]))
    #tmp += sum(li[n-i+1:]) - sum(li[:i]) + 1
    mi = exc(i-1)
    ma = exc(n) - exc(n-i)
    #print(i,mi,ma,ma - mi + 1)
    tmp += ma - mi + 1
print(tmp%(10**9+7))

Measured memory_bytes: 80876
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <utility>
#include <vector>

using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define REP(i, n) for (size_t i = 0; i < (n); i++)
#define nvec(T, v, n) vector<T> v(n); REP(i, n) {cin>>(v)[i];}
#define npairs(T1, T2, v, n) vector<pair<T1, T2>> v(n); REP(i, n){cin>>v[i].first>>v[i].second;}
#define ntuples(T1, T2, T3, v, n) vector<tuple<T1, T2, T3>> v(n); REP(i, n){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);}
#define vec2d(T, v, m, n) vector<vector<T>> (v)(m, vector<T>(n))
#define nvec2d(T, v, m, n) vec2d(T, v, m, n); REP(j, m){REP(i, n) {cin>>(v[j])[i];}}

#define min_index(v) size_t( min_element(all(v)) - (v).begin() )
#define max_index(v) size_t( max_element(all(v)) - (v).begin() )
#define min_e(v) *min_element(ALL(v))
#define max_e(v) *max_element(ALL(v))

#define count_le(v, a) size_t( upper_bound(ALL(v), a) - (v).begin() )
#define count_lt(v, a) size_t( lower_bound(ALL(v), a) - (v).begin() )
#define count_ge(v, a) size_t( (v).end() - lower_bound(ALL(v), a) )
#define count_gt(v, a) size_t( (v).end() - upper_bound(ALL(v), a) )

#define order(neq_sl) [](const auto s, const auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}

#define acm accumulate
#define SUM(v) accumulate(ALL(v), 0l)
#define SORT(v) sort(ALL(v))

#define GCD(v) gcd(ALL(v), 0l)

/*template <typename T>
T gcd(T a, T b) {
    if (a > b) swap(a, b);
    if (a == 0) return b;
    return gcd(b%a, a);
}
template <typename InputItr, typename T>
T gcd(InputItr first, InputItr last, T init) {
    for (; first != last; ++first) init = gcd(init, *first);
    return init;
}*/

template <typename T>
using vec =vector<T>;

template <typename T>
using vvec =vector<vector<T>>;

int main(){
  int n;
  cin>>n;
  long long c=0;
  for (int m = 1; m <= n; m++) {
    long k=n/m;
    c+=m*k*(k+1)/2;
  }
  cout<<c;
}


/* きょむ〜 */




Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace  std;
int const N= 2*10e5+5;
long long arr[N];
int main() {
    long long a;
    cin>>a;
    int cn=1;
    string s;
    cin>>s;
    for(int i=1;i<s.size();i++)
    {
        if(s[i]!=s[i-1])
            cn++;

    }
    cout<<cn;

}


Measured memory_bytes: 512
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<stdio.h>
#define M  100000
using namespace std;
string str[1005];
int cmp(string a,string b)
{
    return a.compare(b)<0;
}
int main()
{
    int n,len;

    while(~scanf("%d %d",&n,&len))
    {    string s = "";
        for (int i=0; i<n; i++)
            cin>>str[i];
        sort(str, str+n, cmp);
        for(int i = 0; i<n; i++)
            s+=str[i];
        cout<<s<<endl;

    }

}


Measured memory_bytes: 384
n,a,b = gets.split.map(&:to_i)
c = b-a
d= n-a 
e= b-1
if c.even?
  puts c/2
elsif  e < d && e < a+(c-1)/2 
  puts e
elsif e < d
  puts a+(c-1)/2 
elsif d < e && d < n-b+1 + (c-1)/2
  puts d
else 
  puts n-b+1 + (c-1)/2
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define int long long
signed main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(abs(b-c)%2){
		cout<<min((b+c)/2,(a*2-b-c+2)/2	)<<endl;
	}
	else cout<<abs(b-c)/2<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>
#include <climits>
#include <map>
#include <numeric>
#include <functional>
#include <utility>

using namespace std;

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

int main(void) {
  ll a, b, c, k;
  cin >> a >> b >> c >> k;

  ll sum = 0;
  if (k <= a) {
    sum = k;
  }
  else if (k <= a + b) {
    sum = a;
  }
  else {
    sum = a - (k - (a + b));
  }
  cout << sum << endl;
  return 0;
}


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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);

int main() {
    ios_base::sync_with_stdio(false);
    string s; cin >> s;
    int bank = 0, ans = 0;

    for(int i = 0; i < s.size(); i++) {
        if(s[i] == 'g') {
            if(bank) ans++, bank--;
            else bank++;
        }
        if(s[i] == 'p') {
            if(bank) bank--;
            else ans--, bank++;
        }
    }

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


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
    ios::sync_with_stdio(false);
    if (fopen("input.in", "r")) {
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n * a, b) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#define endl '\n'
#define EM emplace
#define EM_back emplace_back
#define int long long
#define X first
#define Y second
#define sz(x) ((int)x.size())
#define CLR(x,y) memset(x,y,sizeof(x))
#define lson (root<<1)
#define rson (lson+1)
using namespace std;
typedef pair<int,int> pii;
int h[100020];
int dp[100020];
signed main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>h[i];
	for(int i=1;i<=n;i++)dp[i]=INT_MAX;
	dp[1]=0;
	for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=k;j++)
        {
            if(i-j<=0)break;
            dp[i]=min(dp[i],dp[i-j]+abs(h[i-j]-h[i]));
        }
    }
    cout<<dp[n]<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int solve(vector<vector<bool> >& ice, int y0, int x0)
{
    int dy[] = {0, 0, 1, -1};
    int dx[] = {1, -1, 0, 0};

    ice[y0][x0] = false;
    int ret = 1;
    for(int i=0; i<4; ++i){
        int y = y0 + dy[i];
        int x = x0 + dx[i];
        if(ice[y][x])
            ret = max(ret, 1 + solve(ice, y, x));
    }

    ice[y0][x0] = true;
    return ret;
}

int main()
{
    for(;;){
        int m, n;
        cin >> m >> n;
        if(m == 0)
            return 0;

        vector<vector<bool> > ice(n+2, vector<bool>(m+2, false));
        for(int i=1; i<=n; ++i){
            for(int j=1; j<=m; ++j){
                int a;
                cin >> a;
                ice[i][j] = (a == 1);
            }
        }

        int ret = 0;
        for(int i=1; i<=n; ++i){
            for(int j=1; j<=m; ++j){
                if(ice[i][j])
                    ret = max(ret, solve(ice, i, j));
            }
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 0
import java.util.*

class Scanner(`in`: java.io.InputStream) {
    private val reader = java.io.BufferedReader(java.io.InputStreamReader(`in`))
    private var tokenizer: StringTokenizer? = null

    fun next(): String {
        if (tokenizer?.hasMoreTokens() != true) {
            tokenizer = StringTokenizer(reader.readLine())
        }
        return tokenizer!!.nextToken()
    }

    fun nextLine(): String {
        return if (tokenizer?.hasMoreTokens() != true) {
            reader.readLine()
        } else tokenizer!!.nextToken("\n")
    }
}

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

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

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

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val K = sc.next().toInt()
        val S = sc.next().toCharArray()

        var ans = 0
        var n = 0
        for (i in 1 until N) {
            if (S[i] != S[i - 1]) {
                n++
            } else {
                ans++
            }
        }

        var k = K
        while (n > 1 && k > 0) {
            ans += 2
            n -= 2
            k--
        }

        if (k > 0 && n == 1) {
            ans++
        }

        pw.println(ans)
    }
}


Measured memory_bytes: 32188
import fractions

a, b, c, d = map(int, input().split())

# 最小公倍数を求める
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

def cal(num, a, b):
    x = num // a
    y = num // b
    z = num // (lcm(a, b))
    return num - (x + y - z)

num_a = cal(b, c, d)
num_b = cal(a-1, c, d)

print(num_a - num_b)


Measured memory_bytes: 5204
#include <iostream>

int main() {
    int a, b;
    std::cin >> a >> b;
    
    char c = '0' + std::min(a, b);
    int count = std::max(a, b);
    
    for (int _ = 0; _ < count; _++) {
        std::cout << c;
    }
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main() {
    ll a, b, x;
    cin >> a >> b >> x;
    cout << (a > 0 ? b / x - (a - 1) / x : b / x + 1) << endl;
}

Measured memory_bytes: 256
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int inf=1e9;
const ll INF=1e18;
const double pi=3.1415926535897932384626433832;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c,x;
  cin >> a >> b >> c;
  x=max({a,b,c});
  cout << ((3*x-a-b-c)%2?(3*x+3-a-b-c)/2:(3*x-a-b-c)/2) << endl;
}

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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout << i << endl
using namespace std;
int main(){
  int num[4];
  string ans = "NA";

  REP(i, 4){
      char t;
      cin >> t;
      num[i] = t - '0';
    }

  int a = num[0] * 10 + num[1];
  int b = num[2] * 10 + num[3];
    if(a == 0 && b == 0){
        cout << ans << endl;
        return 0;
      }
      else if(a == 0){if(b <= 12) ans = "YYMM";} 
      else if(b == 0) {if(a <= 12) ans = "MMYY";}
      else if(a <= 12 && b <= 12) ans = "AMBIGUOUS";
       else if(a <= 12){
         ans = "MMYY";
        }else if(b <= 12){
            ans = "YYMM"; 
          }
          cout << ans << endl;
          return 0;
}


Measured memory_bytes: 256
import java.util.*;


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

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int count = 9;
        int ranges[][] = {
            {400, 599},
            {600, 799},
            {800, 999},
            {1000, 1199},
            {1200, 1399},
            {1400, 1599},
            {1600, 1799},
            {1800, 1999}
        };
        for(int range[] : ranges) {
            count--;
            if(range[0] <= n && n <= range[1]) {
                System.out.println(count);
            }
        }
    }
}

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

#define all(x)        (x).begin(),(x).end()
#define eb            emplace_back
#define mp            make_pair
#define pb            push_back
#define fi            first
#define se            second
#define sz(x)         ((int)(x).size())
#define rep(x,y,z)    for(int x=y;x<z;x++)
#define per(x,z,y)    for(int x=z-1;x>=y;x--)
#define trav(y,x)     for(auto& y:x)
#define pii           pair<int, int>
#define pll           pair<ll, ll>
#define vi            vector<int>
#define vpi           vector<pii>

int dbg = 0;
#define cri           if(0)
#define shame         cri cerr<<(++dbg)<<"\n\n";

// aaaaaaaaaaaaaaaa
const int N = 2e5 + 1;
const int lg = 20;
const ll mod = 0xfffff;

void solve() {
  int a, b, c;
  scanf("%d%d%d", &b, &c, &a);
  printf("%d %d %d\n", a, b, c);
}

int main() {
  // int _; scanf("%d", &_) while (_--)
  solve();
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define SF scanf
#define PF printf
#define MAXN 2010
#define MOD 998244353
using namespace std;
typedef long long ll;
ll C[2*MAXN][2*MAXN],bits[2*MAXN];
int n,k;
ll count(int s,int tot){
    return C[s+tot-1][s-1]; 
}
ll solve(int i,int tot){
    //int k2=min(k-i/2,(i-1)/2);
	ll k2=(i-1<=k)?(i-1):(2*k-i+1);
	k2=floor( (double)k2/2 );
    
    int k1=k-k2*2-((i%2)==0);
    ll flag=1;
    ll res=0;
    for(int l=k2;l>=0;l--)
	{
        res+=count(l+k1,tot-l)*bits[l]%MOD*C[k2][l]%MOD;
        res%=MOD;
    }
    return (res+MOD)%MOD;
}
int main()
{
    SF("%d%d",&k,&n);
    int sum=0;
    bits[0]=1;
    for(int i=1;i<=4000;i++)
        bits[i]=bits[i-1]*2ll%MOD;
    C[0][0]=1;
    for(int i=1;i<=4000;i++){
        C[i][0]=1;
        for(int j=1;j<=i;j++)
            C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;
    }
    ll ans=0;
    for(int i=2;i<=2*k;i++){
        if(i%2==0){
            ans=(solve(i,n)+solve(i,n-1))%MOD;
        }
        else{
            ans=solve(i,n);
        }
        PF("%lld\n",ans);
    }
}

Measured memory_bytes: 124160
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map>
#include <map>
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
using namespace std;

int main(){
	char c1[3];
	char c2[3];
	
	cin >> c1;
	cin >> c2;

	if (c1[0] == c2[2] && c1[1] == c2[1] && c1[2] == c2[0]) {
		cout << "YES";
	} else {
		cout << "NO";
	}

	return 0;
}

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

using namespace std;

int min(int a, int b)
{
	return a > b ? b : a;
}

int main()
{
	int n, v[102], t[102], v1[102];
	cin >> n;
	for (int i = 0; i < 102; ++i)
	{
		v[i] = 0;
		t[i] = 0;
		v1[i] = 0;
	}
	for (int i = 1; i <= n; ++i)
	{
		int a;
		cin >> a;
		t[i] = a;
	}
	for (int i = 1; i <= n; ++i)
	{
		int a;
		cin >> a;
		v[i] = a;
	}
	for (int i = n; i > 0; --i)
	{
		v1[i] = min(v[i], v1[i + 1] + t[i]);
	}
	int vel = 0;
	double dist = 0;
	for (int i = 1; i <= n; ++i)
	{
		for (int j = t[i]; j > 0; --j)
		{
			if (vel < v[i])
			{
				if (vel < v1[i + 1])
				{
					dist += vel + 0.5;
					vel++;
				}
				else
				{
					if (j > vel - v1[i + 1] + 1)
					{
						dist += vel + 0.5;
						vel++;
					}
					else
					{
						if (j > vel - v1[i + 1])
						{
							dist += vel + 0.25;
						}
						else
						{
							dist += vel - 0.5;
							vel--;
						}
					}
				}
			}
			else
			{
				if (vel < v1[i + 1])
				{
					dist += vel;
				}
				else
				{
					if (j > vel - v1[i + 1])
					{
						dist += vel;
					}
					else
					{
						dist += vel - 0.5;
						vel--;
					}
				}
			}
		}
	}
	cout << fixed;
	cout << dist;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
int f,p;
string s;
map<char,int>m;
int bns1();
int g_A(){
  int r=0;
  if(s[p]=='('){
    p++;
    r=bns1();
    p++;
  }
  else{
    while(isdigit(s[p])){
      r=r*10+(s[p]-'0');
      p++;
    }
  }
  return r;
}
int bns3(){
  int res=g_A();
  while(m[s[p]]==3){
    int t=p++;
    if(s[t]=='+')res+=g_A();
    if(s[t]=='-')res-=g_A();
    if(s[t]=='*')res*=g_A();
  }
  return res;
}
int bns2(){
  int res=bns3();
  while(m[s[p]]==2){
    int t=p++;
    if(s[t]=='+')res+=bns3();
    if(s[t]=='-')res-=bns3();
    if(s[t]=='*')res*=bns3();
  }
  return res;
}
int bns1(){
  int res=bns2();
  while(m[s[p]]==1){
    int t=p++;
    if(s[t]=='+')res+=bns2();
    if(s[t]=='-')res-=bns2();
    if(s[t]=='*')res*=bns2();
  }
  return res;
}
int dfs(){
  int res=LLONG_MIN;
  r(i,3)r(j,3)r(k,3){
    m['+']=i+1;
    m['-']=j+1;
    m['*']=k+1;
    p=0;
    res=max(res,bns1());
  }
  return res;
}
main(){
  cin>>s;s[(int)s.size()]='(';
  cout<<dfs()<<endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll n;
ll a[110];
vector<ll> res;

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

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

  while(n>0){
    ll idx=-1;
    rep(i,n){
      if(i+1==a[i])idx=i;
    }
    if(idx==-1){
      cout<<-1<<endl;
      return 0;
    }
    res.push_back(idx+1);
    repl(j,idx,n){
      a[j]=a[j+1]; 
    }
    n--;
  }
  reverse(all(res));

  rep(i,res.size())cout<<res[i]<<endl;

  return 0;
}


Measured memory_bytes: 256
from heapq import *
import sys
from collections import *
from itertools import *
from decimal import *
import copy
from bisect import *
import math
sys.setrecursionlimit(4100000)
def gcd(a,b):
    if(a%b==0):return(b)
    return (gcd(b,a%b))
input=lambda :sys.stdin.readline().rstrip()

H,W,K=map(int,input().split())
C=[list(input()) for i in range(H)]



lst=list(product(range(2),repeat=H+W))
nlst=set()
a=0
for l in lst:
    _C=copy.deepcopy(C)
    for h in range(H):
        if l[h]:
            for w in range(W):
                _C[h][w]="R"
    for w in range(W):
        if l[H+w]:
            for h in range(H):
                _C[h][w]="R"
    #print(_C,C)
    if sum([_C[h].count("#") for h in range(H)])==K:
    #    print(_C)
        s=""
        for h in range(H):
            s+="".join(_C[h])
        if not s in nlst:
            a+=1
            nlst.add(s)
print(a)


Measured memory_bytes: 79240
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
typedef long long int llint;
#define  pub push_back
#define mp make_pair
const llint big=9999999;
int main(void){
	llint i,j,k,N,W,wit,w,q,ans=0;
	vector<pair<llint,llint>> mono;//omo,価値
	vector<vector<llint>> dp;//Nの数,追加重さ
	vector<vector<llint>>ddp;
	dp.resize(111);
	ddp.resize(111);
	for(i=0;i<111;i++){
		dp[i].resize(305);
		ddp[i].resize(305);
	}
	scanf("%lld %lld",&N,&W);
	for(i=0;i<N;i++){
		scanf("%lld %lld",&q,&w);
		mono.pub(mp(q,w));
	}
	wit=mono[0].first;
	for(i=0;i<N;i++){
		for(j=0;j<=N;j++){
			for(k=0;k<305;k++){
				if(j-1>=0&&k-(mono[i].first-wit)>=0){ 
					ddp[j][k]=max(dp[j][k],dp[j-1][k-(mono[i].first-wit)]+mono[i].second); 
				} else{
					ddp[j][k]=dp[j][k];
				}
			}
		}
		swap(dp,ddp);
	}
	for(i=0;i<=N;i++){
		for(j=0;j<305;j++){
			if(wit*i+j<=W){
				ans=max(ans,dp[i][j]);
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> X(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i];
  }
  int res = 1 << 28;
  for (int i = 0; i <= 100; i++) {
    int s = 0;
    for (int x : X) {
      s += (x - i) * (x - i);
    }
    res = min(res, s);
  }
  cout << res << '\n';
  return 0;
}


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


#define MAX 502
int n;
int x[MAX];

int ans[MAX*MAX];
vector<pair<int, int> > v[MAX*MAX];

vector<int> tmp;


bool q[MAX*MAX];

int cnt[MAX];

int main(){
	cin >> n;
	memset(ans, -1, sizeof(ans));
	vector<pair<int, int> > vv;

	for (int i = 0; i < n; i++){
		scanf("%d", &x[i]);
		ans[x[i]] = i + 1;
		q[x[i]] = true;
		vv.push_back(make_pair(x[i], i));
	}
	sort(vv.begin(), vv.end());
	for (int i = 0; i < vv.size(); i++){
		for (int j = 0; j < vv[i].second; j++){
			tmp.push_back(vv[i].second+1);
		}
	}
	reverse(tmp.begin(), tmp.end());
	for (int i = 1; i <= n*n; i++){
		if (ans[i] == -1){
			if (tmp.size()){
				ans[i] = tmp.back();
				tmp.pop_back();
			}
		}
	}
	if (tmp.size()){
		puts("No");
		return 0;
	}
	for (int i = 0; i < n; i++){
		v[x[i]].push_back(make_pair(i + 1, n - i - 1));
	}
	for (int i = 1; i <= n*n; i++){
		if (ans[i] == -1){
			if (tmp.size())ans[i] = tmp.back();
			if (tmp.size())tmp.pop_back();
		}
		if (v[i].size()){
			for (int j = 0; j < v[i][0].second; j++){
				tmp.push_back(v[i][0].first);
			}
			v[i].clear();
		}
	}
	if (tmp.size()){
		puts("No");
		return 0;
	}
	for (int i = 1; i <= n*n; i++){
		if (ans[i] == -1){
			puts("No");
			return 0;
		}
		cnt[ans[i]]++;
		if (q[i]){
			int num = ans[i];
			if (cnt[num] != num){
				puts("No");
				return 0;
			}
		}
	}
	puts("Yes");
	for (int i = 1; i <= n*n; i++){
		if (i > 1){
			printf(" ");
		}
		printf("%d", ans[i]);
	}
	puts("");
	return 0;
}

Measured memory_bytes: 8832
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define PI acos(-1)
int main(){
int a,b;
while(cin>>a>>b,a||b){
rep(i,a){
rep(j,b){
if((i+j)%2)cout<<".";
else cout<<"#";
}
cout<<endl;
}
cout<<endl;
}
}

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

using namespace std;

using ll = long long;

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

    int a, b, c, d;

    cin >> a >> b >> c >> d;
    cout << min(a, b) + min(c, d) << endl;

    return 0;
}


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

void solve(int N)
{
    for (int n = 1; n <= N; n++)
    {
        int res = 0;
        for (int x = 1; x < 100; x++)
        {
            for (int y = 1; y < 100; y++)
            {
                int t = n - (x * x + y * y + x * y);
                for (int z = 1; z * (x + y + z) <= t; z++)
                {
                    if (z * (x + y + z) == t)
                    {
                        res++;
                        break;
                    }
                }
            }
        }
        cout << res << endl;
    }
}

int main()
{
    int N;
    cin >> N;
    solve(N);
    return 0;
}


Measured memory_bytes: 3632
use input::*;
use std::cmp::*;
use std::io::*;
use std::num::*;
use std::str::*;

//#[rustfmt::skip]
mod input {
    use super::*;
    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }
    pub fn string() -> String {
        read()
    }
    pub fn int() -> i64 {
        read()
    }
    pub fn char() -> char {
        read::<String>().pop().unwrap()
    }
    pub fn vecchar() -> Vec<char> {
        string().chars().collect()
    }
    pub fn vecint(n: i64) -> Vec<i64> {
        let mut vec = Vec::new();
        for i in 0..n {
            vec.push(int())
        }
        vec
    }
}
fn main() {
    let (a, b) = (int(), int());
    if a < 0 && b > 0 {
        println!("Zero")
    } else if a > 0 {
        println!("Positive")
    } else {
        println!(
            "{}",
            if (b - a + 1) % 2 == 0 {
                "Positive"
            } else {
                "Negative"
            }
        )
    }
}


Measured memory_bytes: 4352
#include<stdio.h>
int main(void)
{
	int sum=0,i,j,n[4],a,b,temp;
	for(i=0;i<4;i++){
		scanf("%d",&n[i]);
	}
	for(i=0;i<3;i++){
		for(j=i+1;j<4;j++){
			if(n[i]<n[j]){
				temp=n[i];
				n[i]=n[j];
				n[j]=temp;
			}
		}
	}
	for(i=0;i<3;i++){
		sum+=n[i];
	}
	scanf("%d %d",&a,&b);
	if(a>=b)sum+=a;
	else sum+=b;
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 600
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
A,B,C,D=map(int,input().split())
print((B-(B//C)-(B//D)+(B//min(B+1,lcm(C, D))))-((A-1)-((A-1)//C)-((A-1)//D)+((A-1)//min(A,lcm(C, D)))))

Measured memory_bytes: 5048
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <algorithm>
using namespace std;

int main(void){
    long long N;
    string S;
    cin >> N >> S;
    long long b = 0;
    long long w = 0;
    for(long long i=0; i<N; i++){
        if(S[i] == '#'){
            b++;
        }else{
            w++;
        }
    }
    long long BL = 0;
    long long WR = w;
    long long ans = w;
    for(long long i=0; i<N; i++){
        if(S[i] == '#'){
            BL++;
        }else{
            WR--;
        }
        ans = min(ans,BL + WR);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
N = int(input())
rangeList = [[0, 1], [-1, -2]]
for i in range(30): 
    a = (-2) ** (i+2)
    rangeList.append([a+rangeList[i+1][1], a+rangeList[i][1]])

maxPower = 0
for i in range(len(rangeList)):
    if min(rangeList[i]) <= N <= max(rangeList[i]):
        maxPower = i
        break
    
S = ""
sum = 0
for i in range(maxPower+1):
    mod = N % (2 ** (i+1))
    if mod - sum == 2 ** i:
        S = "1" + S
        sum += (-2) ** i
    else:
        S = "0" + S

print(int(S))

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iomanip>
#define MOD1 1000000007
#define MOD2 998244353
#define LIMIT1 200002
#define LIMIT2 500002
typedef long long ll;
typedef long double ld;
typedef const void cv;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define per(i,n) for((i)=(n)-1;(i)>=0;(i)--)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
#define zt(a,b) (max((a),(b))-min((a),(b)))
#define setpre(n) fixed << setprecision(n)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
#define sankaku(x) (((x)*((x)+1))/2)
int dx[8]={1,0,-1,0,1,-1,-1,1},dy[8]={0,1,0,-1,1,1,-1,-1};
int upint(cv *a, cv *b) { return *(int *)a < *(int *)b ? -1 : *(int *)a > *(int *)b ? 1 : 0; }
int downint(cv *a, cv *b) { return *(int *)a < *(int *)b ? 1 : *(int *)a > *(int *)b ? -1 : 0; }
int upchar(cv *left, cv *right) {return strcmp((char *)left,(char *)right);}
int downchar(cv *left, cv *right) {return strcmp((char *)right,(char *)left);}
void tmpInit(int *c,ll m) {ll i;rep(i,m) c[i]=i;}
ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= a; if(mod>=1) res %= mod;
    }
    a *= a; if(mod>=1) a %= mod;
    n >>= 1;
  }
  return res;
}
void initialize(){
  
}
int main(void){
  initialize();
  ll n,m,i,j,k,result=0,sum=0;
  ll p[LIMIT2]={0},c[LIMIT1]={0};
  ll dp[5010][2]={0};
  string s;
  
  cin >> n >> k;
  rep(i,n){
    cin >> p[i];//1-indexed to 0-indexed
    p[i]--;
  }
  rep(i,n){
    cin >> c[i];
  }
  rep(i,n){
    ll x=i,cnt=0,score=0;
    sum=0;
    int visited[5010]={0};
    while(visited[x]==0){
      visited[x] = 1;
      x = p[x];
      sum += c[x];
      cnt++;
    }
    x=i;
    for(j=1;j<=min(cnt,k);j++){
      x = p[x];
      score += c[x];
      m = (sum>0 ? ((k-j)/cnt)*sum : 0);
      if(score+m > dp[i][0] || j==1){
        dp[i][0] = score+m;
        dp[i][1] = j+(k-j)/cnt*n;
      }
    }
  }
  result = dp[0][0];
  m = dp[0][1];
  for(i=0;i<n;i++){
    //cout << dp[i][0] << " " << dp[i][1] << endl;
    if(result<dp[i][0]){
      result = dp[i][0];
      m = dp[i][1];
    }
  }
  cout << result << endl;
  
  return 0;
}

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;int d,n,q,i,p,a[1<<18];long long ret;main(){while(cin>>d>>n>>q){for(i=1;i<n;i++)cin>>a[i],a[i+n]=a[i]+d;a[n]=d;sort(a,a+2*n);long long ret=0;while(q--)cin>>i,p=lower_bound(a,a+n,i)-a,ret+=min(a[p]-i,i-a[p+n-1]+d);cout<<ret<<endl;}}

Measured memory_bytes: 3932
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};

int main(void){
    double L;
    cin >> L;
    L/=3;
    cout << pow(L,3) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int N; string S;
  cin >> N >> S;
  string ans = "";
  rep(i, S.size()){
    char T = 'A' + ((S[i] - 'A' + N) % 26);
    ans.push_back(T);
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#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 RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a, b, c;
  cin >> a >> b >> c;
  cout << ((c-a-b>0 && (c-a-b)*(c-a-b)-4*a*b>0 ? "Yes" : "No")) << "\n";
  return 0;
}


Measured memory_bytes: 3672
N = int(input())
s = []
t = []
p = []
ans = 0
for i in range(0,N):
	s.append(input())
M = int(input())
for i in range(0,M):
	t.append(input())
for i in range(0,N):
	p.append(0)
	for j in range(0,N):
		if s[i] == s[j]:
			p[i] += 1
	for k in range(0,M):
		if s[i] == t[k]:
			p[i] -= 1
	if ans < p[i]:
		ans = p[i]
print(ans)

Measured memory_bytes: 3064
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int N, M;
	
	cin >> N >> M;

	ll INF = 1ll << 50;

	int a[2010], b[2010];
	ll c[2010];
	ll d[1010];

	for (int i = 0; i < M; i++)
	{
		cin >> a[i] >> b[i] >> c[i];
		a[i]--;
		b[i]--;
		c[i] = -c[i];
	}
	
	for (int i = 0; i < N; i++)
	{
		d[i] = INF;
	}

	d[0] = 0;

	for (int i = 0; i < N - 1; i++)
	{
		for (int j = 0; j < M; j++)
		{
			if (d[a[j]] != INF && (d[b[j]] > d[a[j]] + c[j]))
			{
				d[b[j]] = d[a[j]] + c[j];
			}
		}
	}

	ll ans = -d[N-1];

	bool neg[N];

	rep(i, N)
	{
		neg[i] = false;
	}

	rep(i, N)
	{
		for(int j = 0; j < M; j++)
		{
			if (d[a[j]] != INF && (d[b[j]] > d[a[j]] + c[j]))
			{
				d[b[j]] = d[a[j]] + c[j];
				neg[b[j]] = true;
			}

			if (neg[a[j]] == true)
			{
				neg[b[j]] = true;
			}
		}
	}

	if (neg[N-1])
	{
		cout << "inf" << endl;
	}
	else
	{
		cout << ans << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
int dp[3010][3010];

signed main(){
	int n, t; cin >> n >> t;
	vector<P> data(n);
	for(int i = 0; i < n; i++) scanf("%d%d", &data[i].first, &data[i].second);
	sort(data.begin(), data.end());
	for(int i = 0; i < n; i++){
		for(int j = 0; j <= t - 1; j++){
			dp[i + 1][j] = dp[i][j];
			if(j - data[i].first >= 0) dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - data[i].first] + data[i].second);
		}
	}
	int ans = 0;
	for(int i = 0; i < n; i++) ans = max(ans, dp[i][t - 1] + data[i].second);
	cout << ans << endl;
}


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

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

int is_prime(int a){
    int sqrt_input = sqrt(float(a));

    for(int i = 2; i <= sqrt_input; i++){
        if(a % i == 0){
            return 0;
        }
    }
    return 1;

    
}
int main(){
    int n; cin >> n;
    int ans = 0;

    rep(i, n){
        int a; cin >> a;
        ans += is_prime(a);
    }
    cout << ans << endl;

}



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

void _139() {
    string s, t;
    cin >> s;
    cin >> t;

    int count = 0;
    for (int i = 0; i < 3; ++i) {
        if (s[i] == t[i])
            count++;
    }
    cout << count << endl;
}

void _138() {
    int a;
    string s;
    cin >> a;
    cin >> s;

    if (a >= 3200)
        cout << s << endl;
    else
        cout << "red" << endl;
}

void _137() {
    int a, b;
    cin >> a >> b;

    int add = a + b;
    int mult = a * b;
    int sub = a - b;

    cout << max(add, max(mult, sub)) << endl;
}

void _136() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(0, c - (a - b)) << endl;
}

void _135() {
    long long a, b;
    cin >> a >> b;

    if (abs(a - b) % 2 != 0)
        cout << "IMPOSSIBLE" << endl;
    else
        cout << (a + b) / 2 << endl;
}

void _134() {
    int r;
    cin >> r;
    cout << 3 * r * r << endl;
}

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

void _132() {
    string s;
    cin >> s;

    char    c[2];
    memset(c, 0, sizeof(c));
    int count[2];
    memset(count, 0, sizeof(count));
    c[0] = s[0];
    count[0] = 1;
    for (int i = 1; i < 4; ++i) {
        if (s[i] == c[0])
            count[0]++;
        else {
            if (c[1] == 0) {
                c[1] = s[i];
                count[1] = 1;
            }
            else {
                if (s[i] == c[1]){
                    count[1]++;
                }
                else {
                    cout << "No" << endl;
                    return;
                }
            }
        }
    }

    if (count[0] == 2 && count[1] == 2)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

void _131() {
    string s;
    cin >> s;

    char prev = s[0];
    for (int i = 1; i < 4; ++i) {
        if (s[i] == prev) {
            cout << "Bad" << endl;
            return;
        }
        else 
            prev = s[i];
    }
    cout << "Good" << endl;
}

void _130() {

}

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



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

int n,k,m,r;

int main(){
    scanf("%d %d",&n,&k);
    for(int i=0;i<n;i++)
        scanf("%d",&m),r+=min(m*2,(k-m)*2);
    printf("%d",r);
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
inline int read(){
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
int k,x;
int main(){
	k=read(),x=read();
	for(int i=x-k+1;i<=x+k-1;i++){
		cout<<i<<" ";
	}
	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    H, W = map(int, input().split())
    a = [input().strip() for i in range(H)]

    print("#"*(W+2))
    for i in range(H):
        print("#" + a[i] + "#")
    print("#"*(W+2))

if __name__ == "__main__":
    main()

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

using namespace std;

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;

	int cnt = 0;

	for (int i = 0; i < n - 2; i++) {
		if (s[i] == 'A'&&s[i + 1] == 'B'&&s[i + 2] == 'C') {
			cnt++;
		}
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 256