akhauriyash/Code-Regression huggingface dataset:
def resolve():
    def dfs(u, v, parent):
        if u == v:
            return True
        for (to, idx) in G[u]:
            if to == parent:
                continue
            if dfs(to, v, u):
                path.append(idx)
                return True
        return False

    N = int(input())
    G = [[] for _ in range(N)]
    for i in range(N-1):
        a, b = map(lambda x:int(x)-1, input().split())
        G[a].append((b, i))
        G[b].append((a, i))

    path = []

    M = int(input())
    cons = [0]*M
    # 制約ごとに、白くなる辺を入れておく
    for i in range(M):
        u, v = map(lambda x: int(x) - 1, input().split())
        path = []
        dfs(u, v, -1)
        for idx in path:
            cons[i] |= 1<<idx

    # 包除原理
    ans = 0
    for bit in range(1<<M):
        eset = 0
        for i in range(M):
            if bit>>i & 1:
                eset |= cons[i]
        white = bin(eset).count("1") # 白くなるべき辺の数
        num = 1<<(N-1-white)
        if bin(bit).count("1") % 2 == 0:
            ans += num
        else:
            ans -= num
    print(ans)

if __name__ == "__main__":
    resolve()

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

ll fact[21];
int main(){
	fact[0]=1;
	for(int i=1;i<=20;i++)fact[i]=fact[i-1]*i;
	string s;cin>>s;
	map<int,int>mp;
	for(char c:s)mp[c]++;
	int k=0;
	for(auto p:mp){
		if(p.second&1)k++;
	}
	if(k!=s.size()%2){
		puts("0");return 0;
	}
	k=s.size()/2;
	ll cnt=1;
	for(auto p:mp){
		if(p.second==1)continue;
		p.second/=2;
		cnt*=fact[k]/fact[k-p.second]/fact[p.second];
		k-=p.second;
	}
	printf("%lld\n",cnt);
}

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

#define EPS (1e-6)
#define EQ(a, b) (std::abs((a) - (b)) < EPS)
using Vector2 = std::complex<double>;
double Dot(Vector2 a, Vector2 b) { return std::real(std::conj(a) * b); }
double Cross(Vector2 a, Vector2 b) { return std::imag(std::conj(a) * b); }

Vector2 Circumcenter(Vector2 a, Vector2 b, Vector2 c) {
  using T = Vector2::value_type;
  T ab2 = Dot(b - a, b - a), bc2 = Dot(c - b, c - b), ca2 = Dot(a - c, a - c);
  T x = bc2 * (ca2 + ab2 - bc2), y = ca2 * (ab2 + bc2 - ca2), z = ab2 * (bc2 + ca2 - ab2);
  return (x * a + y * b + z * c) / (x + y + z);
}

int main() {
  int n;
  cin >> n;
  vector<Vector2> v(n);
  for (auto &e : v) {
    int x, y;
    cin >> x >> y;
    e.real(x);
    e.imag(y);
  }

  double r = 1e9;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      {
        auto p = (v[i] + v[j]) / 2.0;
        double t = 0;
        for (auto e : v) t = max(t, abs(e - p));
        r = min(r, t);
      }
      for (int k = j + 1; k < n; k++) {
        if (EQ(Cross(v[j] - v[i], v[k] - v[i]), 0.0)) continue;
        auto p = Circumcenter(v[i], v[j], v[k]);
        double t = 0;
        for (auto e : v) t = max(t, abs(e - p));
        r = min(r, t);
      }
    }
  }
  cout << fixed << setprecision(7);
  cout << r << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int n = Integer.parseInt(in.nextLine());
    int rem = n%10;
    if (rem == 2 || rem == 4 || rem == 5 || rem == 7 || rem == 9) {
    	System.out.println("hon");
    } else if (rem == 0 || rem == 1 || rem == 6 || rem == 8) {
    	System.out.println("pon");
    } else {
    	System.out.println("bon");
    }
  }
}

Measured memory_bytes: 35708
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String s = sc.next();
    String t = sc.next();
    StringBuffer buff = new StringBuffer();
    for(int i=0;i<n;i++){
      buff.append(s.charAt(i));
      buff.append(t.charAt(i));
    }
    System.out.println(buff);
  }
}


Measured memory_bytes: 21972
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val a = Array(n) { sc.nextInt() }
    var count = 0
    for (i in 0 until n) {
        if (i % 2 == 0 && a[i] % 2 == 1) {
            count++
        }
    }
    println(count)
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 34328
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, a: "List[int]"):
    count = [0 for _ in range(4)]
    for x in a:
        count[x % 4] += 1
    
    M = N - max(0, count[2] - 1)
    if count[0] >= M // 2:
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 59552
#!/usr/bin/env python3

MOD = 2  # type: int



