akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define x first
#define y second
#define pb push_back
#define ll long long
#define ld long double
#define ii pair<int, int>
#define iii pair<int, ii>
#define vi vector<int>
#define vii vector<ii>
#define pq priority_queue
using namespace std;
const int ms = 310;
const int mod = 1e9+7;
const int inf = 1e9;
const int sigma = 30;
int m, k, t = 1;
string s;
double n;

int ele[ms];

double dp[ms][ms][ms];
bool seen[ms][ms][ms];

double sol(int qtOne, int qtTwo, int qtT){
  if(qtOne<0 || qtTwo<0 || qtT<0) return 0;
  // if(qtOne == 1 && qtOne+qtTwo+qtT==1) return n;
  if(qtOne+qtTwo+qtT==0) return 0.0;

  if(seen[qtOne][qtTwo][qtT]) return dp[qtOne][qtTwo][qtT];
  seen[qtOne][qtTwo][qtT] = 1;

  double qt = qtOne + qtTwo + qtT;

  double &ans = dp[qtOne][qtTwo][qtT];

  ans = 0;
  ans += n/qt;
  ans += qtOne==0? 0: (qtOne/qt) * sol(qtOne - 1, qtTwo , qtT);
  ans += qtTwo==0? 0: (qtTwo/qt) * sol(qtOne + 1, qtTwo -1 , qtT);
  ans += qtT==0? 0: (qtT/qt) * sol(qtOne, qtTwo + 1 , qtT -1);

  return ans;
}

void solve(){
  cin>>n;
  int a;
  vector<int> cur(4);
  for(int i = 0; i<n; i++){
    cin>>ele[i];
    cur[ele[i]]++;
  }
  cout<<fixed<<setprecision(10);
  cout<<sol(cur[1], cur[2], cur[3])<<endl;
  
}

int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  while(t--){
    solve();
  }
}

Measured memory_bytes: 256256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>

using namespace std;

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

typedef long long ll;

vector<int> A;
vector<int> B;

void Main()
{
	int N; cin >> N;
	rep(i,N + 1) {
		int a; cin >> a;
		A.push_back(a);
	}
	rep(i,N) {
		int b; cin >> b;
		B.push_back(b);
	}

	ll res = 0;
	rep(i,N) {
		int idx = B.size() - i - 1;
		int num = B[idx];
		num = num - A[idx + 1];
		if (num <= 0) {
			res += B[idx];
			continue;
		}
		num = num - A[idx];
		if (num <= 0) {
			res += B[idx];
			A[idx] = -num;
		} else {
			res += (B[idx] - num);
			A[idx] = 0;
		}
	}
	cout << res << endl;
}

int main()
{
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	Main();
}


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

    int main(){
        string N;
        int x;
        cin>>N;
        for(int i = 0; i<4; i++){
            if(N.at(i) == '2'){
                x += 1;
            }
        }
        cout << x;
    return 0;}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    int t;
    //cin>>t;
    //while(t--)
    {
        string s,t;
        cin>>s>>t;
        int sb,tb;
        cin>>sb>>tb;
        string u;
        cin>>u;
        if(u==t)
        {
            tb--;
        } else if(u==s){
            sb--;
        }
        cout<<sb<<" "<<tb;
    }
    return 0;
}

Measured memory_bytes: 3584
#include "bits/stdc++.h"
using namespace std;

class Cube{
public:
	int f[6];
	Cube(){}
		void roll_z(){roll(1,2,4,3);}
		void roll_y(){roll(0,2,5,3);}//to W
		void roll_x(){roll(0,1,5,4);}//to N
		void roll(int i,int j,int k, int l){
			int t=f[i];f[i]=f[j];f[j]=f[k];f[k]=f[l];f[l]=t;
		}
		void move(char ch){
			if(ch=='E')for (int i = 0; i < 3; ++i) {roll_y();}
			if(ch=='W')roll_y();
			if(ch=='N')roll_x();
			if(ch=='S')for (int i = 0; i < 3; ++i) {roll_x();}
		}
};



int main() {
	Cube c;
	string com;
for (int i = 0; i < 6; ++i) cin>>c.f[i];
cin>>com;
for (int i = 0; i < com.size(); ++i) {c.move(com[i]);}
cout<<c.f[0]<<endl;
return 0;
}

Measured memory_bytes: 3208
n = int(input())
q = []
i = 1
if n == 0:
    q.append(0)
while True:
    if n == 0:
        break
    if abs(n - i) % abs(-2 * i) == 0:
        q.append(1)
        n -= i
    else:
        q.append(0)
    i *= -2
q.reverse()
print("".join(map(str, q)))

Measured memory_bytes: 3060
// Author: Tyler Wang

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdlib>
#include <deque>
#include <functional>
#include <initializer_list>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <utility>
#include <vector>

using namespace std;

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.precision(12);
  std::cerr.precision(12);
  std::mt19937 rng((std::uint_fast32_t)std::chrono::high_resolution_clock::now()
                       .time_since_epoch()
                       .count());
  int n;
  cin >> n;
  vector<vector<int>> abc(n, vector<int>(3));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 3; ++j) {
      cin >> abc[i][j];
    }
  }
  vector<vector<int>> dp(n + 1, vector<int>(3));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 3; ++j) {
      for (int k = 0; k < 3; ++k) {
        if (j != k) {
          dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + abc[i][k]);
        }
      }
    }
  }
  cout << *max_element(dp[n].begin(), dp[n].end()) << '\n';
  return 0;
}

