akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int a, b, w, ans;

int main()
{
	int ans;
	cin >> w >> a >> b;
	if(b + w <a)
		ans = a - (b + w);
	if(a + w < b)
		ans = b - a - w;
	cout << ans << endl;
    return 0;
}

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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = 1e9+7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }






int main(){
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VL a(n);
	rep(i, n) cin >>a[i];
	
	
	VL t(n+1, 0);
	
	rep(i, n) t[i+1] = 2 *a[i] - t[i];
	t[0] = t[n] /2;
	rep(i, n) t[i+1] = 2 *a[i] - t[i];
	
	rep(i, n) cout <<t[i] <<" ";
	cout <<endl;
	return 0;
 }



Measured memory_bytes: 2944
//author: Harsh :)
#include <bits/stdc++.h>
using ll = long long;
using ld = long double;
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 922337203685477;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);
#define maxN 100007
using namespace std;
int main(){
  fastio;
  ll n=0;
  cin>>n;
  ll ar[n];
  ll x=0;
  for(ll i=0;i<n;++i) cin>>ar[i], x^=ar[i];
  for(ll i=0;i<n;++i) cout<<(ar[i]^x)<<" ";
  return 0;

}


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

int main(void) {
  int n, i, size = 0;
  char a, *b, c;
  scanf("%d", &n);
  b = (char *)malloc((n + 1) * sizeof(char));
  for (i = 0; i <= n; i++) {
    scanf("%c", &a);
    b[i] = a;
  }
  for (i = 1; i <= n; i++) {
    c = b[i];
    size++;
    while (b[i + 1] == c) {
      i++;
    }
  }
  printf("%d\n", size);
  free(b);
  return 0;
}


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

int main()
{

	int K;
	int A, B;

	cin >> K;
	cin >> A >> B;

	int maxAB =  (A > B)? A :B;
	int minAB = (A > B)? B: A;
	int div = minAB / K;

	string outStr = "NG";

	if(A % K == 0 || B % K == 0 ){
		outStr = "OK";
	}
	else if (((div + 1) * K)<= maxAB)
	{
		outStr = "OK";
	}

	cout << outStr << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr auto INF = INT_MAX / 2;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	int n, m;
	cin >> n >> m;
	vi a(m), b(m);	
	ll aa = m / 2, bb = m - aa;
	rep(i, aa) {
		a[i] = 1 + i;
		b[i] = (n - 1) / 2 - i;
	}
	rep(i, bb) {
		a[aa + i] = (n + 2) / 2 + i;
		b[aa + i] = n - i;
	}
	rep(i, m) {
		cout << a[i] << " " << b[i] << endl;
	}

}

Measured memory_bytes: 3876
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

ll prime_factor_num(ll n) {
    ll ret = 0;
    for (ll i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            ret += 1;
            while (n % i == 0) n /= i;
        }
    }
    if (n != 1) ret += 1;
    return ret;
}

int main() {
    ll A, B;
    cin >> A >> B;
    ll g = __gcd(A, B);
    cout << prime_factor_num(g) + 1 << endl;
    return 0;
}

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

ans, cnt, node = 0, sum(a), 1
for i in range(n + 1):
    ans += node
    cnt -= a[i]
    node = min(cnt, (node - a[i]) * 2)
    if node < 0:
        print(-1)
        break
else:
    print(ans)


Measured memory_bytes: 20004
#include<bits/stdc++.h>
#include<string.h>
#include<math.h>
#include<limits.h>
#include<stdlib.h>
#define FastRead                      \
            ios_base::sync_with_stdio(false); \
            cin.tie(0);
#define endl "\n"
using namespace std;
int main()
{
    FastRead
    int k,n,c=0,p,i,a,b,j;
    cin>>a>>b;
    cout<<a*b;
    return 0;



}








Measured memory_bytes: 3652
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	var input = input.split("\n");
  	var length = input[0];
	var card = input[1].split(" ");
  	var alice = [];
  	var bob = [];
  	
  
  	// 降順にソートする
  	function compareFunc(a, b){
      return b-a;
    }
  	card.sort(compareFunc);
  
  	// 順番にカードを取る
  	for(var i=0; i<card.length; i++){
      if(i%2==0){
         alice.push(card[i]);
      }else{
         bob.push(card[i]);
      } 
    }

  	aliceSum = alice.map(str => parseInt(str, 10)).reduce((a,x) => a+=x);
    bobSum = bob.map(str => parseInt(str, 10)).reduce((a,x) => a+=x);
	//出力
  	console.log(aliceSum-bobSum);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long long i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define Sort(v, n) sort(v, v+n);