def main():
    N, M = map(int, input().split())
    k = []
    s = []
    for i in range(M):
        l = input().split()
        k.append(l[0])
        s.append(list(map(int, l[1:])))
    p = list(map(int, input().split()))

    ans = 0
    
    for i in range(1<<N):
        t = [0] * M
        for j in range(N):
            if i>>j & 1:
                for r in range(M):
                    # print(j+1, s[r])
                    if j+1 in s[r]:
                        t[r] += 1
        f = True
        for j in range(M):
            if t[j]%2 != p[j]:
                f = False
        
        if f:
            ans += 1

    print(ans)
    
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#ifdef DEBUG
#define line() cout << "[" << __LINE__ << "] ";
#define dump(i) cout << #i ": " << i << " ";
#define dumpl(i) cout << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
#define INF (1ll << 60)

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    map<int, vector<pair<int, ll>>> mp;
    rep(i, n - 1)
    {
        int a, b;
        ll c;
        cin >> a >> b >> c;
        mp[a].push_back(make_pair(b, c));
        mp[b].push_back(make_pair(a, c));
    }
    int q, k;
    cin >> q >> k;

    ll cost[n + 1];
    map<int, bool> unuse;

    rep(i, n + 1)
    {

        cost[i] = INF;
        unuse[i] = true;
    }
    cost[k] = 0;

    unuse.erase(0);
    queue<int> qu;
    qu.push(k);
    unuse[k] = false;

    while (!qu.empty())
    {
        int t = qu.front();
        qu.pop();
        for (auto k : mp[t])
        {
            if (unuse[k.first])
            {
                unuse[k.first] = false;
                cerr << t << "," << k.first << "." << k.second << endl;
                qu.push(k.first);
                cost[k.first] = cost[t] + k.second;
            }
        }
    }
    rep(i, n)
    {
        cerr << i << ":" << cost[i] << endl;
    }

    rep(i, q)
    {
        int x, y;
        cin >> x >> y;
        cout << cost[x] + cost[y] << endl;
    }

    return 0;
}


Measured memory_bytes: 20096
#include <stdio.h>
 
using namespace std;
 
int main(){
    int C[10001];
    for(int i = 0; i < 10001; i++) C[i] = 0;
    int n;
    scanf("%d",&n);
    int* A = new int[n];
    int* B = new int[n];
    for(int i = 0; i < n; i++){
        scanf("%d",&A[i]);
        C[A[i]]++;
    }
 
    for(int i = 0,j=0; i < 10001; i++){
        if(C[i] != 0){
            for(int k = 0; k < C[i]; k++){
                B[j++] = i;
            }
        }
    }
 
    for(int i = 0; i < n-1; i++) printf("%d ",B[i]);
    printf("%d\n",B[n-1]);
    delete[] A;
    delete[] B;
    return 0;
}


Measured memory_bytes: 17880
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define pb(a) push_back
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), n)
#define ub(v,n) upper_bound(v.begin(), v.end(), n)
#define int long long
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7; const int MAX = 2000020;
const double pi = acos(-1); const double EPS = 1e-12;
const ll INF = 1e18;


void solve() {
	set<int>st;
	REP(i, 3) {
		int x; cin >> x;
		st.insert(x);
	}
	if (st.size() == 2) {
		print("Yes");
	}
	else {
		print("No");
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;i <= 0; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x); i++)
#define rreps(i,x) for(ll i = (ll)(x)-1; i <= 1; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}
void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

template<class T, class U>
void print(pair<T,U> &p){
    print(p.first, p.second);
}

int main(){
    string s;cin >> s;
    ll n = s.size();
    vector<vector<ll>> dp(2, vector<ll>(n+1,INF));
    dp[0][0] = 0;
    rep(i,n){
        ll t = s[i] - '0';
        chmin(dp[0][i+1], dp[0][i] + t);
        chmin(dp[1][i+1], dp[0][i] + 10 - t);
        chmin(dp[1][i+1], dp[1][i] + 9 - t);
        chmin(dp[0][i+1], dp[1][i] + t + 1);
    }

    // print(dp[0]);
    // print(dp[1]);

    cout << min(dp[0][n], dp[1][n]+1) << endl;
}

Measured memory_bytes: 24836
S=input()
if S=="SUN":
  print(7)
elif S=="MON":
  print(6)
elif S=="TUE":
  print(5)
elif S=="WED":
  print(4)
elif S=="THU":
  print(3)
elif S=="FRI":
  print(2)
elif S=="SAT":
  print(1)
else:
  print()


Measured memory_bytes: 2940
# 家に帰ったら整理して

# X Y Z K
# A1...AX
# B1...
# C1...

X, Y, Z, K = gets.split.map(&:to_i)
A = gets.split.map(&:to_i).sort.reverse
B = gets.split.map(&:to_i).sort.reverse
C = gets.split.map(&:to_i).sort.reverse
V = []

