akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in1(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in1(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll pmod(ll n, ll p) {
    ll m = n % MOD;
    if (p == 0) return 1;
    ll rtn = pmod((m * m) % MOD, p / 2) % MOD;
    if (p % 2 == 1) rtn = rtn * m % MOD;
    return rtn;
}

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    ll N;
    in1(N);

    ll ans = pmod(10, N);
    ans -= pmod(9, N);
    ans += MOD;
    ans -= pmod(9, N);
    ans += MOD;
    ans += pmod(8, N);
    ans += MOD;
    ans %= MOD;

    outl(ans);

    return 0;
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n, T;
  cin >> n >> T;
  vector<ll> t(n);  rep(i, 0, n) cin >> t[i];
  
  ll sum = 0;
  rep(i, 0, n-1)
    sum += max(0LL, t[i+1]-t[i]-T);
  
  cout << t[n-1]+T-sum << "\n";
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7

#define fi first
#define sc second
#define rep(i, x) for (long long i = 0; i < x; i++)
#define repn(i, x) for (long long i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
vector<pair<string, P>> vec;
// vector<vector<int>> data(3, vector<int>(4));

using Weight = ll;
using Flow = int;
struct Edge {
    int src, dst;
    Weight weight;
    Flow cap;
    Edge() : src(0), dst(0), weight(0) {}
    Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
    g[a].emplace_back(a, b, w);
    g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

Matrix WarshallFloyd(const Graph &g) {
    auto const INF = std::numeric_limits<Weight>::max() / 8;
    int n = g.size();
    Matrix d(n, Array(n, INF));
    rep(i, n) d[i][i] = 0;
    rep(i, n) for (auto &e : g[i]) d[e.src][e.dst] = std::min(d[e.src][e.dst], e.weight);
    rep(k, n) rep(i, n) rep(j, n) {
        if (d[i][k] != INF && d[k][j] != INF) d[i][j] = std::min(d[i][j], d[i][k] + d[k][j]);
    }
    return d;
}

void solve(long long N, std::vector<std::vector<long long>> A) {
    Graph g(N);
    rep(i, N) {
        rep(j, N) {
            if (i == j) continue;
            add_arc(g, i, j, A[i][j]);
        }
    }
    Matrix B = WarshallFloyd(g);
    ll res = 0;
    bool minus = false;
    // rep(i, N) {
    //     rep(j, N) { cout << i << " " << j << " " << B[i][j] << endl; }
    // }
    rep(i, N) {
        rep(j, N) {
            if (i <= j) break;
            bool flg = true;
            rep(k, N) {
                if (i == k || j == k) continue;
                if (A[i][j] > B[i][k] + B[k][j]) minus = true;
                if (A[i][j] == B[i][k] + B[k][j]) flg = false;
            }
            if (flg) res += B[i][j];
        }
    }
    if (minus)
        cout << "-1" << endl;
    else
        cout << res << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<std::vector<long long>> A(N, std::vector<long long>(N));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            scanf("%lld", &A[i][j]);
        }
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 4992
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int[] a = new int[n];
		long sum=0;
		int count=0;
		for(int i=0;i<n;i++) {
			a[i]=scn.nextInt();
			if(a[i]<0) {
				count++;
			}
			a[i]=Math.abs(a[i]);
			sum += a[i];
		}
		if(count%2==1) {
			Arrays.sort(a);
			sum-=a[0]*2;
		}
		System.out.println(sum);
		scn.close();
	}
}

Measured memory_bytes: 49884
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main(){
    ll n;
    cin>>n;
    cout<<(n-1)*n/2<<endl;
    return 0;
    }


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

int main(){
  ll mod=1e9+7;
  int h,w;
  cin>>h>>w;
  ll dp[h][w]={};
  vector<string> vec(h);
  for(int i=0;i<h;i++){
    cin>>vec[i];
  }
  dp[0][0]=1;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(vec[i][j]=='.'){
        if(i>0){
          dp[i][j]+=dp[i-1][j];
        }
        if(j>0){
          dp[i][j]+=dp[i][j-1];
        }
        dp[i][j]%=mod;
      }
    }
  }
  cout<<dp[h-1][w-1]%mod<<endl;
}

Measured memory_bytes: 9088
import sys
import os
import math
import string

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    A, B = il()
    print('Yay!' if max(A, B) < 9 else ':(')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3832
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<map> 
using namespace std;
typedef long long ll;
const double pi=acos(-1.0);
const ll mod=1e9+7;
const int inf=0x3f3f3f3f;

int main()
{
	int a,b,c,d,e,n;
	scanf("%d%d",&a,&b);
	if(a>b)printf("safe\n");
	else printf("unsafe\n");
}



Measured memory_bytes: 1660
require 'date'

