akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
int N;
set<string> T;
void func(string S){
  if(S.size()==N) T.insert(S);
  else{
    int C=S.size();
    char D='a';
    rep(i,0,C) D=max(D,S[i]);
    D++;
    for(char i='a';i<=D;i++){
      string X=S+i;
      func(X);
    }
  }
}
signed main(){
  cin>>N;
  string _="a";
  func(_);
  for(auto p:T) cout<<p<<endl;
  }





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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
bool LTE(double a,double b) { return equals(a,b) || a < b; }
bool LT(double a,double b) { return !equals(a,b) && a < b; }

void compute() {

}

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  rep(i,n) cin >> x[i];
  ll cnt= 0;
  int R = 1;
  int bit = x[0];

  bool debug = 0;
  if( debug ) {
    bitset<10> BIT;
    rep(i,n) {
      cout << i%10 << "-th : " << x[i] << string(5-to_string(x[i]).size(),' ') << " = " << (BIT=x[i]) << endl;
    }puts("");
  }
  rep(i,n) {
    if( i - 1 >= 0 ) {
      bit = bit ^ ( x[i-1] );
    }
    while( R < n && !( x[R] & bit ) ) {
      bit = bit | x[R];
      ++R;
    }
    if( R <= i ) R = i + 1;
    if( debug)
    cout << "i = " << i << " R = " << R << endl;
    cnt += ( R - i );
  }
  cout << cnt << endl;
  compute();
  return 0;
}


Measured memory_bytes: 1024
X = int(input())
 
score =0
half_x = round(X/2)
 
answer = 0
 
if X < 3:
    print(1)
 
elif X <= 8:
    print(4)
 
else:
    while 1 < half_x:
        half_x -= 1
        
        for p in range(2, 10):
            
            score = pow(half_x,p)
            if score > X:
                continue
        
            if answer < score:
                answer = score
                
    print(answer)

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

int main(){
  long long n,d;
  cin >> n >> d;
  long x[n];
  long y[n];
  long long c;
  c=0;
  long long i;
  for(i=1;i <=n;i++){
    cin >> x[i];
    cin >> y[i];
    
    if(x[i]*x[i]+y[i]*y[i]<=d*d){
    c++;
  }
  }
  cout << c <<endl;
}

Measured memory_bytes: 6704
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mx2 102
#define mx3 1003
#define mx4 10004
#define mx5 100005
#define mx6 1000006
#define mod 1000000007
#define PI 3.14159265
#define fo(i,n) for(int i=0 ; i<n ; i++)
#define Fo(i,k,n) for(int i=k ; i<n ; i++)
 
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pair<int,int>,int> piii;

int n ,k, ans , sum , a , b ,arr[mx5];
string str;
 
int main() {
	ios::sync_with_stdio(false);
	//int t;cin>>t;while(t--)
	{
		cin>>n>>k;
		fo(i,n) cin>>arr[i];
		fo(i,n)
		{
			if(k<=arr[i])
			{
				ans++;
			}
		}
		cout<<ans;
	}
	return 0;
}


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

using namespace std; 

int main(){
	
	string s;
	
	cin >> s ;
	
	int ans = 1000;
	string val="";
	
	for(int i=0;i<(int)s.size()-2;i++){
			
		stringstream ss(s.substr(i,3));
		
		int value; 
		
		ss >> value;
		
			ans = min(ans,abs(value-753));
		
	}
	
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int  N ,count ,ans;
  cin >> N ;  
  ans  = 200;

    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }

 for (int i = 0; i < N ; i++) { //N回ループ
   count = 0;                   //count初期化
   while (A.at(i)%2 == 0 )  {   //偶数ならば2で割る
     A.at(i) /= 2 ;    
     count++  ;       //2で割った回数をカウント
   }
   if (count < ans){
     ans = count;
   }
 }

    cout << ans << endl;

}

Measured memory_bytes: 256
from heapq import *
n, m = map(int,input().split())
a = list(map(int,input().split()))
bc = [list(map(int,input().split())) for i in range(m)]
bc = sorted(bc, reverse = True, key = lambda x:x[1])
#print(bc)
heapify(a)

for num, alt in bc:

    while num > 0:
        temp = heappop(a)
        if temp >= alt:
            heappush(a, temp)
            break
        temp = alt
        heappush(a, temp)
        num -= 1
print(sum(a))

Measured memory_bytes: 100760
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main(){
	FOR(i,1,9+1){
		FOR(j,1,9+1){
			printf("%dx%d=%d\n",i,j,i*j);
		}
	}
}

Measured memory_bytes: 1096
function main()
    n = parse(Int, readline())
    s = readline()
    count = 0
    counts = [Int[], Int[], Int[]] #RGB
    x,y,z = 0,0,0
    hoge = 0
    for i in 1:n
        aa = min(i-1, n-i)
        for j in 1:aa
            if s[i] != s[i-j] != s[i+j] != s[i]
                # println(s[i], s[i-j], s[i+j])
                hoge += 1
            end
        end
        c = s[i]
        if c == 'R'
            x += 1
        elseif c == 'G'
            y += 1
        else
            z += 1
        end
    end
    println(x*y*z-hoge)
end

main()


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