A.each_with_index do |a, i|
  B.each_with_index do |b, j|
    break if (i+1) * (j+1) > K
    C.each_with_index do |c, k|
      break if (i+1) * (j+1) * (k+1) > K
      V << (a + b + c)
    end
  end
end

puts V.sort.reverse[0...K]

Measured memory_bytes: 4532
import java.io.InputStream
import java.io.PrintStream
import java.util.*

class Abc088B(
    val input: InputStream,
    val output: PrintStream
) {
    /**
     * 大きいものから順に取るだけ
     */
    fun proc() {
        val sc = Scanner(input)
        val n = sc.nextInt()
        val input = generateSequence { sc.nextInt() }
            .take(n).toList().sortedDescending()

        var alice = 0
        var bob = 0
        for ((i, v) in input.withIndex()) {
            if (i % 2 == 0) {
                alice += v
            } else {
                bob += v
            }
        }
        output.print(alice - bob)
    }
}

fun main(args: Array<String>) {
    Abc088B(System.`in`, System.out).proc()
}


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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;

void run_case()
{
    ll n;
    cin >> n;
    ll ans = (n - 1) * n / 2;
    cout << ans << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 3644
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

dire = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]

def solve(W, H, c):
    ret = 0
    checked = [[0]*W for i in range(H)]
    q = deque()
    for i in range(H):
        for j in range(W):
            if (c[i][j]) and (not checked[i][j]):
                q.append((i, j)) #((now),(before))
                while q:
                    v = q.pop()
                    nowy, nowx = v
                    checked[nowy][nowx] = 1
                    for dy, dx in dire:
                        if (nowy+dy<H) and (nowy+dy>=0) and (nowx+dx<W) and (nowx+dx>=0):
                            if (c[nowy+dy][nowx+dx]) and (not checked[nowy+dy][nowx+dx]):
                                q.append((nowy+dy, nowx+dx))
                ret += 1
    return ret


def main():
    ans = []
    while True:
        W, H = LI()
        if (W==0) and (H==0):
            break
        c = LIR(H)
        ans.append(solve(W, H, c))
    for i in ans:
        print(i)


main()


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

int main() {
	double	x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	cout << fixed << setprecision(8) << sqrt(pow(x1 - x2, 2.0) + pow(y1 - y2, 2.0));
}



Measured memory_bytes: 3276
1000000007
r = -1
g = -1
b = -1
N = int(input())
A = input().split()
A = [int(a) for a in A]

mul = 1
for i in range(N):
    
    same = 0
    same_c = 0
    
    if(r==A[i]-1):
        same += 1
        same_c = 1
    if(g==A[i]-1):
        same += 1
        same_c = 2
    if(b==A[i]-1):
        same += 1
        same_c = 3
        
    if(same_c==1):
        r = A[i]
    elif(same_c==2):
        g = A[i]
    elif(same_c==3):
        b = A[i]
        
    mul *= same
    mul = mul%1000000007
    
    
print(mul)

Measured memory_bytes: 13936
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;


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

int N;
cin >> N;

auto digit_sum = [&](int c) {
    int d,res = 0;
    while(c) {
        d = c % 10;
        res += d;
        c /= 10;
    }
    return res;
};

int fn = digit_sum(N);
if(N % fn == 0) cout << "Yes" << endl;
else cout << "No" << endl;

return 0;
}

Measured memory_bytes: 256
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

#define bip(n) __builtin_popcount(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctz(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clz(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffs(n)//index of first one bit!!

typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;

typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;