table = [["pre-meiji", [   1,  1,  1], [1868,  9,  7]],
         ["meiji"    , [1868,  9,  8], [1912,  7, 29]],
         ["taisho"   , [1912,  7, 30], [1926, 12, 24]],
         ["showa"    , [1926, 12, 25], [1989,  1,  7]],
         ["heisei"   , [1989,  1,  8], [2020,  1,  1]]]
table.map! {|n, d1, d2| [n, Date.new(*d1), Date.new(*d2)]}

$<.readlines.map {|l| Date.new(*l.split.map(&:to_i))}.each do |day|
  table.each do |name, d1, d2|
    if day.between?(d1, d2)
      if name == "pre-meiji"
        puts name
      else
        puts "#{name} #{day.year - d1.year + 1} #{day.month} #{day.day}"
      end
    end
  end
end


Measured memory_bytes: 6968
#include <stdio.h>
#include <string.h>
#define L 100005
int min(int a,int b){ return a<b?a:b; }
int head,tail;
typedef struct pp{
	char name[100];
	int t;
} P;

P Q[L];
void enqueue(P x){
	Q[tail] = x;
	tail = (tail+1)%L; 
}
P dequeue(){
	P x = Q[head];
	head = (head+1)%L;
	return x;
}

int main(){
	int n,q,i,time = 0,c;
	scanf("%d %d",&n,&q);
	for(i=1;i<=n;i++)
		scanf("%s %d",Q[i].name,&Q[i].t);
	head = 1;tail = n+1;
	while(head!=tail){
		P u = dequeue();
		c = min(q,u.t);
		u.t -= c;
		time += c;
		if(u.t) enqueue(u);
		else printf("%s %d\n",u.name,time);
	}
	return 0;
}



Measured memory_bytes: 11896
import java.math.*

fun main(args: Array<String>) {
    readInputLine()
    val s = readInputLine().toCharArray()
    
    var rwNum = s.count { it == '.' }
    var rbNum = s.count { it == '#' }
    
    var lwNum = 0
    var lbNum = 0
    
    var ans = Int.MAX_VALUE
    
    ans = Math.min(ans, lbNum + rwNum)
    
    for (c in s) {
        if (c == '.') {
            lwNum++
            rwNum--
        } else {
            lbNum++
            rbNum--
        }
        
        ans = Math.min(ans, lbNum + rwNum)
    }

    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 34412
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
            
            while(true){
                int count=0;
        
        int n=sc.nextInt();
        int x=sc.nextInt();
            
                
                if(n == 0 && x == 0){
                    break;
                }
        
        for(int i=1;i<=n;i++){
             for(int j=i+1;j<=n;j++){
                  for(int k=j+1;k<=n;k++){
                      if(i+j+k==x){
                          count++;
                          
     	 	  }
    	    }
        }
        
        } System.out.println(count);
}
       
}
}
    


Measured memory_bytes: 26764
import java.util.*;
import java.lang.*;
import java.io.*;
 
public final class Main
{
    public static void main (String[] args) throws java.lang.Exception {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m =  in.nextInt();
        ArrayList<Integer>[] graph = new ArrayList[n+1];
        boolean[] visited = new boolean[n+1]; 
        for(int i=0; i<=n; i++)
             graph[i] = new ArrayList<>();
        for(int i =0; i<m;i++) {
            int u = in.nextInt();
            int v = in.nextInt();
            graph[u].add(v);
        }
        int[] dp = new int[n+1];
        for(int i =1; i<=n ;i++){
            if(!visited[i]){
                dfs(graph, n, i, visited, dp);
            }
        }

        int re =0;
        for(int i=1; i<=n; i++)
        re = Math.max(re, dp[i]);

        System.out.println(re); 
        
    }

    static void dfs(ArrayList<Integer>[] graph, int n, int u,
     boolean[] visited, int[] dp ){
        visited[u] = true;
        for(int v: graph[u]){
            if(!visited[v]){
                dfs(graph, n,v, visited, dp);
            }
            dp[u] = Math.max(dp[u], dp[v]+1);
        }
    }
}

Measured memory_bytes: 108896
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

ll n,k;

bool isOK(ll m){
    ll sum = 0, now = m;
    for(int i = 0; i < n; i++){
        sum += now;
        now /= 2;
        if(now == 0) break;
    }
    return sum <= k;
}

