akhauriyash/Code-Regression huggingface dataset:
#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--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define CMAX(m, x)  m = max(m,x);
#define CMIN(m, x)  m = min(m,x);
#define itn int
typedef long long lint;
const int INF = 1e9;
const lint LINF = 1e18;
int main(){
    int a,b;
    cin >> a >> b;
    int cnt = 1;
    while(1){
        int anuki = cnt * 0.08;
        int bnuki = cnt * 0.1;
        if(anuki == a && bnuki == b)
            break;
        if(bnuki > 100){
            cout << -1 << endl;
            return 0;
        }
        cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
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; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

int main(){
  ll A,B;
  cin >> A >> B;
  cout << lcm(A,B) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll n,k;vector<ll>ch[100010];
bool ans[100010];
void dep(ll now,ll s){
	if(now!=s&&ch[now].size()==1){
		return ;
	}
	for(ll i=0;i<ch[now].size();i++){
		ll next=ch[now][i];
		if(ans[next]==true){
			continue;
		}
		ans[next]=true;
		dep(next,s);
	}
}
int main() {
	cin>>n>>k;
	for(ll i=0;i<k;i++){
		ll x,y,z;
		cin>>x>>y>>z;
		x--;y--;
		ch[x].push_back(y);
		ch[y].push_back(x);
	}
	ll ans2=0;
	for(ll i=0;i<n;i++){
		if(ans[i]==true){
			continue;
		}
		ans2++;
		dep(i,i);
	}
	cout <<ans2;
	// your code goes here
	return 0;
}

Measured memory_bytes: 13832
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 1e5 + 5;
const ll LINF = 1e18 + 5;
int n, W, w[N], v[N];
ll dp[N];
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n >> W;
 	for(int i=1; i<=n; i++) cin >> w[i] >> v[i];
 	for(int i=1; i<=n; i++)
 		for(int j=W; j>=w[i]; j--)
 			dp[j] = max(dp[j], dp[j-w[i]]+v[i]);
 	ll ans = *max_element(dp, dp+W+1);
 	cout << ans;
	return 0;
}


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

int main(){
  int a,b,c;cin >> a >> b >> c;
  cout << min(a,b) + min(max(a,b),c) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define int long long int
#define double long double 
#define inf (int)(1e15)
#define all(x) (x).begin(), (x).end()
#define pair pair<int, int>
typedef vector<int> vi;   // Vector of long long
typedef vector<vi> vvi;   // Vector of vi
typedef vector<pair> vii; // Vector of pairs
typedef vector<vii> vvii; // Vector of Vector of pairs
typedef vector<bool> vb;  // Vector of bool
#define pq priority_queue // Max heap (To convert to min heap, use negative sign before every value)
#define ff first          // For pairs
#define ss second
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, -1, 0, 1};
const int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1}, dy8[] = {1, -1, 1, 0, -1, 1, -0, -1};
#define testcases(t) \
    int(t);          \
    cin >> (t);      \
    while ((t)--)
signed main()
{
    string s;
    cin>>s;
    for (int i = 0; i < s.length();i++){
        if(s[i]=='?')
            cout << "D";
        else
            cout << s[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3756
// 意味不明だったので解説をみたけど意味不明です
package main
import "fmt"
func main(){
	var a, b, x int
	fmt.Scan(&a, &b, &x)
	if a%x == 0{
		fmt.Println(b/x-(a/x-1))
	}else{
		fmt.Println(b/x - a/x)
	}
}

Measured memory_bytes: 1772
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, D, sum = 0, ans = 0;
    cin >> N >> D;
    vector<vector<int>> S(N, vector<int>(D));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < D; j++) {
            cin >> S.at(i).at(j);
        }
    }
    for (int i = 0; i < N - 1; i++) {
        for (int j = i + 1; j < N; j++) {
            for (int k = 0; k < D; k++) {
                sum += (S.at(i).at(k) - S.at(j).at(k)) * (S.at(i).at(k) - S.at(j).at(k));

            }
            for (int l = 0; l < 128; l++){
                if (sum == l * l) {
                    ans += 1;
                    break;
                } 
            }
            sum = 0;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
import sys
import math
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
XY = list(map(int, read().split()))
X = XY[0::2]
Y = XY[1::2]

t = 0
for i in range(N):
    for j in range(i, N):
        #t += ((X[i] - X[j])**2 + (Y[i] - Y[j])**2)**0.5
        t += math.sqrt((X[i] - X[j])**2 + (Y[i] - Y[j])**2)
print(2*t/N)

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main{
    public static void roll(String order, int we[], int ns[]){
        for(int i = 0 ; i < order.length() ; i++)
        {
            switch(order.charAt(i))
            {
                case 'E' : int tmp = we[3]; we[3] = we[2]; we[2] = we[1]; we[1] = we[0]; we[0] = tmp; ns[1] = we[2]; ns[3] = we[0]; break;
                case 'W' :     tmp = we[0]; we[0] = we[1]; we[1] = we[2]; we[2] = we[3]; we[3] = tmp; ns[1] = we[2]; ns[3] = we[0]; break;
                case 'N' :     tmp = ns[0]; ns[0] = ns[1]; ns[1] = ns[2]; ns[2] = ns[3]; ns[3] = tmp; we[2] = ns[1]; we[0] = ns[3]; break;
                case 'S' :     tmp = ns[3]; ns[3] = ns[2]; ns[2] = ns[1]; ns[1] = ns[0]; ns[0] = tmp; we[2] = ns[1]; we[0] = ns[3]; break;
            }
        }
        System.out.println(we[2]);
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int we[] = new int[4];
        int ns[] = new int[4];
        int num[] = new int[6];
        for(int i = 0 ; i < 6 ; i++)
            num[i] = sc.nextInt();
        we[0] = ns[3] = num[5];
        we[1] = num[3];
        we[2] = ns[1] = num[0];
        we[3] = num[2];
        ns[2] = num[1];
        ns[0] = num[4];
        String order = sc.next();
        roll(order,we,ns);
    }
}


Measured memory_bytes: 26244
#include<iostream>
using namespace std;
int gcd(int a,int b){
    int c=1;
    if(a<b){
        c=a;a=b;b=c;
    }
    while(c!=0){
            c=a%b;
            a=b;
            b=c;
        }
   return a;
}

int main()
{
    int k,ans=0;
    cin>>k;
    for(int i=1;i<=k;i++)
        for(int j=1;j<=k;j++)
            for(int n=1;n<=k;n++){
                ans+=gcd(gcd(i,j),n);
            }
    cout<<ans<<endl;
}

Measured memory_bytes: 3556
while line = gets
  line = line.split(" ")
  a = line[0].to_f
  b = line[1].to_f
  c = line[2].to_f
  d = line[3].to_f
  e = line[4].to_f
  f = line[5].to_f
  
  y = (a * f - c * d) / (a * e - b * d)
  x = (c - b * y ) / a
  
  puts sprintf("%.3f %.3f", x, y)
end

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

using namespace std;

int main(){
  int N;
  cin >> N;
  
  vector<long long> A(N);
  for(int i = 0; i < N; i++) cin >> A[i];
  
  long long b = 0;
  for(int i = 1; i < N; i++){
    if(A[i] < A[i - 1]){
      b += A[i - 1] - A[i];
      A[i] = A[i - 1];
    }
  }
  
  cout << b << endl;
  
  return 0;
}

Measured memory_bytes: 4776
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x) ; y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

V,E=map(int,input().split(' '))
Edges=[tuple(map(int,input().split(' '))) for _ in range(E)]

Edges.sort(key=lambda x:x[2])
F=UnionFind(V)
cost=0
for e in Edges:
    if F.same(e[0],e[1]):
        continue
    F.union(e[0],e[1])
    cost+=e[2]
print(cost)


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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

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

//--------------------------------------------

int main(){
  int n;

  scanf("%d",&n);

  int ans = 0;
  int a, b;
  REP (i, n) {
    scanf("%d %d",&a, &b);
    ans += b - a + 1;
  }

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


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
ll s[2005][2005];
ll ans[2005*2005]={0};
int main(){
	ll N,x,y;
	cin>>N>>x>>y;
	ll a=x,b=y;
	x=min(a,b);
	y=max(a,b);
	for(ll i=1;i<=N;i++){
		for(ll j=i+1;j<=N;j++){
			s[i][j]=min(j-i,abs(x-i)+abs(y-j)+1);
		}
	}
	
	for(int i=1;i<=N;i++){
		for(int j=i+1;j<=N;j++){
			ans[s[i][j]]++;
		}
	}
	for(int i=1;i<N;i++){
		cout<<ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 31360
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
#define inputv(v, n)                                                           \
    vl v;                                                                      \
    rep(i, n) {                                                                \
        ll x;                                                                  \
        cin >> x;                                                              \
        v.push_back(x);                                                        \
    }
bool chmin(ll& a, ll& b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll& a, ll& b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main(){
    string S,S1;
    cin >> n;
    r = n - 1;
    l = 0;
    cout << r << endl;
    cin >> S;
    if (S[0] == 'V')return 0;
    cout << l << endl;
    cin >> S;
    if (S[0] == 'V')return 0;
    S1 = S;
    t = 0;
    while (1) {
        x = (l + r) / 2;
        cout << x << endl;
        cin >> S;
        if (S[0] == 'V')return 0;
        if (((x - l) % 2 == 0) ^ (S[0] == S1[0]))r = x;
        else{
          l = x;
          S1=S;
        }
    }
}


Measured memory_bytes: 852
#include <iostream>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <climits>
#include <numeric>
int main() {
	int n; long long int k; std::cin >> n >> k;
	std::vector<int> dests(n); for (auto& a : dests) {
		std::cin >> a; --a;
	}
	if (k <= n) {
		int current = 0;
		for (auto i = 0; i < k; ++i) {
			current = dests[current];
		}
		std::cout << current + 1 << '\n';
	}
	else {
		std::vector<int> first(n, -1);
		int current = 0;
		first[current] = 0;
		while (first[dests[current]] == -1) {
			first[dests[current]] = first[current] + 1;
			current = dests[current];
		}
		const auto cycle = first[current] -first[dests[current]] + 1;
		const auto rest = (k - first[current]) % cycle;
		for (auto i = 0; i < rest; ++i) {
			current = dests[current];
		}
		std::cout << current + 1 << '\n';
	}
}


Measured memory_bytes: 4844
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

#[derive(Clone)]
struct Solver {
    N: usize,
    G: Vec<Vec<usize>>,
    done: Vec<bool>,
}

impl Solver {
    fn reset(&mut self) {
        for i in 0..self.N {
            self.done[i] = false;
        }
    }

    fn dfs(&mut self, u: usize) -> (usize, usize) {
        self.done[u] = true;

        let mut D = 0;
        let mut W = u;

        for i in 0..self.G[u].len() {
            let v = self.G[u][i];
            if self.done[v] {
                continue;
            }

            let (w, d) = self.dfs(v);
            if D < d + 1 {
                D = d + 1;
                W = w;
            }
        }

        (W, D)
    }

    fn solve(mut self) {
        let (u, _) = self.dfs(0);
        self.reset();
        let (v, d) = self.dfs(u);
        debug!(u, v, d);

        println!("{}", if d % 3 != 1 { "First" } else { "Second" })
    }
}

fn main() {
    let N = read!(usize);
    let T = read![usize, usize; N - 1];

    let mut G = vec![vec![]; N];
    for (u, v) in T {
        G[u - 1].push(v - 1);
        G[v - 1].push(u - 1);
    }

    Solver {
        N: N,
        G: G,
        done: vec![false; N],
    }
    .solve()
}


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

const int MAXN = (int)1e5 + 10;
int n, m;
int cnt[MAXN];
bool has[MAXN]; //has[i]µÚiºÅ¸ñ×ÓÊÇ·ñÓÐºìÇò 
int ans;

int main()
{
	cin >> n >> m;

	for(int i = 1; i <= n; i++) cnt[i] = 1; //¸ñ×ÓÖÐµÄÇòÊý 
	has[1] = true; //1ºÅ¸ñ×ÓÓÐºìÉ«Ð¡Çò 
		
	while(m--)
	{
		int x, y;
		cin >> x >> y;		
		if(has[x]) has[y] = true;
		cnt[x]--; cnt[y]++;	
		if(cnt[x] == 0) has[x] = 0;	
	}
	
	ans = 0;
	for(int i = 1; i <= n; i++)
		ans += has[i];
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 768
import java.util.*;

public class Main {

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

	public void execute() {
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		HashMap<Integer, Integer> aCount = new HashMap<>();

		for (int i = 0; i < N; i++) {
			int ai = sc.nextInt();
			int cnt = aCount.getOrDefault(ai, 0) + 1;
			aCount.put(ai, cnt);
		}

		int count = 0;

		for (Integer key : aCount.keySet()) {
			int val = aCount.get(key);
			if (key < val) {
				count += val - key;
			}else if(key > val) {
				count += val;
			}
		}
		System.out.println(count);
		sc.close();
	}

}

Measured memory_bytes: 65848
def main():
  n, k = map(int, input().split())
  arr = list(map(int, input().split()))
  dp = [1000000000] * n
  dp[0] = 0
  for i in range(1, n):
    for j in range(max(0, i - k), i):
      dp[i] = min(dp[i], dp[j] + abs(arr[i] - arr[j]))
  print(dp[-1])
main()  

Measured memory_bytes: 52448
fun main(args: Array<String>) {
    val s = readLine()!!.replace("BC", "D")
    var ans = 0L
    var ac = 0
    s.forEach {
        when (it) {
            'A' -> ac++
            'D' -> ans += ac
            else -> ac = 0
        }
    }
    println(ans)
}


Measured memory_bytes: 44580
#include<bits/stdc++.h>
const int N=305,mo=1e9+7;
int a[N*2],n,i,j,k,f[2][N*2][N*2],s1,s2,nw,x,ss,ans;
bool b1[N*2],b2[N*2];
inline void add(int&x,const int&y){x+=y-mo;x+=x>>31&mo;}
int main(){
	scanf("%d",&n);
	for(i=1;i<=n*2;++i)scanf("%d",a+i);
	for(i=1;i<n*2;i+=2)if(a[i]!=-1 && a[i+1]!=-1)b2[a[i]]=b2[a[i+1]]=1;
		else if(a[i]!=-1)b1[a[i]]=1;else if(a[i+1]!=-1)b1[a[i+1]]=1;else ++ss;
	f[0][0][0]=1;
	for(i=n*2;i;--i)if(!b2[i]){
		nw^=1;(b1[i]?s1:s2)++;
		for(j=0;j<=s1;++j)memset(f[nw][j],0,s2+1<<2);
		for(j=0;j<=s1;++j)for(k=0;k<=s2;++k)if(x=f[!nw][j][k]){
			if(!b1[i]){
				add(f[nw][j][k+1],x);
				if(j)add(f[nw][j-1][k],1ll*j*x%mo);
			}else add(f[nw][j+1][k],x);
			if(k)add(f[nw][j][k-1],x);
		}
		/*
		for(j=0;j<=s1;++j)for(k=0;k<=s2;++k)if(f[nw][j][k])
			printf("f[%d][%d][%d]=%d\n",i,j,k,f[nw][j][k]);
		puts("");
		*/
	}
	ans=f[nw][0][0];
	for(i=1;i<=ss;++i)ans=1ll*i*ans%mo;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

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

using namespace std;

int main() {
  while(1){
    int n;
    cin >> n;
    if(!n) break;
    vector<vector<int>> d(10, vector<int>(10, 1000000000));
    for (int i = 0; i < 10; ++i)
      d[i][i] = 0;
    int cmx = 1;
    for (int i = 0; i < n; ++i) {
      int a, b, c;
      cin >> a >> b >> c;
      d[a][b] = d[b][a] = c;
      cmx = max(cmx, max(a,b)+1);
    }
    for (int k = 0; k < cmx; ++k)
      for (int i = 0; i < cmx; ++i)
        for (int j = 0; j < cmx; ++j)
          d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    int mind = 1000000000;
    int mini = 0;
    for (int i = 0; i < cmx; ++i) {
      int sum=0;
      for (int j = 0; j < cmx; ++j) {
        sum += d[i][j];
      }
      if(mind > sum) {
        mind = sum;
        mini = i;
      }
    }
    cout << mini << ' ' << mind << endl;
  }
  return 0;
}

Measured memory_bytes: 1212
using namespace std;
#include<bits/stdc++.h>
#define int long long
#define pb push_back 
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define repa(i,a,b) for (int i=a; i<=b; i++)
#define repd(i,b,a) for (int i=b; i>=a; i--)
#define endl "\n"
//debugging
#define debug1(a) cout<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;

const int N = 1e+6+5;
int big = 1e+18+3;
int mod = 1e+9+7;

signed main()
{
    IOS;
    
    set<int>s1,s2;

    int n;

    cin>>n;

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

    n--;

    int cnt = 0;

    for (int i=1; i*i<=n; i++)
    {
        if ( n%i==0 )
        {
            s1.insert( (i) );
            s1.insert( (n/i) );
        }
    }

    if (s1.find( 1 )!=s1.end())
        s1.erase(s1.find(1));

    n++;

    for (int i=1; i*i<=n; i++)
        if (n%i==0)
            s2.insert( i ), s2.insert( n/i );
    
    if (s2.find( 1 )!=s2.end())
        s2.erase(s2.find(1));

    for (auto it:s2)
    {
        int buf = n;

        while( buf%it==0 )
            buf/=it;

        if (buf==1)
            s1.insert(it);

        if ( buf%it==1 )
            s1.insert(it);

    }

    cout<<s1.size()<<endl;

}


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

vector<int> stov(string s){
  sort(s.begin(),s.end());
  vector<int> abc(26);
  int kireme=0;
  for(int ii=97;ii<123;ii++){
    char x = ii;
    for(int jj=kireme;jj<s.size();jj++){
      if(s[jj]==x) abc.at(ii-97)++;
      else{
        kireme = jj;
        break;
      }
    }
  }
  return abc;
}

string vtos(vector<int> abc){
  string s="";
  for(int j1=0;j1<26;j1++){
    for(int i1=0;i1<abc.at(j1);i1++){
      char x=j1+97;
      s += x;
    }
  }
  return s;
}

int main(){
  int n;
  cin>>n;
  vector<string> SS(n);
  vector<vector<int>> ABC(n);
  vector<int> minabc(26,100);
  for(int i=0;i<n;i++){
    cin>>SS.at(i);
    ABC.at(i) = stov(SS.at(i));
    for(int j=0;j<26;j++){
      minabc.at(j) = min(minabc.at(j),ABC.at(i).at(j));
    }
  }
  string ans = vtos(minabc);
  cout << ans << endl;
}


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

using namespace std;
char ch[4]={'A','C','G','T'};
int main()
{
    string str;
    cin >> str;
    int ans=0;
    for(int i=0,k=0,f=0;i<str.size();i++)
    {
        for(int j=0;j<4;j++)
        {
            if(ch[j]==str[i])
            {
                f=1,k++;
                break;
            }
        }
        if(!f || i==str.size()-1)
            ans=max(k,ans),k=0;
        f=0;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <vector>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <stack>
#include <utility>
#include <queue>
using namespace std;
typedef long long int lld;
typedef pair<int, int> pii;



int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  n *= 2;
  int arr[n];
  for (int i = 0; i < n; ++i)
    cin >> arr[i];
  sort(arr, arr+n);
  int s = 0;
  for (int i = 0; i < n; i+= 2)
    s += arr[i];
  cout << s << "\n";
  return 0;
}

Measured memory_bytes: 256
import math
a, b, h, m = map(int, input().split())

# 分針の角度
perm = (m / 60) * 360
# 時針の角度
rh = (h / 12) * 360 + (m / 60) * 360 / 12



# print(rh, perm)

deg = min(abs(perm - rh), 360 - abs(perm - rh))
# print(deg)
rdeg = math.pi / 180 * deg
# print(rdeg)
ans = math.sqrt(a * a + b * b - 2 * a * b * math.cos(rdeg))

print(ans)


Measured memory_bytes: 9508
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define reps(i,x) for(ll i=1;i<=(ll)(x);i++)
#define rrep(i,x) for(ll i=((ll)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(ll)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  cout << (a-1)*(b-1) << endl;
}



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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

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

  vector<int> b(n+1);
  for (int i = n; i >= 1; --i) {
    int sum = 0;
    for (int j = i+i; j <= n; j += i) {
      sum ^= b[j];
    }
    b[i] = sum^a[i];
  }
  vector<int> ans;
  for (int i = 1; i <= n; i++) {
    if (b[i]) ans.push_back(i);
  }
  cout << ans.size() << endl;
  rep(i, ans.size()) {
    printf("%d%c", ans[i], i+1==ans.size() ? '\n':' ');
  }
  return 0;
}


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

int main() {
    int n;
    cin >> n;

    bool ret = false;
    for (int i = 1; i <= 9; i++){
        for (int j = 1; j <= 9; j++){
            if (i * j == n){
                ret = true;
            }
        }
    }

    cout << (ret ? "Yes" : "No") << endl;
}

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

#define DEBUG (0)

int main(void)
{
  char moji[11] = {0};
  int len = 0;
  int answer = 0;	/* 0:No, 1:Yes*/
  
  scanf("%s",moji);
  
  len = strlen(moji);
#if DEBUG
  printf("len : %d\n",len);
#endif

  if(len%2 != 0){
    printf("No\n");
    return 0;
  }
  
  for(int i = 0; i < len; i++){
    if(i%2 == 0){
      /*1,3,5,7,9文字目*/
      if(moji[i]=='h'){
        answer = 1;
      }else if(moji[i] == '\n' && answer == 1){
        /* 文字列終端で終了 */
        break;
      }else{
        /*hitachi文字でないと分かった時点で終了*/
        answer = 0;
        break;
      }
    }else{
      /* 2,4,6,8,10文字目 */
      if(moji[i] == 'i'){
        answer = 1;
      }else{
        /*hitachi文字でないと分かった時点で終了*/
        answer = 0;
        break;
      }
    }    
  }
  
  if(answer == 0){
    printf("No\n");
  }else{
    printf("Yes\n");
  }
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
 
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

vector<Int> G[100001];
bool rev[100001];
Int memo[100001];

Int rec(Int x) {
    if (memo[x] >= 0) {
        return memo[x];
    }
    Int ret = 0;
    for (Int i = 0; i < (Int)G[x].size(); i++) {
        Int to = G[x][i];
        ret = max(ret, rec(to) + 1);
    }
    return memo[x] = ret;
}

int main() {
    Int n, m;
    cin >> n >> m;
    vector<Int> x(m), y(m);
    for (Int i = 0; i < m; i++) {
        cin >> x[i] >> y[i];
        x[i]--, y[i]--;
        G[x[i]].push_back(y[i]);
        rev[y[i]] = true;
    }
    fill(memo, memo + n, -1);
    for (Int i = 0; i < n; i++) {
        if (rev[i]) continue;
        rec(i);
    }
    Int res = 0;
    for (Int i = 0; i < n; i++) {
        res = max(res, memo[i]);
    }
    dump(res);
    return 0;
}

Measured memory_bytes: 12800
#include<iostream>
#include<climits>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;
int main(){

    ll a,b,k;

    cin >> a >> b >> k;

    ll last = a;
    for(int i=0 ; i < k ; i++){
        if(a+i <= b){
            cout << a + i << endl;
            last = a + i;
        }
    }

    for(int i=k-1;i>=0;i--){
        if(last < b-i){
            cout << b-i << endl;
        }
    }
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc;

	static final int INF=1<<28;
	static final double EPS=1e-9;

	int n=8;

	int[][] map;

	void run(){
		sc=new Scanner(System.in);
		int d=sc.nextInt();
		for(int t=0; t<d; t++){
			map=new int[n][n];
			for(int j=0; j<n; j++){
				String s=sc.next();
				for(int i=0; i<n; i++)
					map[j][i]=s.charAt(i)=='0'?0:1;
			}
			int x=sc.nextInt()-1;
			int y=sc.nextInt()-1;
			bomb(x, y);
			println("Data "+(t+1)+":");
			for(int j=0; j<n; j++){
				for(int i=0; i<n; i++)
					print(map[j][i]+"");
				println("");
			}
		}
		sc.close();
	}

	void bomb(int x, int y){
		map[y][x]=0;
		for(int i=-3; i<=3; i++){
			if(i==0)
				continue;
			int x2=x+i;
			int y2=y;
			if(x2>=0&&x2<n&&y2>=0&&y2<n)
				if(map[y2][x2]==1)
					bomb(x2, y2);
			x2=x;
			y2=y+i;
			if(x2>=0&&x2<n&&y2>=0&&y2<n)
				if(map[y2][x2]==1)
					bomb(x2, y2);
		}
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

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

Measured memory_bytes: 12000
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define fi first
#define se second

const int MAX_V = 1e5;
const int64 INF = 1e18;

struct edge {
  int64 to, cost;
};

int n;
vector<edge> G[MAX_V];
int64 dis[MAX_V];

void dijkstra(int s){
  priority_queue<pll, vector<pll>, greater<pll>> pq;
  fill(dis, dis + n, INF);
  dis[s] = 0;
  pq.push(pll(0, s));

  while (!pq.empty()){
    pll p = pq.top(); pq.pop();
    int v = p.second;
    if (dis[v] < p.first) continue;
    for (int i = 0; i < (int) G[v].size(); ++i){
      edge e = G[v][i];
      if (dis[e.to] > dis[v] + e.cost){
        dis[e.to] = dis[v] + e.cost;
        pq.push(pll(dis[e.to], e.to));
      }
    }
  }
}

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

  cin >> n;
  int E = n - 1;
  for (int i = 0; i < E; ++i){
    int64 a, b, c; cin >> a >> b >> c; --a; --b;
    G[a].push_back({b, c});
    G[b].push_back({a, c});
  }

  int q, k; cin >> q >> k; --k;
  dijkstra(k);
  rep(i, q){
    int x, y; cin >> x >> y; --x; --y;
    print(dis[x] + dis[y]);
  }

  return 0;
}

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

int main(void)
{
  int d, t, s;
  std::cin >> d >> t >> s;


  if ((float)d / (float)s <= (float)t) {
    // std::cout << (float)d / (float)s;
    std::cout << "Yes\n";
  }
  else {
    std::cout << "No\n";
  }

  return 0;
}

Measured memory_bytes: 3632
S = input()
flag = False
w = []
ans = 0
i = 0

while(i < len(S)-1):
    if(S[i] == S[i+1]):
        if(flag == False):
            if(i < len(S)-2):
                w.append(S[i])
                w.append(S[i+1]+S[i+2])
            else:
                w.append(S[i] + S[i+1])
            flag = True
        else:
            w.append(S[i] + S[i+1])
    else:
        w.append(S[i])

    if(flag):
        i += 3
    else:
        i += 1

    flag = False

if(i == len(S)-1):
    print(len(w)+1)
else:
    print(len(w))




Measured memory_bytes: 8296
#include <bits/stdc++.h>
using namespace std;
// for(int i = 0;i < num; i++){}
int main() {
    //
    int a, b,d;
    int cnt = 0;
    cin >> a >> b >> d;

    for(int i = a;i <= b; i++){
        if (i % d == 0) cnt++;
    }
    cout << cnt;
    //
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
using LP=pair<ll,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007,MOD2=998244353;



int main() {
    int N;
    cin>>N;
    vector<string> S(N);
    rep(i,N)cin>>S.at(i);
    int ans=0;
    rep(i,N){
        rep(j,sz(S.at(i))-1){
            if(S.at(i).at(j)=='A' && S.at(i).at(j+1)=='B')ans++;
        }
    }
    vector<int> num(N);
    rep(i,N){
        if(S.at(i).at(0)=='B')num.at(i)+=10;
        if(S.at(i).at(sz(S.at(i))-1)=='A')num.at(i)+=1;
    }
    int eleven=0,zero=0;
    rep(i,N){
        if(num.at(i)==0)zero++;
        if(num.at(i)==11)eleven++;
    }
    if(eleven+zero==N && eleven>0)ans--;
    int a=0,b=0;
    rep(i,N){
        a+=num.at(i)/10;
        b+=num.at(i)%10;
    }
    cout<<ans+min(a,b)<<endl;
}

Measured memory_bytes: 3724
package main

import "fmt"

func main() {
	var r, g, b int
	fmt.Scan(&r, &g, &b)
	rgb := 100 * r + 10 * g + b
	if rgb % 4 == 0 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp=boost::multiprecision;
using namespace std;
typedef int _int;
typedef long long ll;
#define int mp::cpp_int
ll mod = 1000000007;
void COME_LET_THE_GAMES_BEGIN(){cout << setprecision(20);}
void vin(vector<ll>*a,int N){for (; N; N--){ll x;cin >> x;(*a).push_back(x);}}
void vin(vector<tuple<ll, ll, ll>>*a,int N){for(;N;N--){tuple<ll, ll, ll>x;cin>>get<0>(x)>>get<1>(x)>>get<2>(x);(*a).push_back(x);}}
void output(bool f){if(f){puts("Yes");}else{puts("No");}}
void output(ll a){printf("%lld\n", a);}
ll x, y;
void input() {
    cin >> x >> y;
}
ll solve() {
    ll res = LLONG_MAX;
    for (ll i = 0; i <= 1; i++) {
        for (ll j = 0; j <= 1; j++) {
            ll xx = abs(x)*(i?1:-1), yy = abs(y)*(j?1:-1);
            ll a = 0;
            if (x != xx) a++;
            if (y != yy) a++;
            if (xx <= yy) {
                a += yy-xx;
                res = min(res, a);
            }
        }
    }
    return res;
}
_int main () {
    COME_LET_THE_GAMES_BEGIN();
    input();
    output(solve());
}

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

int main(){
  double n,m,d,ans;
  cin >> n >> m >> d;
  ans=0;
  if(d != 0){
    for(int i=0;i<m-1;i++){
      ans+=(2*(n-d))/(n*n);
    }
  }
  else{
   for(int i=0;i<m-1;i++){
      ans+=1/n;
    }
  }
  cout<<fixed<<setprecision(20)<<ans<<endl;

  return 0;
}


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

const ll mx = 1e5 + 1;
ll n, k, q;
ll b[mx];


int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> k >> q;
    for (int i = 0; i < q; i++) {
        ll a;
        cin >> a;
        b[a]++;
    }

    for (int i = 1; i <= n; i++) {
        if (k - (q - b[i]) <= 0) cout << "No\n";
        else cout << "Yes\n";
    }
    return 0;
}

Measured memory_bytes: 1408
import java.io.*;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
		String str;
		Double wgt;
		Scanner in = new Scanner(System.in);
		while ( in.hasNext() ) {
			wgt = in.nextDouble();
			System.out.println(rank(wgt));
		}
	}
	
	public static String rank( double weight ) {
		String[] date = {"light fly" , "fly" , "bantam", "feather" , "light" ,
						"light welter" , "welter" , "light middle" , "middle" ,
						"light heavy" , "heavy"};
		int index;
		if ( weight <= 48.00 ) index = 0; 
		else if ( weight <= 51.00 ) index = 1; 
		else if ( weight <= 54.00 ) index = 2; 
		else if ( weight <= 57.00 ) index = 3; 
		else if ( weight <= 60.00 ) index = 4; 
		else if ( weight <= 64.00 ) index = 5; 
		else if ( weight <= 69.00 ) index = 6; 
		else if ( weight <= 75.00 ) index = 7;
		else if ( weight <= 81.00 ) index = 8; 
		else if ( weight <= 91.00 ) index = 9;
		else index = 10;
		return date[index];
	}
}

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

int main() {
	char c[5];
	cin >> c[0] >> c[1] >> c[2] >> c[3] >> c[4];
	for (int i = 0; i != 4; i++) {
		if (c[i] == 'A' && c[i + 1] == 'C') {
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i >= n; --i)
typedef long long ll;
#define mod 1000000007
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; }

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a == b && b == c) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


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

int main(){
    string a, b;
    cin >> a >> b;
    int num = stoi(a+b);
    int r = sqrt(num);

    if(r*r == num){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3724
#include <cstring>
#include <cassert>
#include <utility>
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <bitset>
#include <chrono>
#include <cstdlib>
#include <functional>
#include <tuple>
#include <climits>
#include <limits>
#include <deque>
#include <list>
#include <array>
#include <stack>
#include <queue>
#include <random>
#include <complex>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
 
#define init ios::sync_with_stdio(0); cin.tie(NULL);cout.tie(NULL);
#define setpr(x) cout << setprecision((x))
#define PI atan(1)*4
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define mk(a , b) { min((a) , (b)) , max((a) , (b)) }
#define flush cout.flush()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endc "\n"
#define MOD 1000000007
#define meme(x) memset((x), 0, sizeof((x)))
#define memo(x) memset((x),-1, sizeof((x)))
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;

// #define int ll

ll egcd(ll a, ll b, ll &x, ll &y){
    if (a == 0LL){  
        x = 0LL;  
        y = 1LL;  
        return b;  
    }
    ll xx, yy;
    ll val = egcd(b % a, a, xx, yy);  
    x = yy - (b / a) * xx;  
    y = xx;  
    return val;
}

ll gcd(ll a, ll b){
    while(true){
        if(a>b)
            swap(a,b);
        if (a == 0) 
            return b; 
        ll p = b % a  , q = a;
        a = p;
        b = q;
    }
}
 
ll powerMod(ll x,ll y){
    ll res = 1;
    x %= MOD;
    while(y > 0){
        if(y & 1)res = (res*x)%MOD;
        y = y >> 1;
        x = (x * x)%MOD;
    }
    return res%MOD;
}

//  ==========      //\\       //||     ||====//||
//      ||         //  \\        ||     ||   // ||
//      ||        //====\\       ||     ||  //  ||
//      ||       //      \\      ||     || //   ||
//  ==========  //        \\  ========  ||//====|| 
//  code

const int N = 301;
double dp[N][N][N];
int n;

double rec(int x, int y, int z){
    if(dp[x][y][z] > -1)
        return dp[x][y][z] * 1.0;

    int w = x + y + z;
    if(w == 0)
        return 0;
    double ans = n * 1.0;
    if(x) ans += x * rec(x - 1, y, z);
    if(y) ans += y * rec(x + 1, y - 1, z);
    if(z) ans += z * rec(x, y + 1, z - 1);
    // cout << x << " " << y << " " << z << " " << ans / w << endc;
    return dp[x][y][z] = ans / w;
}

void solve(){
    int i,j,k,l,p;
    cin >> n;
    int cnt[4];
    meme(cnt);

    for(i = 0; i < n; i++){
        cin >> j;
        cnt[j]++;
    }

    memo(dp);
    setpr(20);
    cout << rec(cnt[1], cnt[2], cnt[3]) << endc;
}

int32_t main(){
    init;
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 216908
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N;
  cin >> N;
  vector<int> v;
  rep(i,N){
    int a;
    cin >> a;
    v.push_back(a);
  }
  sort(ALLOF(v));

  cout << abs(v[v.size()-1] - v[0]) << endl;
  
  return 0;
}



Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline

    H, W = map(int, input().split())
    grid = []
    for _ in range(H):
        grid.append(input().rstrip('\n'))

    L = [[0] * W for _ in range(H)]
    R = [[0] * W for _ in range(H)]
    U = [[0] * W for _ in range(H)]
    D = [[0] * W for _ in range(H)]
    for h in range(H):
        for w in range(1, W):
            if grid[h][w-1] == '.' and grid[h][w] == '.':
                L[h][w] = L[h][w-1] + 1
    for h in range(H):
        for w in range(W-2, -1, -1):
            if grid[h][w] == '.' and grid[h][w+1] == '.':
                R[h][w] = R[h][w+1] + 1
    for w in range(W):
        for h in range(1, H):
            if grid[h][w] == '.' and grid[h-1][w] == '.':
                U[h][w] = U[h-1][w] + 1
    for w in range(W):
        for h in range(H-2, -1, -1):
            if grid[h][w] == '.' and grid[h+1][w] == '.':
                D[h][w] = D[h+1][w] + 1

    ans = 1
    for h in range(H):
        for w in range(W):
            ans = max(ans, L[h][w] + R[h][w] + U[h][w] + D[h][w] + 1)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 177032
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
using namespace std;
int main(){
	int a,b;
	while(~scanf("%d%d",&a,&b)){
		if((a+b)%2==0) printf("%d\n",(a+b)/2);
		else printf("%d\n",(a+b)/2+1);
	}
}

Measured memory_bytes: 256
//AtCoder ABC052 
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
constexpr ll MOD=1e9+7;

int main() {
#if LOCAL&0
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    ll N=12;
    cin>>N;
    ll ans=1;

    int n=N;
	vector<int> x(n+1);
    for(int n=2;n<=N;++n){
		int num = n; // 素因数分解する変数num
		for(int i = 2; i <= n; i++) {
			while(num % i == 0) { //素数で割り切れなくなるまで割っていく
				x.at(i)++; //割った個数を配列に足す
				num /= i;
			}
		}
	}
	for(int i = 2; i <= n; i++) {
		ans = ans * (x.at(i) + 1) % MOD; //それぞれを+1して掛けていく
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, deque
import sys
import heapq
import bisect
import itertools
import queue
import copy
import time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7

def inp(): return int(sys.stdin.readline())

def inpl(): return list(map(int, sys.stdin.readline().split()))

def inpl_str(): return list(sys.stdin.readline().split())

N, M = inpl()
A = inpl()
days = sum(A)
if N - days >= 0:
    print(N-days)
else:
    print(-1)

Measured memory_bytes: 10856
#include<bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/


int main() {
    cin >> s;
    REP(i,6) {
        if(s[i]=='1'){
            cnt++;
        }
    }
    cout << cnt << endl;
    
}

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

int main() {
  string s;
  cin >> s;
  
  int count = 0, pre = s[0];
  bool flg = false;
  
  for (int i=1;i<=3;i++){
    if (pre==s[i]){
      count++;
      if(count>=2){
        flg=true;
      }
    }
    else{
      count = 0;
    }
    pre = s[i];
  }
  
  if(flg){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int b;
	int f[4][3][10] = {};
	cin >> b;
	for (int i = 0; i < b; i++)
	{
		int a, c, d, e;
		cin >> a >> c >> d >> e;
		f[a-1][c-1][d-1] += e;
	}
	
	for (int i = 0; i < 4; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			for (int k = 0; k < 10; k++)
			{
				cout << " " << f[i][j][k];
			}
			cout << endl;
		}
		if (i < 3)
			for (int i = 0; i < 20; i++)
			{
				cout << "#";
			}
		if (i < 3)
			cout << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

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

using namespace std;
int main(void)
{
  for(;;){
    int n,m,l,r,s,t;
    //city,limit,fre,edge
    cin >> n >> m >> l >> r >> s >> t;
    if(!n) return 0;
    int fre[128]={};
    REP(i,l){
      int tmp;
      cin >> tmp;
      fre[tmp]=1;
    }
    fre[s]=1;
    fre[t]=1;
    int wf[128][128];
    REP(i,128) REP(j,128) wf[i][j]=1048576;
    vector<tuple<int,int,int> > e;
    REP(i,r){
      int x,y,c;
      cin >> x >> y >> c;
      wf[x][y]=c;
      wf[y][x]=c;
    }
    REP(k,n) REP(i,n) REP(j,n) wf[i][j]=min(wf[i][j],wf[i][k]+wf[k][j]);
    REP(i,n) REP(j,n) if(wf[i][j]>m||!fre[i]||!fre[j]) wf[i][j]=1048576;
    REP(k,n) REP(i,n) REP(j,n) wf[i][j]=min(wf[i][j],wf[i][k]+wf[k][j]);
    if(wf[s][t]==1048576) cout << "Help!" << endl;
    else if(wf[s][t]<m) cout << wf[s][t] << endl;
    else cout << wf[s][t]*2-m << endl;
  }
}

Measured memory_bytes: 3128
h,w,k=map(int,input().split())
c=[input() for _ in range(h)]
sumb=0

for i in range(h):
    for j in range(w):
        if c[i][j]=="#":
            sumb+=1
ans=0
for i in range(2**(h+w)):
    lish,lisw=[],[]
    s=sumb
    for j in range(h+w):
        if (i>>j)&1:
            if j<h:
                lish.append(j)
            else:
                lisw.append(j-h)
    for idxh in lish:
        for idx in range(w):
            s=s-(c[idxh][idx]=="#")
    for idx in range(h):
        for idxw in lisw:
            s=s-(c[idx][idxw]=="#")
    for idxh in lish:
        for idxw in lisw:
            s+=(c[idxh][idxw]=="#")
    if s==k:
        ans+=1
print(ans)

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

int main(){
    int n, m;
    cin >> n >> m;
    bool s1[n] = {false}, s2[n] = {false};
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        if (a==1) s1[b-1] = true;
        if (b==n) s2[a-1] = true;
    }
    bool ok = false;
    rep(i, n) {
        if (s1[i] && s2[i]) {
            ok = true;
            break;
        }
    }
    if (ok) puts("POSSIBLE");
    else puts("IMPOSSIBLE");
    return 0;
}

Measured memory_bytes: 640