using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int>v1;
    set<int>s1;
    for(int i=0; i<n; i++)
    {
        int x;
        cin>>x;
        v1.push_back(x);
        s1.insert(x);
    }
  
    sort(v1.begin(),v1.end());
    int m=n/2;
    cout<<v1[m]-v1[m-1]<<endl;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef queue<ll> ql;
typedef deque<ll> dql;
typedef priority_queue<ll/*, vl, greater<ll>*/> pql; //降順(/*昇順*/)
typedef set<ll> sl;
typedef pair<ll, ll> pl;
typedef vector<vl> vvl;
typedef vector<pl> vpl;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define rep2(i, n) for(ll i = 1; i <= ll(n); i++)
//#define rep(i, k, n) for(ll i = k-1; i < ll(n); i++)
//#define rep2(i, k, n) for(ll i = k; i <= ll(n); i++)
#define all(v) (v).begin(), (v).end()
bool chmin(ll &a, ll b) {if(b < a) {a = b; return 1;} return 0;}
bool chmax(ll &a, ll b) {if(b > a) {a = b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;
const ll MAX = 1e9;
const char newl = '\n';

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

  ll n, ans=0;
  cin >> n;
  vl v(n), c(n);
  rep(i, n) cin >> v[i];
  rep(i, n) cin >> c[i];
  rep(i, n)  ans += max(v[i]-c[i], (ll)0);
  cout << ans << newl;
  return 0;
}

Measured memory_bytes: 3628
import java.util.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    static char[][] field;

    public static void main(String[] args) {
        while(read()){
            solve();
            //print();
        }
    }
    static boolean read(){
        if(!sc.hasNext())return false;
        field = new char[12][12];
        for(int i = 0; i < 12; i++){
            field[i] = sc.next().toCharArray();
        }
        return true;
    }
    static void solve(){
        int res = 0;
        for(int i = 0; i < 12; i++){
            for(int j = 0; j < 12; j++){
                if(field[i][j] == '1'){
                    dfs(j, i);
                    res++;
                }
            }
        }
        System.out.println(res);
    }
    static void dfs(int x, int y){
        field[y][x] = 0;
        int []dx = {-1, 0, 0, 1}, dy = {0, 1, -1, 0};
        for(int i = 0; i < 4; i++){
                int nx = x + dx[i], ny = y + dy[i];
                if(0 <= nx && nx < 12 && 0 <= ny && ny < 12 && field[ny][nx] == '1')
                    dfs(nx, ny);
        }
    }

    static void print(){
        for(int i = 0; i < 12; i++){
            for(int j = 0; j < 12; j++){
                System.out.print(field[i][j]);
            }
            System.out.println();
        }
    }
}

Measured memory_bytes: 0
/*
My heart’s beating faster
I know what I’m after
 
I’ve been standing here my whole life
Everything I’ve seen twice
Now it’s time I realized
It’s spinning back around now
On this road I’m crawlin’
Save me 'cause I’m fallin’
Now I can’t seem to breathe right
'Cause I keep runnin' runnin' runnin' runnin'
Runnin' runnin' runnin' runnin'
Runnin' from my heart
*/
 
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
#define nt _int128
#define fir first
#define sec second
#define slow_as_snail ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define debug(x) cout<<x<<"\n";
#define debugged cout<<"debugged\n";
#define inf 0x3f3f3f3f
#define rall(v) v.rbegin(),v.rend()
#define all(v) v.begin(),v.end() 
 
const ll mod = 1000000007;
#define mx 10000005
const ll mxi = 100005;

// vector<ll> gr[mxi];

