akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define REPP(i, n) for (int i = 1; (i) < (int)(n+1); ++ (i))
#define REPR(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i=(m)-1; i>=(n); i--)
#define ALL(v) v.begin(), v.end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define SORTR(c) sort((c).begin(),(c).end(),greater<int>());
#define BIT(n) (1LL<<(n))
#define PCNT(x) __builtin_popcountll(x)
#define GCD(x,y) __gcd(x,y)
#define LCM(x,y) x/__gcd(x,y)*y
#define PB push_back
#define MP make_pair
#define endl "\n"
#define pa cout << ans << endl
#define p(x) cout << x << endl
#define pall(x) for(auto iter : x) p(iter)
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define yn(x) cout << (x ? "Yes" : "No") << endl
using namespace std;
using Graph = vector<vector<int> >;
using WeightedGraph = vector<vector<pair<int, int> > >;
typedef long double LD;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
const int INF = 2000000000;
const long double PI = acosl(-1);
const int MOD = 1000000007;
void print() {cout << endl;}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " ";print(forward<Tail>(tail)...);}
template <class T> void print(vector<T> &vec) {for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " ";} cout << endl;}
template <class T> void print(vector<vector<T>> &df) { for (auto& vec : df) { print(vec);}}


signed main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int ans = 0;
    
    int X, N;
    cin >> X >> N;

    if (N == 0) {
        p(X);
        return 0;
    }
    vector<int> P(N);
    REP (i, N) {
        cin >> P[i];
    }

    SORT(P);

    int i = 0;
    while (1) {
        if (!binary_search(ALL(P),X-i)) {
            p(X-i);
            return 0;
        }
        if (!binary_search(ALL(P),X+i)) {
            p(X+i);
            return 0;
        }
        
        i++;
    }


    
    
    
    return 0;
}

/*
cd ~/Desktop/Programming/AtCoder/contest/abc170/abc170_c && sh shellscripts/test_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc170/abc170_c && sh shellscripts/etest_cpp.sh
cd ~/Desktop/Programming/AtCoder/contest/abc170/abc170_c && sh shellscripts/submit_cpp.sh
*/


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
    int x, y;
    cin >> x >> y;
    string ans = "No";
    // x animals, y legs
    for (int i = 0; i < x + 1; i++) {
        int remaining = x - i;
        if ((2 * i) + (4 * remaining) == y) {
            ans = "Yes";
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
typedef vector<string> vstr;
typedef pair<ll, ll> pll;
typedef vector<pll> vp;
typedef map<ll, ll> mll;
typedef map<string, ll> mstrll;
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
#define out(x) cout << (x)
#define indent() cout << '\n'
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
ll gcd(ll a, ll b){return b != 0 ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}
ll factorial(ll a){return a < 2 ? 1 : factorial(a - 1) * a;}
ll summation(ll a){return a < 1 ? 0 : (a * a + a) / 2;}
const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ll N = 300005;
const string ALPHABETS = "abcdefghijklmnopqrstuvwxyz";
ll dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
//ll dx[] = {-1, 0, 1, -1, 1, -1, 0, 1}, dy[] = {-1, -1, -1, 0, 0, 1, 1, 1};
ll n, m, x, y, z, w, h;
string s, t;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> n >> m >> x){
        ll ans = 0, tmp = 0, cnt = 0, mx = -INF, mn = INF;
        ll a[N] = {}, b[N] = {}, c[N] = {};
        vll v;
        rep(i, n){
            cin >> a[i];
        }
        sort(a, a + n);
        ll first = a[0];
        rep(i, n){
            if(a[i] - first > x){
                ans++, cnt = 1, first = a[i];
            }else{
                cnt++;
                if(cnt > m){
                    ans++, cnt = 1, first = a[i];
                }
            }
        }
        print(ans + 1);
    }
}


Measured memory_bytes: 2560
#include <cstdio>
#include <cstring>

using namespace std;

int n, m;
int fr[501][501];
int s[501];

void f(int from, int depth)
{
	s[from] = 1;
	if (depth == 3) return;
	for (int i = 1; i <= n; ++i) {
		if (fr[from][i]) f(i, depth + 1);
	}
}


int main()
{
	while (scanf("%d %d", &n, &m), n || m) {
		for (int i = 1; i <= n; ++i) memset(fr[i], 0, sizeof(fr[i]));
		memset(s, 0, sizeof(s));
		for (int i = 0; i < m; ++i) {
			int a, b; scanf("%d %d", &a, &b);
			fr[a][b] = fr[b][a] = 1;
		}
		f(1, 1);
		int cnt = 0;
		for (int i = 1; i <= n; ++i) if (s[i]) cnt++;
		printf("%d\n", cnt - 1);
	}
}

Measured memory_bytes: 2008
#include <iostream>

using i64 = long long;

const i64 MOD = 998244353;
const int N = 400 + 7;

i64 inv[N];
int n, p[N], c[N], sp;
i64 f[N][N], g[N], ans;

