akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/




int N, M, A[9][9];
//---------------------------------------------------------------------------------------------------
int check(int y) {
    int win = 0, non = 0;
    rep(x, 0, N) {
        if (A[y][x] == 1) win++;
        else if (A[y][x] < 0 and y != x) non++;
    }
    return win <= (N - 1) / 2 and (N - 1) / 2 <= win + non;
}
//---------------------------------------------------------------------------------------------------
int ans = 0;
void dfs(int cu) {
    int x = cu % N;
    int y = cu / N;

    if (cu == N * N) {
        ans++;
        return;
    }

    if (x == y or 0 <= A[y][x]) {
        if (check(y)) dfs(cu + 1);
        return;
    }
    
    A[y][x] = 1; A[x][y] = 0;
    if(check(y)) dfs(cu + 1);

    A[y][x] = 0; A[x][y] = 1;
    if (check(y)) dfs(cu + 1);

    A[y][x] = A[x][y] = -1;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    while (cin >> N) {
        if (N == 0) return;
        cin >> M;
        rep(i, 0, N) rep(j, 0, N) A[i][j] = -1;
        rep(i, 0, M) {
            int a, b; cin >> a >> b;
            a--; b--;
            A[a][b] = 1;
            A[b][a] = 0;
        }

        ans = 0;
        dfs(0);
        printf("%d\n", ans);
    }
}



Measured memory_bytes: 3160
import Control.Monad
import Data.List

canCompressLine :: String -> Bool
canCompressLine = all (== '.')

compressLines :: [String] -> [String]
compressLines = filter (not . canCompressLine)

compressRows :: [String] -> [String]
compressRows lines = transpose $ compressLines $ transpose lines

main :: IO ()
main = do
  [h, w] <- map read . words <$> getLine
  lines <- replicateM h getLine
  putStrLn $ unlines $ compressRows $ compressLines lines

Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string x="Sunny",y="Cloudy",z="Rainy";
    string s;
    cin>>s;
    if(s==x) cout<<y;
    else if( s==y) cout<<z;
    else if(s==z) cout<<x;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<algorithm>
#include<functional>
using namespace std;

int main() {
    int n,p[10],max=0,sum=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>p[i];
        sum+=p[i];
        if(max<p[i])max=p[i];
    }
    sum-=max/2;
    cout<<sum<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[300][300];
int w[300];
int rec(int s,int t){
  if(dp[s][t]!=-1)return dp[s][t];
  if(s==t)return 0;
  int ans=rec(s+1,t-1);
  if(ans==t-s-1&&abs(w[s]-w[t])<=1)return dp[s][t]=ans+2;
  for(int i=s;i<t;i++){
    ans=max(ans,rec(s,i)+rec(i+1,t));
  }
  return dp[s][t]=ans;
}

int main(){
  int n;
  while(cin>>n,n){
    memset(w,0,sizeof(w));
    for(int i=0;i<n;i++)cin>>w[i];
    memset(dp,-1,sizeof(dp));
    for(int i=1;i<n;i++)
      dp[i-1][i]=(abs(w[i-1]-w[i])<=1?2:0);
    cout<<rec(0,n-1)<<endl;
  }
  return 0;
}



Measured memory_bytes: 3444
from collections import Counter
n = int(input())
A = list(map(int, input().split()))
ANS = sum(A)
A = Counter(A)
Q = int(input())
for i in range(Q):
    B, C = map(int, input().split())
    print(ANS + (C - B) * A[B])
    ANS += (C - B) * A[B]
    A[C] = A[C] + A[B]
    A[B] = 0


Measured memory_bytes: 94240
package main

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

func main() {
	sc := NewScanner()

	n := sc.ReadInt()
	m := sc.ReadInt()
	q := sc.ReadInt()
	abcds := make([]ABCD, q)
	for i := 0; i < q; i++ {
		a := sc.ReadInt()
		b := sc.ReadInt()
		c := sc.ReadInt()
		d := sc.ReadInt()
		abcds[i] = ABCD{a, b, c, d}
	}

	maxScore := 0
	update := func(seqA SeqA) {
		score := computeScore(abcds, seqA)
		if score > maxScore {
			maxScore = score
		}
	}

	cur := make(SeqA, n)
	eachSeqA(update, 1, m, n, 0, cur)

	fmt.Println(maxScore)
}

func eachSeqA(callback func(SeqA), min, max, n, pos int, cur SeqA) {
	if pos == n {
		callback(cur)
		return
	}

	for i := min; i <= max; i++ {
		cur[pos] = i
		eachSeqA(callback, i, max, n, pos+1, cur)
	}
}

func computeScore(abcds []ABCD, seqA SeqA) int {
	totalD := 0
	for _, abcd := range abcds {
		if seqA[abcd.B-1]-seqA[abcd.A-1] == abcd.C {
			totalD += abcd.D
		}
	}
	return totalD
}

type SeqA []int

type ABCD struct {
	A int
	B int
	C int
	D int
}

// util
// *   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base int, exponent uint) int {
	answer := 1
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

// *   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 1768
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
using namespace std;
using ll = long long;
int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    int eastE = 0, westW=0;
    for(int i = 0;i < N;i++){
        if(S[i] == 'E')eastE++;
    }
    int ans = 999999;
    for(int i = 0;i < N;i++){
        if(S[i] == 'E')eastE--;
        if(i != 0)if(S[i-1] == 'W')westW++;
        if(eastE + westW < ans)ans = eastE + westW;
    }
    cout << ans;
}

