akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

ll n,m,q;
vl a(55),b(55),c(55),d(55);
vl score;
vl A(12,0);

void dfs(ll x, ll y){
	if(x < 0 || x > n-1 || y < 0 || y > m-1) return;
	A[x] = y+1;
	if(x == n-1){
		ll sum = 0;
		for(int i=0; i<q; i++){
			if(A[b[i]-1] - A[a[i]-1] == c[i]){
				sum += d[i];
			}
		}
		score.push_back(sum);
	}
	dfs(x+1,y);
	dfs(x,y+1);
}


int main(){
	cin >> n >> m >> q;
	rep(i,q) cin >> a[i] >> b[i] >> c[i] >> d[i];
	dfs(0,0);
	cout << *max_element(all(score)) << endl;
}

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

int main() {
    string s;
    bool flag = true;
    cin >> s;
    rep(i, s.size()) {
        if(i % 2 && s.at(i) == 'R') flag = false;
        if(!(i % 2) && s.at(i) == 'L') flag = false;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

#define REP(i,n) for(ll i=0; i<n; i++)
#define REPN(i,n) for(ll i=0; i<n; i++,cout<<"\n")
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod1 1000000007
#define ll long long
#define clr0(arr) memset(arr,0,sizeof(arr))
#define clrval(arr,val) memset(arr,val,sizeof(arr))
using namespace std;

void solve(){
	ll n;
	cin>>n;

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

	ll dp[n+1];
	clr0(dp);

	dp[1]=abs(a[1]-a[0]);

	for(ll i=2; i<n; i++){
		ll val1 = dp[i-1] + abs(a[i]-a[i-1]);
		ll val2 = dp[i-2] + abs(a[i]-a[i-2]);

		dp[i]=min(val1,val2);
	}

	cout<<dp[n-1]<<"\n";
}

int main(){
	// int t;
	// cin>>t;

	// while(t--){
		solve();
	// }

	return 0;
}


Measured memory_bytes: 5088
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	char b, a;
  	cin >> b;
  if ( b == 'A' ) cout << 'T';
  if ( b == 'C' ) cout << 'G';
  if ( b == 'T' ) cout << 'A';
  if ( b == 'G' ) cout << 'C';
}

Measured memory_bytes: 256
from itertools import combinations

N, X, Y = map(int, input().split())

A = [0] * N
for i, j in combinations(range(1, N + 1), 2):
    A[min(abs(i - j), abs(X - i) + abs(Y - j) + 1, abs(X - j) + abs(Y - i) + 1)] += 1

for a in A[1:]:
    print(a)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto x:v)cerr<<x<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define EPS 1e-9
typedef long long ll;

pair<long long,long long> extGCD(long long a,long long b){
  vector<long long> k;
  long long q;
  bool flag = 1;
  if(a < b)swap(a,b),flag = 0;
  while(b)k.push_back(a/b),q=a%b,a=b,b=q;
  long long x=0,y=1,u=1,v=-k[0],X,Y,U,V;
  for(long long i = 1;i < k.size();i++)X=x,Y=y,U=u,V=v,x=U,y=V,u=X-U*k[i],v=Y-V*k[i];
  if(flag)return make_pair(x,y);
  else return make_pair(y,x);
}

signed main(){
  ll a,b;
  cin >> a >> b;
  pair<ll,ll> p = extGCD(a,b);
  cout << p.first << ' ' << p.second << endl;
}


Measured memory_bytes: 3160
#include<bits/stdc++.h>
#define assn(n,a,b) assert(n<=b && n>=a)
using namespace std;
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define F first
#define S second
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,b) for(i=0;i<b;i++)
#define rep1(i,b) for(i=1;i<=b;i++)
#define pdn(n) printf("%d\n",n)
#define sl(n) scanf("%lld",&n)
#define sd(n) scanf("%d",&n)
#define pn printf("\n")
typedef pair<int,int> PII;
typedef vector<PII> VPII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long long LL;
#define MOD 1000000007
LL mpow(LL a, LL n)
{LL ret=1;LL b=a;while(n) {if(n&1)
    ret=(ret*b)%MOD;b=(b*b)%MOD;n>>=1;}
return (LL)ret;}
#define MAXK 100000
#define MAXN 1000000000
int ar[MAXK];
typedef unsigned long long int ULL;
#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()
bool isSafe(int r, int c, vector<vector<int> > arr) {
	int n = arr.size();
	int m = arr[0].size();
	return (r>=0 && r<n && c>=0 && c<m);
}
LL gcd(LL a,LL b){if(b==0) return a;a%=b;return gcd(b,a);} 
/////////////////////////////////////////////////////////////

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    LL i,j,k,l,n,m,q,d,a,b,c,ans,tot,mx=INT_MIN,mn=INT_MAX;
    cin>>a>>b>>c>>k;
    tot=0;
    if(k<=a) tot=k;
    else {
    	tot=a;
    	if(k>a+b) {
    		tot -= k-a-b;
    	}
    }
    cout<<tot;
    
    
    return 0;
}



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

const long double PI = acos(-1);
constexpr long double EPS = 1e-15;
constexpr int inf = 2e9;
constexpr ll INF = 2e18;
constexpr ll MOD = 1e9+7;
constexpr ll MOD1 = 998244353;
typedef pair<ll,ll> P;