//#define fi1 ifstream cin("input.txt")
//#define of1 ofstream cout("output.txt")
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,a,b;
	cin>>n>>a>>b;
	cout<<min(n*a,b);
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(long long x){
  char f[20];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int A[300][300];
int main(){
  int f, i, j, k;
  long long res=0;
  rd(N);
  for(i=0;i<(N);i++){
    {
      int Lj4PdHRW;
      for(Lj4PdHRW=0;Lj4PdHRW<(N);Lj4PdHRW++){
        rd(A[i][Lj4PdHRW]);
      }
    }
  }
  for(i=0;i<(N);i++){
    A[i][i] = 1;
  }
  for(i=0;i<(N);i++){
    for(j=(i+1);j<(N);j++){
      f = 0;
      for(k=0;k<(N);k++){
        if(A[i][j] > A[i][k] + A[k][j]){
          wt_L(-1);
          wt_L('\n');
          return 0;
        }
        if(A[i][j]==A[i][k]+A[k][j]){
          f=1;
          break;
        }
      }
      if(!f){
        res += A[i][j];
      }
    }
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190822-2

// --- original code ---
// int N, A[300][300];
// {
//   int i, j, k, f;
//   ll res = 0;
// 
//   rd(N);
//   rep(i,N) rd(A[i](N));
// 
//   rep(i,N) A[i][i] = 1;
//   rep(i,N) rep(j,i+1,N){
//     f = 0;
//     rep(k,N){
//       if(A[i][j] > A[i][k] + A[k][j]) wt(-1), return 0;
//       if(A[i][j]==A[i][k]+A[k][j]) f=1, break;
//     }
//     if(!f) res += A[i][j];
//   }
// 
//   wt(res);
// }


Measured memory_bytes: 640
#include<iostream>
#include<map>

using namespace std;

int main(void) {
	map<int, int> m;
	int n, in[12], res;
	bool flg;
	int i;

	while(true) {
		cin >> n;
		if(n == 0) { break; }
		for(i = 0; i < n; i++) {
			cin >> in[i];
		}
		
		res = -1;
		do {
			flg = false;
			m.clear();
			res++;
			for(i = 0; i < n; i++) {
				if(m.count(in[i]) == 0) {
					m.insert(map<int, int>::value_type(in[i], 1));
				} else {
					m[in[i]]++;
				}
			}
			for(i = 0; i < n; i++) {
				if(in[i] != m[in[i]]) {
					flg = true;
					in[i] = m[in[i]];
				}
			}
		} while(flg);

		cout << res << endl;
		for(i = 0; i < n; i++) {
			cout << in[i];
			if(i != n-1) { cout << " "; }
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 0
import math
import collections
N, D, A = map(int, input().split())

XH = [tuple(map(int, input().split())) for i in range(N)]
XH.sort()
q = collections.deque()
c = 0
ans = 0
for x, h in XH:
    while(q and q[0][0] < x):
        c -= q[0][1]
        q.popleft()
    h -= c * A
    if h < 0:
        h = 0
    ans += math.ceil(h/A)
    c += math.ceil(h/A)

    q.append((x+2*D, math.ceil(h/A)))

print(ans)


Measured memory_bytes: 55724
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
n,a,b = iim()
if (b-a)%2 == 0:
    if b-a == 1:
        print('Borys')
    else:
        print('Alice')
else:
    print('Borys')

Measured memory_bytes: 3060
def examB(mod):
    N = I()
    cur = 1
    for i in range(1,N+1):
        cur = (cur*i)%mod
    print(cur)


import sys
import copy
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB(mod)


Measured memory_bytes: 3444
#pragma GCC target("avx,avx2")
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define x first
#define y second
using namespace std;
using pii = pair<int, int>;

const int N = 512;

int n;
int p[N * N];
int a[N][N];
int d[N][N];
pii q[2 * N * N + N];
int ql = 0;
int qr = 0;

signed main() {
#ifdef LC
    assert(freopen("input.txt", "r", stdin));
#endif
    ios::sync_with_stdio(0), cin.tie(0);
	
	cin >> n;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			a[i][j] = min({i + 1, j + 1, n - i, n - j});
			d[i][j] = 1;
		}
	}
	int answer = 0;
	int sum = 0;
	int cnt = 0;
	for (int it = 0; it < n * n; ++it) {
		int cur;
		cin >> cur;
		--cur;
		int i = cur / n;
		int j = cur % n;
		ql = 0;
		qr = 0;
		q[qr++] = {i, j};
		int si = i;
		int sj = j;
		--a[i][j];
		--d[i][j];
		int iter = 0;
		while (ql < qr) {
			++iter;
			assert(qr < 2 * N * N);
			tie(i, j) = q[ql++];
			if (i >= 1 && a[i - 1][j] > a[i][j] + d[i - 1][j]) {
				a[i - 1][j] = a[i][j] + d[i - 1][j];
				q[qr++] = {i - 1, j};
			}
			if (i + 1 < n && a[i + 1][j] > a[i][j] + d[i + 1][j]) {
				a[i + 1][j] = a[i][j] + d[i + 1][j];
				q[qr++] = {i + 1, j};
			}
			if (j >= 1 && a[i][j - 1] > a[i][j] + d[i][j - 1]) {
				a[i][j - 1] = a[i][j] + d[i][j - 1];
				q[qr++] = {i, j - 1};
			}
			if (j + 1 < n && a[i][j + 1] > a[i][j] + d[i][j + 1]) {
				a[i][j + 1] = a[i][j] + d[i][j + 1];
				q[qr++] = {i, j + 1};
			}
		}
		sum += iter;
		cnt += 1;
		answer += a[si][sj];
	}
	cout << answer << "\n";
	cerr << sum / cnt << endl;
    return 0;
}


Measured memory_bytes: 7584
def opecode?(str)
  if (str=="+" || str=="-" || str=="/" || str=="*")
    true
  end
end

def calculate_by_ope(num1,num2,ope)
  if ope == "+"
    res = num1+num2
  elsif ope == "-"
    res = num1-num2
  elsif ope == "/"
    res = num1/num2
  else
    res = num1*num2
  end
end

def remove_and_insert(nums,index,res)
  nums.delete_at(index)
  nums.delete_at(index)
  nums.insert(index,res)
end

def calculation(nums,ope)
  if nums.size == 2
    res = calculate_by_ope(nums[0],nums[1],ope)
    remove_and_insert(nums,0,res)
  else
    res = calculate_by_ope(nums[-2],nums[-1],ope)
    remove_and_insert(nums,-1,res)
  end
  nums
end

def stack_calc
  array = readline.split(/[[:space:]]/)
  num_array=[]
  ans = 0
  array.each do |val|
    if opecode?(val)
      ans = calculation(num_array,val)
    else
      num_array.push val.to_i
    end
  end
  ans
end

puts stack_calc

Measured memory_bytes: 6880
#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 int MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    int a[n],b[n],c[n];
    REP(i,n){
        cin >> a[i];
        a[i]--;
    }
    REP(i,n){
        cin >> b[i];
    }
    REP(i,n - 1){
        cin >> c[i];
    }
    int ans = 0;
    REP(i,n){
        ans += b[i];
    }
    REP(i,n - 1){
        if(a[i + 1] == a[i] + 1){
            ans += c[a[i]];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//Author: Prakhar Asaiya
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=a;i<b;++i)
#define REPN(i,a,b) for(int i=a;i<=b;++i)
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define pb push_back
#define ll long long
//const int M=1e9+7;
const int INF=1000000000;

const double pi=3.14159265358979323846;

int main()
{/*
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#*/
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
   int r;
   cin>>r;
   cout<<fixed<<setprecision(20)<<(double)2*pi*r;
   
    return 0;
}


Measured memory_bytes: 3796
#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(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int M,K;
    cin >> M >> K;

    if(K>=pow(2,M)){
        cout << -1 << endl;

    }else if(M==0 && K!=0){
        cout << -1 << endl;
    }else if(M==1 && K==1){
        cout << -1 << endl;
    }else if(M==1 && K==0){
        cout << "0 0 1 1" << endl;
    }else{
        REP(i,pow(2,M)){
            if(i!=K){
                cout << i << " ";
            }
        }
        cout << K << " ";
        REPR(i,pow(2,M)-1){
            if(i!=K){
                cout << i << " ";
            }
        }
        cout << K << endl;

    }
    
  
    return 0;
}

Measured memory_bytes: 4120
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>

#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
#define pb push_back
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
//const ll MOD=998244353LL;
//const ll MAX_V=114514LL;
const ll MAX = 100010LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};

//const ll MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  ll n;cin>>n;
  vl a(n+1);
  rep(i,n+1)cin>>a[i];
  COMinit();
  map<ll,ll>M;
  ll key=-1;
  rep(i,n+1){
    M[a[i]]++;
  }
  for(auto p:M){
    if(p.second==2)key=p.first;
  }
  ll id1=-1,id2=-1;
  rep(i,n+1){
    if(a[i]==key&&id1==-1){
      id1=i;
    }
    else if(a[i]==key){
      id2=i;
    }
  }
  ll point=id1-0+n-id2;
  for(ll i=1;i<=n+1;i++){
    if(point+1<i){
      cout<<COM(n+1,i)<<endl;
    }
    else {
      ll ans=COM(n+1,i);
      ll d=COM(point,i-1);
      ans=ans+MOD-d;
      ans%=MOD;
      cout<<ans<<endl;
    }
  }
}



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

int main() {
    int N; cin >> N;
    vector<int> w;
    for (int i=1; i<=6; i++) {
        int tmp = pow(6, i);
        if (tmp > N) break;
        w.push_back(tmp);
    }
    for (int i=1; i<=5; i++) {
        int tmp = pow(9, i);
        if (tmp > N) break;
        w.push_back(tmp);
    }
    int W = w.size();
    int dp[W+1][N+1];
    for (int i=0; i<=N; i++) dp[0][i] = i;

    for (int i=0; i<W; i++) {
        for (int j=0; j<=N; j++) {
            if (j - w[i] >= 0) {
                dp[i+1][j] = min(dp[i][j], dp[i+1][j-w[i]] + 1);
            } else {
                dp[i+1][j] = dp[i][j];
            }
        }
    }
    cout << dp[W][N] << endl;
}

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

int main() {
  long long a, b, x;
  cin >> a >> b >> x;
  cout << (b / x) - (max((a - 1), (long long)(0)) / x) + (a == 0 ? 1 : 0) << endl;
  return 0;
}


Measured memory_bytes: 764
//
//  main.cpp
//  1234
//
//  Created by Moha Jain on 14/04/20.
//  Copyright © 2020 Moha Jain. All rights reserved.
//
 
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<stack>
#include<algorithm>
#include<string>
#include<math.h>
#include <iomanip>
#include <numeric>
#define _USE_MATH_DEFINES
 
using namespace std;
 
 
 
int main()
{
   
    long long int n,sum=0,p=1,count=0,rank; cin>>n;
    vector<char>v;
    while(sum<n)
    {
        p*=26;
        sum+=p;
        count++;
    }
        
        sum-=p;
        rank = n - sum;
       
   while(rank!=1)
    {
    long long int sum = 0;
        long long int c = 0;
        
        p/=26;
        count--;
    while(sum<rank)
    {
        sum+=p;
        c++;
    }
        c--;
        sum-=p;
        rank-=sum;
       // cout<<c<<" "<<rank<<endl;
        v.push_back('a'+c);
        
    }
    
    for(int i=0;i<v.size();i=i+1)cout<<v[i];
    for(int i=0;i<count;i=i+1)cout<<'a';
    cout<<endl;
 
}


Measured memory_bytes: 3620
#include<stdio.h>

int main(){
	
	int i,j,k,l;
	int flag;
	int sum,sum_cnt,caseno;
	int s_case[50][2]={0};
	
	for(i=0; i<50; i++){
		scanf("%d %d",&s_case[i][0],&s_case[i][1]);
		if(s_case[i][0]==0 && s_case[i][1]==0){
			break;
		}
	}
	
	caseno = i;
	flag = 0;
	
	for(i=0;i<caseno;i++){
		sum_cnt = s_case[i][1];
		for(j=s_case[i][0]; j>2; j--){
			for(k=j-1; k>1; k--){
				for(l=k-1; l>0; l--){
					if((sum_cnt - j - k - l) == 0){
						flag++;
					}
				}
			}
		}
		printf("%d\n",flag);
		flag = 0;
	}
	
	return 0;
}




Measured memory_bytes: 2048
// ABC121_A
#include <iostream>
#include <string>
#include <vector>
#include <iterator>  // std::prev(iter, n) n 個分デクリメントしたイテレータ
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define MIN(vec) min_element(vec.begin(), vec.end())  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(vec.begin(), vec.end())
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(vec.begin(), vec.end(), 0LL)  // 0 は初期値
#define pll pair<ll, ll>
#define F first
#define S second
const ll INF = 1LL<<60;  // 10^18

int main() {
    // input(sunippets: inpv, inpn, inps)
    ll N, M, h, w;
    cin >> N >> M >> h >> w;
    
    // calculation
    cout << (N-h)*(M-w) << endl;
    
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Ho{
  static void Main(){
    var aho = Console.ReadLine().Split();
    var a = int.Parse(aho[0]);
    var b = int.Parse(aho[1]);
    if(a*500 >= b) Console.WriteLine("Yes");
    else Console.WriteLine("No");
  }
}

Measured memory_bytes: 11092
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let s = { use std :: io :: Read ; let mut s = String :: new ( ) ; std :: io :: stdin ( ) . read_to_string ( & mut s ) . unwrap ( ) ; s } ; let mut iter = s . split_whitespace ( ) ; input_inner ! { iter , $ ( $ r ) * } } ; }
macro_rules ! input_inner { ( $ iter : expr ) => { } ; ( $ iter : expr , ) => { } ; ( $ iter : expr , mut $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let mut $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , mut $ var : ident $ ( $ r : tt ) * ) => { let mut $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ iter , $ t ) ; input_inner ! { $ iter $ ( $ r ) * } } ; ( $ iter : expr , $ var : ident $ ( $ r : tt ) * ) => { let $ var = $ iter . next ( ) . unwrap ( ) . parse ::< usize > ( ) . unwrap ( ) ; input_inner ! { $ iter $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ iter : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ iter , $ t ) ) ,* ) } ; ( $ iter : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ iter , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ iter : expr , chars ) => { read_value ! ( $ iter , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ iter : expr , usize1 ) => { read_value ! ( $ iter , usize ) - 1 } ; ( $ iter : expr , $ t : ty ) => { $ iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) } ; }
use std::cmp::max;
fn dfs(u: usize, cost: &mut Vec<usize>, graph: &Vec<Vec<usize>>) {
    if cost[u] != 0 {
        return;
    }
    let d = cost[u] + 1;
    let mut res = 0;
    for &v in &graph[u] {
        dfs(v, cost, graph);
        res = max(res, cost[v] + d);
    }
    cost[u] = res;
}
fn main() {
    input! { n, m, xy: [(usize1, usize1); m] };
    let mut graph = vec![vec![]; n];
    for &(x, y) in &xy {
        graph[x].push(y);
    }
    let mut cost = vec![0; n];
    for u in 0..n {
        dfs(u, &mut cost, &graph);
    }
    println!("{}", cost.iter().max().unwrap());
}