int main()
{
    slow_as_snail;
    vector<ll> gr[mxi];
    ll n,m;
    cin>>n>>m;
    ll ht[mxi];
    for(int i=0;i<n;i++)
    {
        cin>>ht[i];
    }
    for(int i=0;i<m;i++)
    {
        ll x,y;
        cin>>x>>y;
        x--,y--;
        gr[x].pb(y);
        gr[y].pb(x);
    }
    ll ans = 0;
    for(int i=0;i<n;i++)
    {
        ll fl = 1;
        for(auto it : gr[i])
        {
            if(ht[it]>=ht[i])
            {
                fl = 0;
                break;
            }
        }
        if(fl)
        {
            ans++;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 10260
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <bitset>
#include <tuple>
#include <stack>
#include <utility>

using namespace std;
typedef long long ll;

int main(){
    string S;
    cin >> S;

    int ans1=0, ans2=0;
    for(int i=0; i<S.size(); i++){
        if(i%2==0 && S[i]=='0') ans1 += 1;
        if(i%2==1 && S[i]=='1') ans1 += 1;
    }
    for(int i=0; i<S.size(); i++){
        if(i%2==0 && S[i]=='1') ans2 += 1;
        if(i%2==1 && S[i]=='0') ans2 += 1;
    }

    cout << min(ans1, ans2) << endl;
    return 0;
}

Measured memory_bytes: 512
import java.io.*;
import java.util.*;

public class Main{
	public static void solve(String str){
    	HashSet<String> ptn= new HashSet<String>();
    	ptn.add(str);
    	for(int i=1;i<str.length();i++){
    		String str_frt= str.substring(0,i);
    		String str_bck= str.substring(i);
    		StringBuilder sb_frt_inv= new StringBuilder();
    		StringBuilder sb_bck_inv= new StringBuilder();
    		for(int j=str_frt.length()-1;j>=0;j--){
    			sb_frt_inv= sb_frt_inv.append(str_frt.charAt(j));
    		}
    		for(int j=str_bck.length()-1;j>=0;j--){
    			sb_bck_inv= sb_bck_inv.append(str_bck.charAt(j));
    		}
    		String str_frt_inv= sb_frt_inv.toString();
    		String str_bck_inv= sb_bck_inv.toString();
    		
    		ptn.add(str_frt+str_bck_inv);
    		ptn.add(str_frt_inv+str_bck);
    		ptn.add(str_frt_inv+str_bck_inv);
    		ptn.add(str_bck+str_frt);
    		ptn.add(str_bck+str_frt_inv);
    		ptn.add(str_bck_inv+str_frt);
    		ptn.add(str_bck_inv+str_frt_inv);
    	}
    	
    	System.out.println(ptn.size());
	}
    public static void main(String args[]) throws Exception{
    	BufferedReader br= new BufferedReader(new InputStreamReader(System.in));
    	int rep= Integer.valueOf(br.readLine());
    	for(int i=0;i<rep;i++){
        	solve(br.readLine());
    	}
    }
}

Measured memory_bytes: 59988
import scala.io.StdIn._
import scala.annotation.tailrec

object Main {

  object Dice{
    private val northPer = List(2,6,3,4,1,5).map(_ - 1)
    private val eastPer = List(4,2,1,6,5,3).map(_ - 1)
    private val ccwPer = List(1,4,2,5,3,6).map(_ - 1)
    //private val unitPer = List(1,2,3,4,5,6).map(_ - 1)

    type Per = List[Int]
    type Rot = (Dice,Per) => Dice

    def rot(dice: Dice, perm: Per):Dice = Dice(perm.map(dice.pip))

    def unit(dice: Dice, perm: Per):Dice = dice

    def rev(dice: Dice, perm: Per):Dice = foldLeft(dice,perm)


    def foldLeft(dice: Dice, perm: Per, n:Int = 4, f:Rot = rot):Dice =
      if(n<=0) dice else foldLeft(f(dice,perm),perm,n-1,f)

    def axial(d: Dice,f: Dice=>Dice): List[Dice] = List(d,f(d),f(f(d)),f(f(f(d))))

    def north(d: Dice) = rot(d,northPer)
    def east(d: Dice) = rot(d,eastPer)
    def ccw(d: Dice) = rot(d,ccwPer)

    def south(d: Dice) = rev(d,northPer)
    def west(d: Dice) = rev(d,eastPer)
    def cw(d: Dice) = rev(d,ccwPer)

    def vertical(d: Dice): List[Dice] = axial(d, north)
    def horizontal(d: Dice): List[Dice] = axial(d, east)
    def turn(d: Dice): List[Dice] = axial(d, ccw)

    def enumerateTop(d: Dice, n: Int = 6): List[Dice] = {
      if(n<=0)List[Dice]()
      else d :: enumerateTop(if(n%2==0) north(d) else east(d), n-1)
    }

    def enumerate(d: Dice): List[Dice] = enumerateTop(d).flatMap(turn)
  }

  case class Dice(pip: List[Int] = List(1,2,3,4,5,6)) {

    def rotate(com: Char):Dice = com match {
      case 'N' => Dice.north(this)
      case 'E' => Dice.east(this)
      case 'S' => Dice.south(this)
      case 'W' => Dice.west(this)
      case _ => this
    }
  }

  @tailrec
  def loop(n:Int, all: List[Dice]):Unit = if(n>0){
    val Array(a,b,_*) = readLine.split(" ").map(_.toInt)
    val res = all.filter(d => d.pip(0)==a && d.pip(1)==b)
    println(res(0).pip(2))
    loop(n-1,all)
  }

  def main(args: Array[String]): Unit = {
    val pip = readLine.split(" ").map(_.toInt).toList
    val all: List[Dice] = Dice.enumerate(Dice(pip))
    val Array(n,_*) = readLine.split(" ").map(_.toInt)
    loop(n,all)
  }
}

Measured memory_bytes: 41224
X = int(input())
MAX = 10**4
Flag = False
for i in range(MAX):
    A = i
    for j in range(A,MAX):
        B = j
        if A**5 - B**5 == X:
            print(A,B)
            Flag = True
            break
        elif A**5 + B**5 == X:
            print(A,-B)
            Flag = True
            break
        elif B**5 - A**5 == X:
            print(-A,-B)
            Flag = True
            break
    if Flag:
        break

Measured memory_bytes: 67820
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
#define Max(a) (*max_element(ALL(a)))
#define Min(a) (*min_element(ALL(a)))
using namespace std;
const double PI = acos(-1);
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  double a,b,h,m;cin>>a>>b>>h>>m;
  double d = abs((360.0*m/60.0)-(h*30.0+(m/2.0)));
  printf("%.10f\n",sqrt(a*a+b*b-2*a*b*cos(PI*d/180.0)));
  return 0;
}


Measured memory_bytes: 4244
def main():
    X,A,B = map(int,input().split())
    eat_day = B - A

    if(eat_day <= 0):
        print("delicious")
    elif(eat_day <= X):
        print("safe")
    elif(eat_day > X):
        print("dangerous")

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <stdio.h>
int main(void){
    int n,k;
    scanf("%d%d",&n,&k);
    
    int a[n];
    
    int i,j,l;
    for(i = 0; i < n; i++)
    {
        a[i] = 0;
    }

    
    
    
    for(i = 0; i < k; i++)
    {   
        int d;
        scanf("%d",&d);
        int b[d];
        
        for(j = 0; j < d; j++)
        {
            b[d] = 0;
        }
        
    
        for(l = 0; l < d; l++)
        {
            scanf("%d",&b[l]);
            
            for(int ii = 0; ii < n; ii++)
            {
                if(b[l] == ii+1)
                {
                    a[ii]++;
                }
            }
        }
    }
    
        
    int ans = 0;
    
    for(i = 0; i < n; i++)
    {
        if(a[i] == 0){
            ans++;
        }
    }
    
    printf("%d\n",ans);
        
}

Measured memory_bytes: 1724
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int a[3];
int main() {
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	if (a[0] == 5 && a[1] == 5 && a[2] == 7)cout << "YES" << endl;
	else { cout << "NO" << endl; }
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int h,w;
	cin>>h>>w;
	string board[50];

	for(int j=0;j<h;j++)
	{
		cin>>board[j];
	}

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

	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			if(board[i][j]=='#')
				continue;

			int cnt=0;
			for(int d=0;d<8;d++)
			{
				const int ni=i+dy[d];
				const int nj=j+dx[d];

				if(ni<0 || ni>=h)
					continue;
				if(nj<0 || nj>=w)
					continue;
				if(board[ni][nj]=='#')
					cnt++;
			}
			board[i][j] = char(cnt+'0');
		}
	}
	for(int i=0;i<h;i++)
		cout<<board[i]<<"\n";
}