Measured memory_bytes: 900
n = int(input())
a = list(map(int,input().split()))
a.sort()
b = []
count = 0
sum = 0
for i in a:
    if i < 0:
        i *= -1
        count += 1
    sum += i
    b.append(i)
if count % 2 == 0:
    print(sum)
else:
    b.sort()
    print(sum - b[0]*2)


Measured memory_bytes: 14412
n=int(raw_input())
i=1
SP=[]
while i<=n:
  x=i
  if x%3==0:
    SP.append(str(i))
  else:
    while x:
      if x%10==3:
        SP.append(str(i))
        break
      x/=10
  i+=1
print "", " ".join(SP)

Measured memory_bytes: 4516
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (a, b) = scan!(i64, i64);
    if a == b {
        println!("Draw")
    } else if a == 1 {
        println!("Alice")
    } else if b == 1 {
        println!("Bob")
    } else if b < a {
        println!("Alice")
    } else {
        println!("Bob")
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  string s;
  cin >> s;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == '1')s[i] = '9';
    else if(s[i] == '9')s[i] = '1';
  }
  cout << s << endl;
}


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

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

long long C[51][51];

void cmai(int num) {
  rep (i, num + 1) {
    rep (j, i + 1) {
      if ( j==0 or j == i) C[i][j] = 1LL;
      else C[i][j]=( C[i-1][j-1] + C[i-1][j]);
    }
  }
}

int main() {
  int n, a, b;
  double ave = 0.0;
  const int nmax = 50;
  long long veb[nmax];
  cin >> n >> a >> b;
  rep (i, n) {
    cin >> veb[i];
  }
  
  cmai(n);
  sort(veb,veb + n);
  reverse(veb, veb + n);
  
  rep (i, a) {
    ave += veb[i];
  }
  ave /= a;
  
  int a_th_val_num=0,a_th_val_pos=0;
    rep (i, n) {
        if(veb[i] == veb[a-1]){
            a_th_val_num ++;
            if(i < a) a_th_val_pos++;
        }
    }
  
  long long cnt = 0LL;
  if(a_th_val_pos == a){
    for(a_th_val_pos = a; a_th_val_pos <= b; ++a_th_val_pos){
      cnt += C[a_th_val_num][a_th_val_pos];
    }
  }
  else cnt += C[a_th_val_num][a_th_val_pos];

  cout.precision(20);
  cout << fixed << ave << endl;
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <complex>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const double EPS=1e-10;

typedef complex<double> Point;
struct Line{
	Point pos,dir;
	Line(){}
	Line(Point p,Point d):pos(p),dir(d){}
};
typedef Line Segment;

int Signum(double x)
{
	return abs(x)<EPS?0:x<0?-1:1;
}
double Dot(Point a,Point b)
{
	return real(conj(a)*b);
}
double Cross(Point a,Point b)
{
	return imag(conj(a)*b);
}
double CCW(Point a,Point b,Point c)
{
	Point d1=b-a,d2=c-a;
	double sign=Signum(Cross(d1,d2));
	if(sign)
		return sign;
	if(Dot(d1,d2)<-EPS)
		return -2;
	if(norm(d1)<norm(d2)-EPS)
		return 2;
	return 0;
}

bool IntersectLS(Line a,Segment b)
{
	return CCW(a.pos,a.pos+a.dir,b.pos)*CCW(a.pos,a.pos+a.dir,b.pos+b.dir)<=0;
}
bool IntersectSS(Segment a,Segment b)
{
	return IntersectLS(a,b) && IntersectLS(b,a);
}
Point IntersectPoint(Line a,Line b)
{
	return a.pos+a.dir*Cross(b.pos-a.pos,b.dir)/Cross(a.dir,b.dir);
}

int main()
{
	for(int n;cin>>n,n;){
		vector<Segment> ss(n);
		rep(i,n){
			int x1,y1,x2,y2;
			cin>>x1>>y1>>x2>>y2;
			ss[i]=Segment(Point(x1,y1),Point(x2-x1,y2-y1));
		}
		
		int res=1;
		rep(i,n){
			vector<Point> ps;
			rep(j,i){
				if(IntersectSS(ss[i],ss[j])){
					Point p=IntersectPoint(ss[i],ss[j]);
					if(abs(max(abs(real(p)),abs(imag(p)))-100)<EPS)
						continue;
					ps.push_back(p);
				}
			}
			
			vi flg(ps.size());
			int cnt=0;
			rep(j,ps.size()){
				if(flg[j])
					continue;
				cnt++;
				repi(k,j,ps.size())
					if(abs(ps[k]-ps[j])<EPS)
						flg[k]=1;
			}
			res+=cnt+1;
		}
		
		cout<<res<<endl;
	}
	
	return 0;
}

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

int main(void){
    //入力
    long X;
    cin>>X;
    
    //計算
    long ans=0;
    while(ans*(ans+1)/2<X){
        ans++;
    }
    
    //出力
    cout<<ans<<endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
long long n,m,i,j,s,a[100005],x,y;
int main()
{
	scanf("%lld",&n);
	for (i=1;i<=n;i++)
	{
		scanf("%lld%lld",&x,&y);
		s+=x;
		a[i]=x+y;
	}
	sort(a+1,a+n+1,greater<long long>());
	for (i=2;i<=n;i+=2) s-=a[i];
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)


int main(void){
    //nCr=n!/((n-r)!r!)
    //ナイーブにはn^2 comb = n^4
    //隣り合うnCrを求められないか
    //ai=2*ajのときが最適ではないのか
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    // index=番号-1
    auto maxitr=max_element(a.begin(),a.end());
    int dis=(maxitr-a.begin());
    //最大値を抜く
    int max=*maxitr;
    a.erase(a.begin()+dis);
    double mid=(double)max/2.0;
    vector<double> af(n);
    rep(i,n)af[i]=abs((double)a[i]-mid);
    auto minitr=min_element(af.begin(),af.end());
    double min=*minitr;
    dis=(minitr-af.begin());
    if(a[dis]>mid)cout<<max<<" "<<(int)(min+mid)<<endl;
    else cout<<max<<" "<<(int)(mid-min)<<endl;
    return 0;
}


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

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

typedef long long ll;

signed main()
{
    int n,m; cin >> n >> m;
    vector<int>a(m); rep(i,m) cin >> a[i];

    int sum = 0;
    rep(i,m) sum += a[i];

    if (sum>n) puts("-1");
    else cout << n - sum << endl;    

    return 0;
}


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

long long N,K,A,B,cnt,ans,num[5];
int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0);
    cin >> K >> A >> B;
    if(B-A<=2){
        cout << 1+K;
        return 0;
    }
    K -= A-1;
    cout << A+(B-A)*(K/2)+(K%2);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll dp[110][100010];
int n, arr[110];
int total;
ll w[110];
const ll inf = (ll)1e15;
ll solve( int pos, int val ) {
  if ( val < 0 ) return inf;
  if ( pos < 0 ) {
    if ( val == 0 ) return 0;
    return inf;
  }
  if ( dp[pos][val] != -1 ) return dp[pos][val];
  dp[pos][val] = min(solve(pos-1,val),solve(pos-1,val-arr[pos])+w[pos]);
  return dp[pos][val];
}
int main()
{
  ll cap;
  scanf("%d %lld", &n, &cap);
  for ( int i = 0; i < n; i++ ) {
    scanf("%lld %d", &w[i], &arr[i]);
    total += arr[i];
  }
  ll mx = -1;
  memset(dp,-1,sizeof(dp));
  for ( int i = total; i >= 0; i-- ) {
    ll ans = solve(n-1,i);
    if ( ans <= cap ) {
      mx = (ll)i;
      break;
    }
  }
  cout << mx << endl;
  return 0;
}

Measured memory_bytes: 86144
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;

/**
 * @author david yepes buitrago
 * @date 21-01-2017
 * @time 0.000 ms
 */
public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		for (String line; (line = in.readLine()) != null;) {
			boolean[] arr = new boolean[4];
			line = line.toUpperCase();
			for (int i = 0; i < line.length(); i++) {
				switch (line.charAt(i)) {
				case 'S':
					arr[0] = true;
					break;
				case 'N':
					arr[1] = true;
					break;
				case 'W':
					arr[2] = true;
					break;
				case 'E':
					arr[3] = true;
					break;
				}
			}
			if (arr[0] == arr[1] && arr[2] == arr[3]) {
				out.println("Yes");
			} else {
				out.println("No");
			}

		}
		out.close();
	}

}