signed main(){
    cin >> n >> k;
    ll ok = 0, ng = LINF;
    while(abs(ok - ng) > 1){
        ll mid = (ok + ng) / 2;
        if(isOK(mid)){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    cout << ok << endl;
    return 0;
}


Measured memory_bytes: 3120
n = int(input())
alphabets = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k',
             'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
             'w', 'x', 'y', 'z']

res = ''
while (n > 0):
  n = n - 1
  q = n % 26
  n = n // 26
  res = res + alphabets[q]
res = res[::-1]
print(res)

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

int main() {
  int N, K; cin >> N >> K;
  if (N%2 && N/2+1 >= K) cout << "YES" << endl;
  else if (N%2==0 && N/2 >= K) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ll INF = LLONG_MAX;
const ull MOD = 1000000007;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
ll digitPoor(ll n)
{
    assert(INT_MAX == 2147483647);
    assert(n >= 0);

    if (n < 10)         return 1;
    if (n < 100)        return 2;
    if (n < 1000)       return 3;
    if (n < 10000)      return 4;
    if (n < 100000)     return 5;
    if (n < 1000000)    return 6;
    if (n < 10000000)   return 7;
    if (n < 100000000)  return 8;
    if (n < 1000000000) return 9;
    return 10;
}
struct p{
  ll x;
  bool b;
};
int main(){
    ll a,b;
    cin>>a>>b;

    cout<<ceil(a/2.0+b/2.0);
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3808
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;
// }}}

int N;
ll a[100000];

void init()
{
}

void solve()
{
    ll ret = 0;
    REP(i, N){
        while(a[i] > 0 && a[i] % 2 == 0){
            ret++;
            a[i] /= 2;
        }
    }
    cout << ret << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    REP(i, N) cin >> a[i];
    solve();
    return 0;
}

// vim:set foldmethod=marker:


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define pb push_back
#define rep(i,n) for(int i = 0;i < (n); ++i)
#define all(v) sort(v.begin(),v.end())
#define ALL(v) sort(v.begin(),v.end(),greater<ll>())
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    ll n;
    cin >> n;
    ll ans = 1e18;
    for (ll i = 1; i*i <= n; i++) {
        if (n%i != 0) continue;
        ll j = n/i;
        ans = min(ans, i+j-2); 
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#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 n;
	cin >> n;
	vector<int> a(n);
	vector<int> b(n,0);
	for (int i = 0; i < n; i++) {
		cin >> a.at(i);
	}
	for (int i = n - 1; i >= 0; i--) {
		if (i - 1 > n / 2) {
			if (a.at(i)) b.at(i) = 1;
			else b.at(i) = 0;
		}
		else {
			int q = n / (i + 1);
			bool even = true;
			for (int j = i; j < n; j += i + 1) {
				if (b.at(j) == 1) even = !even;
			}
			if (a.at(i)) {
				b.at(i) = even;
			}
			else {
				b.at(i) = !even;
			}
		}
	}
	vector<int> ans;

	for (int i = 0; i < n; i++) {
		if (b.at(i)) {
			ans.push_back(i + 1);
		}
	}

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

	if (ans.size()) {
		for (int i : ans) {
			cout << i <<' ';
		}
	}
}

Measured memory_bytes: 3064
from collections import Counter

N = int(input())
C = input()

l = 0
r = N - 1

cnt = 0
while l < r:
    while l < r and C[l] == 'R':
        l += 1

    while l < r and C[r] == 'W':
        r -= 1

    if l < r:
        cnt += 1

    l += 1
    r -= 1


d = Counter(C)
min_ = min(d['W'], d['R'])
print(min(min_, cnt))



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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007
int a[26];
int main()
{
	string S;
	cin >> S;
	
	fx(S.size()) {
		int b = S.at(x) - 'A';
		a[b]++;

	}

	ll ans = 0;
	bool flag = true;
	fx(26) {
		if (a[x] > 0) {
			ans++;
			if (a[x] != 2) {
				flag = false;
			}
		}

	}
	if (ans == 2 && flag) {
		ce("Yes")
	}
	else {
		ce("No")
	}
    return 0;
}



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

using namespace std;

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)

int main(){
    int n; cin>>n>>n>>n;
    int px,py; cin>>px>>py;
    int ans=0;
    rep(i,n-1){
        int x,y; cin>>x>>y;
        int dx=x-px, dy=y-py;
        ans+=abs(dx)+abs(dy);
        if(dx*dy>0){
            ans-=min(abs(dx),abs(dy));
        }
        px=x, py=y;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1160
import sys

#+++++


def main():
	s = input()
	#a ='Yes' if ''.join(sorted(s)) == 'abc' else 'No'
	for c in 'abc':
		if c not in s:
			print('No')
			return 
	print('Yes')
	
#+++++

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
	else:
		input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3060
#include<stdio.h>

int main(void){
int a,b,c,d,sum;

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

sum=a+b+c+d;

printf("%d\n",sum/60);
printf("%d\n",sum%60);

return 0;
}


Measured memory_bytes: 2052
#include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
int a[n];

int counter=1;  
for(int i=0;i<n;i++){
    cin>>a[i];
}
int spells=0;
for(int i=1;i<n;i++){
        if(a[i]==a[i-1]){
            counter++;
        }
        else{

            //cout<<counter<<endl;
            if(counter > 1) spells+=counter/2;
            counter=1;
        }
}
if(counter > 1) spells+=counter/2 ;
cout<<spells<<endl;
}


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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;

int main(){
  while(scanf("%d",&n),n){
    int a=0,b=0;
    REP(i,n){
      int x,y;
      scanf("%d%d",&x,&y);
      if(x>y)a+=x+y;
      else if(x<y)b+=x+y;
      else a+=x,b+=y;
    }
    printf("%d %d\n",a,b);
  }
  return 0;
}

Measured memory_bytes: 3176
#include <iostream>

bool test(const int a, const int b, const int c) {
  const int mod_a = a % b;
  if (mod_a == 0) {
    return (c == 0);
  }
  int current_mod = mod_a;
  while (true) {
    current_mod = (current_mod + mod_a) % b;
    if (c == current_mod) {
      return true;
    }
    if (current_mod == mod_a) {
      return false;
    }
  }
}

int main() {
  int a, b, c;
  std::cin >> a >> b >> c;
  std::cout << (test(a, b, c) ? "YES" : "NO") << std::endl;
  return 0;
}

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


int main() {
    int h,w;
    cin >> h >> w;
    vector<vector<char>> a(h,vector<char>(w));

    for(int i = 0;i < h; i ++){
        for(int j = 0;j < w;j ++){
            cin >> a.at(i).at(j);
        }
    }
    for(int i = 0;i < h; i ++){
        for(int j = 0;j < w;j ++){
            if(a.at(i).at(j) == '#'){
                break;
            }
            if(j == w-1){
                for(int k = 0;k < w; k ++){
                    a.at(i).at(k) ='0';
                }
            }
        }
    }
    for(int i = 0;i < w; i ++){
        for(int j = 0;j < h;j ++){
            if(a.at(j).at(i) == '#'){
                break;
            }
            if(j == h-1){
                for(int k = 0;k < h; k ++){
                    a.at(k).at(i) ='0';
                }
            }
        }
    }



    for(int i = 0;i < h; i ++){
        for(int j = 0; j < w; j ++){
            if(a.at(i).at(j) != '0'){
                cout << a.at(i).at(j);
            }
        }
        for(int j = 0;j < w;j ++){
            if(a.at(i).at(j) != '0'){
                cout << endl;
                break;
            }
        }

    }


}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var N = long.Parse(Console.ReadLine());
        var a = new int[N + 1];
        var s = Console.ReadLine().Split();
        for (int i = 0; i < N; i++) a[i + 1] = int.Parse(s[i]);

        var M = 0L;
        var ans = new int[N + 1];

        for (long i = N; 0 < i; i--)
        {
            var sum = 0;
            for (long j = i * 2; j <= N; j += i)
            {
                sum = (sum + ans[j]) % 2;
            }

            if (sum != a[i])
            {
                M++;
                ans[i]++;
            }
        }

        Console.WriteLine(M);
        for (int i = 1; i <= N; i++)
        {
            if (ans[i] != 0)
            {
                Console.Write($"{i} ");
            }
        }
    }
}


Measured memory_bytes: 29140
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;

class Combination_calcurator {
  using ll = long long;

private:
  std::vector<ll> fac;
  std::vector<ll> facinv;
  ll MAX, MOD;
  ll modpow(ll a, ll p, ll m) {
    if (p == 0)
      return 1;
    if (p % 2 == 0) {
      ll d = modpow(a, p / 2, m);
      return d * d % m;
    } else {
      return a * modpow(a, p - 1, m) % m;
    }
  }
  ll modinv(ll a, ll m) {
    // require:m is prime and gcd(a,m) = 1
    return modpow(a, m - 2, m);
  }

public:
  Combination_calcurator(ll max, ll mod) {
    MAX = max;
    MOD = mod;
    fac.resize(MAX + 1);
    facinv.resize(MAX + 1);
    fac[0] = 1;
    for (int i = 1; i <= MAX; i++) {
      fac[i] = fac[i - 1] * i % MOD;
    }
    facinv[MAX] = modinv(fac[MAX], MOD);
    for (int i = MAX - 1; i >= 0; i--) {
      facinv[i] = facinv[i + 1] * (i + 1) % MOD;
    }
  }

  ll calc(ll n, ll r) {
    return (fac[n] * facinv[r]) % MOD * facinv[n - r] % MOD;
  }
};

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  auto COM = Combination_calcurator(1e5 + 7, MOD);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    if (i >= k - 1) {
      ans += COM.calc(i, k - 1) * a[i];
      ans %= MOD;
    }
    if (n - i - 1 >= k - 1) {
      ans -= COM.calc(n - i - 1, k - 1) * a[i];
      ans = (ans % MOD + MOD) % MOD;
    }
  }
  cout << (ans % MOD + MOD) % MOD << endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int a[1010], b[1010], c[1010];
