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

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

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/04/20  Problem: ABC 051 A / Link: http://abc051.contest.atcoder.jp/tasks/abc051_a  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	LL A, B, C, D; cin >> A >> B >> C >> D;
	ans = max(A*B, C*D);
	cout << ans << "\n";

	return 0;
}


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

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		List<Integer> list = new ArrayList<>();		// 整数列

		int num = scan.nextInt();					// 整数の個数
		for(int i = 0; i < num; i++) {
			list.add(scan.nextInt());
		}

		long count = list.stream().distinct().count();
		System.out.println(count);

		scan.close();

	}

}

Measured memory_bytes: 28628
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <climits>
#include <complex>
#include <numeric>
using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RREP(i,n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();++i)
#define ALL(c) (c).begin(), (c).end()

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > pipii;
typedef vector<int> vi;

const int INF = 1e9;
const int MOD = 1e9+7;

int main(void){
	int a, b, c;
	cin >> a >> b >> c;
	int ans = INF;
	REP(i, 2000) {
		if(a > i || b > i || c > i) continue;
		int aa = (i - a) % 2;
		int bb = (i - b) % 2;
		int cc = (i - c) % 2;
		if(aa + bb + cc == 2 || aa + bb + cc == 0) {
			int res = 0;
			res += (i - a) / 2;
			res += (i - b) / 2;
			res += (i - c) / 2;
			if(aa + bb + cc == 2) res++;
			ans = min(ans, res);
		}
	}
	cout << ans << endl;
	return 0;
}

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

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

	string s;
	cin >> s;
	bool a = false;
	bool b = false;
	for (int i = 0; i < s.length(); ++i) {
		if (s[i] == 'A') {
			a = true;
		}
		if (s[i] == 'B') {
			b = true;
		}
	}
	if (a&&b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let mut works = vec![];
    for i in 0..n {
        let v = read_vec::<usize>();
        works.push((v[1], v[0]));
    }
    works.sort();
    let mut current_time = 0;
    for (b, a) in works {
        current_time += a;
        if current_time > b {
            println!("No");
            return;
        }
    }
    println!("Yes");
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 9284
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define sortr(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define MAX 10000005
constexpr int inf = 100000000;

struct Point{
    double x,y;
};

void koch(int n,Point a,Point b){
    if(n==0){
        return;
    }
    Point s,t,u;
    double th=M_PI/3.0000;
    s.x=(2.0*a.x+1.0*b.x)/3.0;
    s.y=(2.0*a.y+1.0*b.y)/3.0;
    t.x=(2.0*b.x+1.0*a.x)/3.0;
    t.y=(2.0*b.y+1.0*a.y)/3.0;
    u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
    u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;

    koch(n-1,a,s);
    printf("%.8f %.8f\n",s.x,s.y);
    koch(n-1,s,u);
    printf("%.8f %.8f\n",u.x,u.y);
    koch(n-1,u,t);
    printf("%.8f %.8f\n",t.x,t.y);
    koch(n-1,t,b);
}
int main(){
    Point a,b;
    int n;
    scanf("%d",&n);
    a.x=0;
    a.y=0;
    b.x=100.0;
    b.y=0;
    printf("%.8f %.8f\n",a.x,a.y);
    koch(n,a,b);
    printf("%.8f %.8f\n",b.x,b.y);
	return 0;
}












Measured memory_bytes: 3172
#include<iostream>
using namespace std;
int main() {
  int n,k;
  char c[55];
  cin >> n >> k;
  for(int i=0;i<n;i++){
    cin >> c[i];
  }
  c[k-1] += 32;
  for(int i=0;i<n;i++){
    cout << c[i];
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main()
{
    cin>>a>>b>>c;
    if(b>a) b-=a;
    else b=a-b;
    if(c>a) c-=a;
    else c=a-c;     
    if(b<c) cout<<"A"<<endl;
    else cout<<"B"<<endl;
	return 0;
}


Measured memory_bytes: 256
import os

def takoyakiCalculator(amount, cap, time):
  div = int(amount / cap)
  
  if (amount % cap != 0):
    return (div * time) + time
  else:
    return div * time

def userInput():
  a = input()
  b = a.split()
  
  X = int(b[0])
  N = int(b[1])
  T = int(b[2])

  return takoyakiCalculator(X, N, T)

print(userInput())

Measured memory_bytes: 9192
from itertools import combinations
n = int(input())
lst = list(map(int, input().split()))
comb = combinations(lst, 3)
count = 0
for i in comb:
  if i[0] != i[1] and i[1] != i[2] and i[0] != i[2]:
    if i[0] + i[1] > i[2] and i[1] + i[2] > i[0] and i[0] + i[2] > i[1]:
      count += 1
print(count)

Measured memory_bytes: 9220
require 'pp'

def fill(c)

	w = c[0].length
	h = c.length

	for y in Range.new(0, h, true) do
		for x in Range.new(0, w, true) do
			if c[y][x] == '.' then
				candidate = [[-1, -1], [0, -1], [1, -1],
							 [-1,  0],          [1,  0],
							 [-1,  1], [0,  1], [1,  1]]
				bombs = 0
				for a in candidate do
					ix = x + a[0]
					iy = y + a[1]
					if ix >= 0 and iy >= 0 and ix < w and iy < h then
						if c[iy][ix] == '#' then
							bombs += 1
						end
					end
				end
				c[y][x] = bombs
			end
		end
	end

end


h, _ = gets.chomp.split(/ /)
h = h.to_i
c = []
for i in Range.new(0, h, true) do
	c[i] = gets.chomp.split(//)
end

fill(c)
for i in Range.new(0, h, true) do
	puts c[i].join()
end



Measured memory_bytes: 2428
#![allow(unused_mut)]
#![allow(non_snake_case)]

#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars,
    }
    let mut m = HashMap::new();
    for c in s {
        if m.contains_key(&c) {
            let x = m.get_mut(&c).unwrap();
            *x += 1;
        } else {
            m.insert(c, 1);
        }
    }
    if m.len() != 2 {
        println!("No");
        return;
    }
    for (_, v) in m {
        if v != 2 {
            println!("No");
            return;
        }
    }
    println!("Yes");
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define LL long long

vector<LL> divisors(LL n){
  vector<LL> ret;
  for(LL i=1 ; i*i<=n ; ++i){
    if(n%i == 0){
      ret.push_back(i);
      if(i!=1 && i*i!=n){
	ret.push_back(n/i);
      }
    }
  }
  return ret;
}

int main(){
  LL n;
  cin>>n;
  vector<LL> v = divisors(n);

  LL ret=0LL;
  REP(i,v.size()){
    LL r = v[i];
    if(n%r==0 && (n/r-1>r))ret+=n/r-1;
  }
  cout<<ret<<endl;
  return 0;
}


Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static final int N_MAX = 100;
    static int N;
    static boolean[] isPrime = new boolean[N_MAX + 1];
    static ArrayList<Integer> idx2Prime;
    static int[][] primeFactor;

    public static void main(String[] args) {
        readInput();

        solve();
    }

    static void solve() {
        calcPrime();
        
        calcPrimeFactor();
        
        int[] primeCount = new int[idx2Prime.size()];
        
        int over75 = 0;
        int over25 = 0;
        int over15 = 0;
        int over5 = 0;
        int over3 = 0;
        
        for(int idx = 0; idx < idx2Prime.size(); idx++) {
            for(int num = 2; num <= N; num++) {
                primeCount[idx] += primeFactor[num][idx];
            }
            
            if(primeCount[idx] >= 74) {
                over75++;
            }
            if(primeCount[idx] >= 24) {
                over25++;
            }
            if(primeCount[idx] >= 14) {
                over15++;
            }
            if(primeCount[idx] >= 4) {
                over5++;
            }
            if(primeCount[idx] >= 2) {
                over3++;
            }
        }
        
        int ans = 0;
        ans += over75;
        ans += over25 *(over3 - 1);
        ans += over15 *(over5 - 1);
        ans += over5 * (over5 - 1) * (over3 - 2) / 2;
        
        System.out.println(ans);
    }


    static void readInput() {
        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextInt();
        }
    }

    static void calcPrime() {
        Arrays.fill(isPrime, true);
        
        idx2Prime = new ArrayList<>();
        
        for(int idx = 2; idx <= N_MAX; idx++) {
            if(isPrime[idx]) {
                idx2Prime.add(idx);
                for(int num = idx; num <= N_MAX; num += idx) {
                    isPrime[num] = false;
                }
            }
        }
        
    }
    
    static void calcPrimeFactor() {
        primeFactor = new int[N_MAX+1][idx2Prime.size()];
        
        for(int num = 2; num<=N_MAX; num++) {
            int tmpNum = num;
            for(int idx = 0; idx<idx2Prime.size(); idx++) {
                int prime = idx2Prime.get(idx);
                
                int count = 0;
                while((tmpNum % prime) == 0) {
                    tmpNum /= prime;
                    count++;
                }
                
                primeFactor[num][idx] = count;
                
                if(tmpNum == 1) {
                    break;
                }
            }
            
        }
    }
    
    static int combo(int idxP, int num, int[] primeCount) {
        int ans = 0;
        
        if(idxP >= primeCount.length) {
            return ans;
        }
        
        if(num < 1) {
            return 1;
        }
        
        int minI = Math.min(num, primeCount[idxP]);
        
        for(int i = 0; i<=minI; i++) {
            ans += combo(idxP + 1, num - i, primeCount);
        }
        
        return ans;
    }
    
}


Measured memory_bytes: 21972
from itertools import combinations

N, M, X = map(int, input().split(' '))
books = [tuple(map(int, input().split(' '))) for _ in range(N)]

cost = 10 ** 9
for r in range(1, N + 1):
    for book_indexes in combinations(range(N), r=r):
        points = [0] * M
        c = 0
        for index in book_indexes:
            book = books[index]
            c += book[0]
            for i in range(len(points)):
                points[i] += book[i + 1]
        if all([point >= X for point in points]):
            cost = min(cost, c)

if cost == 10 ** 9:
    cost = -1
print(cost)


Measured memory_bytes: 9228
#include<stdio.h>
int main()
{
  int a,s,y,t;
  while(1){
    scanf("%d %d",&a,&s);
    if(a == 0 && s == 0)
      break;
    for(y=0;y<a;y++){
      for(t=0;t<s;t++){
        printf("#");
      }
      printf("\n");
        }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 2680
S = input()
r = 0
l = 0
s = [0]*len(S)
for i in range(len(S)-1):
    if S[i] == 'R' and S[i+1] == 'L':
        r += 1
        s[i] += (r + 1) //2
        s[i+1] += r//2
        r = 0
    elif S[i] == 'R':
        r += 1
S = list(reversed(S))
s.reverse()
for i in range(len(S)-1):
    if S[i] == 'L' and S[i+1] == 'R':
        l += 1
        s[i] += (l + 1) //2
        s[i+1] += l//2
        l = 0
    elif S[i] == 'L':
        l += 1
s.reverse()
for i in s:
    print(i, end =' ' )
        

Measured memory_bytes: 5552
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <math.h>

using namespace std;

int main () {
	int N, D, X, A, total;
	cin >> N >> D >> X;
	total = X;
	for (int i = 0; i < N; i++){
		cin >> A;
		
		total += (D-1)/A + 1;
	
	}
	cout << total << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main (String[] args) {
    Scanner scanner = new Scanner(System.in);
    String out = "";
    while (scanner.hasNext()) {
      double l = scanner.nextDouble();
      double w = scanner.nextDouble();
      double h = scanner.nextDouble();
      if (l == 0 && w == 0 && h == 0) {
        break;
      }
      l /= 2;
      w /= 2;
      h /= 2;
      int n = scanner.nextInt();
      for (int ii = 0; ii < n; ii++) {
        double r = scanner.nextDouble();
        out += r * r > l * l + w * w || r * r > l * l + h * h || r * r > h * h + w * w ? "OK\n" : "NA\n";
      }
    }
    System.out.print(out);
  }
}

Measured memory_bytes: 20080
import sys
def input():
	return sys.stdin.readline().strip()

N, x = list(map(int, input().split()))
a = list(map(int, input().split()))

ans = 0

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

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

print(ans)

Measured memory_bytes: 63856
import java.util.HashMap;
import java.util.Scanner;

public class Main {

    Main(){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();

        HashMap<Integer, Long> HM = new HashMap();
        int[] A = new int[N];
        for (int i = 0; i < N; i++) {
            A[i] = scanner.nextInt();
            HM.put(A[i], HM.getOrDefault(A[i],0L) + 1);
        }

        long T = 0;
        for (long l : HM.values()) {
            T += l * (l-1) / 2;
        }

        for (int i = 0; i < N; i++) {
            if (HM.containsKey(A[i])){
                System.out.println(T - HM.get(A[i]) + 1);
            } else {
                System.out.println(T);
            }
        }
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 100444
import java.util.Scanner;
 class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt();
		int count = 0;
		for(int i = a; i <= b; i++){
			if(c%i == 0){
				count++;
			}
		}
		System.out.println(count);
	}
 }
 

Measured memory_bytes: 26228
#define _GLIBCXX_DEBUG
#include <iostream>
#include <bits/stdc++.h>
    
    
using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,m,n) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define REV(v) reverse(v.begin(),v.end())
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cout(n) cout<<fixed<<setprecision(n)
#define dout(n) cout<<# n<<" = "<<n<<endl;
#define v1out(v) FOR(j,0,v.size()){cout<<v[j]; if(j!=(ll)v.size()-1)cout<<" ";else cout<<endl; }
#define v2out(v) FOR(i,0,v.size())v1out(v[i]);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    if(s=="ABC")cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl;


int dp[100005];

int dfs(int v, vector<vector<int>> &graph){
    if(dp[v] != -1){return dp[v];}

    int res = 0;
    for(int i = 0; i < graph[v].size(); i++){
        res = max(res, dfs(graph[v][i],graph)+1);
    }
    dp[v] = res;
    return res;
}

int main(){
    ll n, m;
    cin >> n >> m;
    vector<vector<int>> graph(n);
    for(int i = 0; i < m; i++){
        int x, y;
        cin >> x >> y;
        x--; y--;
        graph[x].push_back(y);
    }

    for(int i = 0; i < n; i++){
        dp[i] = -1;
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        ans = max(ans,dfs(i,graph));
    }

    cout << ans << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppiii;

void solve() {
  int n, m;
  cin >> n >> m;
  ll ret = 1;
  if(n-m > 1 || m-n > 1) ret = 0;
  if(n == m) ret *= 2;
  for(int i = 1; i <= n; i++) {
    ret *= i;
    ret %= 1000000007;
  }
  for(int i = 1; i <= m; i++) {
    ret *= i;
    ret %= 1000000007;
  }
  cout << ret << endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c=0,cnt=0;
  cin>>a;
  for(int i=0;i<a;i++){
  cin>>b;
  if(b%2==0){
        cnt++;
    if(b%3==0 ||b%5==0 ) c++;
  }
  }
  if(c!=cnt)cout<<"DENIED"<<endl;
  else cout<<"APPROVED"<<endl;
return 0;
}


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

int main()
{
	int n, array[200000], a;
	cin>>n;
	for(int i=1; i<=n; i++) array[i] = 0;
	for(int i=1; i<n; i++)
	{
		cin>>a;
		array[a] += 1;  
	}
	for(int i=1; i<=n; i++)
	{
		cout<<array[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 4408
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
using namespace std;
const int MAXN = 305;
const int INF = (LL)1e9 + 5;
const LL MOD = 998244353;

int N, cnt[4];
double dp[MAXN][MAXN][MAXN];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int sushi = 0;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		int x;
		scanf("%d", &x);
		cnt[x]++;
		sushi += x;
	}
	
	for (int tot = 1; tot <= sushi; tot++) {
		for (int k = 0; k <= tot / 3 && k <= cnt[3]; k++) {
			for (int j = 0; j <= (tot - 3 * k) / 2 && j <= cnt[2] + cnt[3]; j++) {
				int i = tot - 3 * k - 2 * j;
				if (i > N) continue;
				double &res = dp[i][j][k];
					
				res = 1.0;
				if (i != 0) res += dp[i - 1][j][k] * i / N;
				if (j != 0) res += dp[i + 1][j - 1][k] * j / N;
				if (k != 0) res += dp[i][j + 1][k - 1] * k / N;
				if (i + j + k != N) res = res * N / (i + j + k);
			}
		}
	}
	
	printf("%.20f\n", dp[cnt[1]][cnt[2]][cnt[3]]);
}


Measured memory_bytes: 219520
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
struct state{
  int pos,money,cic;
  state(int pos=0,int money=0,int cic=0):
    pos(pos), money(money), cic(cic) {}
};
struct edge{
  int to,cost;
  edge(int to=0,int cost=0):
    to(to),cost(cost) {}
};
bool operator < (const state& s, const state& t){
  return s.money > t.money;
}

int main(void){
  int c,n,m,s,d;
  while(cin>>c>>n>>m>>s>>d){
    if(c==0) break;
    s--;d--;
    vector< vector<edge> > graph(n);
    REP(i,m){
      int a,b,f;
      cin>>a>>b>>f;
      a--;b--;
      graph[a].push_back(edge(b,f));
      graph[b].push_back(edge(a,f));
    }
    priority_queue<state> que;
    que.push(state(s));
    bool used[110][20]={};
    while(!que.empty()){
      state nowstate = que.top(); que.pop();
      int pos = nowstate.pos;
      int money = nowstate.money;
      int cicket = nowstate.cic;
      if(pos == d){
        cout<<money<<endl;
        break;
      }
      if(used[pos][cicket])continue;
      used[pos][cicket] = true;
      REP(i,graph[pos].size()){
        edge e = graph[pos][i];
        que.push(state(e.to,money+e.cost,cicket));
        if(cicket != c) que.push(state(e.to,money+e.cost/2,cicket+1));
      }
    }
  }
  return 0;
}

Measured memory_bytes: 0
# 展望台N
# 道M
N, M = map(int, input().split())

# 展望台の高さ
H = list(map(int, input().split()))

#n = [[0] * N for i in range(N)]
n = [0] * N

for m in range(M):
  A, B = map(int, input().split())
  #n[A-1][B-1] = H[B-1]
  #n[B-1][A-1] = H[A-1]
  n[A-1] = max(n[A-1], H[B-1])
  n[B-1] = max(n[B-1], H[A-1])
  
#print(n)

cnt = 0
for i in range(N):
  if H[i] > n[i]:
    cnt +=1
    
print(cnt)
##

Measured memory_bytes: 84980
#include <bits/stdc++.h>
using namespace std; 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0); 
	int N, Q; cin >> N >> Q; 
	long long A[100010] = {}; 
	A[0] = (long long) N; 
	for(int i = 1; i <= Q; i++) cin >> A[i]; 
	long long mn[100010] = {}; 
	mn[Q] = A[Q]; 
	for(int i = Q-1; i >= 0; i--) mn[i] = min(mn[i+1], A[i]); 
	vector<long long> B; 
	for(int i = 0; i <= Q; i++){
		if(A[i] == mn[i]) B.emplace_back(A[i]); 
	}
	long long rem[100010] = {}; 
	long long cnt[100010] = {}; 
	long long ans[100010] = {}; 
	int sz = (int) B.size(); 
	cnt[sz - 1] = 1; 
	for(int i = sz-1; i >= 0; i--){
		long long tmp = B.at(i); 
		while(1){
			int it = lower_bound(B.begin(), B.end(), tmp) - B.begin(); 
			if(it == 0) break; 
			it--; 
			cnt[it] += tmp / B.at(it) * cnt[i]; 
			tmp = tmp % B.at(it); 
		}
		rem[tmp] += cnt[i];
	}
	for(int i = N; i >= 1; i--){
		ans[i] = ans[i+1] + rem[i]; 
	}
	for(int i = 1; i <= N; i++){
		cout << ans[i] << "\n"; 
	}
}

Measured memory_bytes: 7900
#include <stdio.h>
int main(void){
    
    
int a,b;

scanf( "%d%d" , &a,&b);


 if(a > b){
   printf("a > b\n");
 }

else if(a == b){
    printf("a == b\n");
}
 
 else{ printf("a < b\n");
     
 }
 
 
return 0;
    
}



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

int main() {
    int n, q;
    cin >> n >> q;
    vector<int> es[n + 1];
    for (int i = 1; i < n; i++) {
        int a, b;
        cin >> a >> b;
        es[a].push_back(b);
        es[b].push_back(a);
    }
    int xs[n + 1];
    bool used[n + 1];
    fill(xs, xs + n + 1, 0);
    fill(used, used + n + 1, false);
    for (int i = 0; i < q; i++) {
        int p, x;
        cin >> p >> x;
        xs[p] += x;
    }
    queue<int> que;
    que.push(1);
    used[1] = true;
    while (!que.empty()) {
        int v = que.front();
        que.pop();
        for (int u: es[v]) {
            if (used[u])
                continue;
            xs[u] += xs[v];
            used[u] = true;
            que.push(u);
        }
    }
    cout << xs[1];
    for (int i = 2; i <= n; i++) {
        cout << ' ' << xs[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 15732
def resolve():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    A.insert(0, 0)

    route = [1]
    route_set = set(route)
    towns_step = [0] * (N+10)
    step = 0
    now = 1
    while A[now] not in route_set:
        next = A[now]
        route.append(next)
        route_set.add(next)
        step += 1
        towns_step[next] = step
        now = next

    border = towns_step[A[now]]
    head = route[0: border]
    roop = route[border:]

    if K < border:
        ans = head[K]
    else:
        k = (K - border) % len(roop)
        ans = roop[k]
    print(ans)

if __name__ == "__main__":
    resolve()

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

int main()
{
    string s;

    cin >> s;

    if(s == "Sunny") {
        cout << "Cloudy";
    } else if(s == "Cloudy") {
        cout << "Rainy";
    } else if (s == "Rainy") {
        cout << "Sunny";
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        if (a % 2 == 1){
            a = a + 1;
        }

        int b = a/2;
            
        System.out.println(b);
    }
}

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

int main(){
    int A,B,K;
    cin >> A >> B >> K;
    int C = B - A + 2;
    if(C <= 2*K){
        for(int i = A; i <= B; i++){
            cout << i << endl;
        }
    }
    else{
        for(int i = A; i < A+K; i++){
            cout << i << endl;
        }
        for(int j = B-K+1; j <= B; j++){
            cout << j << endl;
        }
    }
    return 0;
}

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

using namespace std;

typedef long long int lint;

const int NMAX = 2000 + 5;

int N, x;
int a[NMAX];

int dp[NMAX][NMAX];

int main()
{
    cin >> N >> x;

    lint ans = 0;
    for (int i = 0; i < N; ++ i) {
        cin >> a[i];
        ans += a[i];
        dp[0][i] = a[i];
    }

    for (int rots = 1; rots < N; ++ rots) {
        lint cost = 1LL * rots * x;
        for (int i = 0; i < N; ++ i) {
            dp[rots][i] = min(a[i], dp[rots - 1][(i + N - 1) % N]);
            cost += dp[rots][i];
        }

        if (cost < ans)
            ans = cost;
    }

    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 15872
# -*- coding: utf-8 -*-
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys

def s():
    return raw_input().strip()
def n():
    return int(raw_input())
def d():
    return float(raw_input())

def ls():
    return raw_input().strip().split()
def ln():
    return map(int, raw_input().strip().split())
def ld():
    return map(float, raw_input().strip().split())

def fs():
    return [raw_input().strip() for i in xrange(input())]
def fn():
    return [int(raw_input().strip()) for i in xrange(input())]
def fd():
    return [float(raw_input().strip()) for i in xrange(input())]

N = n()
S = s()
T = s()

LS = len(S)
LT = len(T)

for i in xrange(LS):
    if i + LT >= N and S[i:] == T[:LS - i]:
        print i + LT
        break
else:
    print LS + LT


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


int main(void)
{
	//変数の宣言
	int n;
	
	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp,temp1,temp2;
	//データの読み込み
	scanf("%d",&n);
	
	
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	if(n<8){
		if(n==3) printf("2 5 63");
		if(n==4) printf("2 5 20 63");
		if(n==5) printf("2 3 4 6 9");
		if(n==6) printf("2 3 4 6 9 12");
		if(n==7) printf("2 3 4 6 8 9 10");
		
		return 0;
	}
	
	j=0;
	for(i=n;i>0;i=i-8){
		if(i>=8){
			if(j!=0) printf(" ");
			printf("%d %d %d %d %d %d %d %d",j+2,j+3,j+4,j+6,j+8,j+9,j+10,j+12);
			j=j+12;
		}else if(i%2==1){
			printf(" %d",j+6);
			i--;
		}
		if(i==2){
			printf(" %d %d",j+2,j+4);
		}else if(i==4){
			printf(" %d %d %d %d",j+2,j+3,j+4,j+9);
		}else if(i==6){
			printf(" %d %d %d %d %d %d",j+2,j+3,j+4,j+8,j+9,j+10);
		}
	}
	
	
	
//	printf("計算部分終了\n");
	//出力
	
	//printf("%d",ans);
	
//	printf("結果の出力終了\n");
	
	return 0;
	
}



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>
#include <chrono>
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 tuple<ll,ll,ll> tll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
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=100050;
//templete
int main() {
	int N,M,C;
	cin>>N>>M>>C;
	int ans=0;
	vint B;
	for(int i=0;i<M;i++){
		int b;
		cin>>b;
		B.pb(b);
	}
	for(int i=0;i<N;i++){
		int sum=0;
		for(int j=0;j<M;j++){
			int a;
			cin>>a;
			sum+=B[j]*a;
		}
		if(sum+C>0)
			ans++;
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
N, H = map(int, input().split())
AB = [[int(i) for i in input().split()] for _ in range(N)]
A, B = map(list, zip(*AB))
B.sort()
X = max(A)
S = sum(B)

cnt = 0
if H > S:
    cnt += (H - S) // X
    H = H - X * cnt
if H > 0:
    for b in B[::-1]:
        H -= max(b, X)
        cnt += 1
        if H <= 0: break
while H > 0:
    H -= X
    cnt += 1
print(cnt)


Measured memory_bytes: 71384
#include <stdio.h>

int main(void)
{
  int  i, n;
  char str[10][4];
  double x, yen=0;
    scanf("%d",&n);
  
  for(i=0; i<n; i++)
  { scanf("%lf",&x);
    scanf("%s",str[i]);
 
   if(str[i][0]=='B')
   {  yen=yen+x*380000;
  }
   else
   {yen=yen+x;}
    

  }
 printf("%lf\n", yen);
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
int main(void){
    // Your code here!
    int H,W;
    char a[100][101];
    
    scanf("%d%d",&H,&W);
    
    for(int i = 0; i < H; i++){
        scanf("%100s",a[i]);
    }
    
    for(int i = 0; i < H + 2; i++){
        printf("#");
        for(int j = 0; j < W; j++){
            if(i == 0 || i == H + 1){
                printf("#");
            }
            else{
                printf("%c",a[i-1][j]);
            }
        }
        printf("#\n");
    }
}


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

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

    ll n;
    cin >> n;

    ll prevprev = 2; //l0
    ll prev = 1; //l1

    if (n == 1){
        cout << prev << endl;
        return 0;
    }

    ll res = prevprev + prev;
    for (int i = 2; i < n; ++i){
        prevprev = prev;
        prev = res;
        res = prevprev + prev;
    }
    cout << res << endl;

}

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

#define rep(i, n) for (ll i=0;i<(n); i++)
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; }
#define ALL(x) (x).begin(),(x).end()
#define Sort(a) sort(ALL(a))
#define Rev(a) reverse(ALL(a))


using namespace std;
//using ll=long long;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pi;
const long double PI=3.14159265358979323846;


template<class T> bool contain(const std::string& s, const T& v) {
   return s.find(v) != std::string::npos;
}


int main(){

  ll n;
  cin>>n;

  map<ll, ll> m;

  ll tmp;
  rep(i,n){
    cin>>tmp;
    m[tmp]++;
  }
  ll ans = 0;
  for(auto x:m){
    if(x.first<=x.second){
      ans += x.second-x.first;
    }
    else{
      //cout<<x.first<<endl;
      ans += x.second;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 6272
str = input()
str_list = list(str)
q = int(input())
for i in range(q):
    order = input().split()
    if order[0] == 'print':
        for i in range(int(order[1]),int(order[2])+1):
            print("{}".format(str_list[i]),end=(''))
        print('')
    elif order[0] == 'replace':
        word=list(order[3])
        j = 0
        for i in range(int(order[1]),int(order[2])+1):
            str_list[i]=word[j]
            j = j + 1
    elif order[0] == 'reverse':
        word = list(str_list[int(order[1]):int(order[2])+1])
        j = len(word)
        for i in range(int(order[1]),int(order[2])+1):
            str_list[i] = word[j-1]
            j = j - 1      


Measured memory_bytes: 5740
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
#include <cstdint>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000000
#define MAX 200001

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
const ll MOD = 1000000007;

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

set<ll> kouho;

void solve(string now){
    if(now.size() <= 10){
        ll a = stoll(now);
        kouho.insert(a);
        for(int i = 0; i < 10; i++){
            int d = now[now.size()-1]-'0';
            if(abs(d-i) <= 1){
                solve(now + toString(i));
            }
        }
    }
}

int main(){
    ll K;
    cin >> K;
    for(ll i = 1; i < 10; i++){
        solve(toString(i));
    }
    vector<ll> v(kouho.begin(), kouho.end());
    cout << v[K-1] << endl;
}

Measured memory_bytes: 14092
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var S = ReadLine();
        var N = S.Length;

        var rle = RunLengthEncoding.Encode(S).ToArray();
        var ans = new int[N];
        var cursor = 0;

        for (int i = 0; i < rle.Length; i += 2)
        {
            var (r, l) = (rle[i], rle[i + 1]);
            var length = r.length + l.length;

            if (length % 2 == 0)
            {
                ans[cursor += r.length - 1] = length / 2;
                ans[cursor += 1] = length / 2;
                cursor += l.length;
            }
            else
            {
                ans[cursor += r.length - 1] = length / 2 + ((r.length % 2 == 1) ? 1 : 0);
                ans[cursor += 1] = length / 2 + ((l.length % 2 == 1) ? 1 : 0);
                cursor += l.length;
            }
        }

        for (int i = 0; i < N; i++)
            Write($"{ans[i]}{((i < N - 1) ? ' ' : '\n')}");
    }
}
static class RunLengthEncoding
{
    public static IEnumerable<(T element, int length)> Encode<T>(IEnumerable<T> collection)
    {
        var isFirst = true;
        var prevElement = default(T);
        var length = 0;

        foreach (var element in collection)
        {
            if (!isFirst && !EqualityComparer<T>.Default.Equals(prevElement, element))
            {
                yield return (prevElement, length);
                length = 0;
            }
            else
                isFirst = false;

            length++;
            prevElement = element;
        }
        if (!isFirst)
            yield return (prevElement, length);
    }

    public static IEnumerable<T> Decode<T>(IEnumerable<(T element, int length)> rle) => rle.SelectMany(t => Enumerable.Repeat(t.element, t.length));
}


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

int main() {
  int N; cin >> N;
  vector<int> l(N);
  vector<int> r(N);
  for (int i = 0; i < N; i++) cin >> l[i] >> r[i];
  
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += r[i]-l[i]+1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>

using namespace std;

int counter(int n, int k, int s);

int main()
{
	int n, k, s;
	while(1){
		cin >> n >> k >> s;
		if(n == 0 && k == 0 && s == 0) break;
		int cnt = 0;
		cnt = counter(n+1, k, s);
		cout << cnt << endl;
	}
	return 0;
}

int counter(int n, int k, int s)
{
	int ans = 0;
	if(s < 1) ans = 0;
	else if(k > 1){
		for(int i = n - 1; i > 1; i--){
			ans += counter(i, (k - 1), (s - i));
		}
	} else if(k == 1){
		if(s < n && 0 < s) ans = 1;
		else ans = 0;
	}
	return ans;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;
    
    int count = 700;
    if (s[0] == 'o') count += 100;
    if (s[1] == 'o') count += 100;
    if (s[2] == 'o') count += 100;
    
    cout << count << endl;
    
}


Measured memory_bytes: 256
n=int(input())
d={"AC":0,"WA":0,"TLE":0,"RE":0}
for i in range(n):
    d[input()]+=1
print("AC x "+str(d["AC"]))
print("WA x "+str(d["WA"]))
print("TLE x "+str(d["TLE"]))
print("RE x "+str(d["RE"]))

Measured memory_bytes: 9200
#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
#define ll long long
#define ld long double
#define pll pair<ll ,ll >
#define plll pair<ll,pll>
#define ppll pair<pll, pll>
#define pii pair<int, int> 
#define pb push_back
#define mod 1000000007
#define N 2000007
ll power(ll a,ll b){
    ll res=1ll;
    while(b>0){
        if(b%2!=0) res=(res*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res%mod;
}
ll ncr(ll n,ll k){
    if(k>n-k) k=n-k;
    ll pro=1;
    for(ll i=0;i<k;i++){
        pro=(pro*(n-i))%mod;
        pro/=(i+1);
    }
    return (pro)%mod;
}

void swap(ll *a,ll *b) {
    ll temp=*a;
    *a=*b;
    *b=temp;
}
vector<ll> prime;
void seive(){
    vector<bool > isprime(1000001,true);
    for(int i=2;i*i<=1000000;i++){
        if(isprime[i]){
            for(int j=i*i;j<=1000000;j+=i){
                isprime[j]=false;
            }
        }
    }
    for(int i=2;i<=1000000;i++){
        if(isprime[i]) prime.push_back(i);
    }
}
vector<ll> parent;
ll find(ll p) {
    if(parent[p]==p) return parent[p];
    return parent[p]=find(parent[p]); 
}
void unun(ll a,ll b) {
    ll r1=find(a);
    ll r2=find(b);
    if(r1!=r2) parent[r2]=r1;
}
vector<vector<ll>> adj;
vector<ll> he,v,visited;
ll dfs(ll src) {
    visited[src]=1;
    v[src]=he[src];
    for(auto itr: adj[src]) {
        if(!visited[itr]) {
            v[src]=max(v[src],dfs(itr));
        }
    }
    return v[src];
}
ll cnt=0;
void bfs(ll src,ll n) {
    queue<ll> q;
    q.push(src);
    visited[src]=1;
    while(!q.empty()) {
        ll p=q.front();
        q.pop();
        int flag=0;
        for(auto itr: adj[p]) {
            if(he[itr]>=he[p]) {
                flag=1;
                break;
            }
        }
        for(auto itr: adj[p]) {
            if(!visited[itr]) {
                visited[itr]=1;
                q.push(itr);
            }
        }
        if(flag==0) cnt++;
    }
}
void solve() {
    ll n,m,a,b;
    cin>>n>>m;
    cnt=0;
    v= vector<ll>(n);
    visited = vector<ll>(n);
    he = vector<ll>(n);
    adj = vector<vector<ll>>(n);
    for(int i=0;i<n;i++) cin>>he[i];
    for(int i=0;i<m;i++) {
        cin>>a>>b;
        a--;
        b--;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    // dfs(0);
    for(int i=0;i<n;i++) 
    if(!visited[i])
    bfs(i,n);
    cout<<cnt;
}   


int main(void){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    int t;
    t=1;
    // cin>>t;
    while(t--) {
        solve();
        // cout<<endl;
    }
    return 0; 

}


Measured memory_bytes: 11636
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;
int a[N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int a, b;
	cin >> a >> b;
	int n = b - a;
	int sum = n * (n + 1) / 2;
	cout << sum - b << endl;

	return 0;
}


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

#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll=long long;



int main(){
  int S;
  cin >> S;
  bool leftMM=true;
  bool rightMM=true;

  if( S/100 > 12 || S/100==0)leftMM=false;
  if( S%100 > 12 || S%100==0)rightMM=false;

  if(leftMM==false && rightMM==false) cout << "NA";
  if(leftMM==true && rightMM==true) cout << "AMBIGUOUS";
  if(leftMM==true && rightMM==false) cout << "MMYY";
  if(leftMM==false && rightMM==true) cout << "YYMM";

}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll;
typedef vector<int> vi; typedef vector<ll> vll; template<class T>using vv = vector<vector<T>>;
template<class T>vv<T> vvec(size_t n, size_t m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 28, MOD = 1e9 + 7; constexpr ll LINF = 1ll << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); }; }aaaa;
ll mpow(ll x, int n) { ll y = 1; for (; n > 0; n /= 2) { y = n % 2 ? y * x % MOD : y; x = x * x % MOD; } return y; }
struct Combination {
    vector<ll> fact, ifact;
    Combination(int n) : fact(n + 1), ifact(n + 1) {
        fact[0] = 1;
        for (int i = 0; i < n; ++i) fact[i + 1] = fact[i] * (i + 1) % MOD;
        ifact[n] = mpow(fact[n], MOD - 2);
        for (int i = n; i > 0; --i) ifact[i - 1] = ifact[i] * i % MOD;
    }
    ll operator ()(int n, int k) { return fact[n] * ifact[n - k] % MOD * ifact[k] % MOD; }
} combi(2e5 + 5);

int N, A, B, C;

int main() {
    cin >> N >> A >> B >> C;
    ll ABinv = mpow(A + B, MOD - 2);
    ll pA = A * ABinv % MOD, pB = B * ABinv % MOD;

    ll ans = 0;

    rep(i, N, 2 * N) {
        ll tmp = (mpow(pA, N) * mpow(pB, i - N) % MOD + mpow(pB, N) * mpow(pA, i - N) % MOD) % MOD;
        ans = (ans + tmp * combi(i - 1, N - 1) % MOD * i * 100 % MOD * ABinv % MOD) % MOD;
    }

    write(ans);
}

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

#define select(_1, _2, x, ...) x

#define repn(i, n) for (int i = 0; i < (n); i++)
#define repr(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, ...) select(__VA_ARGS__, repr, repn)(i, __VA_ARGS__)

#define umax(m, x) (m = max(m, x))
#define umin(m, x) (m = min(m, x))

#define bit(x, n) ((x) >> (n) & 1)

using namespace std;
using ll = long long int;
using vl = vector<ll>;

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


typedef struct bit {
    int b; // ビット列
    int t; // 1の残り数
    int f; // 0の残り数
} Bit;

int main() {
    int n, k;
    cin >> n >> k;
    vl a(n);
    rep(i, n) cin >> a[i];

    stack<Bit> s;
    s.push({1, k - 1, n - k});

    ll ans = LINF;

    // 深さ優先探索で, 1がk個, 0がn-k個のビットの組み合わせを列挙
    while (!s.empty()) {
        Bit cur = s.top(); s.pop();

        // ビット列が完成したら
        if (cur.t == 0 && cur.f == 0) {
            ll high = 0; // 一番高い建物の高さ
            ll cost = 0; // 総コスト

            rep(i, n) {
                // 建物が見えていなかったら
                if (a[i] <= high) {
                    // ビットが建ってる(見えるべき建物)だったら
                    if (bit(cur.b, n - 1 - i)) {
                        cost += high + 1 - a[i];
                        high = high + 1;
                    }
                } else {
                    high = a[i];
                }
            }

            umin(ans, cost);

            continue;
        }

        if (cur.t > 0)
            s.push({(cur.b << 1) + 1, cur.t - 1, cur.f});

        if (cur.f > 0)
            s.push({cur.b << 1, cur.t, cur.f - 1});
    };

    cout << ans << endl;

    return 0;
}


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

int main(){
    string s ;
    cin >> s ;
    if(s[0] == 'S') cout << "Cloudy" << endl ;
    if(s[0] == 'C') cout << "Rainy" << endl ;
    if(s[0] == 'R') cout << "Sunny" << endl ;
}


Measured memory_bytes: 3564
import java.io.*;

/**
 * Created by Ayushi on 17/08/2019.
 */

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        String[] a = r.readLine().split("");
        int n = a.length;
        r.close();
        String c;
        int j;
        String p = a[0];
        int ans = 1;
        for (int i = 1; i < n; i++) {
            if (a[i].equals(p) && i != n-1) {
                p = a[i] + a[i+1];
                i++;
            }
            else if (a[i].equals(p)) {
                p = p + a[i];
                ans--;
            }
            else {
                p = a[i];
            }
            ans++;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 50200