Measured memory_bytes: 19324
#include <iostream>

using namespace std;

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

  int answer = 0;
  for (long i = 0; i < n; i++) {
    int h;
    cin >> h;
    if (h >= k) answer++;
  }

  cout << answer << endl;

  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate
import sys



def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


n, m = LI()
values = sorted(LI(), reverse=True)
weights = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]


dp = [-float('inf')] * (n+1)
dp[0] = 0



for i in values:
    for j in range(weights[i], n+1):
        dp[j] = max(dp[j - weights[i]] * 10 + i, dp[j])


print(dp[-1])

Measured memory_bytes: 67676
using System;
using System.Collections.Generic;
using System.Linq;

namespace PapersPlease
{
    class Program
    {
        static void Main(string[] args)
        {
            var ninput = int.Parse(Console.ReadLine());
            var inputs = Console.ReadLine().Split(' ');
            int[] inputArray = Array.ConvertAll(inputs, x => int.Parse(x));

            List<int> evenArray = new List<int>();
            for (int i = 0; i < inputArray.Count(); i++)
            {
                if (inputArray[i] % 2 == 0)
                {
                    evenArray.Add(inputArray[i]);
                }
            }
            evenArray.RemoveAll(x => x.Equals(0));

            List<int> newArray = new List<int>();

            for (int i = 0; i < evenArray.Count(); i++)
            {
                if(evenArray[i] % 3 == 0)
                {
                    newArray.Add(evenArray[i]);
                }

                else if(evenArray[i] % 5 == 0)
                {
                    newArray.Add(evenArray[i]);
                }
            }

            if(evenArray.Count() == newArray.Count())
            {
                Console.WriteLine("APPROVED");
            }
            else
            {
                Console.WriteLine("DENIED");
            }            
        }
    }
}


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

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    int cnt1 = 0, cnt2 = 0;
    char c = s[0];
    rep(i, n)
    {
        if (i % 2 == 0)
        {
            if (c != s[i])
                cnt1++;
        }
        else
        {
            if (c == s[i])
                cnt1++;
        }
    }
    rep(i, n)
    {
        if (i % 2 == 0)
        {
            if (c == s[i])
                cnt2++;
        }
        else
        {
            if (c != s[i])
                cnt2++;
        }
    }
    int ans = min(cnt1, cnt2);
    cout << ans << endl;
    return 0;
}

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