int dp[5010];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= m; ++i) {
        cin >> a[i] >> b[i];
        for (int j = 1; j <= b[i]; ++j) {
            int x;
            cin >> x;
            c[i] |= (1 << (x - 1));
        }
        
    }
    fill(dp, dp + 5000, 2e9);
    dp[0] = 0;
    for (int i = 1; i <= m; ++i) {
        for (int j = (1 << n) - 1; j >= 0; --j) {
        //    cout << j << " " << dp[(j | c[i])] << '\n';
            dp[(j | c[i])] = min(dp[(j | c[i])], dp[j] + a[i]);
           // cout << j << " " << dp[(j | c[i])] << '\n';
        }
    }
    if (dp[(1 << n) - 1] == 2e9) {
        cout << -1;
    } else {
        cout << dp[(1 << n) - 1];
    }
}

Measured memory_bytes: 3716
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200002
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


int main ()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
		//freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
		double s,t,v;
		cin >> s >> t >> v;
		double ad = v*t;
		if (ad < s) cout << "No" << endl;
		else cout << "Yes" << endl;
		return 0;
}  


Measured memory_bytes: 3752
#include <stdio.h>

int main () {
  int i,j,n,v,N;
  
  scanf("%d",&N);

  int A[N];
 

  for(i=0;i<N;i++) {
    scanf("%d",&A[i]);
  }
  for(n=0;n<N;n++) {
    if(n==0) {
      printf("%d",A[n]);
    }
    else{
      printf(" %d",A[n]);
    }
    }
  printf("\n");

  for(i=1;i<N;i++) {
    v = A[i];
    j = i-1;
     
      while(j>=0 && A[j] > v) {
      A[j+1] = A[j];
      j--;
      
      }
      A[j+1] = v;
   for(n=0;n<N;n++) {
     if(n==0) {
       printf("%d",A[n]);
     }
     else{
      printf(" %d",A[n]);
     }
    }
    printf("\n");
  }

  return 0;
}
      

  

  

  
  



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

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template<typename Head> void dump(Head&& head) { cerr << head; dump(); }
template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do {cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

/////////////////////////////////////////////////////////////////////
const ll inf = 1LL<<60;

struct S {
  int p, y, i;
};

bool comp(pair<int,int> a, pair<int,int> b)
{
  if (a.second != b.second) {
    return a.second < b.second;
  }
  return a.first < b.first;
}

bool c1(S a, S b)
{
  if (a.p != b.p) {
    return a.p < b.p;
  }
  return a.y < b.y;
}

bool c2(S a, S b)
{
  return a.i < b.i;
}

int main()
{
  ll n, m; cin>>n>>m;
  vector<S> a(m);
  rep(i, m) {
    int p, y; cin>>p>>y;
    a[i] = S{p, y, i};
  }
  sort(a.begin(),a.end(), c1);
  a[0].y = 1;
  rep(i, m) {
    if (a[i].p == a[i-1].p) a[i].y = a[i-1].y+1;
    else a[i].y = 1;
  }
  sort(a.begin(),a.end(), c2);
  rep(i, m) {
    printf("%06d%06d\n", a[i].p, a[i].y);
  }

  return 0;
}


Measured memory_bytes: 4576
#include <iostream>
#include <stdio.h>
#include <vector>

using namespace std;

int main() {
 int i,j,n,m,f;
 int a,b,c,d,r,x1,x2,y1,y2,mx[101],my[101],mr[101];
 vector<int> tx,ty,sx,sy;
 while(cin >> n) {
	 if (n==0) break;
	 for (i=0;i<n;i++)  cin >> mx[i] >> my[i] >> mr[i];
	 cin >> m;
	 for (i=0;i<m;i++) { cin >> a >> b >> c >> r; tx.push_back(a); ty.push_back(b); sx.push_back(c); sy.push_back(r);}
	 for (i=0;i<m;i++) { 
		 for (j=0,f=0;j<n;j++) {
		  x1=tx[i]-mx[j]; y1=ty[i]-my[j]; x2=sx[i]-mx[j]; y2=sy[i]-my[j]; r=mr[j];
		  a=x1*x1+y1*y1; b=x2*x2+y2*y2;
		  if ( a<r*r && b<r*r) continue;
		  if ((a<r*r && b>r*r) || (a>r*r && b<r*r)) f=1;
		  a=x2-x1; b=y2-y1;
		  c=b*b*(r*r-x1*x1)+a*a*(r*r-y1*y1)+2*a*b*y1*x1;
		  d=(a*(-x1)+b*(-y1))*((-a)*(-x2)+(-b)*(-y2));
		  if (c>=0 && d>=0) f=1; 
		 }
		 if (f==1) cout << "Safe" << endl; else cout << "Danger" << endl;
	 }
	 tx.clear(); ty.clear(); sx.clear(); sy.clear();
 }
 return 0;
}

Measured memory_bytes: 1212
#include <iostream>
#include <cstdio>
#include <cstring>

#define MOD 1000000007

using namespace std;

typedef long long LL;

const int MAXN = 1000 + 10;

LL power (LL x, LL p) {
	LL cnt = 1;
	while (p) {
		if (p & 1)
			cnt = cnt * x % MOD;
		x = x * x % MOD;
		p >>= 1;
	}
	return cnt;
}

struct Matrix {
	LL a[3][3];

	Matrix () {
		memset (a, 0, sizeof (a));
	}
} ;
Matrix operator * (const Matrix& A, const Matrix& B) {
	Matrix ret = Matrix ();
	for (int i = 1; i <= 2; i ++)
		for (int j = 1; j <= 2; j ++)
			for (int k = 1; k <= 2; k ++)
				ret.a[i][j] = (ret.a[i][j] + A.a[i][k] * B.a[k][j] % MOD) % MOD;
	return ret;
}
LL matpower (Matrix x, LL k) {
	Matrix ret = Matrix ();
	ret.a[1][1] = ret.a[2][2] = 1;
	while (k) {
		if (k & 1)
			ret = ret * x;
		x = x * x;
		k >>= 1;
	}
	return (ret.a[1][1] - ret.a[1][2] + MOD) % MOD;
}

int N, M;
LL k;
char map[MAXN][MAXN];

int main () {
	scanf ("%d%d%lld", & N, & M, & k);
	int tol = 0, toup = 0;
	int lr = 0, ud = 0;
	int cnt = 0;
	for (int i = 1; i <= N; i ++) {
		scanf ("%s", map[i] + 1);
		for (int j = 1; j <= M; j ++)
			if (map[i][j] == '#') {
				cnt ++;
				tol += map[i][j - 1] == '#';
				toup += map[i - 1][j] == '#';
			}
		if (map[i][1] == '#' && map[i][M] == '#') lr ++;
	}
	for (int j = 1; j <= M; j ++)
		if (map[1][j] == '#' && map[N][j] == '#') ud ++;
	if (! lr && ! ud) {
		cout << power (1ll * cnt, k - 1) << endl;
		return 0;
	}
	if (lr && ud) {
		puts ("1");
		return 0;
	}
	if (! lr) swap (lr, ud), swap (tol, toup);
	Matrix x = Matrix ();
	x.a[1][1] = cnt, x.a[1][2] = tol, x.a[2][2] = lr;
	LL ans = matpower (x, k - 1);
	cout << ans << endl;

	return 0;
}

/*
3 3 3
.#.
###
#.#
*/

/*
11 15 1000000000000000000
.....#.........
....###........
....####.......
...######......
...#######.....
..##.###.##....
..##########...
.###.....####..
.####...######.
###############
#.##..##..##..#
*/

Measured memory_bytes: 1280
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define MOD 1000000007
#define INF 1000000000000000000
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main()
{
	int x, a;
	cin >> x >> a;
	if(x < a)
		cout << 0;
	else
		cout << 10;
}


Measured memory_bytes: 256
var l = require('fs').readFileSync('/dev/stdin','utf8').trim().split('');
var db = 0, dw = 0;
for (var i = 0; i < l.length; i++) {
  if (i % 2 === 0) {
    if (l[i] === '0') dw++; else db++;
  } else {
    if (l[i] === '1') dw++; else db++;
  }
}
console.log(Math.min(db, dw));

Measured memory_bytes: 8268
from sys import setrecursionlimit 
setrecursionlimit(10**6)

n, m, k = map(int, input().split())

fr = [set() for _ in range(n)]
bl = [set() for _ in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    fr[a-1].add(b-1)
    fr[b-1].add(a-1)
    
for i in range(k):
    c ,d = map(int, input().split())
    bl[c-1].add(d-1)
    bl[d-1].add(c-1)
    

def connectedcomponents():
    visited = []
    cc = [0]*n
    for i in range(n):
        visited.append(False)
    for v in range(n):
        if visited[v] == False:
            temp = set()
            for i in dfs(fr,v,temp,visited):
                cc[i] = dfs(fr,v,temp,visited)
    return cc
            

def dfs(fr, v, temp, visited):
    visited[v] = True
    temp.add(v)
    for i in fr[v]:
        if visited[i] == False:
            temp = dfs(fr, i, temp, visited)
    return temp

cc = connectedcomponents()

ans = []
for i in range(n):
    aa = len(cc[i]) - len(cc[i] & fr[i]) - len(cc[i] & bl[i]) - 1
    ans.append(aa)
print(*ans)

Measured memory_bytes: 102180
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  string s;
  cin >> s;
  string word[4] = {"dream", "dreamer", "erase", "eraser"};
  reverse(s.begin(), s.end());
  for (int i = 0; i < 4; i++) reverse(word[i].begin(), word[i].end());
  bool judge = true;
  for (int i = 0; i < (int)s.size();) {
    bool c = true;
    for (int j = 0; j < 4; j++) {
      if (s.substr(i, (int)word[j].size()) == word[j]) {
	c = false;
	i += (int)word[j].size();
      }
    }
    if (c) {
      judge = false;
      break;
    }
  }
  dump(judge ? "YES" : "NO");
  return 0;
}


Measured memory_bytes: 512
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>

#define MOD 1000000007

using namespace std;

int main()
{
	int n;
	int t;
	int dp[2][3001];
	vector<pair<int,int>> arr;
	int lmax = 0;
	int time, cand;

	//freopen("input.txt", "r", stdin);

	scanf("%d %d", &n, &t);

	for (int i = 0; i < n; i++)
	{
		int input1, input2;

		scanf("%d %d", &input1, &input2);

		arr.push_back(make_pair(input1, input2));
	}

	sort(arr.begin(), arr.end());

	for (int i = 1; i <= t; i++)
	{
		dp[1][i] = -1;
	}

	dp[1][0] = 0;

	for (int i = 0; i < n; i++)
	{
		dp[i % 2][0] = 0;

		for (int j = 1; j <= t; j++)
		{
			dp[i % 2][j] = dp[!(i % 2)][j];
		}

		for (int j = 0; j < t; j++)
		{
			if (dp[!(i % 2)][j] != -1)
			{
				time = j + arr[i].first;
				cand = dp[!(i % 2)][j] + arr[i].second;

				if (cand > lmax)
				{
					lmax = cand;
				}

				if (time < t && (cand > dp[i % 2][time]))
				{
					dp[i % 2][time] = cand;
				}
			}
		}
	}

	printf("%d\n", lmax);

	return 0;
}

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

using namespace std;

#define llong long long int
#define ldouble long double
#define ternary(condition, x, y) ((condition) ? x : y) 
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) x.begin(), x.end()
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)