int main() {
//	freopen("code.in", "r", stdin);
//	freopen("code.out", "w", stdout);

	inv[1] = 1;
	for (int i = 2; i <= 400; ++i)
		inv[i] = -MOD / i * inv[MOD % i] % MOD;

	scanf("%d", &n);
	for (int i = 1; i <= n; ++i)
		scanf("%d%d", p + i, c + i), sp += p[i];
	c[0] = f[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		for (int v = g[0] = 1; v < c[i]; ++v)
			g[v] = g[v - 1] * p[i] % MOD * inv[sp] % MOD * inv[v] % MOD;
		for (int j = p[0]; ~j; --j)
			for (int u = 0; u < c[0]; ++u)
				for (int v = 0; v < c[i]; ++v)
					( f[j + p[i]][u + v] -= f[j][u] * g[v] ) %= MOD;
		p[0] += p[i], c[0] += c[i];
	}
	for (int i = 1; i <= p[0]; ++i) {
		g[0] = sp * inv[i] % MOD;
		for (int j = 1; j < c[0]; ++j)
			g[j] = g[j - 1] * j % MOD * sp % MOD * inv[i] % MOD;
		for (int j = 0; j < c[0]; ++j)
			( ans -= f[i][j] * g[j] ) %= MOD;
	}
	printf("%lld\n", (ans + MOD) % MOD);

	return 0;
}


Measured memory_bytes: 5040
#include<stdio.h>

void maxHeapify(int);
void buildMaxHeap(void);

int A[500000],n;

int main(){
  int i;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d",&A[i]);
  }
  buildMaxHeap();
  for(i=1;i<=n;i++){
    printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  return 0;
}

void buildMaxHeap(){
  int i;
  for(i=n/2;i>=1;i--)maxHeapify(i);
}


void maxHeapify(int i){
  int l,r,largest,p;
  l=2*i;
  r=2*i+1;

  if(l<=n && A[l]>A[i])largest=l;
  else largest=i;
  if(r<=n && A[r]>A[largest])largest=r;
  if(largest!=i){
    p=A[i];
    A[i]=A[largest];
    A[largest]=p;
    maxHeapify(largest);
  }
}



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

using i8   = int8_t;
using u8   = uint8_t;
using i16  = int16_t;
using u16  = uint16_t;
using i32  = int32_t;
using u32  = uint32_t;
using i64  = int64_t;
using u64  = uint64_t;
using i128 = __int128_t;
using u128 = __uint128_t;

using f32  = float;
using f64  = double;
using f80  = __float80;
using f128 = __float128;
// }}}

constexpr i64 INF = 1'010'000'000'000'000'000LL;

constexpr i64 MOD = 1'000'000'007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = 3.14159265358979323846;

// {{{ util
#define FOR(i, start, end) for(i64 i = (start); i < (end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f,c,...) (([&](decltype((c)) cc) { return (f)(begin(cc), end(cc), ## __VA_ARGS__); })(c))

template<typename T, typename U>
bool chmax(T& xmax, const U& x) {
    if(xmax < x) {
        xmax = x;
        return true;
    }
    else {
        return false;
    }
}

template<typename T, typename U>
bool chmin(T& xmin, const U& x) {
    if(x < xmin) {
        xmin = x;
        return true;
    }
    else {
        return false;
    }
}

template<typename T>
void RD(T& x) {
    cin >> x;
#ifdef PROCON_LOCAL
    assert(cin);
#endif
}

template<typename T>
void RD(vector<T>& v, int n) {
    v.reserve(n);
    REP(_, n) {
        T e; RD(e);
        v.emplace_back(e);
    }
}

template<typename T>
void PRINT(const T& x) {
    cout << x;
}

template<typename T>
void PRINT(const vector<T>& v) {
    for(auto first = begin(v), it = first; it != end(v); ++it) {
        if(it != first)
            cout << ' ';
        cout << *it;
    }
}

template<typename T>
void PRINTLN(const T& x) {
    PRINT(x);
    cout << '\n';
}

template<typename T>
void DBG_IMPL(i64 line, const char* expr, const T& value) {
#ifdef PROCON_LOCAL
    cerr << "[LINE " << line << "]: ";
    cerr << expr << " = " << value << "\n";
#endif
}

#define DBG(expr) DBG_IMPL(__LINE__, #expr, (expr))
// }}}

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

i64 A, B;

// f(0,x)
i64 g(i64 x) {
    i64 res = 0;
    REP(i, 41) {
        i64 d = 1LL<<(i+1);
        i64 q = x / d;
        i64 r = x % d;

        i64 k = q*(1LL<<i);
        if(r >= d/2) {
            k += r - d/2 + 1;
        }
        if(k & 1) {
            res |= 1LL<<i;
        }
    }
    return res;
}

void solve() {
    i64 ans;
    if(A == 0) {
        ans = g(B);
    }
    else {
        ans = g(A-1) ^ g(B);
    }

    PRINTLN(ans);
}

signed main() {
    RD(A);
    RD(B);

    solve();

    return 0;
}


Measured memory_bytes: 256
N, K= map(int,input().split())
H = list(map(int,input().split()))

SUP = 10 ** 6

dp = [SUP] * N
dp[0] = 0

#0 ~ K - 1
if N <= K:
  for i in range(0,min(N,K)):
    dp[i] = abs(H[i] - H[0])
  print(dp[-1])
  
else:
  #K ~ N
  for i in range(1,N):
    cov = max(0,i - K)
    dp[i] = min([abs(front - H[i]) + cost for front,cost in zip(H[cov:i],dp[cov:i])])
  print(dp[-1])

Measured memory_bytes: 14108
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	string str;
	int w;
	cin >> str >> w;
	for (int i = 0; i < str.length(); i++)
	{
		if (i%w) continue;
		putchar(str[i]);
	}
	puts("");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<math.h>
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

