akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll k,a,b;cin >> k >> a >> b;
	if(k<=a) cout << 1 << endl;
	else if(a<=b) cout << -1 << endl;
	else{
		ll ans=1;
		k-=a;
		ans+=(k+(a-b)-1)/(a-b)*2;
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string.h>
#include <cstdio>
#include <string>

using namespace std;

bool MM(int n){
    return 1 <= n && n <= 12;
}

int main(){
    char S[8]={0};
    char lower[4]={0}, upper[4]={0};
    char retStr[16]={0};
    int lower_n,upper_n;

    // [lower][upper]で受け取る
    scanf("%s", S);
    if ( !(isdigit(S[0]) && isdigit(S[1]) && isdigit(S[2]) && isdigit(S[3])) ) {
        printf("NA\r\n");
        return 0;
    }
    memcpy(lower,S,2);
    memcpy(upper,S+2,2);
    lower_n = atoi(lower);
    upper_n = atoi(upper);
    if( MM(lower_n) && MM(upper_n)){
        strcpy(retStr, "AMBIGUOUS");
    }else if(MM(upper_n)){
        strcpy(retStr,"YYMM");
    }else if(MM(lower_n)){
        strcpy(retStr, "MMYY");
    }else{
        strcpy(retStr, "NA");
    }
    printf("%s\r\n", retStr);
    return 0;
}

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

using namespace std;

int main()
{
        double a,b;

        cin >> a >> b;

        cout << fixed << setprecision(8);
        cout << int(a/b) << " " << int(a)%int(b) << " " << a/b << endl;

return 0;
}



Measured memory_bytes: 3288
// 提出時に消す


import java.util.Scanner;

// 提出時にMainに変更する
public class Main {
    public static void main(String[] args) throws Exception {
        // System.out.println("Hello Java");
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        if (s.equals(t.substring(0, s.length())) && (t.length() - s.length() == 1)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
        sc.close();
    }
}

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

using ll = long long;
using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(false)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YN(x)         cout << ((x) ? "YES" : "NO") << endl
#define Yn(x)         cout << ((x) ? "Yes" : "No") << endl
#define yn(x)         cout << ((x) ? "yes" : "no") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )
#define debugvec(v)   rep(i, v.size()) cerr << "L" << __LINE__ << ": " << #v << "[" << i << "] = " << v[i] << endl;
#define debugvec2(v)  cerr << "L" << __LINE__ << ": " << #v << " = { "; rep(i, v.size()) cerr << v[i] << (i + 1 == v.size() ? "" : ", "); cerr << " }" << endl;

ll gcd(ll a, ll b) { return __gcd(a, b); }
ll lcm(ll a, ll b) { return (a == 0 || b == 0) ? 0 : (a / __gcd(a, b) * b); }

int main(int argc, const char* argv[]) {
	ll a, b, c;
	cin >> a >> b >> c;

	cout << (((a - b) > c) ? 0 : (c - (a - b))) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

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

int main(int argc, char **argv)
{
    ll A, B, C, D;
    cin >> A >> B >> C >> D;

    // div by C
    ll nc = (B / C) - (A / C);
    if (A % C == 0) nc++;
    //div by D
    ll nd = (B / D) - (A / D);
    if (A % D == 0) nd++;

    ll l = (C > D)? C : D;
    ll s = (l == C)? D : C;
    ll r = l % s;
    while (r != 0) {
        l = s;
        s = r;
        r = l % s;
    }
    ll lcm = (C * D) / s;
    // div by lcm
    ll nlcm = (B / lcm) - (A / lcm);
    if (A % lcm == 0) nlcm++;

    cout << (B - A + 1) - nc - nd + nlcm << endl;
    return 0;
}


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

// isDebug?
#ifndef ONLINE_JUDGE
#define _DEBUG
#endif

// Function Macros:
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

// -* https://xn--kst.jp/blog/2019/08/29/cpp-comp/ *- Thx :)
// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    cout << __FILE__ << ": " << __LINE__ << ": " << __func__ << " -> ";   \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

// namespace / type / class / struct - alias, def:
using namespace std;

using ll = long long;
using ull = unsigned long long;

// Constants:
const int INF = (1ll << 30) - 1;  // approx 1.07e9
const ll INFLL = 1ll << 60;       // approx 1.15e18
const int MOD = 1e9 + 7;          // 998244353
const long double EPS = 1.0e-14;
const int FACN = 510000;

// Global Variables:
// ll fac[FACN], finv[FACN], inv[FACN];

// Prototype Declarations:
int gcd(int, int);
int lcm(int, int);
template <class T>
inline bool chmin(T&, T);
template <class T>
inline bool chmax(T&, T);

// ================ Main Loop ================
int main() {
    int n;
    cin >> n;

    for(int i = 0; i < 20; i++) {
        if(i * 1000 - n >= 0) {
            cout << i * 1000 - n << endl;
            break;
        }
    }
    return 0;
}
// ===========================================

// Functions:
// 最大公約数 O(log(min(a, b)))
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
// 最小公倍数 O(log(min(a, b)))
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

template <class T>
inline bool chmin(T& a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

template <class T>
inline bool chmax(T& a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}


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



int main() {
    string S;
    cin>>S;
    rep(i,3){
        if(S.at(i)==S.at(i+1)){cout<<"Bad"<<endl;return 0;}
    }
    cout<<"Good"<<endl;
}

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

typedef long long ll;

const int N = 100005;
int n, m, a, b, fa[N], size[N], dep[N];
vector<int> g[N];

void dfs(int u) {
	size[u] = dep[u] & 1 ? 1 : -1;
	for (int v : g[u]) {
		if (v == fa[u]) continue;
		if (dep[v] == -1) {
			fa[v] = u;
			dep[v] = dep[u] + 1;
			dfs(v);
			size[u] += size[v];
		} else if (dep[v] < dep[u])
			a = v, b = u;
	}
}

void solve() {
	scanf("%d%d", &n, &m);
	for (int i = 1, a, b; i <= m; ++i) {
		scanf("%d%d", &a, &b);
		g[a].push_back(b), g[b].push_back(a);
	}
	fill(dep + 2, dep + 1 + n, -1);
	dfs(1);
	if (n - m == 1) {
		if (size[1]) puts("-1");
		else {
			ll ans = 0;
			for (int i = 2; i <= n; ++i) ans += abs(size[i]);
			printf("%lld\n", ans);
		}
		return;
	}
	if (dep[a] % 2 == dep[b] % 2) {
		if (size[1] % 2) puts("-1");
		else {
			ll d = -size[1] / 2;
			for (int i = b; i != a; i = fa[i]) size[i] += d;
			for (int i = a; i; i = fa[i]) size[i] += 2 * d;
			ll ans = abs(d);
			for (int i = 2; i <= n; ++i) ans += abs(size[i]);
			printf("%lld\n", ans);
		}
		return;
	}
	if (size[1]) puts("-1");
	else {
		vector<int> tmp{0};
		for (int i = b; i != a; i = fa[i]) tmp.push_back(size[i]);
		nth_element(tmp.begin(), tmp.begin() + tmp.size() / 2, tmp.end());
		ll ans = 0;
		for (int x : tmp) ans += abs(x - tmp[tmp.size() / 2]) - abs(x);
		for (int i = 2; i <= n; ++i) ans += abs(size[i]);
		printf("%lld\n", ans);
	}
}

int main() {
	solve();
}


Measured memory_bytes: 12156
import sys

max_int = 1000000001  # 10^9+1
min_int = -max_int

n, m = map(int, sys.stdin.readline().split())
G = {}
for _m in range(m):
    a, b = map(int, sys.stdin.readline().split())
    if a not in G:
        G[a] = [[b], -1]
    else:
        G[a][0].append(b)

    if b not in G:
        G[b] = [[a], -1]
    else:
        G[b][0].append(a)

pretends = [1]
L = -1
while pretends:
    L += 1
    new_pretends = []
    for pretend in pretends:
        if G[pretend][1] != -1:
            continue
        G[pretend][1] = L
        for neighbor in G[pretend][0]:
            new_pretends.append(neighbor)
    pretends = new_pretends

for vertex in G:
    if G[vertex][1] == -1:
        print('No')
        exit()

print('Yes')

for i in range(2, n + 1):
    for neighbor in G[i][0]:
        if G[neighbor][1] == G[i][1] - 1:
            print(neighbor)
            break


Measured memory_bytes: 133476
console.log((args=>{
  const [HWK,...s] = args.trim().split`\n`;
  const [H,W,K] = HWK.split` `.map(v=>0|v);
  const map = Array.from({length:H},_=>Array(W).fill(0));
  const cut = (i,j,k) => map[i][j]?(k=map[i][j]):k?(map[i][j]=k):k;
  let g = 0;
  for ( let i = 0; i < H; i++ ) {
    let k = 0;
    for ( let j = 0; j < W; j++ ) {
      if ( s[i][j] === '#' ) k = ++g;
      map[i][j] = k;
    }
    for ( let j = W-1; j >= 0; j-- ) k = cut(i,j,k);
  }
  for ( let j = 0; j < W; j++ ) {
    let k = 0;
    for ( let i = 0; i < H; i++ ) k = cut(i,j,k);
    for ( let i = H-1; i >= 0; i-- ) k = cut(i,j,k);
  }
  return map.map(r=>r.join` `).join`\n`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


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

int main()
{
    char ch;
    int cnt[26] = {};

    while (cin >> ch) {
        if (isupper(ch))
            ch = tolower(ch);
        cnt[ch - 'a']++;
    }

    for (int i = 0; i < sizeof(cnt) / sizeof(cnt[0]); i++)
        cout << (char) (i + 'a') << " : " << cnt[i] << endl;
}


Measured memory_bytes: 3092
/////////////////////////   _LeMur_
#include <iostream>
#include <algorithm>
#include <time.h>
#include <stack>
#include <string>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <set>

using namespace std;

const int N = 100005;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;

int a , b , c;

int main(){
    cin>>a>>b>>c;
    int mx = max(max(a , b) , c);
    if((a + b + c) % 2 != mx % 2)
        mx++;
    cout<<(3 * mx - a - b - c) / 2<<endl;
    return 0;
}


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

struct Ant {
    int i;
    char d;
    int p;
};

void solve(int l, deque<Ant> ants) {
    deque<Ant> t; // initial
    t = ants;
    
    int step = 0;
    while (!ants.empty()) {
        step ++;

        for (int i=0; i<(int)ants.size(); ++i) {
            if (ants[i].d == 'L') ants[i].p --;
            else  ants[i].p ++;
        }
        sort(ants.begin(), ants.end(), [](const Ant &a, const Ant &b) {
            return a.p < b.p;
        });
        for (int i=0; i<(int)ants.size()-1; ++i) {
            if (ants[i].p == ants[i+1].p) {
                swap(ants[i].d, ants[i+1].d);
            }
        }

        if (((int)ants.size() == 1 && (ants.front().p <= 0 || l <= ants.back().p)) ||
            ((int)ants.size() == 2 && (ants.front().p <= 0 && l <= ants.back().p))) {
            cout << step << " " << ants[0].i+1 << endl;
            return ;
        }
        if (ants.front().p <= 0) ants.pop_front();
        if (ants.back().p >= l) ants.pop_back();
    }
}

int main() {
    int n, l;
    while (cin >> n >> l) {
        if (!n) break;

        deque<Ant> ants;
        for (int i=0; i<n; ++i) {
            char d;
            int p;
            cin >> d >> p;
            ants.push_back((Ant){i, d, p});
        }
        solve(l, ants);
    }
    return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define mp make_pair
#define pi pair<int,int>
#define pl pair<long long int,long long int>
#define pb push_back
#define fi first
#define se second
#define len(a) (int)(a).length()
#define sz(a) (int)(a).size()

using namespace std;

const int M = 1e9 + 7;
int n, dp[3100][3100], cum[3100][3100];
string s;

int main ()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	cin >> n;
	string s;
	memset(dp, 0, sizeof(dp));
	memset(cum, 0, sizeof(cum));
	cin >> s;
	dp[0][1] = 1;
	cum[0][1] = 1;
	for (int i=2; i<=n; ++i)
		cum[0][i] = (cum[0][i-1] + dp[0][i]) % M;
	for (int i=1; i<n; ++i) {
		for (int j=1, c; j<=i+1; ++j) {
			if (s[i-1] == '<') {
				c = (cum[i-1][j-1] - cum[i-1][0] + M) % M;
				dp[i][j] = (dp[i][j] + c) % M;
				cum[i][j] = (cum[i][j-1] + dp[i][j]) % M;
			}
			else {
				c = (cum[i-1][i] - cum[i-1][j-1] + M) % M;
				dp[i][j] = (dp[i][j] + c) % M;
				cum[i][j] = (cum[i][j-1] + dp[i][j]) % M;
			}
		}
	}
	int ans = 0;
	for (int i=1; i<=n; ++i)
		ans = (ans + dp[n-1][i]) % M;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 75520
import itertools

N, M = map(int, input().split())
data = []
for x in range(M):
	i = x + 1
	data.append(list(map(int, input().split())))
ps = list(map(int, input().split()))



def lightIsON(switches, light):
	# print('lightIsON()')
	# print('switches'+str(switches))
	# print('light'+str(light))

	p = ps[light - 1]
	datum = data[light - 1]
	is_k = True
	count = 0
	for x in datum:
		if(is_k):
			is_k = False
			continue
		# print('x'+str(x))
		# print('switches[x-1]'+str(switches[x-1]))

		if(switches[x-1] == 1):
			count += 1
	# print('count'+str(count))
	if(count % 2 == p):
		return True
	else:
		return False

def allLightIsON(switches):
	for x in range(M):
		m = x + 1
		if(not lightIsON(switches, m)):
			break
		if(m == M):
			return True
	return False

ans = 0
switch = (0, 1)
# print(N)
# print(str(list(itertools.product(switch, repeat=N))))
for i in itertools.product(switch, repeat=N):
	# print(i)
	if(allLightIsON(i)):
		ans += 1

print(ans)

Measured memory_bytes: 42220
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
using namespace std;
typedef long long ll;

const ll MOD = 1e9 + 7;

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

  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A[i];
  }

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

  bool ok = true;
  if (N % 2 == 1){
    ok &= A[0] == 0;
    for(int i=1;i<N;i++)ok &= A[i] == ((i + 1) / 2) * 2;
  } else {
    for(int i=0;i<N;i++)ok &= A[i] == (i / 2) * 2 + 1;
  }

  ll pw = 1;
  for(int i=0;i<N/2;i++)pw = (pw * 2) % MOD;

  ll res = ok ? pw : 0;
  cout << res << endl;

  return 0;
}


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

using namespace std;
long long mas[100005];
int main()
{
    long long n,m,in,sum=0,b;
    multiset<long long> a;
    cin>>n>>m;
    for(long long i=(long long)0; i<n; i++){
        cin>>in;
        a.insert(in);
    }
    for(long long i=(long long)0; i<m; i++){
        multiset<long long>::iterator it=a.end();
        it--;
        b=*it;
        a.erase(it);
        a.insert(b/(long long)2);
    }
    for(multiset<long long>::iterator it=a.begin(); it!=a.end(); ++it)
        sum+=*it;

    cout<<sum;
}


Measured memory_bytes: 4992
#include <stdio.h>
#define lop(i, n) for(i=0; i<n; i++)

int main()
{
	int i, n, cnt=0, p[20];
	
	scanf("%d", &n);
	
	lop(i, n){
		scanf("%d", &p[i]);
	}
	
	for(i=1; i<n-1; i++){
		if(p[i-1]<p[i]&&p[i]<p[i+1]){ cnt++; }
		else if(p[i-1]>p[i]&&p[i]>p[i+1]){ cnt++; }
	}
	
	printf("%d", cnt);
	
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    priority_queue<int> pq;
    ll ans = 0;
    ll x = 0, c = 0;
    
    rep(i, n) {
        int a;
        cin >> a;
        pq.push(a);
    }
    
    while(pq.size()) {
        if (pq.top() == c) {
            if (x == 0) {
                x = c;
                c = 0;
            }
            else {
                cout << (x * c) << endl;
                return 0;
            }
        }
        else {
            c = pq.top();
        }
        
        pq.pop();
    }
    
    cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define debug(var) do{cout << #var << " : "; print(var); } while(0)
using namespace std;
typedef long long ll;
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); } }
const int INF = 1e9;
const int MOD = 1e9+7;

int n;

void f(string s, int k) {
	if (k==n) {
		cout << s << endl;
		return;
	}

	set<char> st;
	for(const char c: s) st.insert(c);
	for(const auto c: st) f(s+char(c), k+1);
	
	f(s+char(*st.rbegin()+1), k+1);

	return;
}

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

	cin >> n;
	f("a", 1);
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const double PI = acos(-1.0);
// cout << fixed << setprecision(14);
 
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string S;
    cin >> S;
    rep(i,S.size()){
            if(S[i] == '?'){
                S[i] = 'D';
            }
    }
    cout << S << endl;
}

Measured memory_bytes: 3744
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if(a + b < c + d)cout << "Right";
	else if(a + b > c + d)cout << "Left";
	else cout << "Balanced";
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
// cout << "Case #" << test << ": ";
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 2019
using namespace std;
using P = pair<ll, ll>;
vector<ll> Dijkstra_list(int n, int s, vector<vector<pair<ll, ll>>> &Edge) {
    vector<bool> visited(n, false); //確定済み
    vector<ll> d(n, __LONG_LONG_MAX__ / 3);
    // using P = pair<ll,ll>
    priority_queue<P, vector<P>, greater<P>> que; //頂点とsからの距離
    d[s] = 0;
    que.push(make_pair(0, s));
    while(!que.empty()) {
        auto now = que.top();
        que.pop();
        visited[now.second] = true;
        for(auto e : Edge[now.second]) {
            if(visited[e.second])
                continue;
            if(d[e.second] > d[now.second] + e.first) {
                d[e.second] = d[now.second] + e.first;
                que.push(make_pair(d[e.second], e.second));
            }
        }
    }
    return d;
}
int main() {
    int n, m;
    cin >> n >> m;
    int s;
    cin >> s;
    s = min(2500, s);
    vector<vector<P>> edge(n * 2501);
    for(int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        ll a, b;
        cin >> a >> b;
        for(int j = 0; j < 2501; j++) {
            if(j - a >= 0) {
                edge[u * 2501 + j].push_back(make_pair(b, v * 2501 + j - a));
                edge[v * 2501 + j].push_back(make_pair(b, u * 2501 + j - a));
            }
        }
    }
    for(int i = 0; i < n; i++) {
        ll c, d;
        cin >> c >> d;
        for(int j = 0; j < 2501; j++) {
            edge[i * 2501 + j].push_back(
                make_pair(d, i * 2501 + min(2500LL, j + c)));
        }
    }
    auto d = Dijkstra_list(n * 2501, s, edge);
    for(int i = 1; i < n; i++) {
        ll ans = LLONG_MAX;
        for(int j = 0; j < 2501; j++) {
            ans = min(ans, d[i * 2501 + j]);
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 23632
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
 
int main() {
 
  int N; cin >> N;
  string S; cin >> S;
  int M = 0;
  int x = 0;
  
  for(int i=0; i < S.size(); i++){
    if(S.at(i) == 'I') x++;
    else x--;
    
    if(M < x) M=x;
  }
  
  cout << M << endl;
}

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

int main() {
  int m;
  cin >> m;
  for (int i = 0; i < m; ++i) {
    set<string> se;
    string str; cin >> str;
    for (int j = 1; j < (int)str.size(); ++j) {
      string str1 = str.substr(0, j);
      string str2 = str.substr(j);

      se.insert(str1 + str2);
      se.insert(str2 + str1);

      reverse(str1.begin(), str1.end());
      se.insert(str1 + str2);
      se.insert(str2 + str1);

      reverse(str2.begin(), str2.end());
      se.insert(str1 + str2);
      se.insert(str2 + str1);

      reverse(str1.begin(), str1.end());
      se.insert(str1 + str2);
      se.insert(str2 + str1);
    }

    cout << se.size() << endl;
  }
}


Measured memory_bytes: 1292
import java.util.Scanner;
import java.util.regex.Pattern;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        int B = scanner.nextInt();
        String S = scanner.next();

        String Asub = S.substring(0, A);
        String Bsub = S.substring(A+1, A+B+1);

        /*
        System.out.println("Asub：" + Asub);
        System.out.println(isNum(Asub));
        System.out.println("Bsub：" + Bsub);
        System.out.println(isNum(Bsub));
        */

        String result = "No";
        //文字列が数字かつ、文字列のA+1番目がハイフン
        if (isNum(Asub) && isNum(Bsub) && S.substring(A, A+1).equals("-")) {
            result = "Yes";
        }
        System.out.println(result);
    }

    //文字列が数字か判定
    public static boolean isNum(String s) {
        return Pattern.compile("^-?[0-9]+$").matcher(s).find();
    }

}

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


def solve(a: int):
    poly = a + a**2 + a**3
    return poly


# Generated by 1.1.7.1 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()
    a = int(next(tokens))  # type: int
    print(solve(a))

if __name__ == '__main__':
    main()


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

using namespace std;

template< class T >
struct CumulativeSum
{
  vector< T > data;

  CumulativeSum(int sz) : data(sz, 0) {};

  void add(int k, T x)
  {
    data[k] += x;
  }

  void build()
  {
    for(int i = 1; i < data.size(); i++) {
      data[i] += data[i - 1];
    }
  }

  T query(int k)
  {
    if(k < 0) return (0);
    return (data[min(k, (int) data.size() - 1)]);
  }
};

typedef long long int64;

int main()
{
  int64 N, L, K, A[100000], D[100000];

  cin >> N >> L >> K;
  for(int i = 0; i < N; i++) {
    cin >> A[i] >> D[i];
  }

  auto getSum = [&](int64 a, int64 l, int64 d)
  {
    return ((2 * a + (l - 1) * d) * l / 2);
  };

  CumulativeSum< int64 > sum(N);
  for(int i = 0; i < N; i++) {
    sum.add(i, getSum(A[i], L, D[i]));
  }
  sum.build();

  int64 ret = numeric_limits< int64 >::min();

  auto check = [&](int64 st)
  {
    int64 ed = st + K - 1;
    int64 range = sum.query(ed / L - 1) - sum.query(st / L);
    int64 st_index = st / L, ed_index = ed / L;
    st %= L, ed %= L;
    range += getSum(A[st_index] + D[st_index] * st, L - st, D[st_index]);
    range += getSum(A[ed_index], ed + 1, D[ed_index]);
    return (range);
  };

  for(int64 i = 0; i < N; i++) {
    int64 low = i * L, high = min(N * L - K + 1, i * L + L);
    if(low >= high) break;
    while(high - low > 1) {
      int64 mid = (low + high) >> 1LL;
      if(check(mid) - check(mid - 1) > 0) low = mid;
      else high = mid;
    }
    ret = max(ret, check(low));
  }
  cout << ret << endl;
}

Measured memory_bytes: 5136
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int n, T; cin>>n>>T;
    vector<int> c(n), t(n);
    for(int i=0; i<n; i++) cin>>c[i]>>t[i];

    int ans=1e9;
    for(int i=0; i<n; i++){
        if(t[i]<=T){
            chmin(ans, c[i]);
        }
    }

    if(ans==1e9){
        cout << "TLE" << endl;
    }
    else{
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
n, m = map(int, input().split())
d = {i: [1, 0] for i in range(1, n+1)}
d[1][1] = 1
for _ in range(m):
    x, y = map(int, input().split())
    d[x][0] -= 1
    d[y][0] += 1
    if d[x][1] == 1:
        d[y][1] = 1
    if d[x][0] == 0:
        d[x][1] = 0
ans = sum(d[i][1] for i in range(1, n+1))
print(ans)


Measured memory_bytes: 23204
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var nr = Console.ReadLine().Split(' ').Select(num => int.Parse(num)).ToArray();
            Console.WriteLine(nr[1] + (nr[0] > 9 ? 0 : 100 * (10 - nr[0])));
        }
    }
}

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

int main(){
  int n,a,b;
  cin >> n >> a >> b;
  string s;
  cin >> s;
  int x = 0;
  int bx = 0;
  for(int i = 0; i < s.length(); i++){
    if(s[i] == 'a' && x < a + b){
      x++;
      cout << "Yes" << endl;
    }else if(s[i] == 'b' && x < a + b && bx < b){
      x++;
      bx++;
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <iostream>

using namespace std;

int main(void)
{
	unsigned long long a, b;
	char ch;
	cin >> a;
	getchar();
	ch = getchar();
	b = ch - '0';
	getchar();
	ch = getchar();
	b = b * 10 + ch - '0';
	ch = getchar();
	b = b * 10 + ch - '0';
	cout << a * b / 100;

	return 0;
}

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

typedef long long ll;
const int maxn = 100;
const ll inf = 5e16;
int n, deg[maxn + 3], son[maxn + 3], dep[maxn + 3], mx[maxn + 3];
vector<int> G[maxn + 3];
pair<int, ll> ans, res;

void dfs(int u, int pa = 0) {
	son[u] = 0;
	for (int i = 0, v; i < G[u].size(); i++) {
		v = G[u][i];
		if (v == pa) continue;
		dep[v] = dep[u] + 1;
		son[u]++;
		dfs(v, u);
	}
}

pair<int, ll> calc() {
	int x = 0;
	for (int i = 1; i <= n; i++) {
		x = max(x, dep[i]);
	}
	for (int i = 1; i <= x; i++) {
		mx[i] = 0;
	}
	int c = 0;
	for (int i = 1; i <= n; i++) {
		mx[dep[i]] = max(mx[dep[i]], son[i]);
		if (dep[i] == 1) c++;
	}
	ll y = c;
	for (int i = 1; i < x; i++) {
		y = min(inf, y * mx[i]);
	}
	return make_pair(x, y);
}

pair<int, ll> solve_1(int u) {
	dep[u] = 1;
	dfs(u);
	return calc();
}

pair<int, ll> solve_2(int u, int v) {
	dep[u] = dep[v] = 1;
	dfs(u, v), dfs(v, u);
	return calc();
}

void search(int u, int pa = 0) {
	for (int i = 0, v; i < G[u].size(); i++) {
		v = G[u][i];
		if (v == pa) continue;
		res = min(res, solve_2(u, v));
		search(v, u);
	}
}

pair<int, ll> solve() {
	res.first = maxn + 3, res.second = 0;
	for (int i = 1; i <= n; i++) {
		res = min(res, solve_1(i));
	}
	search(1);
	return res;
}

int main() {
	scanf("%d", &n);
	for (int i = 1, u, v; i < n; i++) {
		scanf("%d %d", &u, &v);
		G[u].push_back(v), G[v].push_back(u);
		deg[u]++, deg[v]++;
	}
	ans = solve();
	for (int i = 1; i <= n; i++) if (deg[i] == 1) {
		G[i].push_back(++n);
		ans = min(ans, solve());
		G[i].pop_back(), n--;
	}
	printf("%d %lld\n", ans.first, ans.second);
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl

ll n,m,a,b,c,x,y,z,aa[100010],ba[100010];
bool r,ra,rb,rc;
string s,sa,sb,sc;
char ca,cb,cc,cd[1000][1000];
vector<ll> va,vb,vc;


int main(){
    cin>>n;
    a=1;
    while(a<=n){
        a*=2;
    }
    C a/2 E;
    
}

Measured memory_bytes: 384
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
#define int long long


signed main(void){
  int n;
  cin >> n;
  int ret = 0;
  vector<int> a,b;
  for(int i = 0; i < n; i++){
    int a_,b_;
    cin >> a_ >> b_;
    a.push_back(a_);b.push_back(b_);
  }

  for(int i = n-1; i >= 0; i--){
    if((a[i]+ret)%b[i]){
      ret += b[i] - (a[i]+ret)%b[i];
    }
  }

  cout << ret << "\r\n";
}


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

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    int result = 0;

    for (int i = 1; i <= N; i++) {
        int num = 0;
        int x = i;
        while (x > 0)
        {
            num += x % 10;
            // cout << num << endl;
            x /= 10;
            
        }
        if (A <= num && num <= B) {
            result += i;
        }
            
    }
    cout << result << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
typedef long long LL;
int main(int argc, char* argv[])
{
	int N,M;
	cin>>N;
	LL d;
	map<LL,int> D;
	map<LL,int>::iterator mit;
	int i;
	for (i=0;i<N;i++){
		cin>>d;
		mit=D.find(d);
		if (mit==D.end()){
			D[d]=1;
		}else{
			(*mit).second++;
		}
	}
	cin>>M;
	LL  T;
	for (i=0;i<M;i++){
		cin>>T;
		mit=D.find(T);
		if (mit==D.end()){
			cout<<"NO"<<endl;
			return 0;
		}else{
			if ((*mit).second>=1){
				(*mit).second--;
			}else if ((*mit).second==0){
				cout<<"NO"<<endl;
				return 0;
			}
		}
	}
	cout<<"YES"<<endl;
	return 0;
}

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

int main(){
    bool flag = false;
    char c;
    int N;
    cin >> N;

    for(int i = 0; i < N;i++){
        cin >> c;
        if(c == 'Y')
            flag = true;
    }

    if(flag)
        cout << "Four" << endl;
    else if(!(flag))
        cout << "Three" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INS(x) x.begin(),x.end()
#define debug(x) cout<<x;
    

    
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string s;
    cin>>s;

    if (s[2]==s[3]&&s[4]==s[5])
        cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int A,B;

int main()
{
    int count=0;
    scanf("%d %d",&A,&B);

    for(int i=A;i<=B;i++){
	if(i%10==i/10/10/10/10%10 && i/10%10==i/10/10/10%10)
	    count++;
    }
    printf("%d\n",count);
    return 0;
}



Measured memory_bytes: 128
#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, W;
  cin >> n >> W;
  vector<ll> dp(1000001, INT_MAX / 2);
  dp[0] = 0;
  rep(i, n) {
    int w, v;
    cin >> w >> v;
    for (int j = 1000000 - v; j >= 0; j--)
      dp[j + v] = min(dp[j + v], dp[j] + w);
  }
  cout << dp.rend() -
              find_if(dp.rbegin(), dp.rend(), [=](auto w) { return w <= W; }) -
              1
       << endl;
}

Measured memory_bytes: 8064
#include<algorithm>
#include<iostream>
#include<string.h>
#include<stdio.h>
#include<queue>
using namespace std;

const long long N=200010;
const long long MAXN=N*2+1;

struct Edge
{
	long long next;
	long long dis;
	long long to;
}edge[MAXN];

long long head[MAXN],res[MAXN],r[MAXN];
long long tot=1;
long long n,m;
bool visited[MAXN];

inline void add(long long a,long long b)
{
	edge[tot].next=head[a];edge[tot].to=b;head[a]=tot++;
}

void init()
{
	memset(head,-1,sizeof head);
}

void bfs()
{
	queue <long long> q;
	q.push(1);
	
	while(!q.empty())
	{
		long long x=q.front();q.pop();
		visited[x]=1;
		
		for(long long i=head[x]; ~i; i=edge[i].next)
		{
			long long y=edge[i].to;
			
			if(!visited[y])
			{
				res[y]+=res[x];
				q.push(y);
			}
		}
	}
}

int main()
{
	init();
	scanf("%lld%lld",&n,&m);
	long long a,b;
	
	for(long long i=1; i<n; i++)
	{
		scanf("%lld%lld",&a,&b);
		add(a,b);add(b,a);
	}
	
	for(long long i=1; i<=m; i++)
	{
		scanf("%lld%lld",&a,&b);
		res[a]+=b;
	}
	
	bfs();
	
	for(long long i=1; i<=n; i++)
		printf("%lld ",res[i]);
	puts("");
	
	return 0;
}

Measured memory_bytes: 19712
N=int(input())

def cf(n):
  a=[]
  f=1
  while f*f<=n:
    if n%f==0:
      a.append(f)
      if n//f!=f:
        a.append(n//f)
    f+=1
  return a

def main():
  c=len(cf(N-1))-1
  for f in cf(N):
    t=N
    if f!=1:
      while t%f==0:
        t//=f
      if t%f==1:
        c+=1
  print(c)

main()


Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int h = scanner.nextInt();
        int w = scanner.nextInt();
        int n = scanner.nextInt();
        if (h == w) {
            if (n % w == 0) {
                int needRow = n / w;
                System.out.println(needRow);
                return;
            }
            int needRow = n / w + 1;
            System.out.println(needRow);
        } else {
            if (h > w) {
                if (n % h == 0) {
                    int needRow = n / h;
                    System.out.println(needRow);
                    return;
                }
                int needRow = n / h  + 1;
                System.out.println(needRow);
            } else {
                if (n % w == 0) {
                    int needRow = n / w;
                    System.out.println(needRow);
                    return;
                }
                int needRow = n / w + 1;
                System.out.println(needRow);
            }
        }
    }
}

Measured memory_bytes: 23252
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

int main() {
    int n; scanf("%d", &n);
    if (n / 100 == 7 || n / 10 % 10 == 7 || n % 10 == 7)
        printf("Yes\n");
    else
        printf("No\n");
}

Measured memory_bytes: 1648
def main():
    ans = 0
    n,k = map(int, input().split())
    l = [0]*n
    for i in range(k):
        d = int(input())
        s = list(map(int, input().split()))
        for j in s:
            l[j-1] += 1
    for i in range(n):
        if l[i] == 0:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
signed main()
{
    SPEED;
    int n,cnt=1;
    cin>>n;
    if(n!=2)
    {
        ++cnt;
    }
    for(int i=2;i*i<=(n-1);i++)
    {
        if((n-1)%i==0)
        {
            if((n-1)==i*i)
            {
                ++cnt;
            }
            else
            {
                cnt+=2;
            }
        }
    }
    for(int i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            int temp=n;
            while(temp%i==0)
            {
                temp/=i;
            }
            if(temp%i==1)
            {
                ++cnt;
            }
            if(n!=i*i)
            {
                int temp=n;
                while(temp%(n/i)==0)
                {
                    temp/=(n/i);
                }
                if(temp%(n/i)==1)
                {
                    ++cnt;
                }
            }
        }
    }
    cout<<cnt;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N,K;
  cin>>N>>K;
  long long tempmin,tempmax;
  long long ans=0;
  for(long long i=K;i<=N+1;i++){
    tempmin=(i-1)*i/2;
    tempmax=(2*N+1-i)*i/2;
   // cout<<tempmin<<" "<<tempmax<<endl;
    ans=(ans+tempmax-tempmin+1)%1000000007;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int number500 = 0;
        int number5 = 0;
        while (x >= 500) {
            number500++;
            x -= 500;
        }
        while (x >= 5) {
            number5++;
            x -= 5;
        }
        int happy = 1000 * number500 + 5 * number5;
        System.out.println(happy);
    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -10010
#define bql 2147483647
#define ll long long
#define maxn 100010
using namespace std;
int main(){
	fast;
	int n,ans=0;
	cin>>n;
	int a[n+1],b[n+1];
	for(int i=1;i<=n;i++)cin>>a[i],b[i]=a[i];
	sort(b+1,b+n+1);
	for(int i=1;i<=n;i++){
		if(a[i]!=b[i])
			ans++;
	}
	if(ans<=2)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
	
}/*『你强归你强，我用不示弱』*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INF 10000000;
int main(){
  int dp[100010];
  dp[0] = 0;
  for(int n=1; n<=100000; n++){
    dp[n] = INF;
    int power = 1;
    while(power<=n){
      dp[n] = min(dp[n],dp[n-power]+1);
      power *=6;
    }
    power = 1;
    while(power<=n){
      dp[n] = min(dp[n],dp[n-power]+1);
      power *=9;
    }
  }
  int n;
  cin >> n;
  cout << dp[n] << endl;
  return 0;
}

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

using namespace std;

#define fori(x) for (int i = 0; i < x; ++i)
#define forj(x) for (int j = 0; j < x; ++j)

int main() {
    int n;
    map<string,int> a;
    cin>>n;
    fori(n){string s;cin>>s;++(a[s]);}
    int maxv = 0;
    for (const auto& x : a) {
        int v = x.second;
        if (v > maxv) maxv = v;
    }
    for (auto it = a.begin(); it != a.end(); it++) {
        if (it->second == maxv) {
            cout << it->first << endl;
        }
    }
	return 0;
}

Measured memory_bytes: 25344
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <functional>
#include <deque>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
int main(){
    int n;
    cin >> n;

    vector<int> a(n);
    map<int,ll> mp;
    for(int i = 0;i < n;i++){
        cin >> a[i];
        mp[a[i]]++;
    }

    ll al = 0;
    for(auto p:mp){
        al += p.second * (p.second - 1) / 2;
    }


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


Measured memory_bytes: 11776
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
using namespace std;
long long MOD = 1e9 + 7;

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

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<double> x(n), y(n);
    rep(i,n) cin >> x[i] >> y[i];
    vector<int> v(n);
	rep(i,n) v[i] = i;
    double ans = 0, div = 0;
	do{
		double dist = 0;
        rep(i,n-1){
            dist += sqrt((x[v[i]]-x[v[i+1]])*(x[v[i]]-x[v[i+1]]) + (y[v[i]]-y[v[i+1]])*(y[v[i]]-y[v[i+1]]));
        }
        ans += dist;
        div += 1;
	} while(next_permutation(v.begin(), v.end()));
    ans /= div;
    cout << fixed << setprecision(12) << ans << endl;
    return 0;
}


Measured memory_bytes: 3832
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n)cin >> a[i];
    sort(a.begin(), a.end());
    int l = -1;
    int r = n;
    while(l + 1 < r){
        int x = (l + r) / 2;
        vector<int> dp(k+1, 0);
        dp[0] = 1;
        rep(i, n){
            if(i == x)continue;
            for(int j = k-1; j >= 0; j--){
                if(dp[j] == 1){
                    dp[min(j+a[i], k)] = 1;
                }
            }
        }
        bool v = true;
        for(int i = max(k-a[x], 0); i < k; i++){
            if(dp[i] == 1)v = false;
        }
        if(v)l = x;
        else r = x;
    }
    cout << l + 1 << endl;
}

Measured memory_bytes: 256
from itertools import product

h, w, k = map(int, input().split())
c = [input() for i in range(h)]
ans = 0
 
for maskR in product([0,1], repeat=h):
    for maskC in product([0,1], repeat=w):
        b = 0
        for i in range(h):
            for j in range(w):
                if maskR[i] == 1 and maskC[j] == 1 and c[i][j] == '#':
                    b += 1
        if b ==k:
            ans += 1
print(ans)


Measured memory_bytes: 9076
#include<stdio.h>

int main() {
	int n, a[10005], b[10005], i;
	long long count1, count2;
	while(scanf("%d",&n)!=EOF) {
		count1 = 0, count2 = 0;
		for(i=0;i<n;i++) {
			scanf("%d",&a[i]);
		}
		for(i=0;i<n;i++) {
			scanf("%d",&b[i]);
			if(b[i]<a[i]) {
				count1 += a[i]-b[i];
			}
			else count2 += (b[i]-a[i])/2;
		}
//		printf("%d %d\n",count1,count2);
		if(count2>=count1) printf("Yes\n");
		else printf("No\n");
	}
}

Measured memory_bytes: 256
import math


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


def main():
    n, m = map(int, input().split())
    if n < 2:
        even = 0
    else:
        even = combinations_count(n, 2)
    if m < 2:
        odd = 0
    else:
        odd = combinations_count(m, 2)
    print(even + odd)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9136
#define _USE_MATH_DEFINES
#include<cmath>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>
using namespace std;
#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define ALL(x) (x).begin(),(x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int main() {
	IOS;
	int n;
	cin >> n;
	vector<ll> a(n);
	REP(i, n) {
		cin >> a[i];
	}
	sort(ALL(a));
	vector<ll> v(n);
	v[0] = a[0];
	FOR(i, 1, n) {
		v[i] = v[i - 1] + a[i];
	}
	ll ans = 1;
	for (int i = n - 1; i > 0;i--) {
		if (v[i - 1] * 2>= a[i])ans++;
		else break;
	}
	dump(ans);
	return 0;
}

Measured memory_bytes: 1792
/**
 * File    : B2.cpp
 * Author  : Kazune Takahashi
 * Created : 11/19/2018, 9:09:14 AM
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int main()
{
  string S;
  cin >> S;
  for (auto i = 0; i < (int)S.size(); i += 2)
  {
    cout << S[i];
  }
  cout << endl;
}

Measured memory_bytes: 512
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
class Solve{
    public Solve(){}
    StringBuilder sb;
    public static int Main(){
        new Solve().Run();
        return 0;
    }
    void Run(){
        sb = new StringBuilder();
        Calc();
        Console.Write(sb.ToString());
    }
    void Calc(){
        int N = int.Parse(Console.ReadLine());
        string[] str = Console.ReadLine().Split(' ');
        int f = 0;
        int t = 0;
        int o = 0;
        for(int i=0;i<N;i++){
            int x = int.Parse(str[i]);
            if(x % 4 == 0){
                f++;
            }
            else if(x % 2 == 0){
                t++;
            }
            else{
                o++;
            }
        }
        bool b;
        if(t == 0){
            b = f >= o-1;
        }
        else{
            b = f >= o;
        }
        if(b){
            sb.Append("Yes\n");
        }
        else{
            sb.Append("No\n");
        }
    }
}

Measured memory_bytes: 18016
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int a[n+1];
    int b[n+1];
    int c[n+1];
    int ans=0;
    
    for(int i=1;i<=n;++i){
        cin>>a[i];
    }
    for(int i=1;i<=n;++i){
        cin>>b[i];
        ans+=b[i];
    }
    for(int i=1;i<n;++i){
        cin>>c[i];
    }
    for(int i=1;i<n;++i){
       
        if(a[i]+1==a[i+1]){ans+=c[a[i]];}
    }
    

    cout<<ans<<endl;
    // Your code here!
    
}


Measured memory_bytes: 256