const static long long int MOD = 1000000000 + 7;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

int main (int argc, char *argv[]) {
    cin.tie(0); 
    ios::sync_with_stdio(false);

    llong n, m;
    cin >> n >> m;

    llong ans = -100;
    for (llong i = 1; i * i <= m; ++i) {
        if (m % i == 0) {
            if (n * i <= m) ans = max(ans, i);
            if (n * (m / i) <= m) ans = max(ans, m / i);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n;
double dp[305][305][305];
double solve(int x,int y,int z){
    if(x<0 || y<0 || z<0){
        return 0;
    }
    if(x==0 && y==0 && z==0){
        return 0;
    }
    double &ans=dp[x][y][z];
    if(ans>0){
        return ans;
    }
    ans=(n+x*solve(x-1,y,z)+y*solve(x+1,y-1,z)+z*solve(x,y+1,z-1))/(x+y+z);
    return ans;
}
int32_t main() {
    memset(dp,-1,sizeof(dp));
    cin>>n;
    int x=0,y=0,z=0;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        if(a==1) x++;
        else if(a==2) y++;
        else z++;
    }
    cout<<fixed<<setprecision(10)<<solve(x,y,z)<<endl;
}


Measured memory_bytes: 225436
import java.util.*;
public class Main{
	public static void main(String []args){
    	Scanner sc = new Scanner(System.in) ;
      	int n = sc.nextInt() ;
      	sc.nextLine() ;
      	String s1 = sc.next() ;
      	String s2 = sc.next() ;
      
      
       String res = "" ;
      	for(int i = 0  ; i < s1.length() ; i++) {
        	res+=s1.charAt(i);
            res+=s2.charAt(i) ; 
        }
      System.out.println(res) ;
    }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define ll long long int
#define vi vector<ll>
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define iiii pair<ii,ii>
#define pb push_back
#define fi first
#define se second
using namespace std;
int t;
int a,b;
int solve(){	
	for(int i = 0;i<=2000;i++){
//		cout<<i<<": "<<i * 0.08<<" "<<i*0.1<<" ""\n";
		if(floor(i * 0.08 )== a && floor(i * 0.1) == b) {
			return i;		
		}
	}
	return -1;
}
int main(){
	ios::sync_with_stdio(0), cin.tie(0);
	cin>>a>>b;
	cout<<solve()<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
  int s;
  cin >> s;
  int aa=s/100, bb=s%100;
  if((aa<=12 && bb<=12) && (aa > 0 && bb > 0)) cout << "AMBIGUOUS" << endl;
  else if(aa<=12 && aa > 0) cout << "MMYY" << endl;
  else if(bb<=12 && bb > 0) cout << "YYMM" << endl;
  else cout << "NA" << endl;
  return 0;
}


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); 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()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll K;
    string S;
    cin >> K;
    bool flag = true;

    if(K%2==0||K%5==0){
        cout << -1 << endl;
    }
    else if(K==1){
        cout << 1 << endl;
    }
    else{
        vector<ll> amari(1000000+10);
        amari.at(0) = 7 % K;
        REPS(i,amari.size()-1){
            amari.at(i) = (amari.at(i-1) * 10) % K;
        }

        ll tmp = 0;
        REP(i, amari.size())
        {
            tmp += amari.at(i);
            tmp %= K;
            if(tmp==0){
                cout << i + 1 << endl;
                flag = false;
                break;
            }
        }
        if(flag){
            cout << -1 << endl;
        }
    }
}


Measured memory_bytes: 11116
def can_you_solve_this(n, m, c, bl, al):

    ans = 0

    for i in al:
        count = 0
        for w in range(len(bl)):
            count += bl[w]*i[w]
        if count+c > 0:
            ans += 1

    return ans

def main():
    n, m, c = map(int, input().split())
    bl = list(map(int, input().split()))
    al = [list(map(int, input().split()))for i in range(n)]
    print(can_you_solve_this(n, m, c, bl, al))

if __name__ == '__main__':
    main()


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


int main() {
int N,M;
cin>>N>>M;
vector<long> a(M);
vector<long> b(M);
vector<long> c(M);
for(int i=0;i<M;i++){
  int x,y,z;
  cin>>x>>y>>z;
  x--,y--;
  a[i]=x,b[i]=y,c[i]=z;
}
vector<vector<long>> d(N,vector<long>(N));

for(int i=0;i<N;i++) for(int j=0;j<N;j++)  if(i!=j) d[i][j]=1234567890;

for(int i=0;i<M;i++){
  d[a[i]][b[i]]=c[i];
  d[b[i]][a[i]]=c[i];
}

for(int k=0;k<N;k++) for(int i=0;i<N;i++) for(int j=0;j<N;j++){
  d[i][j]=min(d[i][k]+d[k][j],d[i][j]);
}
long ans=0;

for(int i=0;i<M;i++){
  if(d[a[i]][b[i]]!=c[i]){
    ans++;
  }
}
cout<<ans<<endl;

}


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

#define ll long long int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()
using namespace std;


int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	cout << 1.0-(double)(n/2)/(double)n << endl;
}


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