int main() {
  string s;
  cin>>s; 
  
  for(int i=s.size()-3; i>0;i-=2){
    bool a=true;
  for(int j=0; j<=i/2;j++){
    if(s.at(j)!=s.at(j+(i+1)/2)){
      a=false;
      break;
    }
  }
  if(a){
    cout<<i+1;
    break;
  }
  }
 
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

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

   int n, m;
   cin >> n >> m;
   vector<int> a(n);
   rep(i, 0, m) {
      int k;
      cin >> k;
      rep(j, 0, k) {
         int s;
         cin >> s;
         s--;
         a[s] |= 1 << i;
      }
   }
   int p = 0;
   rep(i, 0, m) {
      int pi;
      cin >> pi;
      p |= pi << i;
   }
   int ans = 0;
   rep(S, 0, 1 << n) {
      int t = 0;
      rep(i, 0, n) {
         if ((S >> i) & 1) {
            t ^= a[i];
         }
      }
      if (t == p) ans++;
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 3552
import numpy

n,d = map(int, input().split())
x = [[int(i) for i in input().split()] for i in range(n)] 
# n=3
# d=2
# x=[[1, 2], [5, 5], [-2, 8]]


cnt=0
for i in range(n):
    for j in range(n-i-1):
#         print(i,j+i+1)
        a = numpy.array(x[i])
        b = numpy.array(x[i+j+1])
        u = b - a
        if numpy.linalg.norm(u).is_integer():
            cnt+=1
print(cnt)

Measured memory_bytes: 12476
n = int(input())
max2 = 0
maxi = 1
for i in range(1, n+1):
  m = 0
  k = i
  while k % 2 == 0:
    m += 1
    k = k / 2
  if max2 < m:
    max2 = m
    maxi = i
print(maxi)

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

int main() {
    long n;
    cin >> n;
    if(n & 1) {
        cout << 0 << endl;
        return 0;
    }
    n /= 2;
    long r = 0;
    while(n)
        r += (n /= 5);
    cout << r << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())
#define maxIndex(v) max_element(v.begin(), v.end()) - v.begin()
#define maxElement(v) *max_element(v.begin(), v.end())
#define minIndex(v) min_element(v.begin(), v.end()) - v.begin()
#define minElement(v) *min_element(v.begin(), v.end())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define MOD 1000000007
using namespace std;

int main()
{
  ll N, M, sum = 0; cin >> N >> M;
  vector<pair<ll, ll>> X(N + M);
  rep(i, 0, N) {
  	ll A; cin >> A;
    X[i] = make_pair(A, 1);
  }
  rep(i, N, N + M) {
  	ll B, C; cin >> B >> C;
    X[i] = make_pair(C, B);
  }
  sort(X.begin(), X.end(), greater<pair<ll, ll>>());
  ll j = 0;
  rep(i, 0, N){
  	sum += X[j].first;
    X[j].second--;
    if (X[j].second <= 0) j++;
  }
  cout << sum << endl;
}

Measured memory_bytes: 3328
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int x = sc.nextInt();
		int[] a = new int[N];
		long ans = 0;
		for(int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
			if(a[i] > x) {
				ans += a[i] - x;
				a[i] = x;			
			}
		}
		for(int i = 0; i < N-1; i++) {
			if(a[i] + a[i+1] > x) {
				ans += a[i] + a[i+1] - x;
				a[i+1] = x - a[i];
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 49984
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <cstring>
using namespace std;
int a[1000];
int main(){
    int n;
    scanf("%d",&n);
    for (int i = 0; i < n; i++){
         scanf("%d",&a[i]);
    }
    sort(a,a + n);
    int s1 = 0,s2 = 0;
    int cnt = 0;
    for (int i = n - 1; i >= 0; i--){
        if (cnt % 2 == 0)
        {
            s1 += a[i]; 
        }else 
        s2 += a[i];
        cnt++;
    }
    printf("%d\n",s1 - s2);
}

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

#define FOR(i, a, b) for (int i = a; i < (int) b; i++)
#define F0R(i, a) FOR (i, 0, a)
#define ROF(i, a, b) for (int i = a; i >= b; i--)
#define R0F(i, a) for (int i = a; i >= 0; i--)
#define GO(i, a) for (auto i : a)

#define f first
#define s second
#define eb emplace_back
#define pb push_back
#define sz(x) (int) x.size()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vpii> vvpii;
typedef long long i64;
typedef vector<i64> vi64;
typedef pair<i64, i64> pi64;
typedef vector<pi64> vpi64;
typedef vector<vi64> vvi64;
typedef vector<vpi64> vvpi64;

const int dr[] = {+1, -1, +0, +0, +1, -1, +1, -1};
const int dc[] = {+0, +0, +1, -1, +1, -1, -1, +1};
const int ms[] = {+31, +29, +31, +30, +31, +30, +31, +31, +30, +31, +30, +31};
const int rm[] = {+1, +4, +5, +9, +10, +40, +50, +90, +100, +400, +500, +900, +1000};

int main () {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, mn = 1e9;
  cin >> n;
  int tot = 0;
  F0R (i, n) {
    int foo;
    cin >> foo;
    tot += (foo < mn);
    mn = min (mn, foo);
  }
  cout << tot << '\n';
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N,M;
    cin >> N >> M;
    vector<vector<char>> A(N,vector<char>(N)),B(M,vector<char>(M));
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++) cin >> A[i][j];
    }
    for(int i = 0; i < M; i++){
        for(int j = 0; j < M; j++) cin >> B[i][j];
    }
    bool f = true;
    for(int i = 0; i < N-M+1; i++){
        for(int j = 0; j < N-M+1; j++){
            f =true;
            for(int s = 0; s < M; s++){
                for(int t = 0; t < M; t++){
                    if(A[i+s][j+t] != B[s][t]){
                        f = false;
                        break;
                    }
                }
                if(f == false) break;
            }
            
            if(f == true){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<queue>
using namespace std;

int main()
{
	int n, q;

	cin >> n >> q;

	vector<priority_queue<int>> v(n);

	for (int i = 0; i < q; i++) {
		int command, t;
		cin >> command >> t;

		if (command == 0) {
			int x;
			cin >> x;

			v[t].push(x);
		}		
		else if (command == 1 && !v[t].empty()) {
			cout << v[t].top() << endl;
		}
		else if (command == 2 && !v[t].empty()) {
			v[t].pop();
		}
	}

	return 0;
}



Measured memory_bytes: 4052
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e18 + 9;

int dp[105][N];
 
signed main() {
	IOS;
	int n, w;
	cin >> n >> w;
	for(int i = 0; i <= n; i++)
		for(int j = 0; j < N; j++)
			dp[i][j] = inf;
	dp[0][0] = 0;
	for(int i = 1; i <= n; i++){
		int w1, v;
		cin >> w1 >> v;
		for(int j = N-1; j >= 0; j--){
			dp[i][j] = dp[i-1][j];
			if(j >= v)
				dp[i][j] = min(dp[i][j], dp[i-1][j-v] + w1);
		}
	}
	for(int j = N-1; j >= 0; j--)
		if(dp[n][j] <= w)
			return cout << j, 0;
	return 0;
}

Measured memory_bytes: 80128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s = new Scanner(System.in);
		String str = s.next();
		String str1 = s.next();
		String ans = "";
		ans = ans +"";
		int i = 0,j=0;

		// StringBuilder sb= new StringBuilder();
		for (i = 0; i < str.length() && j<str1.length(); i++) {
			char cc = str.charAt(i);
		
			char cf = str1.charAt(j);

			ans = ans + cc + cf;
			j++;
		}
		if (str.length() > str1.length()) {
			ans = ans + str.charAt(str.length()-1);
		}
		if (str.length() < str1.length()) {
			ans = ans + str1.charAt(str1.length()-1);
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 21844
S = input()
odd_ls = ['R', 'U', 'D']
even_ls = ['L', 'U', 'D']
result = True
for i in range(len(S)):
    if i % 2 == 0 and S[i] not in odd_ls:
        result = False
    elif i % 2 == 1 and S[i] not in even_ls:
        result = False
if result:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9124
s = gets.chomp
n = s.length
counter = 0
s.each_char.with_index do |c, i|
  if (i.even? and c=='0') or (i.odd? and c=='1')
    counter += 1
  end
end
if counter > n/2
  puts (n-counter).to_s
else
  puts counter.to_s
end
         

Measured memory_bytes: 1916
# 隣り合うブロックの組で色が異なるものがk(0,1,2,...,K)個とする。
# (左端の色) × (2~N番目のうち、どのk箇所を選ぶか) × (2~N番目の色)
# = M * N-1_C_k * (M-1)**(N-k-1)

from math import factorial
N, M, K = map(int, input().split())
p = 998244353

####################################################
# 逆元を用いた組み合わせの計算用


def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n - r] % p


fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用

for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
####################################################
ans = 0

for k in range(K + 1):
    tmp = M * cmb(N - 1, k, p) * pow(M - 1, N - k - 1, p)
    ans += tmp % p

ans = ans % p
print(ans)


Measured memory_bytes: 112012
#include "bits/stdc++.h"
using namespace std;
const int maxn = 300300;
int occ[maxn];
int main(){
    int n, k;
    cin >> n >> k;
    for(int e = 0; e < n; e++){
        int x; cin >> x;
        occ[x]++;
    }
    vector<int> goo;
    for(int e = 0; e < maxn; e++){
        if(occ[e]){
            goo.push_back(occ[e]);
        }
    }
    sort(goo.begin(), goo.end());
    int need = max(0, ((int)goo.size()) - k);
    int ans = 0;
    for(int e = 0; e < need; e++){
        ans += goo[e];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2168
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

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

int main(){
    int N;
    ll X;
    cin >> N >> X;
    int x[N];
    rep(i, N) cin >> x[i];
    rep(i, N){
        x[i] -= X;
        x[i] = fabs(x[i]);
    }
    ll g = x[0];
    rep(i, N){
        g = GCD(g, x[i]);
    }
    cout << g << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;

int main(){
  int n, m;cin>>n>>m;
  cout<<(n==m?"Yes":"No")<<endl;
  return 0;
}



Measured memory_bytes: 256
n, k = map(int,input().split( ))
a = list(map(int,input().split( )))

import collections
s_c=collections.Counter(a)


key, value=zip(*s_c.most_common())
value = list(value)
value.sort()
ans = 0
if len(key) - k >0:
	ans = sum(value[:(len(key)-k)])
print(ans)

Measured memory_bytes: 54428
///-----Bismillahir Rahmanir Rahim-----///

#include<bits/stdc++.h>
using namespace std;

///---FAST I/O---///
#define Boost() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

///---DATA TYPE---///
typedef long long ll;
typedef long long int lli;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<int>::iterator vit;
typedef set<int>::iterator sit;

///---LOOP---///
#define rep0(i,n) for(i=0;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)

///---I/O---///
#define sf scanf
#define pf printf

///---OTHERS---///
#define pb push_back
#define all(c)		c.begin(),c.end()
#define MK make_pair
#define F first
#define S second
#define endl '\n'


///---INITIALIZATION---//
#define mem(a,b) memset(a, b, sizeof(a) )

///---CALCULATE---///
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) ((a) * (a))

///---BIT OPERATION---///
inline bool checkBit(ll n, int i)
{
    return n&(1LL<<i);
}
inline ll setBit(ll n, int i)
{
    return n|(1LL<<i);;
}
inline ll resetBit(ll n, int i)
{
    return n&(~(1LL<<i));
}

///------String/Char Related Functions-----///
string makeintString(int x)
{
    stringstream ss;
    ss << x;
    string str = ss.str();
    ///cout<<str<<endl;
    return str;
}
string makellString(ll x)
{
    stringstream ss;
    ss << x;
    string str = ss.str();
    ///cout<<str<<endl;
    return str;
}
char cpp(char c)
{
    return static_cast<char>(c + 1);
}

///------------Sorting STL----------///
struct func
{
    //this is a sample overloading function for sorting stl
    bool operator()(pii const &a, pii const &b)
    {
        if(a.F==b.F)
            return (a.S<b.S);
        return (a.F<b.F);
    }
};

///---CONSTANT---///
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

int main()
{
    Boost();

    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        int n,ans=99999999;
        cin>>n;
        int a[n+5];
        for(int i=0; i<n; i++) cin>>a[i];

        for(int i=-100;i<=100;i++)
        {
            int cost=0;
            for(int j=0;j<n;j++)
            {
               cost+=(i-a[j])*(i-a[j]);
            }
            ans=min(ans,cost);
        }
         cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3640
s = input()
# s = 'serval'
# s = 'whbrjpjyhsrywlqjxdbrbaomnw'
# s = 'zzz'

cnt = float('inf')
for alpha in [chr(i + ord('a')) for i in range(26)]:
    if not alpha in s:
        continue
    ss = s[:]
    c = 0
    while True:
        check = True
        for i in range(len(ss) - 1):
            if ss[i] != ss[i + 1]:
                check = False
                break
        if check:
            break
        t = ''
        for i in range(len(ss) - 1):
            if ss[i] == alpha or ss[i+1] == alpha:
                t += alpha
            else:
                t += ss[i]
        c += 1
        ss = t
    cnt = min(cnt, c)

print(cnt)


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

typedef long long ll;
ll n, m, a, x, y, t, M = 1e9 + 7, Z = 1e9;
int main()
{
	ll i;
	cin >> n >> m;
	for (i = 1; i<= n; i++) {
		scanf("%lld",&a);
		a = a + Z;
		x = (x + a * (i - 1)) % M;
		t = (a * (n - i)) % M;
		x = (x - t + M) % M;
	}
	for (i = 1; i<= m; i++) {
		scanf("%lld",&a);
		a = a + Z;
		y = (y + a * (i - 1)) % M;
		t = (a * (m - i)) % M;
		y = (y - t + M) % M;
	}
	cout << (x * y) % M;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.close();
		int r = 0;
		for(int i = 1; i <= N; i++) {
			int l = String.valueOf(i).length();
			if(l % 2 != 0) r++;
		}
		System.out.println(r);
	}
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[101010];
ll mo=998244353;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>A[i];
	sort(A,A+N);
	ll ret=1;
	FOR(i,N) ret=ret*__gcd(A[i],i)%mo;
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

string T;

int main(){
	cin>>T;
	
	for(int i = 0;i < T.length();i++){
		if(T[i]=='?'){
			T[i] = 'D';
		}
	}
	
	cout<<T<<endl;
	return 0;
}

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

int main() {
  int n, sum, dig;
  cin >> n;
  sum = 0;
  
  int m = n;
  while (m != 0) {
  	sum += m % 10;
  	m /= 10;
  }
  if (n % sum == 0) {
  	cout << "Yes" << endl;
  }
  else {
  	cout << "No" << endl;
  }
}


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<"\n"

using pint = pair<int,int>;

int main(){
    int n,t;
    cin >> n;
    vector<vector<pint>>v;
    v.assign(n, vector<pint>());
    REP(i,n){
        cin >> t;
        v[i].resize(t);
        REP(j,t){
            cin >> v[i][j].first >> v[i][j].second;
            --v[i][j].first;
        }
    }
    
    int max1 = 0;int count = 0;
    for(int bit=0;bit<(1<<n);bit++){
        vector<int> vec;
        vector<int> vec1;
        count = 0;
        for(int i=0;i<n;i++){
            if(bit&(1<<i)){
                vec.push_back(i);
                vec1.push_back(1);
                count++;
            }
            else vec1.push_back(0);
        }
        bool flag = true;
        for(const int x:vec){
            for(int j=0;j<v[x].size();j++){
                if(v[x][j].second!=vec1[v[x][j].first]){
                    flag = false;
                    break;
                }
            }
        }
        if(flag)max1=max(max1,count);
    }
    COUT(max1);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

main(){
int inNum,i;
int debt = 100000;

cin>>inNum;
for(i = 0; i < inNum; i++){
if((debt=debt+debt*0.05)%1000==0);
 else{
debt/=1000;
debt+=1;
debt*=1000;
}
}
cout<<debt<<endl;
}

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

#define int long long

const int INF = (int)1e18;

vector<int> per, siz;
int setnum;

void init(int x){
  per.clear();
  siz.clear();
  per.resize(x);
  siz.resize(x);

  setnum = x;
  
  for(int i = 0; i < x; i++){
    per[i] = i;
    siz[i] = 1;
  }
}

int find(int x){
  return x == per[x]?x:per[x] = find(per[x]);
}

void unite(int x, int y){
  x = find(x);
  y = find(y);

  if(x == y) return ;

  setnum--;

  if(siz[x] > siz[y]){
    per[y] = x;
    siz[x] += siz[y];
  } else {
    per[x] = y;
    siz[y] += siz[x];
  }
}

bool same(int y, int x){
  return find(x) == find(y);
}


signed main(){

  while(true){
    int n, m;
    int ans = INF;
    vector<pair<int,pair<int,int>>> in; 
    cin>>n>>m;

    if(!n && !m) break;

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


    sort(in.begin(), in.end());

    for(int i = 0; i < m; i++){
      bool flag = false;
      init(n);
      for(int j = i; j < m; j++){
        if(!same(in[j].second.first, in[j].second.second)){
          unite(in[j].second.first, in[j].second.second);
        }
        //cout<<"i = "<<i<<" j = "<<j<<" setnum = "<<setnum<<endl;
        //cout<<in[j].first<<" - "<<in[i].first<<" <><> "<<endl;
        if(setnum == 1){
          ans = min(ans, in[j].first - in[i].first);
          flag = true;
          break;
        }
      }
      if(flag == false) break;
    }


    cout<<(ans!=INF?ans:-1)<<endl;
  }

  return 0;
}



Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
#define LL                  long long
#define ull                 unsigned long long LL
#define scl(n)              scanf("%lld", &n)
#define scf(n)              scanf("%lf", &n)
#define sci(n)              scanf("%d", &n)
#define scii(n,m)           scanf("%d %d",&n,&m)
#define sciii(n,m,p)        scanf("%d %d %d",&n,&m,&p)

#define MOD                 1000000007
#define MODP                99999999999973LL
#define pb                  push_back
#define mp                  make_pair
#define pp                  pair<LL,LL>
#define memo(a,b)           memset(a,b,sizeof(a))
#define INF                 1e9
#define EPS                 1e-8
#define Pi                  acos(-1.0)
LL bigmod(LL b, LL p, LL md){if(p==0) return 1;if(p%2==1){ return ((b%md)*bigmod(b,p-1,md))%md;} else {LL y=bigmod(b,p/2,md);return (y*y)%md;}}
#define N 100002

bool vis[N];
vector<int>v[N];
int dis[N];

int n,m;

int ans=0;

void dfs(int s)
{
    vis[s]=true;

    for(int i=0;i<v[s].size();i++)
    {
        int now=v[s][i];

        if(vis[now]==false)
        {
            dfs(now);

        }
       dis[s]=max(dis[now]+1,dis[s]);


    }

    ans=max(dis[s],ans);

}

int main()
{
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin>>a>>b;
        v[a].pb(b);
    }

    for(int i=1;i<=n;i++)
    {
        if(vis[i]==false)
            dfs(i);
    }
    cout<<ans<<endl;



    return 0;
}



/* LL dx[] = {1,-1,0,0} , dy[] = {0,0,1,-1}; */ // 4 Direction
/* LL dx[] = {1,-1,0,0,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1,1,-1}; */ // 8 Direction
/* LL dx[] = {1,-1,1,-1,2,2,-2,-2} , dy[] = {2,2,-2,-2,1,-1,1,-1}; */ // Knight Direction
/* LL dx[] = {2,-2,1,1,-1,-1} , dy[] = {0,0,1,-1,1,-1}; */ // Hexagonal Direction


Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define repA(i, a, n) for(int  i = a; i <= (n); ++i)
#define repD(i, a, n) for(ll i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define fill(a) memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define endl '\n'
const long double PI = 3.141592653589793238462643383;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long int> vll;
typedef vector<pii> vii;
long long int Ceil(int a, int b){
    if(a%b==0) return a/b;
    else return (a/b)+1;
}
ll p=1000000007;
int main() {
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);   
    // freopen("output.txt", "w", stdout);
    // #endif
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    int n;cin>>n;
    ll a[n][n];
    rep(i,n)rep(j,n)cin>>a[i][j];
    ll dp[1<<n];
    dp[0]=0;
    for(int i=1;i<(1<<n);i++){
        ll x=i;
        dp[i]=0;
        for(int j=0;j<16;j++){
            for(int k=j+1;k<16;k++){
                if(i&(1<<j)&&(i&(1<<k))){
                    dp[i]+=a[j][k];
                }
            }
        }
        while(x!=0){
            ll z=x^i;
            dp[i]=max(dp[i],dp[x]+dp[z]);
            x=(x-1)&i;

        }
    }
    cout<<dp[(1<<n)-1];
    return 0;
}   

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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)
#define fi first
#define se second

using ll = long long;
using v_int = std::vector<int>;
using v2_int = std::vector<v_int>;
using v_ll = std::vector<ll>;
using v2_ll = std::vector<v_ll>;
using v_string = std::vector<std::string>;
using v_bool = std::vector<bool>;
using v2_bool = std::vector<v_bool>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;

const double PI = 3.1415926535897932;
const int INF = (int)1e9;
const ll LINF = (ll)1e18;
const ll MOD = 1000000007;
const int dr[4] = {1, 0, -1, 0};
const int dc[4] = {0, 1, 0, -1};

using namespace std; 

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p)
{
    return o << "{" << p.first << "," << p.second << "}";
}

template<typename T, typename U, typename V> inline
ostream& operator<<(ostream &o, tuple<T,U,V> &p)
{
    return o << "{" << get<0>(p) << "," << get<1>(p) << "," << get<2>(p) << "}";
}

template<typename T> inline
istream& operator>>(istream &is, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) {
        is >> v[i]; 
    }
    return is;
}

template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) { 
        os << v[i];
        if(i != len-1) { os << ","; } 
    } 
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }

template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    int n;
    cin >> n;
    map<ll, ll> mp;
    
    irep(i, n) {
        int tmp;
        cin >> tmp;
        mp[tmp]++;
    }
    int q;
    cin >> q;
    ll sum = 0;

    for(auto a : mp) {
        sum += a.first * a.second;
    }
    
    v_ll output(q);
    irep(i, q) {
        int b, c;
        cin >> b >> c;
        
        sum -= b * mp[b];
        sum += c * mp[b];
        mp[c] += mp[b];
        mp.erase(b);
        output[i] = sum;
    }
    irep(i, q) {
        cout << output[i] << endl;
    }
    return 0;
}

/*atcoder*/


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, s, e) for (int i = (int)(s); i < (int)(e); i++)
#define _rep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define _REP(i, e, s) for (int i = (int)(e - 1); i >= (int)(s); i--)

#define yes cout << "yes" << endl;
#define Yes cout << "Yes" << endl;
#define YES cout << "YES" << endl;

#define no cout << "no" << endl;
#define No cout << "No" << endl;
#define NO cout << "NO" << endl;

#define AC cout << "AC" << endl;
#define WA cout << "WA" << endl;

#define out(s) cout << s << endl;

#define ll long long
#define ull unsigned long long
#define vi vector<int>

const double PI = 3.14159265358979323846;

int main() {
    int N, Q, l, r;
    string S;
    cin >> N >> Q >> S;
    vector<int> v(S.size(), 0);

    REP(i, 1, S.size()) {
        if (S.substr(i - 1, 2) == "AC") {
            v[i] += v[i - 1] + 1;
        } else {
            v[i] = v[i - 1];
        }
    }

    rep(i, Q) {
        cin >> l >> r;
        cout << v[r - 1] - v[l - 1] << endl;
    }
}

Measured memory_bytes: 1408
h1, m1, h2, m2, k = map(int,input().split())

if m1 > m2:
    x = (h2 - h1 - 1)*60 + m2 - m1 + 60 - k

else:
    x = (h2 - h1)*60 + m2 - m1- k

print(x)

Measured memory_bytes: 9164
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define inf 100000000000000000
#define mod 1000000007
#define MAX 100005
#define pb push_back
#define vit vector<int>::iterator
typedef pair<lint,lint> pii;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    lint n,x,m;
    cin>>n>>x>>m;
    vector<lint> vis(m,0);
    vector<lint> pr(100005,0),ps(100005,0);
    vis[x]=1;
    lint pos=2,sm=x;pr[1]=x;ps[x]=1;
    while(pos<=n){
        x=(x*x)%m;
        if(!x){
            cout<<sm;
            return 0;
        }
        if(vis[x]) break;
        vis[x]=1;
        ps[x]=pos;
       // cout<<x<<' '<<ps[x]<<endl;
        sm=sm+x;
        pr[pos]=sm;
        pos++;
    }
    if(pos>n) cout<<sm;
    else{
        pos--;n-=pos;

        lint pss=ps[x]-1,ds=sm-pr[pss],dl=pos-pss;
       // cout<<pos<<' '<<n<<' '<<pss<<' '<<ds<<' '<<dl<<endl;
        sm=sm+ds*(n/dl)+pr[pss+n%dl]-pr[pss];
        cout<<sm;
    }
    return 0;
}


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