Measured memory_bytes: 11264
s = gets.chomp
a = 0
b = 0

for i in 0...s.size
  if i % 2 == 0 then
    if s[i] == "1" then
      a += 1
    else
      b += 1
    end
  else
    if s[i] == "1" then
      b += 1
    else
      a += 1
    end
  end
end

puts [a, b].min


Measured memory_bytes: 1916
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000)

def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math

n = getN()
nums = sorted(getList())

tmp = nums[0]
for num in nums[1:]:
    tmp = (tmp + num) / 2

print(tmp)

Measured memory_bytes: 39856
#include <algorithm>
#include <bitset>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

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;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

signed main() {
    ll n, m;
    cin >> n >> m;
    if (n >= m / 2) {
        cout << m / 2 << endl;
        return 0;
    }
    else
        cout << n + (m / 2 - n) / 2 << endl;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  string s,t;cin>>s>>t;
  int c=0;
  rep(i,s.size()){
    if(s[i]!=t[i]){
      c++;
    }
  }
  Ans(c==0);
}

Measured memory_bytes: 3596
from fractions import gcd

def lcm(a,b):
    return a*(b//gcd(a,b))

mod=10**9+7

n=int(input())
A=list(map(int,input().split()))

L=A[0]
for i in range(1,n):
    L=lcm(L,A[i])
L%=mod

coef=sum(pow(x,mod-2,mod) for x in A)
print(L*coef%mod)

Measured memory_bytes: 6136
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue = BinaryHeap!(Array!long, "a<b");
// dfmt on

void main()
{
    long N = lread();
    long ans = long.max;
    for (long x = 1; x * x <= N; x++)
        if (N % x == 0)
        {
            long y = N / x;
            ans = min(ans, x + y - 2);
        }
    writeln(ans);
}


Measured memory_bytes: 380
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    VL A(N); REP(i,N) cin >> A[i];

    VL accinv(N+1);
    accinv[1] = 1;
    FOR(i,2,N+1){
        accinv[i] = (accinv[i-1] + modinv(i,MOD)) % MOD;
    }

    VL ans(N+1);

    FOR(i,1,N+1){
        if(i == 1){
            ans[i] = accinv[N];
        }
        else if(i == N){
            ans[i] = accinv[N];
        }
        else{
            int st = abs(1-i) + 1;
            int fi = abs(N-i) + 1;
            ans[i] = (accinv[st] + accinv[fi] - 1) % MOD;
        }

        ans[i] = (ans[i]*A[i-1])%MOD;
    }
    LL tmp = 0;

    FOR(i,1,N+1){
        dump(i)
        dump(ans[i])
        tmp += ans[i];
        tmp %= MOD;
    }
    FOR(i,1,N+1){
        tmp *= i;
        tmp %= MOD;
    }
    cout << tmp << endl;

}


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