Measured memory_bytes: 20820
n = int(input())
a = list(map(int, input().split()))
b = sorted(a)

diff = []
for i in range(n):
	if(a[i] != b[i]):
		diff.append(a[i])

if(len(diff) == 2 or len(diff) == 0):
	print("YES")
else:
	print("NO")  

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#define int long long
using namespace std;
const int N = 305;
int n, k, mod, C[N][N], s[N][N], f[N][N];
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') {x = (x << 3) + (x << 1) + (ch ^ 48); ch = getchar();}
	return x * f;
}
signed main()
{
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	n = read(); k = read(); mod = read();
	for(int i = 0; i <= n; i ++) for(int j = C[i][0] = 1; j <= i; j ++) C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
	for(int i = 0; i <= k; i ++) f[1][i] = 1, s[1][i] = k - i + 1;
	for(int i = 2; i <= n + 1; i ++)
	{
		for(int j = 0; j <= k; j ++) for(int l = 1; l < i; l ++) f[i][j] = (f[i][j] + f[i - l][j] * s[l][j + 1] % mod * C[i - 2][l - 1] % mod) % mod;
		for(int j = k; j >= 0; j --) s[i][j] = (s[i][j + 1] + f[i][j]) % mod;
	}
	printf("%lld\n", f[n + 1][0]);
	fclose(stdin);
	fclose(stdout);
	return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define MOD 998244353

using namespace std;
long long fact[10005];
long long inv[10005];
long long power(long long a,long long b){
    if(b==0) return 1;
    long long f=power(a,b/2);
    f=(f*f)%MOD;
    if(b%2) return (a*f)%MOD;
    return f;
}
long long comb(long long n,long long r){
    if(n<r || n<0) return 0;
    if(n==r || r==0) return 1;
    long long temp=(inv[n-r]*inv[r])%MOD;
    return (fact[n]*temp)%MOD;
}
int main(){
    int k,n;
    cin >> k >> n;
    fact[0]=inv[0]=1;
    for(long long i=1;i<=10000;++i){
        fact[i]=(i*fact[i-1])%MOD;inv[i]=power(fact[i],MOD-2);
    }
    for(int i=2;i<=2*k;++i){
       long long ans=comb(n+k-1,k-1);
       long long one=-1;
       int cnt=0;
       for(int j=1;j<=i/2;++j){
            if(i-j>k) continue;
            ++cnt;
       }
       for(int j=1;j<=cnt;++j){
            long long ogre=(comb(cnt,j)*comb(n-2*j+k-1,k-1))%MOD;
            ans=(ans+one*ogre)%MOD;

            one=(one*(-1));
       }
       cout << (ans+MOD)%MOD << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

using namespace std;

int main(){
    int h,w;
    cin>>h>>w;
    vector<vector<char>> v(h,vector<char>(w));
    rep(i,0,h)rep(j,0,w)cin>>v[i][j];
    rep(i,0,h){
        rep(j,0,w){
            if(v[i][j]=='.')continue;
            bool ok=true;
            rep(k,0,4){
                int ny=i+dy[k],nx=j+dx[k];
                if(0<=ny&&0<=nx&&ny<h&&nx<w&&v[ny][nx]=='#')ok=false;
            }
            if(ok){
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
main :: IO ()
main = do
  ls <- getContents
  let ls' = map split2 . lines $ ls
  mapM_ putStrLn $ solve ls'

split2 :: String -> [String]
split2 [] = []
split2 (x:y:r) = [x,y]:(split2 r)
split2 [x] = [[x]]
table = zip ["11","12","13","14","15",
             "21","22","23","24","25",
             "31","32","33","34","35",
             "41","42","43","44","45",
             "51","52","53","54","55",
             "61","62","63","64","65"]
        (['a'..'z'] ++ ".?! ")

solve :: [[String]] -> [String]
solve xs = map change xs
  where
    change :: [String] -> String
    change xs
      | all (isInTable table) xs = change' xs
      | otherwise = "NA"
      where
        isInTable :: [(String,Char)] -> String -> Bool
        isInTable [] xs = False
        isInTable ((a,b):r) xs
          | xs == a = True
          | otherwise = isInTable r xs
        change' :: [String] -> String
        change' [] = []
        change' (x:xs) = (toC x table):(change xs)
          where
            toC :: String -> [(String,Char)] -> Char
            toC x ((a,b):r)
              | x == a = b
              | otherwise = toC x r

Measured memory_bytes: 3812
#include<bits/stdc++.h> 
using namespace std;
int dp[200007],nxtpos[200007],pos[100],c,nxtchr[200007];
string s;
int main()
{
	cin>>s;
	int n=s.length();
	s='.'+s;
	for(int i=0;i<26;i++)
	{
		pos[i]=n+1;
	}
	for(int i=n;i>=0;i--)
	{
		int mn=n+5;
		for(int j=0;j<26;j++)
		{
			if(mn>dp[pos[j]])
			{
				mn=dp[pos[j]];
				c=j;
			}
		}
		dp[i]=dp[pos[c]]+1;
		nxtpos[i]=pos[c];
		nxtchr[i]=c;
		pos[s[i]-'a']=i;
	}
	int x=0;
	while(x<=n)
	{
		cout<<char(nxtchr[x]+'a');
		x=nxtpos[x];
	}
}

Measured memory_bytes: 6112
#include <cstdio>
#include <algorithm>
using namespace std;
#define INF 100000000

int main(){
	int p = INF, j = INF;
	for(int i = 0; i < 3; i++){
		int t; scanf("%d", &t);
		p = min(p,t);
	}
	for(int i = 0; i < 2; i++){
		int t ; scanf("%d", &t);
		j = min(t,j);
	}
	printf("%d\n", p+j-50);
}

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

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

int main() {
    int a, b; cin >> a >> b;
    int ans = b;
    if(6 <= a && a <= 12) ans /= 2;
    if(a < 6) ans = 0;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
c = [list(map(int,input().split())) for _ in range(3)]
for i in range(3):
    for j in range(i+1,3):
        t = c[i][0]-c[j][0]
        for k in [1,2]:
            if t != c[i][k]-c[j][k]:
                print("No")
                exit(0)
        t = c[0][i]-c[0][j]
        for k in [1,2]:
            if t != c[k][i]-c[k][j]:
                print("No")
                exit(0)
print("Yes")

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

int main() {
  int N, A, l, r;
  cin >> N;
  A=0;
  
  for (int i=0; i<N; i++){
    cin>>l>>r;
    A=A+r-l+1;
  }
  cout<<A<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
   double i,j,k,t;
   cin>>i>>j>>k;
   double n;
   n=i/k;
   if(n<=j)
    cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
}


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

#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif

signed main(){

  int n; cin >> n;
  vector<int> x(n),y(n);
  for(int i = 0; i < n; i++){
    cin >> x[i] >> y[i];
  }

  map<pair<int,int>,int> mp;
  for(int i = 0; i < n; i++){
    for(int j = i+1; j < n; j++){
      mp[make_pair(x[i]-x[j],y[i]-y[j])]++;
      mp[make_pair(x[j]-x[i],y[j]-y[i])]++;
    }
  }

  int res = 0;
  for(auto &p : mp){
    //cout << p << " " << p.second << endl;
    res = max(res,p.second);
  }
  cout << n - res << endl;

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <queue>
#include <utility>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

const int INF = 100000000;
typedef pair<int, int> P;

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

int dot_num = 0;

char inputs[50][50];

int bfn()
{
    queue<P> que;
    que.push(P(0,0));
    int matrix_dis[H][W];
    
    fill((int*)matrix_dis, (int*)(matrix_dis+H), INF);
    
    matrix_dis[0][0] = 0;
    while(que.size()) {
        P p = que.front();
        que.pop();
        if (p.first == H && p.second == W) {
           break; 
        }
        for (int i = 0; i < 4; i++) {
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];
            
            if (0 <= nx && nx < H && 0<= ny && ny < W && inputs[nx][ny] != '#' && matrix_dis[nx][ny] == INF ) {
                que.push(P(nx, ny));
                matrix_dis[nx][ny] = matrix_dis[p.first][p.second] + 1;
            }
        }
    }
    return matrix_dis[H-1][W-1];
}    

int main(int argc, char const* argv[])
{
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cin >> inputs[i][j];
            if (inputs[i][j] == '.') {
                dot_num++;
            }
        }
    }

    int min_dis = bfn();
    if (min_dis == INF) {
        cout << -1 << endl;
    }
    else {
        cout << dot_num - min_dis - 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
R = input()

rain_count = 0
reset = False
max_count = 0

for i in range(len(R)):
  if R[i] == "R":
    rain_count += 1
  else:
    reset = True
  
    if reset:
      max_count = max(max_count, rain_count)
      rain_count = 0

print(max(rain_count, max_count))

Measured memory_bytes: 9116
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
//using namespace atcoder;
using ll = long long;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
typedef vector<vector<int> > Graph;
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; }
const ll INF = numeric_limits<ll>::max();


#define debug(v) cout<<#v<<": ",prt(v);
template <typename A,typename B>
inline void prt(pair<A,B> p){cout<<"("<<p.first<<", "<<p.second<<")\n";}
template <typename A,typename B,typename C>
inline void prt(tuple<A,B,C> p){cout<<"("<<get<0>(p)<<", "<<get<1>(p)<<", "<<get<2>(p)<<")\n";}
inline void prt(bool p){if(p)cout<<"True"<<'\n';else cout<<"False"<<'\n';}
template <typename T> 
inline void prt(vector<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(deque<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
template <typename A,typename B>
inline void prt(map<A,B> v){cout<<'{';ll c=0;for(auto &p: v){cout<<p.first<<":"<<p.second;c++;if(c!=v.size())cout<<", ";}cout<<'}'<<'\n';}
template <typename A,typename B>
inline void prt(unordered_map<A,B> v){cout<<'{';ll c=0;for(auto &p: v){cout<<p.first<<":"<<p.second;c++;if(c!=v.size())cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(set<T> v){cout<<'{';for(auto i=v.begin();i!=v.end();i++){cout<<*i;if(i!=--v.end())cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(multiset<T> v){cout<<'{';for(auto i=v.begin();i!=v.end();i++){cout<<*i;if(i!=--v.end())cout<<", ";}cout<<'}'<<'\n';}

ll n,k;
ll p[3];//もらえるポイント
string t;

//r-0, s-1, p-2に対応

ll dp[200000][3];

bool win(int x,int y){
    if(t[x]=='r'&&y==2)return true;
    if(t[x]=='s'&&y==0)return true;
    if(t[x]=='p'&&y==1)return true;
    return false;
}

ll rec(int x,int y){
    if(dp[x][y]!=-1)return dp[x][y];
    if(x<k){
        if(win(x,y))return dp[x][y]=p[y];
        else return 0;
    }
    if(win(x,y)){
        ll res = 0;
        rep(i,3) {
            if(i==y)continue;
            chmax(res,rec(x-k,i));
        }
        return dp[x][y]=res+p[y];
    }
    else{
        ll res = 0;
        rep(i,3) {
            if(i==y)continue;
            chmax(res,rec(x-k,i));
        }
        return dp[x][y]=res;
    }
}


int main(){
    cin >> n >> k;
    cin >> p[0] >> p[1] >> p[2];
    cin >> t;
    ll ans = 0;
    rep(i,200000)rep(j,3)dp[i][j]=-1;
    for(int i=n-k;i<n;i++){
        ll tmp = 0;
        rep(j,3){
            chmax(tmp,rec(i,j));
        }
        ans += tmp;
    }
    cout << ans << endl;
    return 0;
}



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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N, C;
	cin >> N >> C;

	ll D[31][31];
	ll c[501][501];

	REP(i, C) REP(j, C) cin >> D[i][j];
	REP(i, N) REP(j, N) cin >> c[i][j];

	ll res = INT_MAX/3;
	ll soku[3][31];
	REP(i, 3)REP(j, 31) soku[i][j] = 0;
	REP(i, N) REP(j, N) soku[(i+j)%3][c[i][j]-1]++;

	REP(i, C)REP(j, C)REP(k, C){
		if(i==j||j==k||k==i) continue;
		ll tmp = 0;
		REP(l, C){
			tmp += soku[0][l] * D[l][i];
			tmp += soku[1][l] * D[l][j];
			tmp += soku[2][l] * D[l][k];
		}
		if(tmp<res) res = tmp;
	}
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  int n=s.size();
  int t=7,sz=32;
  vector<int> vec(n);
  for(int i=0;i<n;i++) vec[i]=s[i]-'0';
  vector<vector<int>> dp(n+1,vector<int> (sz*2,0));
  dp[0][sz]=1;
  for(int i=0;i<n;i++){
    for(int j=10;j<50;j++){
      dp[i+1][j]+=dp[i][j-vec[i]];
      dp[i+1][j]+=dp[i][j+vec[i]];
    }
  }
  if(dp[n][t+sz]>0){
    string ans=to_string(t)+'=';
    int now=t+sz;
    for(int i=n;i>1;i--){
      ans.push_back(s[i-1]);
      if(dp[i-1][now+vec[i-1]]>0){
        ans.push_back('-');
        now+=vec[i-1];
      }
      else if(dp[i-1][now-vec[i-1]]>0){
        ans.push_back('+');
        now-=vec[i-1];
      }
    }
    ans.push_back(s[0]);
    reverse(ans.begin(),ans.end());
    cout << ans << endl;
  }
  else{
    cout << -1 << endl;
  }
}

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

typedef vector<int> vi;
typedef long long int ll;
#define clr(v, d)           memset(v, d, sizeof(v))
#define all(v)   (v.begin()),(v.end())
#define lp(i,n)     for(int i=0;i<n;i++)
#define sz(v)       v.size()
#define f           first
#define s           second
#define pb           push_back
#define MP           make_pair

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    long long int c , m , n;
    cin>>n;
    m=sqrt(n);
    for(int i=m;i>=1;i--){
        if(n%i==0){
            c=i+n/i-2;
            cout<<c<<endl;
            return 0;
        }
    }
    return 0;
}

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

int main() {
  long long a,b,k;
  cin >> a >> b >> k;
  if (a - k >= 0) {
    cout << a-k << " " << b << endl;
  }
  else if (b - (k-a) >= 0) {
    cout << 0 << " " << b-(k-a) << endl;
  }
  else {
    cout << 0 << " " << 0 << endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<iostream>
using namespace std;
int main()
{
	int  n;
scanf("%d",&n);

	int b[100000+5]={0};
	
		
	int max=0,k;
		for(int j=0;j<n;j++)
		{
		scanf("%d",&k);
	b[k]++;
	b[k+1]++;
	b[k-1]++;
		
		}
		for(int i=0;i<99999;i++)
			if(b[i]>max)
		max=b[i];
		printf("%d\n",max);
		
		
		
	
	
	
	
	
	
	
}

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

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = Integer.parseInt(scanner.next());
        String S = scanner.next();
        int count = 1;
        char now_char = S.charAt(0);

        for(int i = 0; i < N; i++) {
            if(now_char != S.charAt(i)) {
                count++;
                now_char = S.charAt(i);
            }
        }

        System.out.println(count);

        scanner.close();
    }
}

Measured memory_bytes: 23792
N, M = map(int, input().split())
T = list(map(int, input().split()))

s = set(range(N))
G = [[] for _ in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    a, b = a - 1, b - 1
    G[a].append(b)
    G[b].append(a)
    if a in s:
        s.remove(a)
    if b in s:
        s.remove(b)

res = 0
for i in range(N):
    if len(G[i]) != 0:
        for g in G[i]:
            if T[i] <= T[g]:
                break
        else:
            # print(i + 1)
            res += 1

res += len(s)

print(res)


Measured memory_bytes: 34452
#include <iostream>
#include <algorithm>

using namespace std;

int main(){

	int w, h, x, y, r;

	cin >> w >> h >> x >> y >> r;

	if(0 <= x-r && x+r <= w && 0 <= y-r && y+r <= h){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
}

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

int main() {
	int w, h, n;
	int a[105], b[105], c[105];
	cin>>w>>h>>n;
	for(int i=0;i<n;++i) {
		cin>>a[i]>>b[i]>>c[i];
	}
	
	int x2 = w, y2 = h;
	int x1 = 0, y1 = 0;
	for(int j=0;j<n;++j) {
		if(c[j]==1) x1 = max(x1, a[j]);
		else if(c[j]==2) x2 = min(x2, a[j]);
		else if(c[j]==3) y1 = max(y1, b[j]);
		else if(c[j]==4) y2 = min(y2, b[j]);
	}

	//printf("%d %d %d %d\n", x2, x1, y2, y1);
	int res;
	if(x1>=x2 || y1>=y2) res = 0;
	else res = (x2-x1) * (y2-y1);
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
S = input()
flag1 = False
flag2 = False

num1 = int(S[0] + S[1])
num2 = int(S[2] + S[3])

if num1 >= 0 and (num2 >= 1 and num2 <= 12):
    flag1 = True

if (num1 >= 1 and num1 <= 12) and num2 >= 0:
    flag2 = True
    


if flag1 == True and flag2 == False:
    print("YYMM")
elif flag1 == False and flag2 == True:
    print("MMYY")
elif flag1 == True and flag2 == True:
    print("AMBIGUOUS")
else:
    print("NA")


Measured memory_bytes: 38292
#include <bits/stdc++.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
#define rn(i,n) for(int i=1;i<=n;i++)

int main(){
  int n,k;
  cin>>n>>k;
  int tmp,cnt=0;
  r(i,n){
    cin>>tmp;
    if(tmp>=k)cnt++;
  }
  cout<<cnt<<endl;


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define I_L_Z_D ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); 
const int N = 1e6 + 5;


int32_t main(){
    I_L_Z_D ;
	int n;
	cin >> n;
	int a[n];
	for(int i = 0 ; i < n ; i++) cin >> a[i];
	sort(a , a + n);
	cout << a[n/2] - a[n/2 - 1];	
	
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
class Trees{
  vector<int> par;
  vector<int> rank;
  public:
  int root(int i){
    int rt;
    if(par[i]==i){rt=i;rank[i]=1;}
    else{rt=root(par[i]);par[i]=rt;rank[i]=2;}
    return rt;
  }
  void unite(int i,int j){
    int rki=rank[i];int rkj=rank[j];
    if(rki<rkj){par[root(i)]=root(j);rank[i]++;}
    else{par[root(j)]=root(i);rank[j]++;}
  }
  bool same(int i,int j){
    return root(i)==root(j);
  }
  Trees(int n){
    for(int i=0;i<n;i++) {par.push_back(i);rank.push_back(1);};
  }
  void solve(){
    vector<int>s(par.size());
    for(long i=0;i<s.size();i++)s[root(i)]++;
    for(long i=0;i<s.size();i++)cout<<s[root(i)]<<endl;
  }
};
struct S{
  long x,y,id;
};
bool cmpx(S a,S b){return a.x<b.x;}
bool cmpy(S a,S b){return a.y<b.y;}
bool cmpid(S a,S b){return a.id<b.id;}
int main(){
  long N;cin>>N;
  vector<S> A(N);
  Trees tree(N);
  for(long i=0;i<N;i++){
    long x,y;cin>>x>>y;
    A[i]={x,y,i};
  }
  sort(A.begin(),A.end(),cmpx);
  vector<S> maxy(N);
  for(long i=N-1;i>=0;i--){
    if(i!=N-1)maxy[i]=maxy[i+1];
    if(A[i].y>maxy[i].y)maxy[i]=A[i];
  }
  for(long i=0;i<N-1;i++){
    if(A[i].y<maxy[i+1].y){
      //cout<<"y: "<<A[i].y<<" "<<maxy[i+1].y<<" "<<A[i].id<<" "<<maxy[i+1].id<<endl;
      tree.unite(A[i].id,maxy[i+1].id);
    }
  }
  vector<S> miny(N,{N+1,N+1,N+1});
  for(long i=0;i<N;i++){
    if(i!=0)miny[i]=miny[i-1];
    if(A[i].y<miny[i].y)miny[i]=A[i];
  }
  for(long i=N-1;i>0;i--){
    if(A[i].y>miny[i-1].y){
      tree.unite(A[i].id,miny[i-1].id);
    }
  }
  
  
  
  
  
  sort(A.begin(),A.end(),cmpy);
  vector<S> maxx(N);
  for(long i=N-1;i>=0;i--){
    if(i!=N-1)maxx[i]=maxx[i+1];
    if(A[i].x>maxx[i].x)maxx[i]=A[i];
  }
  for(long i=0;i<N-1;i++){
    if(A[i].x<maxx[i+1].x){
      //cout<<"x: "<<A[i].x<<" "<<maxx[i+1].x<<" "<<A[i].id<<" "<<maxx[i+1].id<<endl;    
      tree.unite(A[i].id,maxx[i+1].id);
    }
  }
  vector<S> minx(N,{N+1,N+1,N+1});
  for(long i=0;i<N;i++){
    if(i!=0)minx[i]=minx[i-1];
    if(A[i].x<minx[i].x)minx[i]=A[i];
  }
  for(long i=N-1;i>0;i--){
    if(A[i].x>minx[i-1].x){
      tree.unite(A[i].id,minx[i-1].id);
    }
  }
  
  
  
  
  tree.solve();
}

Measured memory_bytes: 29268
#include <iostream>
#include <algorithm>
#define rgi register int
using namespace std;
int n;
char ss[100005];
string s;
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	cin>>n>>s;
	for(rgi i=0;i<n;++i)
		ss[i]=s[i];
	int k=unique(ss,ss+n)-ss;
	cout<<k<<endl;
	return 0;
}

Measured memory_bytes: 592
#include <stdio.h>

int main()
{
     int a,b,c;
        scanf("%d %d %d", &a, &b, &c);
        
        if((a*c)<=b)
        {
            printf("%d",c);
        }
        else if((a*c)>c)
        {
            printf("%d",b/a);
        }
        else if(a>b)
        {
            return 0;
        }
    
}

Measured memory_bytes: 128
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
minans = inf ;ans = 0 ;count = 0 ;pro = 1



n=int(input())
if n%2==1:
    print(0)
    exit()
k=10
for i in range(1,100):
    count+=n//(k)
    k*=5
print(count)

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

int main (void) {
	long long s;
	cin >> s;
	long long n = sqrtl(s);
	if (n * n == s) {
		printf("%lld %lld ", 0ll, 0ll);
		printf("%lld %lld ", 0ll, n);
		printf("%lld %lld\n", n, 0ll);
	} else {
		n ++;
		long long a=n;
		long long b=n;
		b=(s+a-1)/a;
		printf("%lld %lld ", 0ll, 0ll);
		printf("%lld %lld ", a, 1ll);
		printf("%lld %lld\n", a*b-s, b);
	}
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=5050;
//templete
int main() {
	int A,B;
	cin>>A>>B;
	cout<<max({A+B,A-B,A*B})<<endl;
	return 0;
}

Measured memory_bytes: 256
// #pragma GCC optimize("O3")
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace ::std;
// clang-format off
template<typename T> T nxt() {T res; cin >> res; return res;}
#define tests() for (int _ = nxt<int>(); _ > 0; _--)
#define nxt1(t,n) t (n); cin >> n
#define nxt2(t,n,m) t (n),(m); cin >> n >> m
#define nxt3(t,n,m,k) t (n),(m),(k); cin >> n >> m >> k
#define rep(i, A) for (int i = 0 ; i < A ; i++)
#define ll long long
typedef pair<int,int> pii;typedef pair<ll, ll> pll;typedef vector<int> vi;typedef vector<vi> vvi;typedef vector<ll> vl;typedef vector<vl> vvl;
#define dbg(vari) cerr<<#vari<<" = "<<(vari)<<endl;
template<typename T,typename TT> ostream& operator<<(ostream &s,pair<T,TT> t) {return s<<"("<<t.first<<","<<t.second<<")";}
template<typename T> ostream& operator<<(ostream &s,vector<T> t){for(T ti : t)s<<ti<<" ";return s; }
#define all(x) (x).begin(), (x).end()
#define last(vec) vec[vec.size()-1]
#define has(c,x) ((c).find(x) != (c).end())
// clang-format on

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

    nxt3(ll, N, X, M);

    ll res = X;
    ll last = X;
    map<ll, pair<ll, ll>> midsum;
    rep(i, N - 1) {
        last = (last % M);
        ll tmp = (last * last) % M;
        last = tmp;
        res += tmp;
        if (midsum.find(tmp) == midsum.end()) {
            midsum[tmp] = make_pair(res, i);
        } else {
            ll cycle_length = (i - midsum[tmp].second);
            ll cycle_sum = res - midsum[tmp].first;

            ll remaining_cycles = (N - 2ll - (ll)i) / cycle_length;
            res += remaining_cycles * cycle_sum;
            ll leftover = (N - 2ll - (ll)i) % cycle_length;
            while (leftover > 0) {
                last = (last * last) % M;
                res += last;
                leftover--;
            }
            break;
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 6680
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
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();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

multiset<char> Alphabets;

int main(){
    string s;
    cin>>s;
    REP(i,s.size()){
        char a=s[i];
        if(Alphabets.count(a)==0){
            Alphabets.insert(a);
        }
        else{
            cout<<"no"<<endl;
            exit(0);
        }
    }
    cout<<"yes"<<endl;





}


Measured memory_bytes: 384
import math

a, b, h, m = map(int, input().split())

long_rad = ((h + m / 60) * math.pi) / 6
short_rad = (m * math.pi) / 30

rad = abs(long_rad - short_rad)

print(math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(rad)))

Measured memory_bytes: 62504
#include <stdio.h>

int main() {
  int times_stay, number_k, fee_high, fee_low, total_fee;
  scanf("%d", &times_stay);
  scanf("%d", &number_k);
  scanf("%d", &fee_high);
  scanf("%d", &fee_low);
  if(times_stay > number_k) {
    total_fee = number_k * fee_high + (times_stay - number_k) * fee_low;
  } else {
    total_fee = times_stay * fee_high;
  }
  printf("%d\n", total_fee);
  return 0;
}


Measured memory_bytes: 128
import math
s = int(input())

r = math.ceil(math.sqrt(s))
rem = r*r - s

x1, y1 = 0, 0
x2, y3 = r, r
x3, y2 = (0 if rem == 0 else 1), rem

print(x1, y1, x2, y2, x3, y3)

#ss = abs(x2 * y3 - y2 * x3)
#print(f'{s} and {ss}')



Measured memory_bytes: 3064
#include "bits/stdc++.h"
#include <unordered_set>

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP3(i, x, n) for(decltype(x) i = (x); i <= (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1;i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define INF 1000000000
#define PI 3.14159265358979323846

#define _CRT_SECURE_NO_WARNINGS

using namespace std;

// N, E, S, W
const int dx[4] = { -1, 0,  1,  0 };
const int dy[4] = { 0, 1,  0, -1 };

typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<LL> vll;
//==============================================

// ??±???
vi D(100005);

struct node { int p, l, r; };
struct node N[100005];

void print(int u) {
	cout << "node " << u << ": ";
	cout << "parent = " << N[u].p << ", ";
	cout << "depth = " << D[u] << ", ";

	if (N[u].p == -1) cout << "root, ";		 // ???
	else if (N[u].l == -1) cout << "leaf, "; // ???
	else cout << "internal node, ";			 // ?????¨??????

	cout << "[";

	// ????????????????????¨???
	for (int i = 0, c = N[u].l; c != -1; i++, c = N[c].r) {
		if (i) cout << ", ";
		cout << c;
	}

	cout << "]" << "\n";
}

// ??????????????±???????±???????
int rec(int u, int p) {
	D[u] = p;
	if (N[u].r != -1) rec(N[u].r, p);		 // ???????????????????????±???????¨????
	if (N[u].l != -1) rec(N[u].l, p + 1);	 // ?????????????????????????????±???+1????¨????
	return 0;
}

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

	int n;
	cin >> n;

	REP(i, n) N[i].p = N[i].l = N[i].r = -1;

	int id, k, nextId, broId;
	REP(i, n) {
		cin >> id >> k;
		REP(j, k) {
			cin >> nextId;
			if (j == 0) {
				N[id].l = nextId;
			} else {
				N[broId].r = nextId;
			}
			broId = nextId;
			N[nextId].p = id;
		}
	}

	int r;

	//????????????????±???????
	REP(i, n) {
		if (N[i].p == -1) r = i;
	}

	// ??±???????±???????
	rec(r, 0);

	// ??????
	REP(i, n) print(i);
	return 0;
}

Measured memory_bytes: 7456