int main() {
  string a;
  cin >> a;
  
  if (a[0] == a[1] && a[0] == a[2]) cout << "Yes" << endl;
  else if (a[3] == a[1] && a[3] == a[2]) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0) return 1;

  if (p % 2 == 0) {
    ll half = modpow(a, p / 2, mod) % mod;
    return half * half % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1;  // 分母
  ll numerator = 1;    // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= a - i;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

class UnionFind {
 private:
  vector<ll> parents;

 public:
  UnionFind(ll n) : parents(n, -1) {}

  bool issame(ll x, ll y) { return root(x) == root(y); }

  bool merge(ll x, ll y) {
    if (issame(x, y)) return false;

    ll rx = root(x);
    ll ry = root(y);
    if (parents[rx] > parents[ry]) swap(rx, ry);
    // サイズ情報を更新
    parents[rx] += parents[ry];
    // yの親を更新
    parents[ry] = rx;

    return true;
  }

  ll size(ll x) { return -parents[root(x)]; }

 private:
  ll root(ll x) {
    if (parents[x] < 0) return x;
    // 根の親の値に木の(-)サイズの情報を入れる
    return parents[x] = root(parents[x]);
  }
};

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

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);

  ll N, K;
  cin >> N >> K;

  if (N == 0) {
    cout << N << endl;
  } else if (K == 1) {
    cout << 0 << endl;
  } else if (N == K) {
    cout << 0 << endl;
  } else if (N < K) {
    cout << min(N, K - N) << endl;
  } else {
    // N > K
    ll n = N / K;
    cout << min(abs(N - n * K), abs(N - (n + 1) * K));
  }

  return 0;
}


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