#define VSort(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define cY cout<<"Yes";
#define cN cout<<"No";
#define cA(a) cout<<a;
const ll MOD = 1000000007;



int main() {
    string s;string t;
    cin >> s >> t;
    int ans = 0;
    rep(i,3) {
        if(s[i] == t[i]) ans++;
    }
    cout << ans;
}



Measured memory_bytes: 256
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int q;
    cin >> q;
    set<int> st;
    while (q--) {
        int com, x;
        cin >> com >> x;
        if (com == 0) {
            st.insert(x);
            cout << st.size() << endl;
        } else if (com == 1) {
            cout << st.count(x) << endl;
        } else {
            st.erase(x);
        }
    }
}



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

typedef long long ll;
ll t,a,b,c,d;

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

int main(){
	cin>>t;
	while(t--){
		cin>>a>>b>>c>>d;
		{
			ll g=gcd(b,d);
			bool flag=a%g>c%g;
			a/=g;
			b/=g;
			c/=g;
			d/=g;
			if(flag)
				--c;
		}
		if(b>d||a<b||c+1<b)
			puts("No");
		else
			puts("Yes");
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define repn(repvalue) for(int i=0;i<repvalue;i++)
#define repm(repvalue) for(int j=0;j<repvalue;j++)
using namespace std;


int main(){

	int n; cin>>n;

	vector<int> dp(3,0);
	for(int t=1;t<=n;t++){

	vector<int> a(3),dp_new(3,0);
	for(int i=0;i<3;i++) cin>>a[i];


	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			if(i!=j){
				dp_new[j]=max(dp_new[j],dp[i]+a[j]);
			}
		}
	}
	dp=dp_new;
	}
	cout<<*max_element(dp.begin(),dp.end())<<"\n";
return 0;
}

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

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; }

using ll=long long;
const int Nmax=100010;
int N,K; 
ll dp[Nmax];
int h[Nmax];
const ll INF=1LL<<60;