//#define all(v) (v).begin(), (v).end()
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
//#define mp make_pair

void solve() {
  int n,m;
  cin >> n >> m;
  vector<ll> s[m];
  REP(i,m) {
    int k;
    cin >> k;
    REP(j,k) {
      ll tmp;
      cin >> tmp;
      s[i].pb(tmp-1);
    }
  }
  int p[m];
  REP(i,m) cin >> p[i];

  int ans = 0;
  for (ll i = 0; i < (1LL << n); i++) {
    int cnt = 0;
    for (int j = 0; j < m; j++) {
      int num = 0;
      for (int k = 0; k < s[j].size(); k++) {
        if (i & (1LL << s[j][k])) num++;
      }
      if (num % 2 == p[j]) cnt++;
      // cout << " " << num << " " << p[j] << endl;
    }
    if (cnt == m) ans++;
    // cout << i << " " << cnt << endl;
  }
  cout << ans << endl;
}

int main(int argc, char *argv[]){
  int case_num = 1;
  // while (1) if (solve()) break;
  if (argc > 1 && stoi(argv[1])) cin >> case_num;
  REP(case_no, case_num) {
    cerr << endl << "case " << case_no + 1 << endl;
    solve();
  }
  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 x = sc.nextInt();
    		if(x<1200) {
    			System.out.println("ABC");
    		}
    		else{
    			System.out.println("ARC");
    		}
    	}
    }

Measured memory_bytes: 22612
// problem: "https://atcoder.jp/contests/abc125/tasks/abc125_d"

#include<iostream>
#include<vector>
#include<limits.h>
#include<math.h>
#define ll long long

using namespace std;

vector<vector<ll>>dp(100001,vector<ll>(2,LONG_MIN));

ll maxim(int i,int x,vector<ll>&V)
{
    if(i == V.size()-1)
        return pow(-1,x)*V[i];

    if(dp[i][x] == LONG_MIN)
        dp[i][x] = max(pow(-1,x)*V[i]+maxim(i+1,0,V),pow(-1,x+1)*V[i]+maxim(i+1,1,V));

    return dp[i][x];
}

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

    vector<ll>V(n);
    int i;
    for(i=0;i!=n;i++)
        cin>>V[i];

    cout<<maxim(0,0,V);

    return 0;
}


Measured memory_bytes: 15872
from sys import stdin, stdout 
def main(): 
	n = stdin.readline() 
	arr = [int(x) for x in stdin.readline().split()] 
	ok = 0
	pro = 1 
	INF = 1e18
	for x in arr:
		if(x == 0):
			ok = 1
	if(ok==1):
		return 0 
	else:
		for x in arr:
			pro = pro*x ;
			if(pro > INF):
				return -1
	return pro
# call the main method 
if __name__ == "__main__": 
	ans = main()
	stdout.write(str(ans))


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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<ll,ll>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

int N;
int A[200100];
std::vector<P> B;

ll rmb(int n){
    ll res = 0;
    while(n > 0){
        res = n & -n;
        n -= n & -n;
    }
    return res;
}

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

    std::cin >> N;

    for(int i=0;i<N;++i){
        std::cin >> A[i];
    }

    std::sort(A, A+N);

    for(int i=0,j=0;i<N;i=j){
        while(j < N && A[j] == A[i]){
            ++j;
        }

        B.emplace_back(A[i], j - i);
    }

    int M = B.size();
    int res = 0;
    for(int i=M-1;i>=0;--i){
        ll a1, c1;
        std::tie(a1, c1) = B[i];

        ll sum = rmb(a1) * 2;
        int j = std::lower_bound(B.begin(), B.end(), std::make_tuple(sum - a1, -1)) - B.begin();

        if(j >= M || a1 + fst(B[j]) != sum){
            continue;
        }

        if(j == i){
            res += c1 / 2;
        }else{
            int n = std::min(c1, snd(B[j]));
            res += n;
            snd(B[j]) -= n;
        }
    }

    std::cout << res << std::endl;
}


Measured memory_bytes: 7280
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    ll n,k;
    cin>>n>>k;

    n=n%k;
    while(abs(n-k) < n)
    {
        n=abs(n-k);
    }
    cout<<n<<"\n";
return 0;
}


Measured memory_bytes: 384
N = int(input())
P = list(map(int, input().split()))

def swap(i, j):
    return j, i

now = P[0]
count = 0
for i in range(N-1):
    after = P[i+1]
    if now == i+1:
        now, after = swap(now, after)
        count += 1    
    now = after

if now == N:
    count += 1
    
print(count)

Measured memory_bytes: 83984
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#include<map>
#include<cstring>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = int(1e9);
typedef long long int ll;

/* -- template -- */
int main(){
    int N; cin >> N;
    string S[N];
    rep(i, N)cin >> S[i];
    sort(S, S + N);
    map<string, int> a;
    rep(i, N)a[S[i]] += 1;
    int maxv = 0;
    rep(i, N)maxv = max(maxv, a[S[i]]);
    rep(i, N)if(maxv == a[S[i]])cout << S[i] << endl,a[S[i]] = 0;
}


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