double h,w,x,y;

int main(){

    cin>>w>>h>>x>>y;
    printf("%.9lf ",(w*h/2));
    if(x*2==w&&y*2==h){
        cout<<1<<endl;
    }else{
        cout<<0<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		Set<Integer> set = new HashSet<>();
		for(int i = 0; i < n; i++) set.add(sc.nextInt());
		System.out.println(set.size());
		
	}
}

Measured memory_bytes: 21588
SIZE=200001; MOD=998244353 #ここを変更する

SIZE += 1
inv = [0]*SIZE  # inv[j] = j^{-1} mod MOD
fac = [0]*SIZE  # fac[j] = j! mod MOD
finv = [0]*SIZE # finv[j] = (j!)^{-1} mod MOD
inv[1] = 1
fac[0] = fac[1] = 1
finv[0] = finv[1] = 1
for i in range(2,SIZE):
    inv[i] = MOD - (MOD//i)*inv[MOD%i]%MOD
    fac[i] = fac[i-1]*i%MOD
    finv[i]= finv[i-1]*inv[i]%MOD

def choose(n,r): # nCk mod MOD の計算
    if 0 <= r <= n:
        return (fac[n]*finv[r]%MOD)*finv[n-r]%MOD
    else:
        return 0

# coding: utf-8
# Your code here!
import sys
read = sys.stdin.read
readline = sys.stdin.readline 

n,m,k = list(map(int,read().split()))

ans = 0
for i in range(k+1):
    ans += m*pow(m-1,n-1-i,MOD)*choose(n-1,i)
    ans%=MOD

print(ans%MOD)



Measured memory_bytes: 75888
/*
█████████████.....██████....██.........█....██████████....██.........██.
██.........██.......██......█.█........█....██......██.....██.......██..
██.........██.......██......█..█.......█....██......██......██.....██...
██.........██.......██......█...█......█....██......██.......██...██....
██.........██.......██......█....█.....█....██......██........██.██.....
██.........██.......██......█.....█....█....██......██.........███......
█████████████.......██......█.....█....█....██████████.........███......
██..................██......█......█...█....██......██.........███......
██..................██......█......█...█....██......██.........███......
██..................██......█.......█..█....██......██.........███......
██..................██......█.......█..█....██......██.........███......
██..................██......█........█.█....██......██.........███......
██..................██......█........█.█....██......██.........███......
██................██████....█.........██....██......██.........███......
ЗАПУСКАЕМ
░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░
▄███▀░◐░░░▌░░░░░░░
░░░░▌░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░▄▀▒▒▀▀▀▀▄
░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░▄▄▌▌▄▌▌░░░░░
 */

#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <math.h>
#include <set>
#include <stack>
#include <map>
#include <queue>
#include <random>
#define DEBUG
#define pqueue priority_queue
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
#define int long long
#define  mk(a, b) make_pair(a, b)
//#define x first;
//#define y second;

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ull> vull;
typedef vector<ll> vll;
typedef tuple<int, int, int> tiii;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector< vector<int> > vvi;
typedef vector<char> vc;

const int INF = 1e9;
const ll INFLL = 1e12;
const int MOD = 1000000007;
const ld eps = 1e-6;
const int MOD2 = (1<<30)+1;
const int dosz = 5e5;

void fast_io(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef DEBUG
//    freopen("a.in", "r", stdin);
#else
    //    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif
}

//map<int, int> kek;

void solve(){
    int a, b, c;
    cin >> a >> b >> c;
    int st_a = a;
    a = max(0ll, a-c);
    c = max(0ll, c-st_a);
    b = max(0ll, b-c);
    cout << a << " " << b;
}

signed main() {
    int q = 1;
//    cin >> q;
    while(q--){
        solve();
    }
    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[] arr = new int[n];
		for (int i = 0; i < n; i++) {
		    arr[i] = sc.nextInt();
		}
		Arrays.sort(arr);
		int left = arr[0];
		int idx = 0;
		int max = 1;
		for (int i = 1; i < n; i++) {
		    if (arr[i] - left > 2) {
		        while (arr[i] - arr[idx] > 2) {
		            idx++;
		            left = arr[idx];
		        }
		    } else {
		        max = Math.max(max, i - idx + 1);
		    }
		}
        System.out.println(max);
	}
}


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

int main(){
  int M,D,sum,dif,dma; cin >> M >> D;
  sum=0;
  
  for(int p=1;p<=M;p++){
    for(int i=22;i<=D;i++){
       dif=(i-i%10)/10; dma=i%10;
       if(dma*dif==p && dif!=1 && dma!=1){
         sum++;
       }
     }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256