akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;


void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}

//mod計算用のクラス
class ModInt{
public:
    long long int x;
    long long int mod;
	ModInt(){}
    ModInt(long long int _x, long long int _mod = 1000000007){
        this->x = _x % _mod;
        this->mod = _mod;
    }
	ModInt operator+(ModInt other){
		return ModInt(this->x + (other.x % this->mod),this->mod);
	}
	ModInt operator-(ModInt other){
		long long int res = this->x - (other.x % this->mod);
		if (res < 0) return ModInt(res + this->mod, this->mod);
		return ModInt(res);
	}
	ModInt operator*(ModInt other){
		return ModInt(this->x * (other.x % this->mod),this->mod);
	}
	ModInt operator/(ModInt other){
		return ModInt(*this * other.inv());
	}
	ModInt pow(long long int n){
		ModInt res(1, this->mod), a(this->x, this->mod);
		while (n){
			if (n & 1){
				res = res * a;
			}
			n >>= 1;
			a = a * a;
		}
		return res;
	}
	ModInt inv(){
		return ModInt(this->pow(this->mod - 2));
	}
	void disp(){
		cout << this->x << endl;
	}
};
ostream& operator<<(ostream& stream, const ModInt m){
	stream << to_string(m.x);
	return stream;
}

//最大公約数を返す関数.
long long int gcd(long long int x, long long int y){
    if (x < y) swap(x,y);
    while (y > 0){
        long long int r = x % y;
        x = y;
        y = r;
    }
    return x;
}