Measured memory_bytes: 256
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/


const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {//階乗、その逆元も存在する。
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
  mint p(int n,int k){
  return fact[n]*ifact[n-k];
  }
}comb(100005);//100005まで計算（どこまで必要かで変更）


int main() {
ll N,M;
cin>>N>>M;
if(abs(N-M)>1){
  cout<<0<<endl;
  return 0;
}
mint ans;
if(M==N){
  ans=comb.fact[N]*comb.fact[M]*2;
}
else{
  ans=comb.fact[N]*comb.fact[M];
}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 4628
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s, t;
  cin >> s >> t;
  int ls = s.size(), lt = t.size();
  int ans = lt;
  for(int i=0; i<ls-lt+1; ++i){
    int sub = lt;
    for(int j=0; j<lt; ++j){
      if(s[i+j] == t[j]) --sub;
    }
    ans = min(ans, sub);
  }
  cout << ans << endl; 
}

Measured memory_bytes: 3592
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <cmath>
#include <string>
#include <set>
#include <map>
#define SIZE 200005
#define MOD 1000000007

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

ll inv[SIZE],fac[SIZE],finv[SIZE];
void make()
{
	fac[0]=fac[1]=1;
	finv[0]=finv[1]=1;
	inv[1]=1;
	for(int i=2;i<SIZE;i++)
	{
		inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
		fac[i]=fac[i-1]*(ll) i%MOD;
		finv[i]=finv[i-1]*inv[i]%MOD;
	}
}
ll C(int a,int b)
{
	if(a<b) return 0;
	return fac[a]*(finv[b]*finv[a-b]%MOD)%MOD;
}
int main()
{
	make();
	int n,m;
	scanf("%d %d",&n,&m);
	if(n<m) swap(n,m);
	if(n==m)
	{
		printf("%lld\n",fac[n]*fac[m]%MOD*(ll) 2LL%MOD);
	}
	else if(n==m+1)
	{
		printf("%lld\n",fac[n]*fac[m]%MOD);
	}
	else
	{
		puts("0");
	}
	return 0;
}


Measured memory_bytes: 4864
#include <stdio.h>
#include <string.h>

int main(){
	char S[100];
	scanf("%s", &S);
	if(strcmp(S, "ABC") == 0){
		printf("ARC\n");
	}
	if(strcmp(S, "ARC") == 0){
		printf("ABC\n");
	}
	return 0;
}

Measured memory_bytes: 1664
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;

const long long INF = 1LL << 60;

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

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

long long h[1000000];
long long dp[1000000];

int main() {
	int n;
	cin >> n;
	for (int i = 0;i < n;i++)cin >> h[i];
	for (int i = 0;i < n;i++) dp[i] = INF;

	dp[0] = 0;

	for (int i = 1;i < n;i++) {
		chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
		if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
	}

	cout << dp[n - 1] << endl;
}