int main(void) {
    vector<int> A(3);
    for(int i=0;i<3;i++) {
        cin >> A[i];
    }
    
    sort(A.begin(), A.end());
    cout << A[2] - A[0] << endl;
    return 0;
}


Measured memory_bytes: 256
q=[]
qq=[]
def dfs(j,q,count,n,qq):
    if len(qq)==n:
        count+=1
        return count    
    for j2 in q[j]:
        if not j2 in qq:
            qq.append(j2)
            count=dfs(j2,q,count,n,qq)
            qq.pop()
    return count

n,m=map(int,input().split())
q=[[]*2 for i in range(n)]
for i in range(m):
    ai,bi=list(map(int,input().split()))
    if not q[bi-1] in q[ai-1]:
        q[ai-1].append(bi-1)    
    if not q[ai-1] in q[bi-1]:
        q[bi-1].append(ai-1)    

count=0
j=0
qq=[j]
count=dfs(j,q,count,n,qq)
print(count)


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;

typedef struct Edeg {
    int to, id;
} Edge;

vector<vector<Edge>> graph;
vector<int> ans;

void dfs(int now, int before = -1, int bcolor = -1) {
    int color = 1;
    for (int i = 0; i < graph[now].size(); i++)
    {
        int next = graph[now][i].to;
        int gid = graph[now][i].id;
        if (next == before) continue;
        if (color == bcolor) color++;

        ans[gid] = color;
        color++;
        dfs(next, now, ans[gid]);
    }
}

int main() {
    int n; cin >> n;
    graph.resize(n);
    for (int i = 0; i < n-1; i++)
    {
        int a, b; cin >> a >> b;
        a--; b--;
        graph[a].push_back((Edge){ b, i});
        graph[b].push_back((Edge){ a, i});
    }

    ans.resize(n-1);
    dfs(0);

    int mx = 0;
    for (int i = 0; i < n-1; i++)
    {
        mx = max(ans[i], mx);
    }
    cout << mx << endl;

    for (int i = 0; i < n-1; i++)
    {
        cout << ans[i] << endl;
    }
        

    return 0;
}

Measured memory_bytes: 8320