int main(){
  cin >> N >> K;
  for (int i=0;i<N;i++)
    cin >> h[i];
  for (int i=0;i<Nmax;i++)
    dp[i]=INF;
  dp[0]=0;
  for (int i=0;i<N;i++){
    for (int j=1;j<=K;j++){
      chmin(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
    }
  }
  cout << dp[N-1] << endl;
  
}

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

int main(){
vector<int> vec(5);
for(int i=0;i<5;i++){
    cin >> vec.at(i);
}
int k;
cin >> k;
bool b=true;
for(int i=0;i<4;i++){
    for(int j=i+1;j<5;j++){
        if(vec.at(j)-vec.at(i)>k){
            b=false;
        }
    }

}
if(b==true){
    cout << "Yay!" << endl;
}
else{
    cout << ":(" << endl;
}
}



Measured memory_bytes: 256
#!/usr/bin/env python3
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(a[K-1])


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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define MAXX 500005
#define INF INT_MAX

#define PI   3.14159265358979323846264338327950

#define PB push_back
#define PF push_front
#define F first
#define S second

#define fixx(n) fixed << setprecision(n)

#define ll 	 long long

#define mod  1000000007



int main()
{
	FAST;
	string s, t;
	
	cin >> s >> t;
	int ans = 10000;
	int n = s.size(), m = t.size();
	for(int i = 0; i <= n - m; i ++){
		int x = 0;
		for(int j = i; j < i + m; j ++){
			if(s[j] != t[j-i]){
				x ++;
			}
		}
		ans = min(x, ans);
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 3656
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, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func sum(a []int) int {
	ret := 0
	for _, v := range a {
		ret += v
	}
	return ret
}

func min(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v < ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	w := nextInts(n)

	ans := 10000
	for i := 0; i < n-1; i++ {
		ans = min(ans, abs(sum(w[0:i+1])-sum(w[i+1:n])))
	}
	fmt.Println(ans)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    vector<int>p(n);
    REP(i,n)cin>>p[i];
    int ans=0;
    if(p[0]==1){
        swap(p[0],p[1]);
        ans++;
    }
    for(int i=1;i<n;i++){
        if(p[i]==i+1){
            if(p[i+1]!=i+1){
                swap(p[i],p[i+1]);
            }
            else{
                swap(p[i-1],p[i]);
            }
            ans++;
        }
    }
    cout<<ans<<endl;
}

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

#ifndef __TOPCYBERFLOWER
#define debug(...) 0
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif

#define TYPEMAX(type)   numeric_limits<type>::max()
#define TYPEMIN(type)   numeric_limits<type>::min()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main(void){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    string s; cin>>s;
    if(s.compare("RRR")==0) cout<<3;
    else if(s.compare("RRS")==0 || s.compare("SRR")==0) cout<<2;
    else if(s.compare("SSS")==0) cout<<0;
    else cout<<1;
    return 0;
}

Measured memory_bytes: 3648
#include<cstdio>
#include<iostream>
#include<string>

using namespace std;

string inp;
int cnt;
int val;

bool culc(bool a,char c,bool b){
	switch((char)c){
	case '+':
		return a||b;
	case '*':
		return a&&b;
	case '>':
		if(a==false&&b==true) return false;
		else return true;
	}
}

char formula2(){
	cnt++;
	if(inp[cnt]=='>') cnt++;
	return (char)inp[cnt-1];
}

bool formula(){
	bool f;
	switch(inp[cnt]){
	  case '-':
		cnt++;
		f=formula();
		if(f==1) f=0;
		else f=1;
	    break;
	  case '(':
		cnt++;
		f=culc(formula(),formula2(),formula());
		cnt++;
		break;
	  case 'T':
		  cnt++;
		  f=true;
		  break;
	  case 'F':
		  cnt++;
		  f=false;
		  break;
	  default:
		  f=(val>>(inp[cnt]-'a'))&1;
		  cnt++;
		  break;
	}
	return f;
}

int main(void){

	bool left,right;
	bool ans;

	while(1){
		cin>>inp;
		if(inp=="#") break;
		ans=true;
		for(val=0;val<(1<<11);val++){
			cnt=0;
			left=formula();
			cnt++;
			right=formula();
			if(left!=right){
				ans=false;
				break;
			}
		}
		if(ans) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}

	return 0;
}

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

int N,A[10000];

int check(int k,int I){
	int a[10000];
	for(int i=0;i<N;i++) if(k==i) a[i]=I; else a[i]=A[i];
	int check=1;
	while(check){
		check=0;
		for(int i=0;i<N;i++){
			if(a[i]!=4){
				int c=1;
				for(int j=i+1;j<N;j++){
					if(a[j]==4) continue;
					if(a[j]!=a[i]||c>=4) break;
						c++;
				}
				if(c>=4){
					check=1;int e=a[i];
					for(int j=i;j<N;j++){
						if(a[j]==4) continue;
						if(a[j]!=e) break;
						a[j]=4;
					}
				}
			}
		}
	}
	int count=0;
	for(int i=0;i<N;i++) if(a[i]!=4) count++;
	return count;
}

int main(){
	while(scanf("%d",&N),N){
		for(int i=0;i<N;i++) scanf("%d",&A[i]);
		int res=N;int z=0;
		for(int k=0;k<N;k++){
			for(int i=1;i<=3;i++){
				int x=0;
				for(int j=k+1;j<N;j++) if(A[j]==i) x++; else break;
				for(int j=k-1;j>=0;j--) if(A[j]==i) x++; else break;
				if(x>=3) res=min(res,check(k,i));
			}
		}
		printf("%d\n",res);
	}
}

Measured memory_bytes: 1256
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
#define dbg4(w,x, y, z) cerr << #w << " = " << w << ", " <<#x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;


int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
    //cin >> T;
    T = 1;
    for(int cs = 1; cs <= T; cs++){
      ll n;
      cin >> n;
      n--;
      ll ans = (n*n + n)/2;
      cout << ans << endl;
    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<set>
#include<bitset>
#include<map>

#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)

using namespace std;

typedef long long LL;
typedef double db;

int get(){
	char ch;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	if (ch=='-'){
		int s=0;
		while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
		return -s;
	}
	int s=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')s=s*10+ch-'0';
	return s;
}

const int MAXN = 10003;
const int mo = 998244353;
const int g = 3;

LL js[MAXN],inv[MAXN];
int n,t,m;
int a[MAXN],b[MAXN];
int N,L;
LL A[33400],mi[33400],bitr[33400],ans[33400],ny;

LL calc(int n,int m){
	return js[n]*inv[m]%mo*inv[n-m]%mo;
}

LL quickmi(LL x,LL tim){
	LL ans=1;
	x=x%mo;
	for(;tim;tim/=2,x=x*x%mo)
	if (tim&1)ans=ans*x%mo;
	return ans;
}

void prepare(){
	fo(i,0,N-1){
		bitr[i]=0;
		fo(j,0,L-1)
		if ((i&(1<<j))>0)bitr[i]|=1<<(L-1-j);
	}
	LL G=quickmi(g,(mo-1)/N);
	ny=quickmi(N,mo-2);
	mi[0]=1;
	fo(i,1,N)mi[i]=mi[i-1]*G%mo;
}

LL add(LL x,LL y){
	return x+y>=mo?x+y-mo:x+y;
}

LL dec(LL x,LL y){
	return x>=y?x-y:x+mo-y;
}

void DFT(LL *a){
	fo(i,0,N-1)
	if (i<bitr[i])swap(a[i],a[bitr[i]]);
	for(int now=2;now<=N;now<<=1){
		int half=now/2;
		fo(i,0,half-1){
			LL w=mi[N/now*i];
			for(int j=i;j<N;j+=now){
				LL l=a[j],r=w*a[j+half]%mo;
				a[j]=add(l,r);
				a[j+half]=dec(l,r);
			}
		}
	}
}

void IDFT(LL *a){
	fo(i,0,N-1)
	if (i<bitr[i])swap(a[i],a[bitr[i]]);
	for(int now=2;now<=N;now<<=1){
		int half=now/2;
		fo(i,0,half-1){
			LL w=mi[N-N/now*i];
			for(int j=i;j<N;j+=now){
				LL l=a[j],r=w*a[j+half]%mo;
				a[j]=add(l,r);
				a[j+half]=dec(l,r);
			}
		}
	}
	fo(i,0,N-1)a[i]=a[i]*ny%mo;
}

void twice(LL *a){
	DFT(a);
	fo(i,0,N-1)a[i]=a[i]*a[i]%mo;
	IDFT(a);
	fo(i,t+1,N-1)a[i]=0;
}

LL C[33400];

void ntt(LL *a,LL *b){
	fo(i,0,N-1)C[i]=b[i];
	DFT(a),DFT(b);
	fo(i,0,N-1)a[i]=a[i]*b[i]%mo;
	IDFT(a);
	fo(i,0,N-1)b[i]=C[i];
	fo(i,t+1,N-1)a[i]=0;
}

int main(){
	char s[MAXN];
	scanf("%s",s+1);
	n=strlen(s+1);
	fo(i,1,n)a[i]=s[i]-'0';
	scanf("%s",s+1);
	fo(i,1,n)b[i]=s[i]-'0';
	fo(i,1,n){
		if (a[i]&&b[i])t++;
		m+=(a[i]+b[i])&1;
	}
	js[0]=inv[0]=inv[1]=1;
	fo(i,1,n)js[i]=js[i-1]*i%mo;
	fo(i,2,n)inv[i]=1ll*(mo-mo/i)*inv[mo%i]%mo;
	fo(i,1,n)inv[i]=inv[i]*inv[i-1]%mo;
	m/=2;
	ans[0]=js[t];
	N=1,L=0;
	while(N<=2*t)N<<=1,L++;
	prepare();
	fo(i,0,t)A[i]=inv[i+1];
	for(int tim=m;tim;tim/=2,twice(A))
		if (tim&1)ntt(ans,A);
	fo(i,0,t)ans[i]=ans[i]*inv[t-i]%mo*js[i+m]%mo;
	LL val=0;
	fo(i,0,t)val=(val+ans[i]*js[t-i]%mo*js[t-i]%mo*calc(m+t,t-i)%mo)%mo;
	val=val*js[m]%mo;
	printf("%lld\n",val);
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

ll combination ( ll a, ll b) {
    ll ret = 1LL;
    if ( a / 2 < b ) {
        b = a - b;
    }
    else {

    }
    for ( int i = 0; i < b; ++i ) {
        ret *= a;
        --a;
    }
//    cout << ret << endl;
    while(1) {
        if ( b == 0 ) break;
        ret /= b;
        --b;
    }
    return ret;
}

int main(){
    int n, p;
    cin >> n >> p;
    vector<int> a(n);
    int odd_num = 0;
    rep(i, n) {
        cin >> a[i];
        if ( a[i]&1 ) {
            ++odd_num;
        }
    }
    ll ans = 1LL;
    ll tmp_ans = 0;
    if ( p == 1 && odd_num == 0 ) {
        cout << 0 << endl;
        return 0;
    }
    if ( p == 0 ) {
        rep(i, n - odd_num) {
            ans *= 2LL;
        }
//        cout << ans << endl;
        for ( int i = 0; i <= odd_num; i += 2 ) {
//            cout << combination((ll)odd_num, (ll)i) << endl;
            tmp_ans += combination((ll)odd_num, (ll)i);
        }
//        cout << tmp_ans << endl;
        ans *= tmp_ans;
    }
    else {
//        cout << odd_num << endl;
        rep(i, n - odd_num) {
            ans *= 2LL;
        }
        for ( int i = 1; i <= odd_num; i += 2 ) {
            tmp_ans += combination((ll)odd_num, (ll)i);
//            cout << tmp_ans << endl;
        }
//        cout << tmp_ans << endl;
        ans *= tmp_ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> void Max(T &m, const T q) { if (m < q) m = q; }
template<typename T> void Min(T &m, const T q) { if (m > q) m = q; }
template<typename T1, typename T2> pair<T1, T2> operator+(pair<T1, T2> &l, pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(pair<T1, T2> &l, pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;

string S, T;

int main()
{
    cin >> S;
    T = S;
    reverse(T.begin(), T.end());
    REP(i, T.size())
    {
        if (T[i] == 'b') T[i] = 'd'; else
        if (T[i] == 'd') T[i] = 'b'; else
        if (T[i] == 'p') T[i] = 'q'; else
        if (T[i] == 'q') T[i] = 'p';
    }
    cout << (S == T ? "Yes" : "No") << endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
using namespace std;
int main(){
  
  int a[10],c=0,num;

  while( scanf("%d",&num) != EOF ){

    if( num != 0 ){
      a[c]=num;
      c++;
    }else{
      cout <<a[c-1]<<endl;
      c--;
    }   

  }
  return 0;

}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include <stack>
using namespace std;
#define ll long long
int main()
{
	//int t;
	//cin>>t;
	//for(int i=0;i<t;i++)
	//{
	  
	  char a;
	  cin>>a;
	  if(a>='a' and a<='z') cout<<"a";
	  else cout<<"A";
		
}
	
	
	
	

		



Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
inline int_fast64_t read(){int_fast64_t x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
inline string read_s(){string s="";char c=getchar();while(c<'!'||c>'~'){c=getchar();}while(c>='!'&&c<='~'){s+=c;c=getchar();}return s;}
void Main(){
    string S = read_s();
    for (int i = 1; i < S.size(); i++) {
        if (S[i] == S[i-1]) {
            printf("Bad\n");
            return;
        }
    }
    printf("Good\n");
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String t = sc.next();
        if (a.equals(t)) {
            System.out.println("H");
        } else {
            System.out.println("D");
        }
    }
}

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

int main(int argc, char const *argv[])
{
    int a; cin >> a;
    cout << a + a*a + a*a*a << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000000000
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; }
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
constexpr int MOD = 1000000007;

void print(const std::vector<int>& v)
{
  std::for_each(v.begin(), v.end(), [](int x) {
    std::cout << x << " ";
  });
  std::cout << std::endl;
}

int main ()
{
    int N;cin>>N;
    vector<ll> a(N);
    ll cnt;
    REP(i,N) {
        cin>>a[i];
        while(a[i]%2==0){
            cnt++;
            a[i] = a[i]/2;
        }
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
typedef pair<int, int> P;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int m;
  while(cin>>m,m) {
    vector<P> d;
    int sy, sx; cin >> sx >> sy;
    int by = sy, bx = sx;
    FOR(i, 0, m - 1) {
      int x, y; cin >> x >> y;
      d.push_back(P(y - by, x - bx));
      by = y, bx = x;
    }
    int n; cin >> n;
    vector<P> point(n);
    set<P> SET;
    FOR(i,0,n) {
      int x, y; cin >> x >> y;
      point[i] = P(y, x);
      SET.insert(P(y, x));
    }
    FOR(i,0,n) {
      int y = point[i].first;
      int x = point[i].second;
      bool ok = true;
      int Y = y;
      int X = x;
      FOR(j, 0, m - 1) {
        Y = Y + d[j].first;
        X = X + d[j].second;
        if(SET.count(P(Y, X)) == 0) {
          ok = false;
          break;
        }
      }
      if(ok) {
        cout << x - sx << " " << y - sy << '\n';
        break;
      }
    }
  }
  return 0;
}

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

//const int INF = 1001001001;
//const ll INF = 1000000000000000000;

ll a, b, v, w, t;

int main() {
	ll A, V;
 cin >> A >> V;
 ll B,W;
 cin >> B >> W;
 ll T;
 cin >> T;
 ll D=abs(A-B);
 ll D2=(V-W)*T;
 cout << (D<=D2?"YES":"NO") << endl;
	return 0;
}


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

typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);

ll const inf = 1e18;
ll const maxn = 1e6+5;
ll const mod = 1e9+7;

// code begins here

vector<ll> arr;
ll dp[maxn][2];

void recur( ll k, ll cur ){
    if(dp[k][cur]!=-1)
        return;
    
    if(k==0){
        dp[k][cur] = !cur;
        return;
    }
    
    ll ans = 0;
    for(auto u: arr){
        if( k >= u ){
            recur(k-u, !cur);
        }
    }
    
    dp[k][cur] = !cur;
    
    for(auto u: arr){
        if( k>=u && dp[k-u][!cur]==cur){
            dp[k][cur] = cur;
        }
    }
}

int main(){
    fast;
    
    ll n,k;
    cin>>n>>k;
    
    for(ll i=0;i<n;i++){
        ll x;
        cin>>x;
        arr.push_back(x);
    }
    
    for(ll i=0;i<maxn;i++){
        dp[i][0] = -1;
        dp[i][1] = -1;
    }
    
    recur(k, 1);
    
    cout<< ( dp[k][1] ? "First" : "Second" ) <<endl;
    
    return 0;
}

Measured memory_bytes: 25408
#include <iostream>
#include <queue>
#include <unordered_set>
#include <vector>

using namespace std;

class State{
public:
  int n;
  int src;
  int depth;
  State(int n, int src, int depth): n(n), src(src), depth(depth) {};
};

int main(){
  int N, M, a, b;
  cin >> N >> M;
  vector<unordered_set<int>> A;
  for (int i=0; i<N; i++){
    A.emplace_back(unordered_set<int>());
  }
  for (int i=0; i<M; i++){
    cin >> a >> b;
    a--; b--;
    A[a].insert(b);
    A[b].insert(a);
  }
  queue<State> Q;
  vector<bool> visited(N, false);
  vector<int> parent(N, -1);
  Q.emplace(0, 0, 0);
  while(!Q.empty()){
    State e = Q.front();
    Q.pop();
    if (!visited[e.n]){
      visited[e.n] = true;
      parent[e.n] = e.src;
      for (int dst : A[e.n]){
        Q.emplace(dst, e.n, e.depth + 1);
      }
    }
  }
  cout << "Yes" << "\n";
  for (int i=1; i<N; i++){
    cout << parent[i] + 1 << "\n";
  }
  return 0;
}

Measured memory_bytes: 30560
#include<bits/stdc++.h>
                using namespace std;
                 
                int main(){
                  long long n; cin>>n;
                  long long m=INT_MIN,h=0;
                  int f=0;
                  for(int i=0;i<n;i++){
                    
                     long long x; 
                    if(f=0){
                    cin>>x;
                      f=1;
                    }
                    else{
                    cin>>x;
                    }
                    m=max(m,x);
                    h+=m-x;
                  }
                
                  cout<<h<<endl;
                 return 0;
                }

Measured memory_bytes: 3600
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;


class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;


    void solve()
    {
        int N = cin.nextint;
        int A = cin.nextint;
        int B = cin.nextint;

        int ans = 0;
        for (int i = 1; i <= N; i++)
        {
            int k = 0;
            int t = i;
            while (t > 0)
            {
                k += t % 10;
                t /= 10;
            }
            if (A <= k && k <= B)
            {
                ans += i;
            }
        }
        WriteLine(ans);
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 11220
// in case of multiple test cases and N=1e5 don't intialize arrays as global except for graph vector-array
// always check whether or not you are doing mod of a negative number
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
 
using namespace __gnu_pbds;
using namespace std;

#define double      	long double
#define int         	long long
#define pb          	push_back
#define pii         	pair<int,int>
#define vi          	vector<int>
#define vii         	vector<pii>
#define mi          	map<int,int>
#define mii         	map<pii,int>
#define all(a)      	(a).begin(),(a).end()
#define sz(x)       	(int)x.size()
#define endl        	"\n"
#define repp(i,a,b) 	for(int i=a;i<b;i++)
#define rep(i,a,b) 		for(int i=a;i<=b;i++)
#define brep(i,a,b)     for(int i=a;i>=b;i--)
#define deb1(x)      	cout << #x << "=" << x << endl
#define deb2(x, y)  	cout << #x << "=" << x << "," << #y << "=" << y << endl
#define deb3(x, y, z)  	cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define trace(v) 		for(auto it=v.begin();it!=v.end();it++)cout<<*it<<" ";cout<<endl;
#define tracearr(a,l,r) for(int iii=l;iii<=r;iii++)cout << a[iii] << " ";cout << endl;
#define PI          	3.1415926535897932384626
#define F 				first
#define S 				second
#define clr(x,y) 		memset(x, y, sizeof(x))
#define IOS         	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
// *s.find_by_order(1) - gives the 2nd samllest element in set
// s.order_of_key(x)   - gives the number of elements in the set which are strictly smaller than x


const int N=1e5 + 5;
const int MOD=1e9 + 7;

int32_t main()
{
	IOS;
	int T=1;
	//cin >> T;
	// int numOfSetBits = __builtin_popcountll(n);
	std::cout << std::fixed << std::setprecision(12);
	while(T--)
	{
		/*
		
		*/
		int x;
		cin >> x;
		if(x>=400 && x<=599)
			cout << "8" << endl;
		else if(x>=600 && x<=799)
			cout << "7" << endl;
		else if(x>=800 && x<=999)
			cout << "6" << endl;
		else if(x>=1000 && x<=1199)
			cout << "5" << endl;
		else if(x>=1200 && x<=1399)
			cout << "4" << endl;
		else if(x>=1400 && x<=1599)
			cout << "3" << endl;
		else if(x>=1600 && x<=1799)
			cout << "2" << endl;
		else if(x>=1800 && x<=1999)
			cout << "1" << endl;
	}
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int r;
string str;

void solve() {
	cin >> r;
	cin >> str;
	if(r >= 3200) cout << str << "\n";
	else cout << "red" << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 256
// When you are hungry for something and you're determined and you're focused 
// and you're committed to something it's hard to surrender, isn't it?

#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define setbit(x) __builtin_popcount(x)
#define fff(i,n) for(int i=0;i<n;i++)
#define ff first
#define ss second
#define pb push_back
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}
 
int32_t main() {
    fio
    
    string s;
    cin >> s;
    if(s[0]=='S')
    cout << "Cloudy";
    else if(s[0]=='C')
    cout << "Rainy";
    else
    cout << "Sunny";
	return 0;
    
}

Measured memory_bytes: 8832
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define Rep(i,l,r)for(lld i=(lld)l;i<(lld)r;i++)
#define rep(i,n)Rep(i,0,n)
typedef long long lld;
typedef long double Lf;
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))
#define N 100001

int main(){
	int n, m, p, jud[N]={0}, ac=0, wa=0;
	char s,t;
	scanf("%d%d", &n, &m);
	rep(i, m) {
		scanf("%d %c%c", &p,&s,&t);
		if (s=='A') {
			if (jud[p] <= 0) { wa -= jud[p]; ac++; }
			jud[p]=1;//AC
		}
		else if(jud[p]!=1){
			jud[p]--;
		}
	}
	printf("%d %d", ac, wa);
}

Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a, b, k;
  cin >> a >> b >> k;
  a -= k;
  if (a >= 0) {
    cout << a << " " << b << endl;
  } else {
    b = max(0LL, a + b);
    cout << 0 << " " << b << endl;
  }
  return 0;
}


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

int main()
{
  int K, S;
  int X, Y, Z;
  int ans=0;
  cin >> K >> S;
  
  for(X=0; X<=K; X++)
    for(Y=0; Y<=K; Y++)
    {
      int Z = S - X - Y;
      if(0<=Z && Z<=K)
        ans += 1;
    }
  
  cout << ans;
}

Measured memory_bytes: 256
/* Code by : Suraj (@suraj1611) */

#include<bits/stdc++.h>
#include <string>

using namespace std;

#define ll long long int
#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mx INT_MAX
#define mn INT_MIN
#define md 1000000007
#define pb push_back
#define mp make_pair
#define maxsize 1100005
#define lb cout<<endl;
#define endl "\n"
#define F first
#define S second
#define label cout<<"hello!"<<endl
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);


ll power(ll x, ll  y) 
{ 
	ll m=md;
   	ll ans=1;
    while (y > 0) 
    {
        if (y & 1)
            ans = (ans * x) % m;
        x = (x * x) % m;
        y >>= 1;
    }
    return ans;
} 

int main()
{
	IOS
	



		ll n;
		cin>>n;
		ll a[n];
		ll dp[n];
		rep(i,n)
		cin>>a[i];
		dp[0]=a[0];
		dp[1]=abs(a[1]-a[0]);
		for(ll i=2;i<n;i++)
		{
			if(i==2)
			{
				dp[i]=min(dp[i-1]+abs(a[i-1]-a[i]),abs(a[i-2]-a[i]));
				continue;
			}
			dp[i]=min(dp[i-1]+abs(a[i-1]-a[i]),dp[i-2]+abs(a[i-2]-a[i]));
		}
		cout<<dp[n-1]<<endl;

	

	

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const ll inf = 1e18;const double INF = 1e12, EPS = 1e-9;

using VL = vector<ll>;
using VVL = vector<VL>;
int n, a[5000];
vector<vi> e;

const VVL rec(int c, int p){
	VVL dp(1, VL(2, inf));
	dp[0][a[c] < 0] = a[c];
	
	for(int cld : e[c]) if(cld != p){
		const VVL tmp = rec(cld, c);
		VVL next(dp.size() + tmp.size(), VL(2, inf));
		
		rep(i, tmp.size()) rep(j, 2) if(tmp[i][j] < inf)
		rep(k, dp.size()) rep(l, 2) if(dp[k][l] < inf){
			
			next[i + k][j | l] = min(next[i + k][j | l], tmp[i][j] + dp[k][l]);
			if(j == 0 || tmp[i][j] < 0) next[i + k + 1][l] = min(next[i + k + 1][l], dp[k][l]);
		}
		
		dp.swap(next);
	}
	return dp;
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	cin >> n; e.resize(n);
	rep(i, n) cin >> a[i];
	rep(i, n - 1){
		int u, v; cin >> u >> v; u--; v--;
		e[u].pb(v);
		e[v].pb(u);
	}
	VVL ans = rec(0, 0);
	int res = n - 1;
	rep(i, ans.size()) rep(j, ans[i].size()) if(ans[i][j] < inf) if(j == 0 || ans[i][j] < 0) res = min(res, i);
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 2152
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound

int main(){
  int N,X;
  cin>>N>>X;
  if(N==2){
    if(X==2){
      cout<<"Yes"<<endl;
      cout<<1<<endl;
      cout<<2<<endl;
      cout<<3<<endl;
    }else cout<<"No"<<endl;
    return 0;
  }
  if(X==1 or X==2*N-1){
    cout<<"No"<<endl;
    return 0;
  }
  VI ans;
  cout<<"Yes"<<endl;
  if(X==2){
    int tmp=5;
    rep(i,N-3){
      cout<<tmp<<endl;
      tmp++;
    }
    cout<<4<<endl;
    cout<<1<<endl;
    cout<<2<<endl;
    cout<<3<<endl;
    rep(i,N-2){
      cout<<tmp<<endl;
      tmp++;
    }
  }else{
    rep(i,2*N-1) if(i+1<X-2 or i+1>X+1) ans.pb(i+1);
    int tmp=0;
    rep(i,N-3){
      cout<<ans[tmp]<<endl;
      tmp++;
    }
    cout<<X-1<<endl;
    cout<<X+1<<endl;
    cout<<X<<endl;
    cout<<X-2<<endl;
    rep(i,N-2){
      cout<<ans[tmp]<<endl;
      tmp++;
    }
  }
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
int N,M,Q;
vector<vector<int> > sum;
void buildsumtable(vector<int> r,vector<int> l){
    sum=vector<vector<int> >(N+1,vector<int>(N+1,0));
    for(int i=0;i<M;i++){
        sum[l[i]][r[i]]++;
    }
    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++){
            sum[i][j]+=sum[i-1][j];
            sum[i][j]+=sum[i][j-1];
            sum[i][j]-=sum[i-1][j-1];
        }
    }
}
int getsumrange(int l,int r){
    int ans=sum[r][r]-sum[r][l-1]-sum[l-1][r]+sum[l-1][l-1];
    return ans;
}
int main(){
    cin>>N>>M>>Q;
    vector<int> l(M);
    vector<int> r(M);
    for(int i=0;i<M;i++){
        cin>>l[i]>>r[i];
    }
    vector<int> p(Q);
    vector<int> q(Q);
    for(int i=0;i<Q;i++){
        cin>>p[i]>>q[i];
    }
    buildsumtable(r,l);
    for(int i=0;i<Q;i++){
        cout<<getsumrange(p[i],q[i])<<endl;
    }
    return 0;
}


Measured memory_bytes: 5120