int main() {
	int r;
	cin >> r;
	cout << r * r << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cassert>
#include <functional>

int main() {
    int N; // the number of vertices
    int M; // the number of edges
    std::cin >> N >> M;
    assert(2 <= N && N <= 100'000);
    assert(1 <= M && M <= 100'000);

    // Getting edges in adjacency list
    std::vector<int> A[N]; // A_i: the adjacency list of the vertex i

    for (int i=0; i<M; i++) {
        int x, y, z;
        std::cin >> x >> y >> z;
        assert(1 <= x && x <= N);
        assert(1 <= y && y <= N);
        assert(x < y);
        assert(1 <= z && z <= 100);
        A[x-1].push_back(y-1);
        A[y-1].push_back(x-1);
    }

    // Deciding the number of the connected components
    int cc = 0; // the number of the connected components
    bool visited[N];

    std::function<void(int)> DFS;
    DFS = [&](int v) {
        if (visited[v]) return;
        visited[v] = true;
        for (int i=0; i<A[v].size(); i++) DFS(A[v].at(i));
    };

    for (int i=0; i<N; i++) visited[i] = false;
    for (int i=0; i<N; i++) {
        if (visited[i]) continue;
        DFS(i);
        cc++;
    }

    std::cout << cc << std::endl;

    return 0;
}


Measured memory_bytes: 12032
n=gets.to_i
a=gets.split.map(&:to_i)
mod=1000000007
x=0
k=1
60.times do
  c=a.count{|b|b/k%2==1}
#  a=a.map{|b|b/2}
  x+=c*(n-c)*k
  x%=mod
  k*=2
end
puts x


Measured memory_bytes: 34820
from itertools import accumulate

S = input()
N = len(S)

A = [0] + list(accumulate(1 if s == "1" else -1 for s in S))

ma = max(A)
cur = A[-1]
C = [ma - cur]
for a in reversed(A):
    cur = max(a, cur)
    C.append(ma - cur)

d, e = 0, 0
D, E = A[:], A[:]
for i, (s, c) in enumerate(zip(S, reversed(C[:-1])), 1):
    if s == '?' and c >= d + 2:
        d += 2
    if s == '?' and c >= e + 1:
        e += 2
    D[i] += d
    E[i] += e

print(min(max(D) - min(D), max(E) - min(E)))

Measured memory_bytes: 177532
P=10**9+7
N=int(input())
S1=input()
S2=input()
L=[1]
k=0
P=10**9+7
for i in range(1,N):
    if S1[i]!=S1[i-1]:
        L.append(0)
        k+=1
    L[k]+=1
M=len(L)
S=1
if L[0]==1:
    S=3
else:
    S=6
for i in range(1,M):
    if L[i-1]==1:
        S=(S*2)%P
    else:
        if L[i]==2:
            S=(S*3)%P
print(S)


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

#define N_MAX 100

int main() {
    long n, m;
    cin >> n >> m;
    pair<long, long> Shop[n];
    for (long i = 0; i < n; i++) {
        cin >> Shop[i].first >> Shop[i].second;
    }

    sort(Shop, Shop + n);

    long long cnt = 0;
    long long cost = 0;
    long i = 0;
    while(cnt < m) {
        long b = Shop[i].second;
        for (long j = 0; j < b; j++) {
            cnt++;
            cost += Shop[i].first;
            if (cnt >= m) {
                break;
            }
        }
        i++;
    }

    cout << cost << endl;

    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//printf("%d", n);
//printf("%d", sum);
//scanf("%d", &n);
//scanf("%c", &c);
//scanf("%lf", &d);


ll attack(ll hp){
    if(hp == 1){
        return 1;
    }

    ll hp2 = hp / 2;

    return 1 + 2 * attack(hp2);
}

#define NUM (10000)

int main(int argc, char** argv){
    ll H;
    scanf("%lld", &H);

    ll cnt = attack(H);
    printf("%lld\n", cnt);

    return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <queue>
 
using namespace std;
 
typedef pair<int, int> P;
 
int main() {
    int n, m, a, b, c;
    int days[400];
    int count[400];
    vector<P> path[400];
    queue<int> q;
    cin >> n >> m;
    for (int i=0; i<n ;i++) {
        count[i] = 0;
    }
    for (int i=0; i<m; i++) {
        cin >> a >> b >> c;
        path[a].push_back(P(b, c));
        count[b]++;
    }
    for (int i=0; i<n; i++) {
        days[i] = 0;
    }
    q.push(0);
    while (!q.empty()) {
        int a = q.front();
        q.pop();
        for (int i=0; i<(int)path[a].size(); i++) {
            int b = path[a][i].first;
            int c = path[a][i].second;
            days[b] = max(days[b], days[a]+c);
            count[b]--;
            if (count[b] == 0) {
                q.push(b);
            }
        }
    }
    cout << days[n-1] << endl;
    return 0;
}

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

typedef long long ll;

#define REP(i, N) for (int i = 0; i < (int)(N); i++)

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

int main() {
    vector<ll> v(4);
    REP(i,4) cin >> v[i];
    
    ll ans = - 1e+18 - 10;
    
    for ( int i = 0; i < 2; ++i){
        for ( int j = 2; j < 4; ++j){
            ll ans2 = v[i] * v[j];
            chmax(ans,ans2);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a; }

int main() {
    int n, X;
    cin >> n >> X;
    vint x(n);
    rep(i, n) cin >> x[i];
    x.push_back(X);
    sort(all(x));

    vint d(n);
    rep(i, n) d[i] = x[i+1] - x[i]; 

    int ans = d[0];
    srep(i, 1, n) ans = gcd(ans, d[i]);

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

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;

namespace AtCoder
{
	public class Program
	{
		static void Main()
		{
			var abc = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

			int ans = abc[0] * abc[1] / 2;
			Console.WriteLine(ans);
		}
	}
}

Measured memory_bytes: 13268
<?php

fscanf(STDIN, "%d", $n);
$A = array_map('intval', explode(' ', trim(fgets(STDIN))));
fscanf(STDIN, "%d", $q);
$B = []; $C = [];
for ($i = 0; $i < $q; ++$i) {
    fscanf(STDIN, "%d %d", $b, $c);
    $B[] = $b; $C[] = $c;
}
const N_MAX = 100005;

$sum = 0;
$map = array_fill(0, N_MAX, 0);
for ($i = 0; $i < $n; ++$i) {
    ++$map[$A[$i]];
    $sum += $A[$i];
}
/* print_r($map); */

for ($i = 0; $i < $q; ++$i) {
    $cnt = $map[$B[$i]];
    $map[$B[$i]] -= $cnt;
    $map[$C[$i]] += $cnt;

    $sum -= $cnt * $B[$i];
    $sum += $cnt * $C[$i];

    echo (int) $sum, PHP_EOL;
}


Measured memory_bytes: 33592
#include<bits/stdc++.h>
using namespace std;
int main()
{
   string s;
   cin>>s;
   int c=0,m=0;
   for(int i=0;i<3;i++)
   {
       if(s[i]=='R')
       {
           c++;
           for(int j=i+1;j<3;j++)
           {
               if(s[j]=='R')
               {
                   c++;
                   s[j]='0';
               }
               else break;
           }
       }
       m=max(m,c);
       c=0;
   }
   cout<<m<<endl;
}


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

#define fi first
#define se second

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

    int n;cin>>n;

    map<int,int> m;
    for(int i=0;i<n;i++)
    {
        int a;cin>>a;
        m[a-1]++;
        m[a]++;
        m[a+1]++;
    }

    int ans=0;
    for(auto mm:m)
    {
        ans=max(ans,mm.se);
    }

    cout<<ans<<"\n";

    return 0;
}


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

#define	PI	acos(-1)
#define	mp	make_pair
#define f	first
#define s	second
#define mset(arr, val)	memset(arr, val, sizeof(arr))
#define	srt(arr)	sort(arr.begin(), arr.end())

using namespace std;

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef long long ll;

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

  string cad;

  cin >> cad;

  int l = 0, r = cad.length() - 1;
  ll c = 0;
  while(l < r){
		if(cad[l] == cad[r]){
			l++;
			r--;
		}
		else{
			if(cad[l] == 'x'){
				l++;
				c++;
			}
			else {
				if(cad[r] == 'x'){
					r--;
					c++;
				}
				else{
					break;
				}
			}
		}
  }

  if(l >= r){
		cout << c << endl;
  }
  else{
		cout << -1 << endl;
  }
	return 0;
}


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

int N,l,r,A[300100];
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	
	l = r = 150000; l--;
	cin >> N;
	for(int i = 1;i<=N;i++)	if(i%2) cin >> A[r++]; else cin >> A[l--];
	if(N%2)	for(int i = r-1;i>l;i--) cout << A[i] << ' ';
	else for(int i = l+1;i<r;i++) cout << A[i] << ' ';
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
 
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define len(x) int((x).size())
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define randint(n) uniform_int_distribution<int>(1, (n))(rng)

const int MAXN=100000;
const ll p = 7LL + ll(1e9); // both of these may need to be edited, problem dependent
 
ll fac[MAXN+1];
ll inv_fac[MAXN+1];
 
ll mod_exp(ll a, ll b)
{
	if(b==0LL) return 1LL;
 
	ll ans = mod_exp(a,ll(b/2LL));
	ans*=ans;
	ans%=p;
 
	if(b%2LL==1LL) ans*=a;
	ans%=p;
 
	return ans;
}
 
ll C(int n, int k)
{
	if(k<0 || k>n) return 0;

	ll ans = fac[n]*inv_fac[k];
	ans%=p;
	return (ans*inv_fac[n-k])%p;
}
 
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	#ifdef ARTHUR_LOCAL
		ifstream cin("input.txt");
	#endif
 
	fac[0]=1LL;
	inv_fac[0]=1LL;
 
	for(int i=1; i<=MAXN; i++)
	{
		fac[i] = ll(i)*fac[i-1];
		fac[i] %= p;
 
		inv_fac[i] = mod_exp(fac[i],p-2LL);
		// if(i<10) cout << i << " " << fac[i] << " " << inv_fac[i] << endl;
	}

	int n;
	cin>>n;

	ll ans=0LL;

	for(int terms=1; terms<=n; terms++)
	{
		int cur_sum = n - 3*terms;
		if(cur_sum < 0) break;

		// make cur_sum with terms number of terms

		ans += C(cur_sum + terms - 1, terms - 1);
		ans %= p;
	}

	cout << ans << "\n";
}

Measured memory_bytes: 5228
N,M = [int(i) for i in input().split()]
P = 10**9+7
nn = M+1
fa = [1] * (nn+1)
fainv = [1] * (nn+1)
for i in range(nn):
    fa[i+1] = fa[i] * (i+1) % P
fainv[-1] = pow(fa[-1], P-2, P)
for i in range(nn)[::-1]:
    fainv[i] = fainv[i+1] * (i+1) % P
C = lambda a, b: fa[a] * fainv[b] % P * fainv[a-b] % P if 0 <= b <= a else 0

ans = ((fa[M]*fainv[M-N]%P)**2)%P
for i in range(1,N+1):
  ans += (-1)**i * C(N,i) * fa[M]%P * fa[M-i]%P * fainv[M-N]%P * fainv[M-N]%P
  ans %= P
print(ans)

Measured memory_bytes: 91456
main = getLine >>= putStrLn . solve 0 . map read . words

solve t (a:b:c:d:_)
  | a <= 0 = "No"
  | c <= 0 = "Yes"
  | t == 0 = solve 1 (a:b:c-b:d:[])
  | otherwise = solve 0 (a-d:b:c:d:[])

Measured memory_bytes: 3928
/*
[abc100] D - Patisserie ABC
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 1000;
const int K = 3;

int N, M;
ll x[MAX_N][K];

ll solve() {
    ll ans = 0;
    for (int pat = 0; pat < (1 << K); pat++) {
        vector<ll> v;
        for (int i = 0; i < N; i++) {
            ll s = 0;
            for (int k = 0; k < K; k++) {
                s += (((pat >> k) & 1) ? 1LL : -1LL) * x[i][k];
            }
            v.push_back(s);
        }
        sort(v.rbegin(), v.rend());
        ll sum = 0;
        for (int i = 0; i < M; i++) {
            sum += v[i];
        }
        ans = max(ans, sum);
    }
    return ans;
}

int main() {
    cin >> N >> M;
    for (int i = 0; i < N; i++) {
        for (int k = 0; k < K; k++) {
            cin >> x[i][k];
        }
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,ans;
int main()
{
    scanf("%d %d",&n,&m);
    if(n%2==0)
	{
		        int m2 = m / 2;
        int m1 = m - m2;
        for (int i = 1; i <= m1; ++i) {
            std::cout << i << " " << m1 * 2 + 1 - i << std::endl;
        }
 
        int d = m1 * 2;
        for (int i = 1; i <= m2; ++i) {
            std::cout << d + i << " " << d + m2 * 2 + 2 - i << std::endl;
        }
	}
	else
	{
		for(int i=1;i<=m;i++)printf("%d %d\n",i,n-(n%2==0)-i+1);
	}
    return 0;
}

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

int main() {
int N,L,min_b,sum=0,i;
bool flag=false;
cin>>N>>L;
int a[N],b[N];
for(i=0;i<N;i++)
{
	a[i]=i;
	b[i]=L+a[i];
	if(b[i]==0)
	flag=true;
	sum+=b[i];
}
sort(b,b+N);
if(flag)
cout<<sum;
if(b[0]>0)
cout<<sum-b[0];
if(b[N-1]<0)
cout<<sum+abs(b[N-1]);

	return 0;
}

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


int main(){
  int S[100],i=0,num1,j=0;
  char array[1000000];
  while(scanf("%s",array)!=EOF){
    if(array[0]!='+' && array[0]!='-' && array[0]!='*'){
      num1=atoi(array);
      S[j]=num1;
      //printf("%d\n",S[j]);
      j++;
    }
   
    else if(array[0]=='+'){
      S[j-2]=S[j-2]+S[j-1];
      j=j-1;
    }
    else if(array[0]=='-'){
      S[j-2]=S[j-2]-S[j-1];
      j=j-1;
      }
    else if(array[0]=='*'){
      S[j-2]=S[j-2]*S[j-1];
      j=j-1;
    }
  }
  printf("%d\n",S[0]);
  return 0;
}


Measured memory_bytes: 2104
(defun main ()
  (let ((k (read))
        (ans 0))
    (dotimes (a k)
      (dotimes (b k)
        (dotimes (c k)
          (setf ans (+ ans (gcd (1+ a) (1+ b) (1+ c)))))))
    (format t "~d~%" ans)))

(main)


Measured memory_bytes: 24380
#include<stdio.h>
int n[1000001]={};
int main(){

int N;

int c=0;
while(1){
scanf("%d",&N);
if(N==0)break;
int c=0;

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

for(int i=0;i<N;i++)
for(int j=N-1;j>i;j--)
{if(n[j]<n[j-1]){int T=n[j];n[j]=n[j-1];n[j-1]=T;c++;}


}
printf("%d\n",c);
for(int i=0;i<N;i++)
	n[i]=0;

}
return 0;
}

Measured memory_bytes: 1028
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(),a.end());
  int ans = 0;
  rep(i,k) ans += a[i];
  cout << ans << endl;
}


Measured memory_bytes: 3624
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#define FOR( a,b ) for( a=0;a<b;a++ )
 
int main(){
    int a,b;
    char buf[200][20];
    int cnt = 0;
    while( scanf( "%d %d",&a,&b ) != EOF ){
    	sprintf( buf[cnt++],"%d",a+b );
    }
    
    FOR( a,cnt )printf( "%d\n",strlen( buf[a] ));
    return 0;
}

Measured memory_bytes: 620
#include <stdio.h>
int main(void)
{
        int W, H, x, y, r;
        int flag = 0;
        scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);
        
        if ( (r <= x) && (x <= W - r) && r <= y && (y <= H - r)) {
                puts("Yes");
        } else {
                puts("No");
        }
        return 0;
}

Measured memory_bytes: 580
n,k=map(int,input().split())
s=input()
cnt=0
for i in range(n-1):
    if s[i]!=s[i+1]:
        cnt+=1
order=0
left=0
if cnt%2==0:
    order=cnt//2
elif cnt%2!=0:
    order=cnt//2
    left=1
checker=s[0]
count=0
lists=[]

s=s+"e"
for i in range(n+1):
    if s[i]==checker:
        count+=1
    elif s[i]!=checker:
        lists.append(count-1)
        count=1
        checker=s[i]
base=sum(lists)

if order>=k:
    ans=k*2+base
elif order<k:
    ans=n-1
print(ans)

Measured memory_bytes: 4092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s;
string strd(int n){
    string x;
    while(n){
        int d=n%10;
        x+=(d+'0');
        n/=10;
    }
    reverse(x.begin(),x.end());
    return x;
}
void digit()
{
    for(int i=1;i<=10000;i++){
        s+=strd(i);
    }
}
int main()
{
     int n,x,t;
     cin>>n>>x>>t;
     if(n%x==0)n/=x;
        else n=n/x+1;
     cout<<n*t<<endl;
}


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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (c > a&&c < b || c<a&&c>b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
main :: IO ()
main = do
  [x, y] <- map asHex . words <$> getLine
  putStr $ solve x y
 
solve :: Int -> Int -> String
solve x y
  | x < y = "<"
  | x > y = ">"
  | otherwise = "="

asHex :: String -> Int
asHex s = read $ "0x" ++ s

Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
ll mod=1e9+7;

vector<ll> tfact(1e7+1);
void fact(ll n) {
  for(ll i=0;i<=n;i++) {
    if(i==0) {
      tfact[i]=1;
    }
    else {
      tfact[i]=tfact[i-1]*i%mod;
    }
  }
}

int main() {
  ll n;
  string s;
  cin >> n >> s;
  n*=2;
  vector<ll> d(n);
  d[0]=-1;
  for(ll i=0;i<n-1;i++) {
    if(s[i]==s[i+1]) {
      d[i+1]=-d[i];
    }
    else {
      d[i+1]=d[i];
    }
  }
  if(s[0]=='W'||s[n-1]=='W'||d[n-1]==-1) {
    cout << 0 << endl;
    return 0;
  }
  ll l=1;
  ll ans=1;
  for(ll i=1;i<n;i++) {
    if(d[i]==1) {
      ans=ans*l%mod;
      l--;
      if(l<0) {
        cout << 0 << endl;
        return 0;
      }
    }
    else {
      l++;
    }
  }
  fact(n/2);
  ans=ans*tfact[n/2]%mod;
  if(ans<0||l!=0) {
    ans=0;
  }
  cout << ans << endl;
}

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

int n, d, x;
int a;
int main(){
  int choco = 0;
  cin >> n >> d >> x;
  for(int i = 0; i < n; i++){
    cin >> a;
    for(int j = 0; j*a < d; j++){
      choco++;
    }
  }
  choco += x;
  cout << choco << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

type edge struct {
	node, weight int
}
var colors []int
var g [][]edge

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	g = make([][]edge, n)
	for i := 0; i < n; i++ {
		g[i] = make([]edge, 0)
	}
	colors = make([]int, n)

	for i := 0; i < n-1; i++ {
		u, v, w := nextInt(), nextInt(), nextInt()
		u--; v--
		w %= 2
		g[u] = append(g[u], edge{v, w})
		g[v] = append(g[v], edge{u, w})
	}

	dfs(0, -1, 1)

	w := bufio.NewWriter(os.Stdout)
	for i := 0; i < len(colors); i++ {
		fmt.Fprintln(w, colors[i])
	}

	w.Flush()
}

func dfs(node, parent, color int) {
	colors[node] = color
	for _, e := range g[node] {
		if e.node == parent {
			continue
		}
		if e.weight == 1 {
			dfs(e.node, node, 1-color)
		} else {
			dfs(e.node, node, color)
		}
	}
}

Measured memory_bytes: 23296
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x,cne=0,cnt=0;
    cin>>n;
    while(n--)
    {
        cin>>x;
        if(x%2==0)
        {
            cne++;
            if(x%3==0||x%5==0)
                cnt++;
        }
    }
    if(cne==cnt)
        cout<<"APPROVED"<<endl;
    else
        cout<<"DENIED"<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  string s;
  cin >> s;
  if (s == "ABC") cout << "ARC" << endl;
  else  cout << "ABC" << endl;
  return 0;
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}


void solve()
{
	ll h, w;
	cin >> h >> w;	
	if(h == 1 || w == 1){
		cout << 1;
	} 
	else
	cout << (h * w + 1) / 2;
}


 
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
inf = 10**10
n,ma,mb = map(int, input().split())

a = []
b = []
c = []
for _ in range(n):
    x,y,z = map(int, input().split())
    a.append(x)
    b.append(y)
    c.append(z)

memo = {}
def rec(i, maj, mbj):
    k = str(i)+"-"+str(maj)+"-"+str(mbj)
    if k in memo:
        return memo[k]
    # print(i, ":", maj, mbj, maj/ma, mbj/mb)
    ret = 0
    if i==n:
        if maj>0 and mbj>0 and maj/ma == mbj/mb:
            ret = 0
        else:
            ret = inf
    elif maj>0 and mbj>0 and maj/ma == mbj/mb:
        ret = 0
    else:
        r1 = rec(i+1, maj, mbj) # i番目を使わない場合
        # i番目を使う場合
        r2 = rec(i+1, maj+a[i], mbj+b[i]) + c[i]
        if r1>0 and r2==0:
            ret = r1
        elif r1==0 and r2>0:
            ret = r2
        else:
            ret = min(r1,r2)
    memo[k] = ret
    return ret

ret = rec(0, 0, 0)
if ret == inf:
    print(-1)
else:
    print(ret)


Measured memory_bytes: 34392
import sys
sys.setrecursionlimit(10**9)


class RollingHash:

    def __init__(self,string):
        base1 = 1007
        mod1 = 10**9+7

        base2 = 2009
        mod2 = 10**9+9

        self.string = string
        n = len(string)
        hash1 = [0]*(n+1)
        power1 = [1]*(n+1)

        hash2 = [0]*(n+1)
        power2 = [1]*(n+1)
        for i,e in enumerate(string):
            hash1[i+1] = (hash1[i]*base1 + ord(e))%mod1
            power1[i+1] = (power1[i]*base1)%mod1
            hash2[i+1] = (hash2[i]*base2 + ord(e))%mod2
            power2[i+1] = (power2[i]*base2)%mod2

        self.hash1 = hash1
        self.power1 = power1
        self.hash2 = hash2
        self.power2 = power2
        self.base1 = base1
        self.mod1 = mod1
        self.base2 = base2
        self.mod2 = mod2

    def calc(self,i,j):
        ans = ((self.hash1[j]-self.hash1[i]*self.power1[j-i]%self.mod1)%self.mod1)*(10**10)
        ans += (self.hash2[j]-self.hash2[i]*self.power2[j-i]%self.mod2)%self.mod2
        return ans

def main():
    N = int(input())
    S = input()

    rh = RollingHash(S)


    ans = 0
    l = 0
    r = N


    while r-l > 1:
        mid = (l+r)//2
        seen = set()
        dic = {}
        found = False
        for i in range(N-mid+1):
            if not i < i+mid-1: continue

            hash = rh.calc(i,i+mid-1)
            # print(hash,i,i+mid-1,mid)
            if hash in seen:
                for _i,j in dic[hash]:
                    if j < i and S[_i:j+1] == S[i:i+mid]:
                        ans = max(ans,mid)
                        found = True
                        break
                else: continue

                dic[hash].append((i,i+mid-1))
                break
            else:
                dic[hash] = [(i,i+mid-1)]
                seen.add(hash)


        if found:
            l = mid
        else:
            r = mid

    print(ans)



if __name__ == "__main__":
  main()

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

int main() {

    string a,b,c;

    cin >> a >> b >> c;

    if(a[a.size()-1] == b[0] && b[b.size()-1] == c[0]){
        cout << "YES" << endl;
        return 0;
    }

    cout << "NO" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
#define debugone(x) cerr << #x << " " << x << "\n"; cerr.flush();
#define debugtwo(x) cerr << #x << "-------------" << "\n";for(auto &it: x) cerr << it << " ";cerr << "\n"; cerr.flush();
#define debugthree(x_, i_, j_) cerr << #x_ << "------------" << "\n";cerr << "from " << i_ << " to " << j_ << "\n";for(ll k_=i_; k_<=j_; k_++) cerr << x_[k_] << " ";cerr << "\n"; cerr.flush();
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

const ll MOD = 1e9 + 7;
const int INF = 2e9;
const int MAX_LOG = 21;
const int MAX_N = 12800;

#define forn(i, n) for(int i = 0; i < n; i++)
#define forsn(i, s, n) for(int i = s; i < n; i++)
#define all(x) x.begin(), x.end()

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll a, b, k;
	cin >> a >> b >> k;
	if(a >= k){
		a -= k;
		k = 0;
	}
	else{
		k -= a;
		a = 0;
	}

	if(b >= k){
		b -= k;
		k = 0;
	}
	else{
		k -= b;
		b = 0;
	}
	cout << a << " " << b << endl;
}

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

int main()
{
    int n,k;
    scanf("%d %d",&n,&k);
    int p[n+5]={0};
    for(int i=1;i<=n;i++)scanf("%d",&p[i]);
    sort(p+1,p+n+1);
    int sum=0;
    for(int i=1;i<=k;i++)sum=sum+p[i];
    printf("%d",sum);
    return 0;
}


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

void boost(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

int main(){
    boost();
    ll t=1;
    //cin >> t;
    while(t--){
       ll i;
       for(i=0;i<5;i++){
           ll a;
           cin >> a;
           if(a==0)
           cout << i+1 ;
       }
    }
}

Measured memory_bytes: 3644
/// Code By t_bone_289 (Tushar Singh)
/// An Immature Programmer.... I'm still developing !!
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef long double ld;
template <typename T>
void ContainerError(T &v){cout<<"{";for(auto &x:v){cout<<x<<',';}cout<<"}"<<endl;return;}
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
ll mpow(ll base,ll exp){ll res=1;while(exp>0){if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return (res);}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin>>s;
    ll n = s.size();
    for(ll i=0;i<n;i+=2)
    {
        char x = s[i];
        if(x!='R' && x!='U' && x!='D')
        {
            cout<<"No";
            return 0;
        }
    }
    for(ll i=1;i<n;i+=2)
    {
        char x = s[i];
        if(x!='L' && x!='U' && x!='D')
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}



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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b,c;
  cin >> a >> b >> c;
  if((a < c && c < b)||(b<c && c<a)) cout << "Yes" << "\n";
  else cout << "No" << "\n";
  return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque

input = sys.stdin.readline


def main():
    N = int(input())
    G = [[] for _ in range(N)]
    for i in range(N - 1):
        u, v, w = map(int, input().split())
        u -= 1
        v -= 1
        G[u].append((v, w))
        G[v].append((u, w))

    ans = [-1] * N
    ans[0] = 0
    stack = deque([(-1, 0)])
    while stack:
        p, u = stack.pop()
        for v, w in G[u]:
            if v == p:
                continue
            if w % 2 == 0:
                ans[v] = ans[u]
            else:
                ans[v] = (ans[u] + 1) % 2
            stack.append((u, v))

    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main()


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

int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    for(int i = 0; i < n; i++){
        cin >> l[i];
    }
    ll ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            for(int k = j+1; k < n; k++){
                if(l[i] + l[j] > l[k] && l[j] + l[k] > l[i] &&
                    l[k] + l[i] > l[j] && l[i] != l[j] &&
                    l[j] != l[k] && l[k] != l[i]){
                        ans++;
                    }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main(void)
{
        char s[3];
        scanf("%s",s);

        for(int i=0;i<3;i++){
                if(s[i]=='1') s[i]='9';
                else s[i]='1';
        }
        printf("%s",s);
        return 0;
}


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

int main() {
  int k;
  vector<int> A(5);
  for(int i=0;i<5;i++){
    cin >> A.at(i);
  }
  cin >> k;
  sort(A.begin(),A.end());
  if(A.at(4)-A.at(0)>k){
    cout << ":(" << endl;
  }
  else{
    cout << "Yay!" << endl;
  }
}

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

#define int long long 
#define MIN -1e18
#define MAX 1e18

using namespace std;

void solve()
{
    int a,b,c,d,cnt=0;
    cin >> a>> b >> c >> d;
    cnt=max(a*c,a*d);
    cnt=max(cnt,b*c);
    cnt=max(cnt,b*d);
    cout << cnt << endl;
}

int32_t main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#endif
ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    //int t;cin >> t;while(t--)
        solve();

    return 0;
}

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

using namespace std;
using LL = long long;

const int MOD = 1e9+7;

class Edge{
public:
    LL from,to, value;
    Edge(int f,int t, int c){
        from = f;
        to = t;
        value = c;
    }
};

int main(){
    long long N;cin >> N;
    long long ans = 1e18;
    for(long long i = 1;i <= sqrt(N)+1;i++){
        if(N % i == 0){
            ans = min(i + N / i -2, ans);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
//const int mod=1e9+7;
const int mod=998244353;
const double eps = 1e-10;
const double pi=acos(-1.0);
const int maxn=1e6+10;
const ll inf=0x3f3f3f3f;
const int dir[4][2]={{0,1},{1,0},{0,-1},{-1,0}};

int a[110];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    int n,m;
    cin>>n>>m;
    int sum=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sum+=a[i];
    }
    sum=(sum+4*m-1)/(4*m);
    int ans=0;
    for(int i=1;i<=n;i++){
        if(a[i]>=sum)ans++;
    }
    if(ans>=m)cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;
int main(){
	for(;;){
		int n,m,sum = 0;
		cin >>n;
		if(!n){break;}
		cin >>m;
		vector<pair<int, pair<int,int> > > edge;
		bool done[100] = {false};
		for(int i=0; i<m ;i++){
			int a,b,cost;
			scanf("%d,%d,%d",&a,&b,&cost);
			edge.push_back(make_pair(cost,make_pair(a,b)));
		}
		sort(edge.begin(),edge.end());
		done[edge[0].second.first] = true;
		done[edge[0].second.second] = true;
		sum += edge[0].first/100;
		if(!(edge[0].first%100)){sum--;}
		for(int i=0; i<n-1; i++){
			for(int k=0; k<m; k++){
				if(done[edge[k].second.first]^done[edge[k].second.second]){
					sum += edge[k].first/100;
					if(!(edge[k].first%100)){sum--;}
					done[edge[k].second.first] = true;
					done[edge[k].second.second] = true;
					break;
				}
			}
		}
		cout<<sum<<endl;
	}
	return 0;
}

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

int main() {
    vector<char> S(3);


    cin >> S.at(0)>> S.at(1) >> S.at(2);
    
    if(S.at(0)=='7'||S.at(1)=='7'||S.at(2)=='7'){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }





}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    ll N, M;
    cin >> N >> M;

    ll ct = 1;
    rep(i, M) {
        ct *= 2;
    }

    ll ans = ct * M * 1900 + ct * (N - M) * 100;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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 COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll i=2;i<=sqrt(n);i++){
    if(n%i!=0) continue;
    ll tmp=0;
    while(n%i==0){
      n/=i;
      tmp++;
    }
    ans.push_back(make_pair(i,tmp));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll a,b;
  cin>>a>>b;
  set<ll> st;
  Rep(i,sqrt(b)){
    if(b%i==0){
      st.insert(i);
      st.insert(b/i);
    }
  }
  vector<ll> v;
  for(auto c:st) v.push_back(c);
  sort(ALL(v));
  if(upper_bound(ALL(v),b/a)-v.begin()<1) cout<<1<<endl;
  else cout<<v[(upper_bound(ALL(v),b/a)-v.begin())-1]<<endl; 
}

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

int main(){

  int w, n, a, b, p[30], tmp;

  cin >> w >> n;

  for(int i=1; i<=w; i++){
    p[i] = i;
  }

  for(int i=1; i<=n; i++){
    scanf("%d,%d", &a, &b);
    tmp = p[a];
    p[a] = p[b];
    p[b] = tmp;
  }

  for(int i=1; i<=w; i++){
    cout << p[i] << endl;
  }

  return 0;

}

Measured memory_bytes: 1240
#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
	ll n, ans = 0;
	string s;
	vecll count(3, 0);
	vector<bool> color(3, false);

	cin >> n;
	cin >> s;

	forll(i, 0, n)
	{
		if(s[i]=='R')
			count[0]++;
		if (s[i] == 'G')
			count[1]++;
		if (s[i] == 'B')
			count[2]++;
	}

	forll(i, 0, n-2)
	{
		if (s[i] == 'R')
			count[0]--;
		if (s[i] == 'G')
			count[1]--;
		if (s[i] == 'B')
			count[2]--;

		vecll count2 = count;

		forll(j, i + 1, n - 1)
		{
			if (s[j] == 'R')
				count2[0]--;
			if (s[j] == 'G')
				count2[1]--;
			if (s[j] == 'B')
				count2[2]--;

			if (s[i] != s[j])
			{
				ll len = j - i;

				if (s[i] == 'R' || s[j] == 'R')
					color[0]=true;
				if (s[i] == 'G' || s[j] == 'G')
					color[1] = true;
				if (s[i] == 'B' || s[j] == 'B')
					color[2] = true;

				if (j + len >= n)
				{
					if (!color[0])
						ans += count2[0];
					if (!color[1])
						ans += count2[1];
					if (!color[2])
						ans += count2[2];
				}
				else
				{
					if (!color[0])
					{
						ans += count2[0];
						if (s[j + len] == 'R')
							ans--;
					}
					if (!color[1])
					{
						ans += count2[1];
						if (s[j + len] == 'G')
							ans--;
					}
					if (!color[2])
					{
						ans += count2[2];
						if (s[j + len] == 'B')
							ans--;
					}
				}

				forll(k, 0, 3)
					color[k] = false;
			}
		}
	}


	cout << ans << endl;

}

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


int main() {

    int n, m;
    cin >> n >> m;
    vector<int> a(m*2);
    rep(i,m*2) cin >> a[i];
    sort(a.begin(), a.end());
    for (int i = 1; i <= n; ++i) {
        int cnt = 0;
        rep(j,m*2) {
            if (i == a[j]) ++cnt;
        }
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T, class U> inline bool chmax(T& a,U b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class U> inline bool chmin(T& a,U b) { if (a > b) { a = b; return 1; } return 0; }

template<class VAL, class TIME> struct SlideMin {
    const VAL INF = numeric_limits<VAL>::max();
    const TIME null = -1;
    const pair<VAL, TIME> id = make_pair(INF, null);

    deque<pair<VAL, TIME>> data;

    SlideMin () { }

    pair<VAL, TIME> get () {
        return (data.empty() ? id : data.front());
    }

    void push (VAL v, TIME t) {
        while (not data.empty() and data.back().first >= v) data.pop_back();
        data.emplace_back(v, t);
    }

    void pop (TIME t) {
        while (not data.empty() and data.front().second < t) data.pop_front();
    }

};


int main() {
    int n, l;
    cin >> n >> l;
    vector<int> a(n);
    for (auto&e : a) cin >> e;
    
    SlideMin<int, int> sm;
    for (int i = 0; i < n; i++) {
        sm.push(a[i], i);
        if (i < l-1) continue;
        cout << sm.get().first << (i+1 == n ? '\n' : ' ');
        sm.pop(i-l+2);
    }
    return 0;
}


Measured memory_bytes: 6816
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a;
	for(int i=0;i<n;i++)
	{
		int tmp;
		cin >> tmp;
		a.push_back(tmp);
	}
	sort(a.begin(),a.end());
	int ans=a[0];
	while(1)
	{
		int count=0;
		for(int i=0;i<n;i++)
		{
			if(a[i]%ans!=0)
				ans=a[i]%ans;
			else
				count++;
		}
		if(count==n)
			break;
	}
	cout << ans << endl;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define rep(i, n) for(int i=0; i<n; ++i)
#define REP(i, n) for(int i=1; i<=n; ++i)
#define all(obj) (obj).begin(), (obj).end()
using P = pair<int, int>;
const int inf = 1e9;
const ll INF = 1e18;
const ll MOD = 1e9+7;
const ll MAX = 1e9+7;

int main(){
    int n; cin >> n;
    vector<vector<int>> dp(10, vector<int>(10, 0));
    int highest_digit, lowest_digit;
    int tmp;
    REP(i, n){
        lowest_digit = i % 10;
        tmp = i;
        while(tmp / 10 != 0){
            tmp /= 10;
        }
        highest_digit = tmp;
        dp[highest_digit][lowest_digit] += 1;
    }
    ll ans = 0;
    REP(i, 9){
        REP(j, 9){
            ans += ((ll)dp[i][j]) * ((ll)dp[j][i]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
                using namespace std;
                #define int long long
                #define fi first
                #define se second
                #define pi pair<int,int>  
                #define pb push_back

                // dont forget to initialize global variables inside main() ;
                int mod = 1e9 + 7;
                
                
                int32_t main() {
                
                ios::sync_with_stdio(false);
                cin.tie(0);
                cout.tie(0);

                int tt=1;//;cin>>tt; 
                
                
                while( tt-- ){

                    int d,t,s;
                    cin>>d>>t>>s;
                    if( d <= t*s )
                        cout<<"Yes"<<endl;
                    else
                        cout<<"No"<<endl;
                }
                return 0;
            }

                        


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

const int N = 1e6;

int pr[N];

void init() {
	fill(pr, pr + N, 1);
	for (int i = 2; i < N; i++) {
		for (int j = 2 * i; j < N; j += i) {
			pr[j] = 0;
		}
	}
}

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

    int x;
    cin >> x;
    init();
    while (!pr[x]) {
    	x++;
    }
    cout << x << endl;
}   


Measured memory_bytes: 4224