int main(){
  char C;
  cin >> C;
  if(C=='A'){
    cout << 'T' << endl;
  }
  else if(C=='T'){
    cout << 'A' << endl;
  }
  else if(C=='G'){
    cout << 'C' << endl;
  }
  else{
    cout << 'G' << endl;
  }
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
//#define ll long long
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define rep_rev(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
ll t1,t2,t3;
const ll mod = 998244353;
const int INF = 1e9;
const ll INFLONG = 1e18;

ll calc_n(ll k){
  ll ret = 1;
  while(ret * (ret+1) / 2 <= k){
    ret++;
  }
  return ret-1;
}

int main(){
  ll n;
  cin >> n;
  ll ans = 0;
  ull len = sqrt(n);
  REP(i,2,len+1){
    ll sum = 0;
    while(n % i == 0){
      n /= i;
      sum++;
    }
    ans += calc_n(sum);
  }
  if(n != 1){
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3680
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define  _CRT_SECURE_NO_DEPRECATE
using namespace std;
#define maxv 100005
#define che 1LL<<32
#define modi 1000000007
int main()
{
    ll n,d,i,j,k;
    cin>>n>>d;
    ll x[n][d];
    for(i=0;i<n;i++)
        for(j=0;j<d;j++)
            cin>>x[i][j];
    ll c=0;
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            ll dist=0;
            for(k=0;k<d;k++)
                dist+=((x[i][k]-x[j][k])*(x[i][k]-x[j][k]));
            ll xx=sqrt(dist);
            if(xx==(double)(sqrt(dist)))
                c++;
        }
    }
    cout<<c<<endl;
}

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

#define pb push_back
#define F first
#define S second
#define y1 dasdasfasfas
#define x1 wqdadfasfasfas
#define All(c) c.begin(), c.end()
#define SZ(A) (int((A).size()))
#define umap unordered_map
#define __ fflush(stdout)
#define FILENAME ""

typedef long long ll;
typedef long double ld;    

using namespace std;

void FREOPEN() {
	#ifdef LOCAL
		freopen(".in", "r", stdin);
		freopen("1.out", "w", stdout);
	#else
		//freopen(FILENAME".in", "r", stdin);
		//freopen(FILENAME".out", "w", stdout);
	#endif
}

inline double Time() {return (clock() * 1.0) / CLOCKS_PER_SEC; }             

const int N = 200500, inf = 1e9 * 2;

const ll MOD = 1e9 + 7ll, INF = 1e18;

const int dx[] = {1, -1, 0, 0, -1, 1, -1, 1};
const int dy[] = {0, 0, 1, -1, -1, 1, 1, -1};

ll dp[2][N];

int w[N], v[N];

int main() {
	FREOPEN();
	int n, W;
	cin >> n >> W;
	for (int i = 1; i <= n; i++) scanf("%d %d", w + i, v + i);
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= W; j++) {
			dp[i & 1][j] = dp[(i - 1) & 1][j];
			if (j >= w[i])
				dp[i & 1][j] = max(dp[i & 1][j], dp[(i - 1) & 1][j - w[i]] + v[i]);
		}
	}
	ll ans = 0;
	for (int i = 0; i <= W; i++) ans = max(ans, dp[n & 1][i]);
	printf("%lld ", ans);
	return 0;
}


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

int main() {
    int n, a, b;
    while(cin >> n, n){
        a = 0;
        b = 0;
        REP(i,n){
            int x, y;
            cin >> x >> y;
            if(x>y) a += x+y;
            else if(x<y) b += x+y;
            else {
                a += x;
                b += y;
            }
        }
        cout << a << " " << b << endl;
    }
    return 0;
}   



Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int arr[N];
int main()
{
    int n;
    cin >> n;
    for(int i = 0; i < n; ++i) {
        scanf("%d", &arr[i]);
    }
    stack<int> st;
    int cnt = 0;
    for(int i = 0; i < n; ++i) {
        if(st.empty()) {
            st.push(arr[i]);
            ++cnt;
        } else {
            while(st.size() && arr[i] < st.top()) {
                st.pop();
            }
            if(st.empty()) cnt++;
            st.push(arr[i]);
        }
    }
    cout << cnt << endl;
    return 0;
}

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