Measured memory_bytes: 5120
#include<stdio.h>
int main()
{
    int a,b,i;
    scanf("%d%d",&a,&b);
    char k[20];
    if(a==b)
    {
        for(i=0; i<a; i++)
        {
            k[i]=a;
        }
        k[i]='\0';
        for(i=0; k[i]!='\0'; i++)
        {
            printf("%d",k[i]);
        }
    }
    else if(a>b)
    {
        for(i=0; i<a; i++)
        {
            k[i]=b;
        }
        k[i]='\0';
        for(i=0; k[i]!='\0'; i++)
        {
            printf("%d",k[i]);
        }
    }
    else
    {
        for(i=0; i<b; i++)
        {
            k[i]=a;
        }
        k[i]='\0';
        for(i=0; k[i]!='\0'; i++)
        {
            printf("%d",k[i]);
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <cassert>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;
//#define int long long

string s;

signed main() {
	int i, j;
	
	int ans = 11451419;
	cin >> s;
	for (i = 0; i + 2 < s.length(); i++) {
		int x = 0;
		for (j = i; j < i + 3; j++) {
			x *= 10;
			x += s[j] - '0';
		}
		ans = min(ans, abs(753 - x));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,s,n) for (int i = (s); i < (n); ++i)
#define rrep(i,n,g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define len(x) (int)(x).size()
#define dup(x,y) (((x)+(y)-1)/(y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int mod = 1000000007;

ll mmod(ll a) {
  a %= mod;
  if (a < 0) a += mod;
  return a;
}

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  ll k = 0;
  rep(i,0,n) {
    cin >> a[i];
    k += a[i];
    k %= mod;
  }
  ll ans = 0;
  rep(i,0,n-1) {
    k = mmod(k-a[i]);
    ans += k * a[i];
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4840
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <iomanip>

#include <map>
#include <set>
#include <queue>
#include <stack>

#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdbl vector<double>
#define vstr vector<string>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	int N,M;
	cin >> N >> M;

	int cnt[N+1] = {};
	rep(i,M){
		int a,b;
		cin >> a >> b;
		cnt[a]++;
		cnt[b]++;
	}

	rep(i,N){
		if(cnt[i+1] & 1){
			cout << "NO" << endl;
			return 0;
		}
	}

	cout << "YES" << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int v[300005];

int main()
{
	long long a,b,n;
	scanf("%lld %lld %lld",&n,&a,&b);
	if(n > a*b || (a+b-1) > n)
	{
		puts("-1");
		return 0;
	}
	v[1] = b;
	for(int i = 2; i <= a; i++)
	{
		v[i] = 1;
	}
	int tot = a + b - 1;
	int idx = 2;
	while(tot < n)
	{
		while(v[idx] == b)
			idx++;
		v[idx]++;
		tot++;
	}
	vector<int>ans;
	long long val = 0;
	for(int i = 1; i <= a; i++)
	{
		for(int j = val+v[i]; j >= val + 1 ; j--)
		{
			ans.push_back(j);
		}
		val += v[i];
	}
	for(int i = 0; i < ans.size(); i++)
	{
		printf("%d%c",ans[i]," \n"[i == ans.size()-1]);
	}
	return 0;
}


Measured memory_bytes: 4208
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <numeric>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
int INF = 1e9;
const int mod = 1000000007;
class mint {
	long long x;
public:
	mint(long long x=0) : x((x%mod+mod)%mod) {}
	mint operator-() const { 
	return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod-2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res/=a;
	}
	friend ostream& operator<<(ostream& os, const mint& m){
		os << m.x;
		return os;
	}
};
int main(){
	ll n;cin >> n;
	if(n==1) {
		cout << 0 << endl;
		return 0;
	}
	mint ans = mint(10).pow(n) - mint(2)*mint(9).pow(n) + mint(8).pow(n);
	cout << ans << endl;


} 
 

Measured memory_bytes: 3628
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 1e5 + 10;
int f[N];
int find(int x) {
  if (f[x] != f[f[x]]) f[x] = find(f[x]);
  return f[x];
}

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<int> p(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &p[i]);
    --p[i];
    f[i] = i;
  }
  while (m--) {
    int x, y;
    scanf("%d%d", &x, &y);
    --x; --y;
    int rx = find(x), ry = find(y);
    if (rx != ry) {
      f[ry] = rx;
    }
  }
  int ret = 0;
  for (int i = 0; i < n; ++i) {
    if (find(p[i]) == find(i)) ++ret;
  }
  printf("%d\n", ret);
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
ll fact(int n)
{
    return n == 1 ? 1 : (n * fact(n - 1)) % (1000000007);
}
int main()
{
    int n, m;
    cin >> n >> m;
    ll ans;

    if (n == m)
    {
        // cout << fact(n) * fact(m) << endl;
        ans = ((fact(n) * fact(m)) * 2) % 1000000007;
    }
    else if (abs(n - m) == 1)
    {
        ans = (fact(n) * fact(m)) % 1000000007;
    }
    else
    {
        ans = 0;
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef long double ld;

const int inf = 1e9;
const ll inf64 = 1e18;

int main() {

#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    string s;
    cin >> s;

    int n = (int) s.size();

    if (n % 2) {
        cout << "No\n";
        return 0;
    }

    for (int i = 0; i < n; i += 2) {
        if (s[i] != 'h' || s[i + 1] != 'i') {
            cout << "No\n";
            return 0;
        }
    }

    cout << "Yes\n";
    return 0;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#define MAX_N 90
using namespace std;
typedef long long ll;

ll lucas[MAX_N];

int main() {
    ll N;
    cin >> N;
    lucas[0] = 2, lucas[1] = 1;
    for (int i = 2; i <= N; i++) lucas[i] = lucas[i - 1] + lucas[i - 2];
    cout << lucas[N] << endl;
    return 0;
}

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


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    ll n,q;
    string s;
    cin>>n>>s>>q;
    while(q--){
        ll k;
        cin>>k;
        ll m=0,c=0,cnt=0;
        ll r = 0;
        ll ans = 0;
        for(int i=0;i<k;i++){
            if(s[i]=='M') m++;
            if(s[i]=='C') c += m,cnt++;
        }
        for(int i=0;i<n;i++){
            if(s[i]=='D' && m>0 && c>0) ans += c;
            if(s[i]=='M'){
                c -= cnt;
                m--;
            }
            if(s[i]=='C') cnt--;
            if(i+k<n){
                if(s[i+k]=='M') m++;
                if(s[i+k]=='C') c += m,cnt++;
            }
            //cerr<<i<<" "<<ans<<endl;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1948
#include <stdio.h>
#define Min(a,b) a<b?a:b
#define inf 1 << 30
void heapsort(int a[], int len);
void add_heap(int a[], int len);
void upheap(int a[], int add);
void rm_heap(int a[], int len);
void down_heap(int a[], int len);
int max_child(int a[], int num, int len);

int swap(int *a, int *b);

void heapsort(int a[], int len)
{
    add_heap(a, len);
    rm_heap(a, len);
    len--;
}

void add_heap(int a[], int len)
{
    if (len == 0)
    {
        return;
    }

    int i = 2;
    while (i <= len)
    {
        upheap(a, i);
        i++;
    }
}

void upheap(int a[], int add)
{
    while (add > 1)
    {
        if (a[add - 1] > a[add / 2 - 1])
        {
            swap(&a[add - 1], &a[add / 2 - 1]);
            add /= 2;
        }
        else
        {
            break;
        }
    }
}

void rm_heap(int a[], int len)
{
    while (len > 1)
    {
        swap(&a[0], &a[len - 1]);
        down_heap(a, len - 1);
        len--;
    }
}

void down_heap(int a[], int len)
{
    int pare_p = 1;
    while (2 * pare_p <= len)
    {
        int child_p = max_child(a, pare_p, len);
        if (a[pare_p - 1] < a[child_p - 1])
        {
            swap(&a[pare_p - 1], &a[child_p - 1]);
            pare_p = child_p;
        }
        else
        {
            break;
        }
    }
}

int max_child(int a[], int num, int len)
{
    if (2 * num == len)
    {
        return 2 * num;
    }

    if (a[2 * num - 1] > a[2 * num])
    {
        return 2 * num;
    }
    else
    {
        return 2 * num + 1;
    }
}

int swap(int *a, int *b)
{
    int tmp = *a;
    *a = *b;
    *b = tmp;
}

int main(void)
{
    int n,k;
    scanf("%d%d",&n,&k);
    int a[n],i = 0;
    for(i = 0; i < n; i++)
    {
        scanf("%d",&a[i]);
    }
    heapsort(a, n);
    int min = inf;
    for(i = 0; i < n - k + 1; i++)
    {
        min = Min(min, a[i + k - 1] - a[i]);
    }
    printf("%d\n",min);
    return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(vec) (vec).begin(), (vec).end()
#define SUM(...) accumulate(ALL(__VA_ARGS__),0LL)
#define DSUM(...) accumulate(ALL(__VA_ARGS__),0.0)
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 便利関数
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

// 出力
void print() { std::cout << '\n'; }
template <class T>void print(const T &x) {std::cout << x <<'\n';}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}

const int INF = 2002002002;

void solve(long long N){
    print(800 * N - (N / 15) * 200);
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
constexpr long N = 300000;
constexpr long mod = 998244353;

long mpow(long a, long p){
    long x=a;
    long y=1;
    while(p>0){
        if((p&1)==1){
            y=x*y%mod;
        }
        x=x*x%mod;
        p>>=1;
    }
    return y;
}

long minv(long a){
    return mpow(a, mod-2);
}

long fact[4*N+1];
void init_fact(){
    long t=1;
    fact[0]=1;
    for(long i=1; i<=N; i++){
        t=t*i%mod;
        fact[i]=t;
    }
}

long mcomb(long n, long r){
    return fact[n]*minv(fact[n-r]*fact[r]%mod)%mod;
}

int main(void){
    long n, a, b, k;
    scanf("%ld %ld %ld %ld", &n, &a, &b, &k);
    init_fact();
    long sum = 0;
    long s = max(0l, (k-n*b)/a);
    long e = min(n, k/a);
    for(long i=s; i<=e; i++){
        long q=(k-a*i)/b;
        long m=(k-a*i)%b;
        if(m==0){
            sum = (sum+mcomb(n,i)*mcomb(n,q))%mod;
        }
    }
    if(sum==0)sum++;
    printf("%ld\n", sum);
    return 0;
}


Measured memory_bytes: 4476
package main

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

////////////////////////////////////////
///        templates                 ///
////////////////////////////////////////

var sc = bufio.NewScanner(os.Stdin)

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

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readBigLine() string {
        buf := make([]byte, 0, 1000000)
        for {
                l, p, e := rdr.ReadLine()
                if e != nil {
                        panic(e)
                }
                buf = append(buf, l...)
                if !p {
                        break
                }
        }
        return string(buf)
}

func strSprit(str string) []string {
        cols := strings.Split(str, " ")
        return cols
}

func parseInt(str string) int {
        n, _ := strconv.Atoi(str)
        return n
}

func intSprit(str string) []int {
        strs := strSprit(str)
        cols := make([]int, len(strs))
        for i, v := range strs {
                cols[i] = parseInt(v)
        }
        return cols
}

func bitCount(n uint) int {

        x := uint64(n)

        const m = 1<<64 - 1
        const m0 = 0x5555555555555555
        const m1 = 0x3333333333333333
        const m2 = 0x0f0f0f0f0f0f0f0f

        x = x>>1&(m0&m) + x&(m0&m)
        x = x>>2&(m1&m) + x&(m1&m)
        x = (x>>4 + x) & (m2 & m)
        x += x >> 8
        x += x >> 16
        x += x >> 32

        return int(x) & (1<<7 - 1)
}

func bitExist(n, i int) bool {
        return ((n >> uint(i)) & 1) == 1
}

////////////////////////////////////////
///        end templates             ///
////////////////////////////////////////
var m map[string]bool

func init() {
        m = map[string]bool{}
}

func doComb(n int) []string {
        ret := []string{"3", "5", "7"}
        for i := 2; i <= n; i++ {
                ret = append(ret, addCombination(ret)...)
        }
        return ret
}
func addCombination(l []string) []string {
        ret := []string{}
        pref := "357"
        for _, v := range l {
                for _, p := range pref {
                        s := string(p) + v
                        if ok, _ := m[s]; !ok {
                                ret = append(ret, s)
                                m[s] = true
                        }
                }
        }
        return ret
}

func has753(s string) bool {
        return (strings.Index(s, "3") >= 0) && (strings.Index(s, "5") >= 0) && (strings.Index(s, "7") >= 0)
}

func main() {
        line := nextLine()

        N := parseInt(line)

        comb := doComb(len(line))

        sum := 0
        for _, v := range comb {
                n := parseInt(v)
                if has753(v) && n <= N {
                        sum++
                }
        }
        fmt.Println(sum)
}


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

using namespace std;

using int64 = long long;

int main() {
  int N;
  cin >> N;
  map< int64, int > mp;
  int64 sum = 0;
  mp[0]++;

  int64 ret = 0;
  for(int i = 0; i < N; i++) {
    int x;
    cin >> x;
    sum += x;
    ret += mp[sum];
    mp[sum]++;
  }

  cout << ret << endl;

}

Measured memory_bytes: 12800
n=int(input())
f=["aabbc","hi..c","hi..d","g.jjd","gffee"]
if n==2:print(-1);exit()
if n==3:print("abb","a.c","ddc");exit()
if n==5:print("aabbc","hi..c","hi..d","g.jjd","gffee");exit()
if n==7:print("..abc..","..abc..","aax..aa","bbx..bb","cc.yycc","..abc..","..abc..");exit()
a=[n*["."]for _ in range(n)]
if n%2:
  for i in range(5):
    for j in range(5):a[-i-1][-j-1]=f[i][j]
  n-=5
for i in range(0,n,2):
  a[i][i],a[i][i+1]="a","a"
  a[i+1][i],a[i+1][i+1]="b","b"
if n%4==0:
  for i in range(0,n,2):
    a[n-i-2][i],a[n-i-2][i+1]="c","d"
    a[n-i-1][i],a[n-i-1][i+1]="c","d"
else:
  for i in range(0,n-2,2):
    a[i][i+2],a[i][i+3]="c","d"
    a[i+1][i+2],a[i+1][i+3]="c","d"
  a[n-2][0],a[n-2][1]="c","d"
  a[n-1][0],a[n-1][1]="c","d"
for i in a:print("".join(i))

Measured memory_bytes: 11892
/*
 _    _    _______   _    _
| |  / /  |  _____| | |  / /
| | / /   | |       | | / /
| |/ /    | |_____  | |/ /
| |\ \    |  _____| | |\ \
| | \ \   | |       | | \ \
| |  \ \  | |_____  | |  \ \
|_|   \_\ |_______| |_|   \_\

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair <int, int> PII;
typedef pair <ll, ll> PLL;


#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define right(x) x << 1 | 1
#define left(x) x << 1
#define forn(x, a, b) for (int x = a; x <= b; ++x)
#define for1(x, a, b) for (int x = a; x >= b; --x)
#define mkp make_pair
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define y1 kekekek

#define fname ""

const ll ool = 1e18 + 9;
const int oo = 1e9 + 9, base = 1e9 + 7;
const ld eps = 1e-7;
const int N = 2e6 + 6;

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

    #ifdef krauch
        freopen("input.txt", "r", stdin);
    #else
        //freopen(fname".in", "r", stdin);
        //freopen(fname".out", "w", stdout);
    #endif

    int n, a, b;
    cin >> n >> a >> b;
    cout << (abs(a - b) % 2 == 0 ? "Alice" : "Borys") << "\n";

	return 0;
}


Measured memory_bytes: 256
// https://atcoder.jp/contests/abc149/tasks/abc149_d
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, K, a, b, c;
    cin >> N >> K >> a >> b >> c;
    string s;
    cin >> s;
    int ans = 0;

    REP(i, K) {
        if (s[i] == 's') {
            ans += a;
        } else if (s[i] == 'p') {
            ans += b;
        } else if (s[i] == 'r') {
            ans += c;
        }
    }
    FOR(i, K, N) {
        if (s[i] == s[i - K]) {
            // 得点を加算せず、現時点＋Kでは必ず得点を加算
            s[i] = '-';
        } else if (s[i] == 's') {
            ans += a;
        } else if (s[i] == 'p') {
            ans += b;
        } else if (s[i] == 'r') {
            ans += c;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
n,k = map(int,input().split())
clis = [0]*10**5

for i in range(n):
    a,b = map(int,input().split())
    clis[a-1] += b
cnt = 0    
for i in range(10**5):
    cnt += clis[i]
    if k <= cnt:
        print(i+1)
        break

Measured memory_bytes: 5748
#include <stdio.h>
#include <inttypes.h>

int N;
int A[271828];
uint64_t K;

int dest[281828][70];

int main(void) {
	int i, j;
	int mofu = 1;
	if (scanf("%d%" SCNu64, &N, &K) != 2) return 1;
	for (i = 1; i <= N; i++) {
		if (scanf("%d", &A[i]) != 1) return 1;
	}
	for (i = 1; i <= N; i++) {
		dest[i][0] = A[i];
	}
	for (j = 1; j < 70; j++) {
		for (i = 1; i <= N; i++) {
			dest[i][j] = dest[dest[i][j - 1]][j - 1];
		}
	}
	for (i = 0; i < 64; i++) {
		if ((K >> i) & 1) mofu = dest[mofu][i];
	}
	printf("%d\n", mofu);
	return 0;
}


Measured memory_bytes: 57208
#include <bits/stdc++.h>
#define owo(i,a, b) for(int i=(a);i<(b); ++i)
#define uwu(i,a, b) for(int i=(a)-1; i>=(b); --i)
#define senpai push_back
#define ttgl pair<int, int>
#define ayaya cout<<"ayaya~"<<endl
 
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
gpu_hash_map<int, int> mp;*/
using ll = long long;
using ld = long double;
const ll MOD = 1000000007;
const ll root = 62;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll binpow(ll a,ll b){ll res=1;while(b){if(b&1)res=(res*a)%MOD;a=(a*a)%MOD;b>>=1;}return res;}
ll modInv(ll a){return binpow(a, MOD-2);}
const double PI = acos(-1);
const double eps = -1e6;
const int INF = 0x3f3f3f3f;
const int NINF = 0xc0c0c0c0;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll NINFLL = 0xc0c0c0c0c0c0c0c0;
ll nCr(ll n, int r) {
    if(r==3) {
        return (((n*(n-1))%MOD)*(((n-2)*modInv(6))%MOD))%MOD;
    }else {
        return (n*(n-1)/2)%MOD;
    }
}
ll h, w, k;
int main() {
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    cin.tie(0)->sync_with_stdio(0);
    cin>>h>>w>>k;
    ll ans = 0;
    ans+=k;
    ans=(ans + (h+w)*((k*modInv(h+w))%MOD + (((((nCr(k, 2)*modInv(nCr(h+w, 2)))%MOD)*modInv(2))%MOD)*(h+w-1))%MOD)%MOD)%MOD;
    ans = (ans + ((h*w)%MOD)*((nCr(k, 2)*modInv(nCr(h+w, 2)))%MOD + (((((nCr(k, 3)*modInv(nCr(h+w, 3)))%MOD)*modInv(3))%MOD)*(h+w-2))%MOD))%MOD;
    owo(i, 0, k) {
        ans = (ans*(h+w-i))%MOD;
    }
    cout<<ans<<"\n";
    return 0;
}

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

using namespace std;

const int N = 1e5 + 100;

int n;
long long a[N], l, sum = 0LL;

int main (int argc, char const *argv[]) {
    //freopen("input.txt", "r", stdin);

    scanf("%d %lld", &n, &l);
    for (int i = 1; i <= n; ++i) scanf("%lld", a + i), sum += a[i];

    int p;
    bool flag = 1;
    for (int i = 1; i < n; ++i) {
        if (a[i] + a[i + 1] >= l) {
            p = i;
            flag = 0;
            break;
        }
    }

    if (flag) {
        printf("Impossible\n");
        return 0;
    }

    printf("Possible\n");
    for (int i = 1; i < p; ++i) printf("%d\n", i);
    for (int i = n - 1; i > p; --i) printf("%d\n", i);
    printf("%d\n", p);
    return 0;
}



Measured memory_bytes: 1536
from collections import Counter

N = int(input())
S = input()

C_E = Counter(S[1:])
C_W = Counter()
ans = C_E['E']

for i in range(N - 1):
    C_E[S[i + 1]] -= 1
    C_W[S[i]] += 1
    ans = min(ans, C_E['E'] + C_W['W'])
print(ans)


Measured memory_bytes: 4084
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mt make_tuple
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e8;
const ll INF=1e16;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	ll a,b;
	cin>>a>>b;
	if(abs(a-b)<2)cout<<"Brown"<<endl;
	else cout<<"Alice"<<endl;
}





Measured memory_bytes: 256