int main(){
    int a, b ,t;
    cin >> a >> b >> t;
    int time = 0;
    int ans = 0;
    while(time <= t){
        if(time == 0 ){
            time = a;
            continue;
        }
        ans += b;
        time += a;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3520
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

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

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	N := getInt()
	ans := "No"
	for N > 0 {
		if N%10 == 9 {
			ans = "Yes"
			break
		}
		N /= 10
	}
	out(ans)
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#define INF 1e+9
using namespace std;

int main(){
	int n;
	while(cin >> n,n){
		int w[10],s[10],dp[1 << 10][10],prev[1 << 10][10][2];
		string f[10];
		for(int i = 0;i < (1 << n);i++){
			for(int j = 0;j < n;j++) dp[i][j] = INF;
		}
		for(int i = 0;i < n;i++) dp[0][i] = 0;
		for(int i = 0;i < n;i++) cin >> f[i] >> w[i] >> s[i];
		for(int i = 1;i < (1 << n);i++){
			int sum = 0,cnt = 0;
			for(int j = 0;j < n;j++){
				if((i >> j) & 1) {
					sum += w[j];
					cnt++;
				}
			}
			for(int j = 0;j < n;j++){
				if(((i >> j) & 1) && s[j] >= sum - w[j]){
					for(int k = 0;k < n;k++){
						if(dp[i & ~(1 << j)][k] + (n - cnt + 1) * w[j] < dp[i][j]){
							dp[i][j] = dp[i & ~(1 << j)][k] + (n - cnt + 1) * w[j];
							prev[i][j][0] = i & ~(1 << j);
							prev[i][j][1] = k;
						}
					}
				}
			}
		}
		int mi = INF,mix;
		for(int i = 0;i < n;i++) {
			if(mi > dp[(1 << n) - 1][i]){
				mi = dp[(1 << n) - 1][i];
				mix = i;
			}
		}
		cout << f[mix] << endl;
		int pos = (1 << n) - 1;
		for(int i = 0;i < n - 1;i++){
			cout << f[prev[pos][mix][1]] << endl;
			int p = prev[pos][mix][0];
			mix = prev[pos][mix][1];
			pos = p;
		}
	}
	return 0;
}

Measured memory_bytes: 3312
import std.stdio, std.range, std.conv, std.string;
import std.algorithm.comparison, std.algorithm.iteration, std.algorithm.mutation, std.algorithm.searching, std.algorithm.setops, std.algorithm.sorting;

struct Strut{
    long A;
    long B;
}

void main()
{
    long[] input = readln().split.to!(long[]);
    long A = input[0];
    long B = input[1];
    writeln(f(A-1)^f(B));
}

long f(long x)
{
    switch(x%4)
    {
        case 0:
        return x;
        case 1:
        return 1;
        case 2:
        return x ^ 1;
        case 3:
        return 0;
        default:
        return 0;
    }
}

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


int main(){
	int x,y,s;
	while(cin>>x>>y>>s,x|y|s){
		int ans=-1;
		for(int i=1;i<s;i++){
			for(int j=1;j<s;j++){
				if(i*(100+x)/100+j*(100+x)/100!=s)continue;
				ans=max(ans,i*(100+y)/100+j*(100+y)/100);
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0
for coin500 in range(A + 1):
    for coin100 in range(B + 1):
        for coin50 in range(C + 1):
            if coin50 * 50 + coin100 * 100 + coin500 * 500 == X:
                cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define endl "\n"
#define shalaby ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);cerr.tie(0);

using namespace std;

inline int D()
{
    int t;
    scanf("%d",&t);
    return t;
}
inline ll llD()
{
    ll t;
    scanf("%lld",&t);
    return t;
}
ll mod=1e9+7;
const int OO=-1e6;
int xt[4]= {1,0,0,-1};
int yt[4]= {0,1,-1,0};
////////////////////////////////////////////////////////////////////////////////////
 vector <int> adj[200005];
    bool visited[200005];
const int N = 1e6+1;
ll greatestPF[N];
int cnt,nodes,edges;
  void dfs(int s) {
        visited[s] = true;
        cnt++;

        for(int i = 0;i < adj[s].size();++i)    {
         if(visited[adj[s][i]] == false)
         {
             dfs(adj[s][i]);
         }
        }
    }

int mem[100005][3],a[200005],b[105],n,m,k,frq[1000005];
bool valid(int x,int y)
{
    return x>-1 && y>-1 && x<n && y<m;
}
void init()
{
    memset(mem,-1,sizeof mem);
}
int sieve[N];
int main()
{
int x,y;
     cin >> nodes;
        cin >> edges;
        for(int i = 0;i < edges;++i) {
         cin >> x >> y;
         adj[x].push_back(y);
         adj[y].push_back(x);
        }
        int mx=0,mn=2000006;
        for(int i = 1;i <= nodes;++i) {
         if(visited[i] == false)     {
             dfs(i);
           ///  cout<<i<<" "<<cnt<<endl;
             mx=max(cnt,mx);
             mn=min(cnt,mn);
             cnt=0;
         }
    }
cout<<mx-mn+mn;
}


Measured memory_bytes: 20924
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <functional>
#include <algorithm>
#include <complex>
#include <map>
#include <cmath>
#include <string>
#include <cstdio>
#include <stdio.h>
#include <cstdlib>
#include <istream>
//------------------------------------define------------------------//

//------------------------------------typedef-----------------------//


using namespace std;

int n,A[1000000];
//--------------------------------------------------------------//
int binafySearch(int key) {
	int left = 0;
	int right = n;
	int midle;
	while (left < right) {
		midle = (left + right) / 2;
		if (key == A[midle]) {
			return 1;
		}
		 if (key < A[midle]) {
			right = midle;
		}else if (key > A[midle]) {
			left = midle+1;
		}
	}
	return 0;
}


int main() {
	int sum = 0;
	int q;
	int key;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin>>A[i];
	}
	cin>>q;
	for (int i = 0; i < q; i++) {
		cin >> key;

		if (binafySearch(key)) {
			sum++;
		}
	}
	printf("%d\n", sum);
	return 0;
}

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

int main(void) {
  int n, w[100];
  scanf("%d", &n);
  int sum = 0, s = 0, min;

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

  min = sum;
  for ( int i = 0; i < n; i++ ) {
    s += w[i];
    if ( abs(sum - 2*s) < min ) {
      min = abs(sum - 2*s);
    }
  }
  printf("%d", min);
  return 0;
}

Measured memory_bytes: 128
//pragma
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define YOU using
#define DONT namespace
#define SAY std

YOU DONT SAY;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define REPP(i,a,b,d) for(int i=a;i<=b;i+=d)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=a;i>=b;i-=d)
#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) for(int i=0; i<a; i++)
#define FORD(i,a) for(int i=(int)a-1; i>=0; i--)

#define pb push_back
#define F first
#define S second

const int OO = 1e9;
const ll INF = 1e18;

const int irand(int lo,int hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

const ll lrand(ll lo,ll hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

inline void scani(int& x){
	scanf("%d",&x);
}

//end of macro

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define endl '\n'
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);
    
    int a,b;
    cin>>a>>b;
    if(a < b)cout << 0 << endl;
    else cout << 10 << endl;
    
    return 0;
}

Measured memory_bytes: 256
//              _      _                 
//             (_)    | |                
//    _ __ ___  _  ___| |__   __ _  ___  
//   | '_ ` _ \| |/ __| '_ \ / _` |/ _ \ 
//   | | | | | | | (__| | | | (_| | (_) |
//   |_| |_| |_|_|\___|_| |_|\__,_|\___/ 
//                                       
// 
#include <bits/stdc++.h>
#define int long long
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const int MAX=5e5+5;
const int mod=1e9+7;
int fact[MAX];
int invfact[MAX];

int fastpow(int a,int b)
{
	if (a==0)return 0;
	int wynik=1;
	while (b)
	{
		if (b&1)wynik=(wynik*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return wynik;
}

int inv(int a)
{
	return fastpow(a,mod-2);
}

int binom(int a,int b)
{
	if (b>a || a<0 || b<0)return 0;
	b=(fact[b]*fact[a-b])%mod;
	b=inv(b);
	a=fact[a];
	return (a*b)%mod;
}
int32_t main()
{
  BOOST;
  int n,m;
  cin>>n>>m;
  fact[0]=1;
  invfact[0]=inv(fact[0]);
  for (int i=1;i<MAX;i++)fact[i]=(fact[i-1]*i)%mod,invfact[i]=inv(fact[i]);
  int ans=0,skl=1;
  ans+=binom(m,n)*fact[n],ans%=mod;
  int akt=0;
  for (int i=0;i<=n;i++)
  {
  	int ile=binom(n,i);
  	ile=(ile*binom(m-i,n-i))%mod;
  	ile=(ile*fact[n-i])%mod;
  	ile*=skl;
  	akt=(akt+ile+mod)%mod;
  	skl*=-1;
  }
  cout<<(ans*akt)%mod;
  return 0;
}


Measured memory_bytes: 11344
w = input()                    
l = list(w)                    
l.sort()                       
ans = "Yes"                    
if len(l)%2 != 0:
    print("No")
    exit()
for i in range(int(len(l)/2)): 
    if l[2*i] != l[2*i+1]:     
        ans = "No"             
        break                  
print(ans)                     


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

int main()
{
    ll w,h,i,j,k,m;
    cin>>h>>w>>m;
    vector<ll>hh(h+1),ww(w+1);
    vector<pair<ll,ll>>q(m+1);
    map<pair<ll,ll>,ll>p;
    for(i=1;i<=m;i++){
        ll x,y;
        cin>>x>>y;
        q[i].first=x;
        q[i].second=y;
        p[{x,y}]=1;
        hh[x]++;
        ww[y]++;
    }ll ans=0,kk=0;
    ll m1=0,m2=0;
    for(i=1;i<=h;i++){
        if(hh[i]>=m1)
            m1=hh[i];
    }
    for(i=1;i<=w;i++){
        if(ww[i]>=m2)
            m2=ww[i];
    }ll xx=0,yy=0;
    vector<ll>u,v;
    for(i=1;i<=w;i++){
        if(ww[i]==m2)
            v.push_back(i);
    }
    for(i=1;i<=h;i++)
    {
        if(hh[i]==m1)
            u.push_back(i);
    }
    for(i=0;i<u.size();i++){
        for(j=0;j<v.size();j++){
            if(p[{u[i],v[j]}]!=1){
                cout<<m1+m2<<endl;
                return 0;
            }
        }
    }
        cout<<m1+m2-1<<endl;
}


Measured memory_bytes: 39744
#include<iostream>
#include<iomanip>
#include<cstdlib>
#include<stdio.h>
#include<time.h>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int qx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
int qy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(void) {
	while(true) {
		ll h;
		cin>>h;
		if(h == 0) break;
		vector<string> s(5);
		REP(i, 5) {
			s[i].resize(h);
		}
		REP(i, h) {
			REP(j, 5) {
				cin>>s[j][h - 1 - i];
			}
		}
		ll score = 0;
		vector<P> majikesu;
		while(true) {
			REP(i, h) {
				ll cnt = 0;
				vector<ll> kesu;
				FOR(j, 1, 5) {
					if(s[j][i] == '0') continue;
					if(s[j][i] == s[j - 1][i]) {
						if(cnt == 0) {
							cnt = 2;
							kesu.pb(j);
							kesu.pb(j - 1);
						} else {
							++cnt;
							kesu.pb(j);
						}
						if(cnt == 3) {
							if(j + 1 < 5 && s[j + 1][i] == s[j][i]) {
								if(j + 2 < 5 && s[j + 2][i] == s[j][i]) {
									kesu.pb(j + 1);
									kesu.pb(j + 2);
								} else {
									kesu.pb(j + 1);
								}
							}
							break;
						}
					} else {
						kesu.resize(0);
						cnt = 0;
					}
				}
				if(kesu.size() >= 3) {
					if(s[kesu[0]][i] != 0) {
						score += (s[kesu[0]][i] - '0') * kesu.size();
						REP(k, kesu.size()) {
							majikesu.pb(P(kesu[k], i));
						}
					}
				}
			}
			if(majikesu.size() == 0) break;
			else {
				REP(j, majikesu.size()) {
					s[majikesu[j].first][majikesu[j].second] = '.';
				}
				REP(j, 5) {
					REP(k, s[j].size()) {
						if(s[j][k] == '.') {
							s[j].erase(s[j].begin() +  k);
							--k;
						}
					}
				}
				REP(j, 5) {
					REP(k, h - s[j].size()) {
						s[j] += "0";
					}
				}
				majikesu.resize(0);
			}
		}
		cout<<score<<endl;
	}
}

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

int main() {

	string S, T;
	cin >> S >> T;

	T.pop_back();

	if (S == T) {
		cout << "Yes" << "\n";
	}
	else {
		cout << "No" << "\n";
	}

}

Measured memory_bytes: 3544
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

using namespace std;

int main(){

	int n,m;
	vector<int> p;
	map<int,int> s;
	map<int,vector<int>> xy;
	map<int,set<int>> z;
	char flag[100010];
	char ansFlag[100010];

	for(int i=0;i<100010;i++){
		flag[i]=0;
		ansFlag[i]=0;
	}

	cin>>n>>m;
	for(int i=0;i<n;i++){
		int tmp;
		cin>>tmp;
		p.push_back(tmp-1);
		s[tmp-1] = i;
	}
	for(int i=0;i<m;i++){
		int tmpX,tmpY;
		cin>>tmpX>>tmpY;
		xy[tmpX-1].push_back(tmpY-1);
		xy[tmpY-1].push_back(tmpX-1);
	}

	/*学習実施、どことどこが繋がってるのか？*/
	
	int ans=0;
	for(int i=0;i<n;i++){
		if(flag[i]==1)continue;
		queue<int> q;
		q.push(i);
		set<int> touch;
		touch.insert(i);
		flag[i]=1;
		while(q.size()!=0){
			int now = q.front();
			q.pop();
			if(xy[now].size()==0)continue;
			int size = xy[now].size();
			for(int j=0;j<size;j++){
				int next = xy[now].at(j);
				if(flag[next]==0){
					touch.insert(next);
					flag[next]=1;
					q.push(next);
				}
			}
		}
		/*
		for(int j=0;j<n;j++){
			int targetPos = p[j];
			if(touch.count(targetPos)==1){
				ans++;
			}
		}
		*/
		for(auto itr = touch.begin(); itr != touch.end();itr++){
			int targetPos = p[*itr];
			if(touch.count(targetPos)==1){
				ans++;
			}
		}
		/*
		for(auto itr = touch.begin(); itr != touch.end(); itr++){
			for(auto itr2 = itr; itr2 != touch.end() ;itr2++){
				z[*itr].insert(*itr2);
				z[*itr2].insert(*itr);
			}
		}*/
	}


	/*学習結果について表示してみる。*/
	
	/*
	for(int i=0;i<n;i++){
		cout<<"i="<<i<<" next = ";
		for(auto itr = xy[i].begin(); itr != xy[i].end();itr++){
			cout<<*itr<<" ";
		}
		cout<<endl;
	}
	*/
	
	for(int i=0;i<n;i++){
		int targetPos = p[i];
		if(z[i].count(targetPos)==1){
			ans++;
		}
	}

	cout<<ans<<endl;
	return 0;

}

Measured memory_bytes: 25720
require 'prime'
x = {}
(0..100000).each { |i| x[i] = (i.prime?&&((i+1)/2).prime? ? 1 : 0) }
(3..100000).each { |i| x[i] += x[i-1]}

gets.to_i.times do |_|
  l, r = gets.split.map(&:to_i)
  puts x[r]-x[l-1]
end


Measured memory_bytes: 9852
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int i,x,y,best,ans;

int main(){
	while(1){
		best=0;
		for(i=0;i<5;i++){
			scanf("%d %d",&x,&y);
			if(x==0 && y==0)return 0;
			if(x+y>best){best=x+y;ans=i;}
		}
		printf("%c %d\n",'A'+ans,best);
	}
	return 0;
}

Measured memory_bytes: 600
def change_U_D_R_L(changelst):
    changelst = changelst.replace("U", "上")
    changelst = changelst.replace("D", "下")
    changelst = changelst.replace("R", "右")
    changelst = changelst.replace("L", "左")
    re_lst = changelst.replace("上", "D").replace("下", "U").replace("右", "L").replace("左", "L")
    return re_lst


sx, sy, tx, ty = map(int, input().split())
go1 = []

for i in range(abs(ty - sy)):
    go1.append("U")
for i in range(abs(tx - sx)):
    go1.append("R")
go1 = "".join(go1)
back1 = change_U_D_R_L(go1)

print(go1 + back1 + "LU" + go1 + "RDRD" + back1 + "LU")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    char a;
    cin >> a;
    if ('A' <= a && a <= 'Z') cout << 'A' << endl;
    else cout << 'a' << endl;
    return 0;
}


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

using namespace std;
#define ll long long
#define ld long double
#define PI 3.141592653L
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll INF = (ll)1e18;
const int N = 2e5 + 5;
const ll MOD = 1e9 + 7;

int parent[N];

int gcd(int a, int b) { 
    if (a == 0) 
        return b;  
    return gcd(b%a, a);  
} 
   
int lcm(int a, int b) {  
    return (a*b)/gcd(a,b);  
} 

ll pow(ll x, ll y, ll p) {
    if(y == 0) return 1;
    ll res = 1;
    x %= p;
    if(x == 0) return 0LL;
    while(y > 0) {
        if(y & 1) res = (res*x) % p;
        y >>= 1;
        x = (x*x) % p;
    }
    return res;
}

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

void Union(int x, int y) {
    int xPar = find(x), yPar = find(y);
    if(xPar != yPar) parent[xPar] = yPar;
}

int main()
{
    IOS
    int n;
    cin >> n;
    ll res = 1;
    vector<ll> a(n);
    bool hasZero = false;
    for(int i=0;i<n;i++) {
        cin >> a[i];
        if(a[i] == 0) hasZero = true;
    }
    for(int i=0;i<n;i++) {
        if(res > (ll)1e18 / a[i]) {
            res = -1;
            break;
        }
        res *= a[i];
    }
    cout << ((hasZero) ? 0 : res) << endl;
    return 0;
}



Measured memory_bytes: 3972
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define vec vector
#define fi first
#define se second
#define eb emplace_back
#define ef emplace_front
#define pof pop_front()
#define pob pop_back()
#define Rep(i,n) for(li i=0,nn=(li)(n);i!=nn;++i)
#define Rep1(i,n) for(li i=1,nn=(li)(n)+1;i!=nn;++i)
#define Size(v) (li)(v.size())
#define SortA(v) sort(v.begin(),v.end())
#define SortD(v) sort(v.rbegin(),v.rend())
#define All(a) (a).begin(),(a).end()
#define Input(a) for(li ii=0,nn=(li)(a.size());ii!=nn;++ii){cin>>(a).at(ii);}
#define Input2(a,b) for(li ii=0,nn=(li)(a.size());ii!=nn;++ii){cin>>(a).at(ii)>>(b).at(ii);}
#define mp make_pair
using li = int64_t;
using intl = int64_t;
using vi = vec<li>;
using vb = vec<bool>;
using vvi = vec<vi>;
using qi = deque<li>;
using pi = pair<li, li>;
using vpi = vec<pi>;
using si = set<li>;
using vsi = vec<si>;
using mii = map<li, li>;
using vmii = vec<mii>;
vec<li> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<li> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr li INF = 9223372036854775807;

void Yes(li b) {
	if (b)cout << "Yes";
	else cout << "No";
}
void yes(li b) {
	if (b)cout << "yes";
	else cout << "no";
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	cout.precision(16);

	li K;
	cin >>K;

	if(!(K%2)||!(K%5)){cout<<-1;return 0;}

	li num=7,add=70;
	li cnt=1;
  num%=K;

	while(num){
		cnt++;
		num+=add;
		add*=10;
		num%=K;
		add%=K;
	}

	cout<<cnt;



}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

int main(){
    int n;
    cin >> n;
    vector<pair<int,int>> r(n);
    for(int i = 0; i < n; i++){
        int x,l;
        cin >> x >> l;
        r[i] = {x+l,x-l};
    }
    int ans = 1;
    sort(r.begin(),r.end());
    int now = r[0].first;
    for(int i = 1; i < n; i++){
        int nxt = r[i].second;
        if(nxt >= now){
            now = r[i].first;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
n = int(input())
a = [1]
b = 6
while True:
    a.append(b)
    b *= 6
    if b > 10 ** 5:
        break
b = 9
while True:
    a.append(b)
    b *= 9
    if b > 10 ** 5:
        break
a.sort()
a = [0] + a
dp = [[0 for _ in range(n + 1)] for _ in range(len(a))]
for i in range(n + 1):
    dp[0][i] = 10 ** 5
for i in range(1, len(a)):
    for j in range(1, n + 1):
        if a[i] > j:
            dp[i][j] = dp[i - 1][j]
        else:
            dp[i][j] = min(dp[i - 1][j], dp[i][j - a[i]] + 1)
print(dp[len(a) - 1][n])

Measured memory_bytes: 29592
package main

import (
	"fmt"
)

func main() {
	var (
		n,a,b int
		sum = 0
	)
	fmt.Scan(&n,&a,&b)
	for i := 0; i < n+1; i++ {
		if v:= check(i); v>= a && v <=  b {
			sum += i
		}
	}
	fmt.Println(sum)
}

func check(i int) int {
	var wa = 0
	for i > 0{
		wa += i % 10
		i /= 10
	}
	return wa
}


Measured memory_bytes: 512
import java.util.*;
import java.io.*;
 
class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        int n = Integer.parseInt(br.readLine());
        List<Integer> list = new LinkedList<Integer>();
        System.out.print(n+":");
 
        for (int i=2; i*i<=n; i++) {
            while (n%i == 0) {
                n /= i;
                list.add(i);
            }
        }
 
        if (n > 1)
            list.add(n);
 
        for (int i : list) {
            System.out.print(" "+i);
        }
        System.out.println();
 
        br.close();
    }
}

Measured memory_bytes: 24468
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<iomanip>
 
using namespace std;
 
int main(){
    int L;
    cin>>L;
    cout<<fixed<<setprecision(7)<<(double)(L*L*L)/27;
    return 0;
 
}

Measured memory_bytes: 256
def resolve():
    N, M = list(map(int, input().split()))
    A = [list(map(int, input().split())) for i in range(M)]
    cnt = 0
    import itertools
    L = list(itertools.permutations(range(2, N+1)))
    for route in L:
        src = 1
        for point in route:
            dst = point
            if not ([src, dst] in A or [dst, src] in A):
                break
            src = dst
        else:
            cnt += 1
    print(cnt)

if '__main__' == __name__:
    resolve()

Measured memory_bytes: 41452
import bisect
from itertools import*
n,m,k,*x=[int(v)for l in open(0) for v in l.split()];a=accumulate([0]+x[:n]);b=[*accumulate(x[n:])];print(max(i+bisect.bisect(b,k-v)for i,v in enumerate(a)if v<=k))

Measured memory_bytes: 41624
function Main(input) {
  lines = input.split("\n");
  ans = 0
  for (i=0;i<lines[0].length;i++) {
      if (lines[0][i] == lines[1][i]) {
          ans++
      }
  }
  console.log(ans)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
import java.util.Scanner;
 
public class Main {
 
	public static final MyScanner in = new MyScanner();

	public static void main(String[] args) {


		int K = in.nextInt();
		int A = in.nextInt();
		int B = in.nextInt();

		for(int i=A;i<B+1;i++) {
			if (i%K==0) {
				System.out.println("OK");
				return;
			}
		}
		
		String answer = "NG";
		System.out.println(answer);
	}



	public static class MyScanner {
		Scanner sc = new Scanner(System.in);
		String next() { return sc.next();}
		int nextInt() { return Integer.valueOf(sc.next());}
		long nextLong() { return Long.valueOf(sc.next()); }
	}
}

Measured memory_bytes: 35676
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
#include<iomanip>
int lim[21000*2];
int aa[110],bb[110];
int main(){
	int n;cin>>n;
	for(int i=0;i<n;i++)cin>>aa[i];
	for(int i=0;i<n;i++)cin>>bb[i];
	int ruiseki=0;
	lol(i,21000*2)lim[i]=i;
	lol(u,n){
		int a=aa[u],b=bb[u];
		a*=2;b*=2;
		a+=ruiseki;
		for(int i=0;i<21000*2;i++){
			if(i<ruiseki)lim[i]=min(lim[i],ruiseki-i+b);
			if(i>a)lim[i]=min(lim[i],i-a+b);
			if(ruiseki<=i&&i<=a)lim[i]=min(lim[i],b);
		}
		ruiseki=a;
	}
	lol(i,21000*2)lim[i]=min(lim[i],ruiseki-i);
	int ans=0;
	for(int i=0;i<ruiseki;i++){
		ans+=(lim[i]+lim[i+1]);
		//cout<<lim[i]<<" ";
	}
	double tmp=ans+0.0;
	tmp/=8.0;
	cout<<fixed<<setprecision(10)<<tmp<<endl;
	return 0;
}


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

int main() {
    string a,b,c;
    cin>>a>>b>>c;

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

    else {
        cout<<"NO"<<endl;
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

void solve(){
	int n;
	vector<vector<int>> gr(3,vector<int>(3,0));
	vector<vector<bool>> vis(3,vector<bool>(3,false));

	for(int i=0;i<3;i++)
		for(int j=0;j<3;j++)
			cin>>gr[i][j];

	cin>>n;

	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++)
				if(gr[j][k]==x)
					vis[j][k]=true;
		}
	}

	bool flag=false;
	for(int i=0;i<3;i++){
		flag=(flag||(vis[i][0]&&vis[i][1]&&vis[i][2]));
		flag=(flag||(vis[0][i]&&vis[1][i]&&vis[2][i]));
	}
	if((vis[0][0]&&vis[1][1]&&vis[2][2])||(vis[0][2]&&vis[1][1]&&vis[2][0])){
		flag=true;
	}
	if(flag){
		cout<<"Yes\n";
	}
	else{
		cout<<"No\n";
	}
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	solve();
	return 0;
}

Measured memory_bytes: 256
# 分母Bについて周期性があり、さらに単調増加のため、
# Nが周期以下ならN、Nが周期を超えるならB-1を代入した値が答え
a,b,n =map(int,input().split())
import math
x = min(n, b-1)
print((a * x) // b - a * (x // b))

Measured memory_bytes: 9084
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	int n, a, b, c, d;
	string str;
	static int m[200002];
	bool goal;
	cin >> n >> a >> b >> c >> d;
	
	cin >> str;

	goal = true;

	for (int i = 0; i < str.length(); i++) {
		if (str[i] == '#') {
			m[i + 1] = 1;
		}
		else {
			m[i + 1] = 0;
		}
	}
	m[n] = 1;

	if (b < c) {
		if (c < d) {
			for (int i = b + 1; i < d - 1; i++) {
				if (m[i] == 1 && m[i + 1] == 1) {
					goal = false;
					break;
				}
			}

			if (goal) {
				for (int i = a + 1; i < c - 1; i++) {
					if (m[i] == 1 && m[i + 1] == 1) {
						goal = false;
						break;
					}
				}
			}
		}
		else {
			//bが適当な座標に行ったあと、aがゴールして、その後bがゴール
			for (int i = b; i <= d; i++) {
				if (m[i] == 0 && m[i - 1] == 0 && m[i + 1] == 0) {
					break;
				}
				if (i == d) {
					goal = false;
				}
			}
			if (goal) {
				for (int i = a + 1; i < c - 1; i++) {
					if (m[i] == 1 && m[i + 1] == 1) {
						goal = false;
						break;
					}
				}
			}
			if (goal) {
				for (int i = b + 1; i < d - 1; i++) {
					if (m[i] == 1 && m[i + 1] == 1) {
						goal = false;
						break;
					}
				}
			}
		}
	}
	else {
		for (int i = a + 1; i < c - 1; i++) {
			if (m[i] == 1 && m[i + 1] == 1) {
				goal = false;
				break;
			}
		}
		if (goal) {
			for (int i = b + 1; i < d - 1; i++) {
				if (m[i] == 1 && m[i + 1] == 1) {
					goal = false;
					break;
				}
			}
		}
	}

	if (goal) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 1284
import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;

void main() {
    auto N = readln.split[0].to!ulong;
    auto A = readln.split.to!(ulong[]);
    auto grps = sort(A.dup).group;
    size_t[ulong] nums;
    
    //grps.array.writeln;
    
    foreach (tup; grps) {
        nums[tup[0]] = tup[1];
    }
    
    //nums.writeln;
    
    ulong all_num = nums.values.dup.map!(a => a*(a-1)).sum / 2;
    assert(all_num == grps.map!(a => a[1]*(a[1]-1)).sum / 2);
    
    foreach (k; 0 .. N) {
        //writeln("he", A[k], " ", nums[A[k]], " ", ((nums[A[k]])*(nums[A[k]]-1))/2, " ", ((nums[A[k]]-1)*(nums[A[k]]-2))/2 );
        writeln( all_num - (nums[A[k]] - 1) );
    }
}



Measured memory_bytes: 26512
#include<bits/stdc++.h>
#define XX first
#define YY second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define REP rep
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
const ll MOD=1e9+7;

#define rall(X) (X).rbegin(),(X).rend()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}

int N;

signed main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);

  cin >> N;
  rep(i, N) {
    int a;
    cin >> a;
    if (a%2) continue;
    if (a%3 && a%5) {
      cout << "DENIED\n";
      return 0;
    }
  }
  cout << "APPROVED\n";
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(100000)


def main():
    n = int(input().strip())
    L = sorted([int(i) for i in input().strip().split()])
    cnt = 0
    for i in range(0, n - 2):
        for j in range(i + 1, n - 1):
            for k in range(j + 1, n):
                if L[i] < L[j] and L[j] < L[k] and L[i] + L[j] > L[k]:
                    cnt += 1
    print(cnt)
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 67824
#include <stdio.h>

int S(int n);

int main(){
    int n;
    scanf("%d", &n);

    printf(n % S(n) == 0 ? "Yes\n" : "No\n");
    return 0;
}

int S(int n){
    int sum = 0;
    for(int i = n; i > 0; i /= 10){
        sum += (i % 10);
    }
    return sum;
}

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

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
typedef long long ll;
int main(){
ll n;
  cin>>n;
  string s="";
  if(n==0)
    cout<<0;
  else{
while(n!=1){
if(n%(-2)==0){
s.insert(0,"0");
  n=n/(-2);
}
  else{
    s.insert(0,"1");
    if(n<0){
    n=(n/(-2))+1;
    }
    else{
    n=(n/(-2));
    }
  }
}
      s.insert(0,"1");
     cout<<s;
  }

return 0;
}


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

ll solve() {
    ll N, X;
    cin >> N >> X;
    vector<ll> A(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
    }
    ll num = 0;
    for ( int i = 1; i < N; i++ ) {
        ll d = A[i-1] + A[i] - X;
        if ( d > 0 ) {
            num += d;
            if ( A[i] >= d ) {
                A[i] -= d;
            } else {
                A[i-1] -= d - A[i];
                A[i] = 0;
            }
        }
    }
    return num;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

typedef long long int ll; 
#define MOD 1000000007
#define ON 200000
#define rep(i,n) fp(i,0,n)  
#define fp(i,a,b) for(ll i=(a);i<(b);++i)
#define fn(i,a,b) for(ll i=(a);i>(b);i--)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define FF first
#define SS second
typedef pair<ll, ll> pll; 
typedef vector<pll> vpll;
typedef vector<ll> vll;
#define rs(t) string t;cin>>t
#define ri(t) int t;cin>>t
#define rll(t) long long int t;cin>>t
#define MK make_pair
#define PB push_back
#define PO pop_back


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  rll(n);
  vector <ll> v(n);
  rep(i,n){
  	cin >> v[i];
  }
  vector <ll> v2(n);
  rep(i,n){
  	cin >> v2[i];
  }
  vector <ll> v3(n-1);
  rep(i,n-1){
  	cin >> v3[i];
  }
  ll sum = v2[0];
  for(ll i=1;i<n;i++){
  	sum += v2[i];
  	if(v[i]==v[i-1]+1){
  		sum += v3[v[i-1]-1];
  	}	
  }
  cout << sum << endl;
  return 0;
  
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var K, X int
	fmt.Scan(&K, &X)

	ans := ""
	for i := 0; i < K-1; i++ {
		ans += strconv.Itoa(X - K + 1 + i)
		ans += " "
	}
	ans += strconv.Itoa(X) + " "
	for i := 0; i < K-1; i++ {
		ans += strconv.Itoa(X + i + 1)
		ans += " "
	}

	fmt.Println(ans)
}


Measured memory_bytes: 1952
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

string S;

int main()
{
    cin >> S;
    long long ans = 0LL;
    int len = S.length();

    int cnt = 0;
    for (int i = 0; i < len; i++)
    {
        if(S[i] == 'W')
        {
            ans += max(i - cnt, 0);
            cnt++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1336
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "YES" : "NO"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n,m;
	bool ans=true;
	cin >>n>>m;
	VP path(m);
	cin >> path;
	V dis(n, 0LL);
	rep(i,m){
		path[i].F--;
		path[i].S--;
		if(path[i].F > path[i].S){
			swap(path[i].F, path[i].S);
		}
		dis[path[i].F]++;
		dis[path[i].S]--;
	}
	rep(i, n) { ans &= (dis[i] % 2 == 0); }
	cout<<solve(ans)<<endl;
}
/*
1 1 |  4 4

 1 13 |4 5  5 
*/

Measured memory_bytes: 5608
N,X = map(int, input().split())
L= list(map(int, input().split()))

count= 0
sumList=[]
sumList.append(0)

for i in range(N):
  if(sum(L[0:i+1]) > X):break
  sumList.append(sum(L[0:i+1]))

print(len(sumList))

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(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)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n;
    cin >> n;
    vector<int> v(n);
    int ma = -inf, p = -1;
    REP(i, n){
        cin >> v[i];
        if(chmax(ma, v[i])) p = i;
    }
    vector<int> u(v);
    sort(rall(u));
    REP(i, n){
        cout << (i == p ? u[1] : ma) << endl;
    }
    return 0;
}


Measured memory_bytes: 3200