int main(int argc, char const* argv[])
{
	int n, x;
	while (cin >> n >> x && (n != 0 || x != 0)) {
		int ans = 0;
		for (int i=1; i<=n-2; i++) {
			for (int j=i+1; j<=n-1; j++) {
				for (int k=j+1; k<=n; k++) {
					if (i + j + k == x) {
						ans++;
						break;
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<cmath>
#include<random>
#include<string.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(vector<T> s) {
	auto itr = s.begin();
	cout << *(itr++);
	while (itr != s.end()) {
		cout << " " << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

int main() {
	int kami = 0;
	bool futsu = false;
	int gomi = 0;
	makei(N);
	rep(N) {
		makei(a);
		if (a % 4 == 0)++kami;
		else if (a % 2 == 0)futsu = true;
		else ++gomi;
	}
	if (futsu) yn(kami >= gomi);
	else yn(kami + 1 >= gomi);
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;
typedef long double ld;

string S;

int main(){
    cin>>S;

    rep(i,3) cout<<S[i];
    cout<<endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <ctype.h>
#include <algorithm>
#include <cmath>
 
#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define square(x) (x) * (x)
 
const int INF = 1e9;
 
using namespace std;
 
int main() {
    long double x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    long double result = sqrt(square(x2 - x1) + square(y2 - y1));
    cout << setprecision(10);
    cout << result << endl;
 
    return 0;
}

Measured memory_bytes: 1280
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

/*BigInteger
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
namespace xxx = boost::multiprecision;
using Bint = xxx::cpp_int;
using Real = xxx::number<xxx::cpp_dec_float<1024>>;
*/

#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0LL, sizeof(x))
#define mm(x) memset((x), -1LL, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define Bit(n) (1LL << (n))
#define Bitset(a, b) (a) |= (1LL << (b))
#define Bitunset(a, b) (a) &= ~(1LL << (b))
#define Bitcheck(a, b) ((((a) >> (b)) & 1LL) == 1LL)
#define Bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
constexpr int INF = (int)1e18;
constexpr int MOD = (int)1e9 + 7;
constexpr double PI = (double)acos(-1);
constexpr double EPS = (double)1e-10;
constexpr int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
constexpr int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
template <typename T>
void chmax(T &a, T b) { a = max(a, b); }
template <typename T>
void chmin(T &a, T b) { a = min(a, b); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
} Accelerate_Cin;

int M, K;

signed main() {
  cin >> M >> K;
  if (M == 0) {
    if (K == 0) {
      cout << 0 << " " << 0 << endl;
    } else {
      cout << -1 << endl;
    }
    return 0;
  }

  if (Bit(M) <= K) {
    cout << -1 << endl;
    return 0;
  }

  if (K == 0) {
    for (int i = 0; i < Bit(M + 1); i++) {
      if (i != 0) cout << " ";
      cout << i / 2;
    }
    cout << endl;
    return 0;
  }

  int tmp = 0;
  for (int i = 0; i < Bit(M); i++) {
    if (i != K) tmp ^= i;
  }

  if (tmp != K) {
    cout << -1 << endl;
    return 0;
  }

  vector<int> v;
  for (int i = 0; i < Bit(M); i++) {
    if (i != K) v.push_back(i);
  }
  vector<int> rev = v;
  reverse(ALL(rev));
  v.push_back(K);
  rev.push_back(K);

  for (auto x : v) cout << x << " ";
  for (int i = 0; i < rev.size(); i++) {
    if (i != 0) cout << " ";
    cout << rev[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 4080
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define F first
#define S second
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define REV(i,a,n) for(int i=a;i>=n;i--)
#define all(a) a.begin(),a.end()
#define UB upper_bound
#define LB lower_bound
const int NUM = 2e5 + 5;

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int num_tests=1; 
    //cin >> num_tests;
    while(num_tests-->0){
        int n; cin >> n;
        vector<int> a(n);
        FOR(i,0,n) cin >> a[i];
        vector<int> ans(n,0);
        ans[1] = abs(a[1] - a[0]);
        FOR(i,2,n){
            ans[i] = min(abs(a[i] - a[i-1]) + ans[i-1], abs(a[i] - a[i-2]) + ans[i-2]);
        }
        cout << ans[n-1] ;
    }   
}

Measured memory_bytes: 4744
#include<cstdio>
#include<iostream>
using namespace std;
int num[1000000];
int main()
{
	int n, k, ans = 0, sans=0;
	while (1)
	{
		scanf("%d%d", &n, &k);
		if (n == 0 && k == 0)
			break;
		for (int i = 0; i < n; i++)
		{
			scanf("%d", &num[i]);
		}
		for (int i = 0; i < n - k; i++)
		{
			for (int j = i; j < i + k; j++)
			{
				sans += num[j];
			}
			if (ans < sans)
				ans = sans;
			sans = 0;
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 3520
#include <iostream>
#include <utility>
#include <set>
#include <algorithm>

using namespace std;

typedef pair<int, int> pii;
typedef multiset<int> si;

int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    int p[n];
    pii pi[n];
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        pi[i] = {p[i], i};
    }
    sort(pi, pi+n);
    reverse(pi, pi+n);

    si s;
    s.insert({-1, -1, n, n});
    int left1[n], left2[n], right1[n], right2[n];
    for (int i = 0; i < n; i++) {
        int x = pi[i].second;
        auto it = s.lower_bound(x);
        left1[x] = *prev(it);
        left2[x] = *prev(prev(it));
        right1[x] = *it;
        right2[x] = *next(it);

        s.insert(x);
    }

    long long ans = 0;
    for (int i = 0; i < n; i++) {
        ans += p[i] * (  1ll * (left1[i] - left2[i]) * (right1[i] - i)
                       + 1ll * (right2[i] - right1[i]) * (i - left1[i]));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 7680
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long int 
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define from(i,n)       for(int i=1;i<=(int)n;i++)
#define from_j(i,j,n)   for(int i=j;i<(int)n;i++)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int max_value[101][100001]={0};
int weight[101]; 
int value[101]; 
int n,w; 
void solve(){
    for(int i=1;i<=n;i++){
        for(int j=1;j<=w;j++){
            if(weight[i]<=j){
                int temp = value[i]+max_value[i-1][j-weight[i]];
                max_value[i][j] = max(temp,max_value[i-1][j]);
            }
            else{
                max_value[i][j] = max_value[i-1][j];
            }
            // cout<<i<<" "<<j<<" "<<max_value[i][j]<<"\n";
        }
    }
}
 
int32_t main()
{
    c_p_c();
    cin>>n>>w;
    from(i,n)cin>>weight[i]>>value[i];
    // from(i,n)
    solve();
    cout<<max_value[n][w];
    
    
    
    return 0;
}

Measured memory_bytes: 78464
/*
        Author: Prokash
                CSE48, JU

*/

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

typedef long long ll;
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int ara[2005];
int main()
{
    FAST;
    int n,cnt=0;
    string str;
    cin>>n>>str;
    for(int i=1;i<n;i++)
    {
        if(str[i]=='E')
        {
            cnt++;
        }
    }
    int mn=cnt;
    for(int i=1;i<n;i++)
    {
        if(str[i-1]=='W')
        {
            cnt++;
        }
        if(str[i]=='E')
        {
            cnt--;
        }
        mn=min(cnt,mn);
    }
    cout<<mn<<endl;
    return 0;
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = 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;i >= n;i--)
#define INF 999999999
 
ll max(ll a, ll b){
	if (a>b) return a;
	else return b;
}
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b, c;
	cin >> a >> b >> c;
	if (a+b >= c){cout << "Yes" << endl;}
	else {cout << "No" << endl;}
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================



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

    ll N, P;
    cin >> N >> P;

    string S;
    cin >> S;

    reverse(S.begin(), S.end());

    Vl SS(N);
    ll base = 1;
    for (int i = 0; i < N; i++) {
        SS[i] = (S[i] - '0') * base % P;
        base = base * 10 % P;
    }

    Vl T(N + 1);
    for (int i = 0; i < N; i++) {
        T[i + 1] = (T[i] + SS[i]) % P;
    }

    unordered_map<ll, ll> mp;
    for (int i = 0; i < N + 1; i++) {
        ++mp[T[i]];
    }

    ll ans = 0;
    for (const auto& u : mp) {
        ll num = u.second;
        ans += num * (num - 1) / 2;
    }

    if (P == 2 || P == 5) {
        ans = 0;
        for (int i = 0; i < N; i++) {
            if ((S[i] - '0') % P == 0) {
                ans += N - i;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3988
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		int m = int.Parse(input[1]);
    long[] numsn = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
    long[] numsm = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
    long mod = 1000000007;

		Console.WriteLine(SubstringPairCount(numsn,numsm,mod));
	}

  static long SubstringPairCount(long[] a, long[] b, long mod)
  {//空集合を含む共通部分列の組の個数(mod)
    int n = a.Length;
    int m = b.Length;
    long[,] dp1 = new long[n+2,m+2];
    long[,] dp2 = new long[n+2,m+2];
    dp1[0,0] = 1;

    for(int i = 0; i <= n; i++)
    {
      for(int j = 0; j <= m; j++)
      {
        dp1[i+1,j] += dp1[i,j];
        dp1[i+1,j] %= mod;
        dp2[i,j] += dp1[i,j];
        dp2[i,j] %= mod;
        dp2[i,j+1] += dp2[i,j];
        dp2[i,j+1] %= mod;
        if(i < n && j < m)
        {
          if(a[i] == b[j])
          {
            dp1[i+1,j+1] += dp2[i,j];
            dp1[i+1,j+1] %= mod;
          }
        }
      }
    }

    return dp2[n,m];
  }
  
}

Measured memory_bytes: 73816
while True:
  n,x = map(int, input().split())
  if n==0 and x==0:
    break
  ans = 0
  for i in range(1,n+1):
    for j in range(1,n+1):
      if j >= i:
        continue
      for k in range(1,n+1):
        if k >= j:
          continue
        if i+j+k == x:
          ans += 1
  print(ans)


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

int main() {
	int n, x;
	cin >> n >> x;
	
	int ans = 0;
	int dist = 0;
	rep(i, n) {
		if(dist <= x)ans++;
		int l;
		cin >> l;
		dist += l;
	}
	if (dist <= x)ans++;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,n) for(int i=(a); i<(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

int main(){
  int A, B, K; cin >> A >> B >> K;
  vector<bool> chk(B+1,0);
  int count=0;
  for(int i=A; i<=B; i++){
    chk[i]=1;
    count++;
    if(count == K) break;
  }
  count = 0;
  for(int i=B; i>=A; i--){
    chk[i]=1;
    count++;
    if(count == K) break;
  }
  
  for(int i=A; i<=B; i++){
    if(chk[i]) cout << i << endl;
  }
  
}
  

Measured memory_bytes: 125224
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int ar[200005];
int br[200005];
int main()
{
    ll r,s,i,j,mx,m;
    ll ans;
    cin>>r;
    for(i=0;i<r;i++){
        cin>>ar[i];
        br[i]=ar[i];
    }
    sort(ar,ar+r);
    for(i=0;i<r;i++){
        if(ar[r-1]==br[i])cout<<ar[r-2]<<endl;
        else
            cout<<ar[r-1]<<endl;
    }

    return 0;
}



Measured memory_bytes: 3200
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <numeric>
#include <complex>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


constexpr int R = 50000;

void func(const string &a, const string &b, int offset, bool *ok) {
	for (int ib = 0; ib < (int)b.size(); ib++) {
		int ia = offset + ib;
		ok[offset + R] &=
			ia < 0 || ia >= a.size() || a[ia] == '?' || b[ib] == '?' || a[ia] == b[ib];
	}
}

bool ab[2*R], ac[2*R], bc[2*R];

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	for (int i = 0; i < 2*R; i++) {
		ab[i] = ac[i] = bc[i] = true;
	}
	for (int i = -R; i < R; i++) func(a, b, i, ab);
	for (int i = -R; i < R; i++) func(a, c, i, ac);
	for (int i = -R; i < R; i++) func(b, c, i, bc);
	int ans = 1e9;
	for (int i = -4000; i <= 4000; i++) {
		for (int j = -4000; j <= 4000; j++) {
			if (ab[i + R] && ac[j + R] && bc[j - i + R]) {
				int l = min({ 0, i, j });
				int r = max({ (int)a.size(), i + (int)b.size(), j + (int)c.size() });
				ans = min(ans, r - l);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main()
{
    int a,b,c;
    cin >> a;
    if(a == 1){
        cout << "Hello World";
    }
    else {
        cin >> b >> c;
        cout << b + c;
    }
    return 0;
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
const ll INF = 1e10;

int main() {
    int n; cin >> n;
    string s; cin >> s;
    bool flag = false;
    vector<char> ans;

    for (int bit = 0; bit < 4 ; bit ++) {
        ans = {};
        int ani0 = (bit>>0)&1;
        int ani1 = (bit>>1)&1;

        if (ani0) ans.push_back('W');
        else ans.push_back('S');
        if (ani1) ans.push_back('W');
        else ans.push_back('S');
        
        int before1 = ani1;
        int before2 = ani0;
        for (int i = 0; i < n - 1 ; i ++ ) {
            int tmp;
            if (s.at(i + 1) == 'o') tmp = before1^before2;
            else tmp = before1^before2^1;

            before2 = before1;
            before1 = tmp;

            if (i != n - 2) {
                if (before1) ans.push_back('W');
                else ans.push_back('S');
            }
        }
        
        int tmp;
        if (s.at(0) == 'o') tmp = before1^before2;
        else tmp = before1^before2^1;

        before2 = before1;
        before1 = tmp;

        if (before1 == ani1 && before2 == ani0) {
            flag = true;
            break;
        }
    }

    if (flag) {
        for (int i = 0; i < n; i ++) cout << ans[i];
        cout << '\n';
    }
    else cout << -1 << endl;
}



Measured memory_bytes: 768
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<cmath>
 
#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
 
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9
#define MOD 1000000007
 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef std::pair<ll, ll> P;
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}

typedef std::pair<ll, ll> P;
 
using namespace std;

int main(){
    ll n;
    cin >> n;
    vector<ll> x(n), y(n);
    rep(i, n){
        cin >> x[i];
        y[i] = x[i];
    }
    sort(all(y));

    rep(i, n){
        if(x[i] >= y[(n+1)/2]){
            cout << y[(n-1)/2] << endl;
        }else cout << y[(n+1)/2] << endl;
    }
}

Measured memory_bytes: 5376
#include <iostream>

using namespace std;

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

int main(){
 
  int n;
  int a[200];
  int ans = 0;
  
  cin >> n;
  
  rep(i, n){
    cin >> a[i];
  }
  
  for(int i = 0;;){
    if(a[i] % 2){
      break;
    }
    a[i] /= 2;
    i++;
    if(i == n){
      ans++;
      i = 0;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> va(n+1);
    vector<int> vb(n);
    for (int i=0; i<n+1; i++)
        cin >> va[i];
    for (int j=0; j<n; j++)
        cin >> vb[j];
    long long sum = 0;
    for (int i=0; i<n; i++)
    {
        int x = min(va[i], vb[i]);
        sum += x;
        vb[i] -= x;
        x = min(va[i+1], vb[i]);
        sum += x;
        va[i+1] -= x;
    }
    cout << sum;
    
    return 0;
}

Measured memory_bytes: 1024
N, x = map(int, input().split())
A = list(map(int, input().split()))
ans = 0

if A[0] > x:
    ans += A[0] - x
    A[0] = x

for i in range(N-1):
    if A[i] + A[i+1] > x:
        dif = A[i] + A[i+1] - x
        A[i+1] -= dif
        ans += dif

print(ans)

Measured memory_bytes: 14052
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace ConsoleApplication32
{
    class Program
    {  
      static void Main()
      {
		  double a = double.Parse(Console.ReadLine());
		  Console.WriteLine("{0} {1}",Math.PI*a*a,a*2*Math.PI);
		  		}
	 }
 }

      
      

Measured memory_bytes: 9196
from collections import defaultdict
from functools import reduce

n, a, b = map(int, input().split())

MOD = 10 ** 9 + 7

def mul(a, b):
  return ((a % MOD) * (b % MOD)) % MOD

def power(x, y):
  if y == 0:
    return 1
  elif y == 1:
    return x % MOD
  elif y % 2 == 0:
    return power(x, y // 2) ** 2 % MOD
  else:
    return mul(power(x, y // 2) ** 2, x)

def div(a, b):
  return mul(a, power(b, MOD - 2))

def dict1():
  return {0: 1}

numer_cache = defaultdict(dict1)
denom_cache = dict1()

def combinations_count(n, r):
  r = min(r, n - r)

  r2 = max(x for x in numer_cache[n] if x <= r)
  if r2 < r:
    numer_cache[n][r] = reduce(mul, range(n - r2, n - r, -1), numer_cache[n][r2])
  numer = numer_cache[n][r]

  r3 = max(x for x in denom_cache if x <= r)
  if r3 < r:
    denom_cache[r] = reduce(mul, range(r3 + 1, r + 1), denom_cache[r3])
  denom = denom_cache[r]

  return div(numer, denom)

r1 = min(a, n - a)
r2 = min(b, n - b)

if r1 > r2:
  r1, r2 = r2, r1

print((power(2, n) - 1 - combinations_count(n, r1) - combinations_count(n, r2)) % MOD)


Measured memory_bytes: 3684
#python3
import collections as col
n,m=map(int, input().split())
l=[]
for i in range(m):
  x,y=map(int, input().split())
  l.extend([x,y])

d=col.defaultdict(int, col.Counter(l))

for i in range(1,n+1):
  print(d[i])

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {
	static int maxn = 300 + 10;

	public static void main(String[] args) 
	{
		Scanner cin = new Scanner(System.in);
		int numa,numb;
		String stra,strb;
		stra=cin.next();
		strb=cin.next();
		numa=cin.nextInt();
		numb=cin.nextInt();
		String temp=cin.next();
		if(temp.equals(stra))
		{
			numa--;
		}
		else if(temp.equals(strb))
		{
			numb--;
		}
		System.out.println(numa+ " "+numb);
	}

}

Measured memory_bytes: 23124
s=input()
if "M" in s:
    print("6")
elif "D" in s:
    print("4")
elif "E" in s:
    print("5")
elif "H" in s:
    print("3")
elif "F" in s:
    print("2")
elif "A" in s:
    print("1")
else:
    print("7")

Measured memory_bytes: 9032
#include <iostream> 
#include <list>

using namespace std;

int main(int argc, char *argv[]) {
	int N;
	cin >> N;
	list<int> b;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		if (i % 2 == 0) b.push_back(a);
		else b.push_front(a);
	}

	if (N % 2 != 0) b.reverse();

	for (auto i : b) printf("%d ", i);
	printf("\n");

	return 0;
}

Measured memory_bytes: 8448
n = int(input())
s = []

mrch = ["M","A","R","C","H"]
memo = [0 for i in range(5)]

for i in range(n):
    a = list(input())
    for j in range(5):
        if a[0] == mrch[j]:
            memo[j] += 1

ans = 0
for i in range(2**5):
    cnt = 0
    memo2 = 1
    for j in range(5):
        #print(bin(i)," ",i," ",j," ",i>>j)
        if (i >> j) & 1:
            #print(bin(i)," ",i," ",j," ",i>>j)
            cnt += 1
            memo2 *= memo[j]
    if cnt == 3:
        ans += memo2
        #print(bin(i))

print(ans)

Measured memory_bytes: 3064
//  RAKSHIT KADAM

 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
#warning !!!check the size of arrayss!!!
 
// NUMERIC DEFINITIONS :
    #define INF 100000000000000005
    #define inf 1000000004
    #define MOD  1000000007
    #define newMOD  998244353
    #define MAX 300006
    #define pi 3.1415926535897932384626433832795
#define ld long double
 #define ll long long
 #define int long long
 
 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>
 
 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
 
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;return (y%2 == 0)? p : (x * p) % m;}
ll modInverse(int a, int m){{ return power(a, m-2, m);}}
const int maxn = 500003;
// ll fact[1000005];
//void facto()
//{
//    ll lim =1000005;fact[0]=1;
//    for(ll i=1;i<lim;i++)
//    {
//        fact[i]=(fact[i-1]*i)%MOD;
//    }
//}
//ll ncr(ll a,ll b)
//{
//    ll ret = 0;
//    ret = fact[a]*(modInverse(fact[b],MOD));
//    ret%=MOD;
//    ret*=modInverse(fact[a-b],MOD);
//    ret%=MOD;
//    return ret;
//}
void solve(ll tt)
{
    
    cout<<"Case #"<<tt<<":"<<endl;
    
}

void s()
{
    ll n,k;cin>>n>>k;
    ll a[n];
    for(ll i=0;i<n;i++)cin>>a[i];
    for(ll i=k;i<n;i++)
    {
        if(a[i]>a[i-k])
        {
            cout<<"Yes"<<endl;
        }
        else cout<<"No"<<endl;
    }
}

signed main()
{
   Need_for_speed(activated);
//    input;
//    ll ttt;cin>>ttt;
//    for(ll tt=1;tt<=ttt;tt++)
//    {
//  solve(tt);
//   }
    
//    solve();
    s();
//    satisfy{s();}
    return 0;
}
//Concentrate while implementing,,,!!!
 


Measured memory_bytes: 5204
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), k = scanner.nextInt();
			char[] s = scanner.next().toCharArray();
			List<Block> list = new ArrayList<>();
			int max = 0;
			// 直前に1があるかどうか
			boolean prevOne;
			if (s[0] == '0') {
				list.add(new Block(k, 0, 0));
				prevOne = true;
			} else {
				prevOne = false;
			}
			for (int i = 0; i < s.length; i++) {
				if (prevOne && ('0' == s[i])) {
					for (int j = 0; j < list.size(); j++) {
						Block result = list.get(j);
						if (result.k > 0) {
							result.k--;
						} else {
							// 反転できる回数が0になったら
							result.count = i - result.start;
							if (result.count > max) {
								max = result.count;
							}
							list.remove(j);
							j--;
						}
					}
					prevOne = false;
				} else if (!prevOne && ('1' == s[i])) {
					if (i < n - max) {
						list.add(new Block(k, i, 0));
					}
					prevOne = true;
				}
			}
			if (!list.isEmpty()) {
				Block result = list.get(0);
				result.count = n - result.start;
				if (result.count > max) {
					max = result.count;
				}
			}
			System.out.println(max);
		}
	}

	/**
	 * 0の連続したブロックを表すクラス
	 */
	private static class Block {
		/** 反転できる回数 */
		int k;
		/** 開始index */
		int start;
		/** 連続した長さ */
		int count;

		Block(int k, int start, int count) {
			super();
			this.k = k;
			this.start = start;
			this.count = count;
		}
	}
}


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

int main(void){
  int n,m; cin >> n >> m;
  int l[m],r[m];
  rep(i,m) cin >> l[i] >> r[i];
  sort(l,l+m);
  sort(r,r+m);
  if(r[0] - l[m-1] + 1 > 0) cout << r[0] - l[m-1] + 1 << endl;
  else cout << 0 << endl;
  return 0;
}


Measured memory_bytes: 1024
#[allow(unused_macros)]
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

fn main() {
    input! {
        n: usize,
        a_: [i32; n],
    }
    let mut a = a_.clone();
    a.sort();
    a.reverse();

    let mut ret = 0;
    for i in 0..a.len() {
        if i % 2 == 0 {
            ret += a[i];
        } else {
            ret -= a[i];
        }
    }

    println!("{}", ret);
}


Measured memory_bytes: 2192
/*input
23
00110111001011011001110
*/
#include <bits/stdc++.h>
#define pb push_back
#define x first
#define y second
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define rd() abs((int)rng())
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
const int maxn = 2e5 + 100;
const int mod = 1e9 + 7;
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0);
	int n;
	cin >> n;
	string X;
	cin >> X;
	int ones = 0;
	for (char c : X) {
		ones += (c == '1');
	}

	vector<int>pw1(n), pw2(n);
	pw1[0] = pw2[0] = 1;

	int fi = 0, se = 0;
	reverse(all(X));
	for (int i = 0; i < n; i++) {
		if (i > 0) {
			if (ones - 1 != 0)
				pw1[i] = pw1[i - 1] * 2 % (ones - 1);
			pw2[i] = pw2[i - 1] * 2 % (ones + 1);
		}
		if (X[i] == '1') {
			if (ones - 1 != 0)
				fi = (fi + pw1[i]) % (ones - 1);
			se = (se + pw2[i]) % (ones + 1);
		}
	}

	vector<int>num(n);
	for (int i = 0; i < n; i++) {
		if (X[i] == '1') {
			if (ones - 1 == 0) {
				num[i] = 0;
			} else {
				num[i] = ((fi - pw1[i]) % (ones - 1) + (ones - 1)) % (ones - 1);
			}
		} else {
			num[i] = (se + pw2[i]) % (ones + 1);
		}
	}

	for (int i = n - 1; i >= 0; i--) {
		if (X[i] == '1' && ones == 1) {
			cout << "0\n";
			continue;
		}
		int a = num[i], ans = 1;
		while (a > 0) {
			int pcount = __builtin_popcount(a);
			a = a % pcount;
			++ans;
		}
		cout << ans << "\n";
	}
	return 0;
}

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

const int64_t MOD = 1e9+7;

int main(){
  int N;
  cin >> N;
  vector<int64_t> vec(N);
  vector<int64_t> sum(N);
  for(int i=0; i<N; i++){
    cin >> vec[i];
  }
  
  for(int i=1; i<N; i++){
    sum[i] = sum[i-1] + vec[i-1];
  }
  
  int64_t ans = 0;
  
  for(int i=0; i<N; i++){
    ans += (sum[i] % MOD) * vec[i];
    ans %= MOD;
  }
  
  cout << ans << endl;
}
  

Measured memory_bytes: 6412
N = int(input())
A = [int(input()) for i in range(N)]

max1 = max(A[0], A[1])
max2 = min(A[1], A[0])
if A[0] > A[1]:
    maxi1 = 0
    maxi2 = 1
else:
    maxi1 = 1
    maxi2 = 0


for i, a in enumerate(A[2:], 2):
    if max1 < a:
        max2 = max1
        maxi2 = maxi1
        max1 = a
        maxi1 = i
    elif max2 < a:
        max2 = a
        maxi2 = i

for i in range(N):
    if i != maxi1:
        print(max1)
    else:
        print(max2)



Measured memory_bytes: 12588
object Main extends App {
  val inputLine = io.StdIn.readLine()
  val arr = inputLine.split(" ")
  val intArr = arr.map(_.toInt)

  def waru(A: Int, B: Int, C: Int): Unit = {
    val Answer = B / A
    if (Answer >= C) {
      println(C)
    } else {
      println(Answer)
    }
  }

  waru(intArr(0), intArr(1), intArr(2))
}

Measured memory_bytes: 25408