int main() {
    
    int N, T;
    cin >> N >>  T;

    int ans = 2000;
    bool ok = false;
    for (int i = 0; i < N; i++) {
        int c, t;
        cin >> c >> t;
        if (t <= T) {
            ans = min(ans,c);
            ok = true;
        }
    }
    if (ok) cout << ans << endl;
    else    cout << "TLE" << endl;
    return 0;
}

Measured memory_bytes: 256
// class point	の練習（クラスの高度な実装）
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>

typedef long long llong;
using namespace std;

int main() {
	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	cout <<fixed<<setprecision(10)<< sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
	return 0;
}



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

int main()
{
	int A, B;
	char P[40];
	char Q[40];
	char R[40];
	
	scanf("%s %s", &P, &Q);
	scanf("%d %d", &A, &B);
	scanf("%s", &R);
	
	if(strcmp(P, R)==0)
{
	A--;
	printf("%d %d", A, B);
}
	else
{
	B--;
	printf("%d %d", A, B);
}
	return 0;
}

Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,m,ans; string str;

double dp[3005];
int solve(){
    cin>>n;
    dp[0]=1;
    rep(i,0,n-1){
        double coin; cin>>coin;
        double x=1;
        rep1(j,i+1,0){
            if(j==0) dp[j]=dp[j]*(1-coin);
            else dp[j]=dp[j-1]*coin+dp[j]*(1-coin);
        }
    }
    double ans=0;
    rep(i,n/2+1,n) ans+=dp[i];
    cout<<fixed<<setprecision(10)<<ans;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 256
S = list(input())
t = len(S)
p = 0
for i in range(t//2):
    if S[i] != S[t-1-i]:
        p = 1
        break

if p == 1:
    print("No")
else:
    H = S[:(t-1)//2]
    q = len(H)
    for i in range(q // 2):
        if H[i] != H[q - 1 - i]:
            p = 1
            break
    if p == 1:
        print("No")
    else:
        K = S[(t+3)//2 - 1:]
        k = len(K)
        for i in range(k // 2):
            if K[i] != K[k - 1 - i]:
                p = 1
                break
        if p == 1:
            print("No")
        else:
            print("Yes")


Measured memory_bytes: 38256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int n, m;
    cin >> n >> m;
    int A[n];
    pair<int, int> tmp[m];
    ll ans = 0;
    repi(i, n, 0)
    {
        cin >> A[i];
    }
    repi(i, m, 0)
    {
        int c, b;
        cin >> b >> c;
        tmp[i].first = c;
        tmp[i].second = b;
    }
    sort(A, A + n);
    sort(tmp, tmp + m);
    int cnt = 0;
    repi(i, m, 0)
    {
        int c = tmp[m - i - 1].first;
        int b = tmp[m - i - 1].second;
        repi(j, b, 0)
        {
            ans += max(c, A[cnt]);
            cnt++;
            if (cnt == n)
            {
                cout << ans << endl;
                return 0;
            }
        }
    }
    if (cnt < n)
    {
        repi(i, n, cnt)
        {
            ans += A[i];
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    string S;
    cin >> S;
    bool flag = true;
    for (int i = 1; i < (S.length()-1); i++){
        flag = true;
        for (int j = 0; j < (S.length()-i); j++){
            if ((S.length()-i) % 2 == 0){
                for (int k = 0; k < ((S.length()-i) / 2); k++){
                    if (S[k] != S[((S.length()-i) / 2) + k]){
                        flag = false;
                        break;
                    }
                }
            }
            else {
                flag = false;
            }
            if (flag){
                cout << S.length()-i << endl;
                break;
            }
        }
        if (flag){
            break;
        }
    }
    if (flag == false) {
        cout << 1 << endl;
    }
}


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

string sub_string(string a,string b){
  string res = a;
  for(int i=b.size()-1;i>=0;i--){
    int n = a[i]-'0';
    int m = b[i]-'0';
    if(n-m<0){
      res[i] = n-m + '0' + 10;
      a[i-1]--;
    }else{
      res[i] = n-m + '0';
    }
  }
  return res;
}

int main(){
  string a;
  int n;
  map<string,int> list;
  while(cin>>a>>n,n!=0){
    list.clear();
    for(int i=a.size();i<n;i++){
      a='0'+a;
    }

    int c=0;
    while(!list.count(a)){
      list[a]=c;
      sort(a.rbegin(),a.rend());
      string max_s = a;
      string min_s(max_s.rbegin(),max_s.rend());
      a =  sub_string(max_s,min_s);
      c++;
    }

    cout<< list[a] << " " << stoi(a) << " " << c - list[a] << endl;
  }
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define VS vector<string>
#define ll long long int
int main(void) {
    ll n;
    ll a;
    ll b;
    ll ans=0;
    cin >> n >> a >> b;
    ll x[n];
    REP(i,n) {                                                                                       
        cin >> x[i];
    }
    ll dis[n-1];
    REP(i,n-1) {
        dis[i] = x[i+1] - x[i];
    }
    REP(i,n-1) {
        if(dis[i]*a > b) ans += b;
        else ans += a*dis[i];
    }
 
    cout << ans << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
void divide(int* a, int n);
bool isEven(int* a, int n);
int main() {
  int n, cnt = 0;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++)
  	cin >> a[i];
  while(isEven(a, n) != false) {
    divide(a, n);
	cnt++;
  }
  cout << cnt << endl;
}
void divide(int* a, int n) {
  for(int i = 0; i < n; i++)
    a[i] /= 2;
}
bool isEven(int* a, int n) {
  for(int i = 0; i < n; i++)
    if(a[i] % 2 == 1) 
      return false;
  return true;
}

Measured memory_bytes: 256
if __name__ == '__main__':
	a,b,c,x,y = map(int, input().split())

	if x==y:
		p = min(x*a+y*b, 2*x*c)
	elif x>y:
		p = min(x*a+y*b, 2*x*c, 2*y*c+(x-y)*a)
	else:
		p = min(x*a+y*b, 2*y*c, 2*x*c+(y-x)*b)

	print(p)

Measured memory_bytes: 3064
N, M, Q = map(int, input().split())
a = [0]*Q
b = [0]*Q
c = [0]*Q
d = [0]*Q
for i in range(Q):
  a[i], b[i], c[i], d[i] = map(int, input().split())
  a[i] -= 1
  b[i] -= 1

ans = 0
A = [0]*N
def f(p):
  global ans
  if p>=N:
    x = 0
    for i in range(Q):
      if A[b[i]]-A[a[i]]==c[i]:
        x += d[i]
    ans = max(ans, x)
  else:
    for i in range(1 if p==0 else A[p-1], M+1):
      A[p] = i
      f(p+1)
f(0)
print(ans)


Measured memory_bytes: 9180
#include<iostream>
#include<string>
using namespace std;
int main(){
  string a;
  string b="CODEFESTIVAL2016";
  cin >> a;
  int c=0;
  for(int i=0;i<16;i++){
    if(a[i]!=b[i])
      c++;
  }
  cout << c <<endl;
  return 0;
}


Measured memory_bytes: 256