akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, b, e) for (i64 i = (b); i <= (e); ++i)
#define repr(i, b, e) for (i64 i = (b); i >= (e); --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

#ifdef DEBUG
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// input
void input() {}
template <class Head, class... Tail>
void input(Head&& head, Tail&&... tail) {
  cin >> head;
  input(forward<Tail>(tail)...);
}

// outs
void outs() {}
template <class Head, class... Tail>
void outs(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  outs(forward<Tail>(tail)...);
}

template <class T>
void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

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

// outl
void outl() {}
template <class Head, class... Tail>
void outl(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  outl(forward<Tail>(tail)...);
}

template <class T>
void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// outn
void outn() {}
template <class Head, class... Tail>
void outn(Head&& head, Tail&&... tail) {
  cout << head;
  outn(forward<Tail>(tail)...);
}

template <class T>
void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

// dump
template <class T>
void dump_(const char *s, T&& x) {
  clog << '{';
  while(*s != '\0') clog << *(s++);
  clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void dump_(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  dump_(s, forward<Tail>(tail)...);
}
// }}} End

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

  vector<i64> x(3);
  rep(i, 3) input(x[i]);

  sort(all(x), greater<>());

  outl(x[0] - x[1] + x[1] - x[2]);

  return 0;
}


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

struct Card {
	char suit;
	int value;
};

void bubble(struct Card A[], int N) {
	for (int i = 0; i < N; ++i) {
		for (int j = N - 1; j > i; --j) {
			if (A[j].value < A[j - 1].value) {
				Card t = A[j];
				A[j] = A[j - 1];
				A[j - 1] = t;
			}
		}
	}
}

void selection(struct Card A[], int N) {
	for (int i = 0; i < N; ++i) {
		int minj = i;
		for (int j = i; j < N; ++j) {
			if (A[j].value < A[minj].value) minj = j;
		}
		Card t = A[i];
		A[i] = A[minj];
		A[minj] = t;
	}
}

void print(struct Card A[], int N) {
	for (int i = 0; i < N; ++i) {
		if (i > 0) cout << " ";
		cout << A[i].suit << A[i].value;
	}
	cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N) {
	for (int i = 0; i < N; ++i) {
		if (C1[i].suit != C2[i].suit) return false;
	}
	return true;
}

int main() {
	Card C1[100], C2[100];
	int N;
	char ch;

	cin >> N;
	for (int i = 0; i < N; ++i) cin >> C1[i].suit >> C1[i].value;

	for (int i = 0; i < N; ++i) C2[i] = C1[i];

	bubble(C1, N);
	selection(C2, N);

	print(C1, N);
	cout << "Stable" << endl;
	print(C2, N);
	if (isStable(C1, C2, N)) cout << "Stable" << endl;
	else cout << "Not stable" << endl;
}


Measured memory_bytes: 3116
#include <string>
#include <iostream>

using namespace std;

void b()
{
	string S;

	cin >> S;
	int k = S.length();

	int count = 0;
	for (int i = 0; i < k; i++) {
		if (S[i] == 'o')
			count++;
	}

	std::cout << (count+(15-k) >= 8 ? "YES" : "NO") << std::endl;
}

int main()
{
	b();
}



Measured memory_bytes: 256
D, G = map(int, input().split())
p = D * [0]
c = D * [0]
for i in range(D):
    p[i], c[i] = map(int, input().split())

counter = []

for i in range(1 << D):
    goukei = 0
    count = 0
    amari = [i for i in range(D)]
    for j in range(D):
        if (i >> j) & 1:
            goukei += p[j] * 100 * (j + 1) + c[j]
            count += p[j]
            amari.remove(j)
    if goukei < G:
        for i in range(p[max(amari)]):
            goukei += 100 * (max(amari) + 1)
            count += 1
            if goukei >= G:
                counter.append(count)
                break
    else:
        counter.append(count)

print(min(counter))


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

int main() {
	ll n, a, b;
	cin >> n >> a >> b;

	ll c = n / (a + b);
	ll r = n % (a + b);

	cout << a * c + min(r, a) << endl; 

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
// #include <bits/stdc++.h>
// #include <cstdint> 
// #include <limits>
using namespace std;
int md=998244353;
int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;++i) cin>>a[i];
    int cost[n];
    for(int i=0;i<n;++i) cost[i] = INT32_MAX;
    cost[0]=0;
    for(int i=1;i<n;++i){
        for(int j=1;j<=k && i-j>=0;++j){
            cost[i] = min(cost[i],cost[i-j]+abs(a[i]-a[i-j]));
        }
    }
    cout<<cost[n-1];
}

Measured memory_bytes: 3896
# -*- coding: utf-8 -*-
N = int(input())
S = input()

s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
ans = ""
for i in range(len(S)):
    n = (s.index(S[i]) + N)
    if n >= 26:
        n -= 26
    ans += s[n]
    
print(ans)

Measured memory_bytes: 3060
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000000
#define MOD 1000000007
#define MAXR 100000

int main() {
  string S;
  cin >> S;
  string A,B,C;
  A=S;
  B=S.substr(0,((SIZE(S))-1)/2);
  C=S.substr(((SIZE(S))+1)/2,(SIZE(S))-1);
  reverse(ALL(S));
  string D,E;
  D=S.substr(0,((SIZE(S))-1)/2);
  E=S.substr(((SIZE(S))+1)/2,(SIZE(S))-1);
  if(A==S&&B==E&&C==D){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import math

N,D = map(int,input().split())
X = [list(map(int,input().split())) for _ in range(N)]

c = 0
for i in range(N):
    for j in range(i+1,N):
        dist = 0
        for d in range(D):
            dist += (X[i][d]-X[j][d])**2
        dist = math.sqrt(dist)
        if dist-int(dist) == 0:
            c += 1

print(c)

Measured memory_bytes: 3060
function Main(input){
  var s = input.split('\n');
  var N = s[0].split(' ').map((a)=>Number(a));
  var m = [];
  for(var i=1;i<s.length-1;i++){
    m.push(Number(s[i]));
  }
  var re = N[1]-m.reduce((a,b)=>a+b);

  console.log(N[0]+Math.floor(re/Math.min(...m)));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
from sys import stdin

n, m = [int(x) for x in stdin.readline().rstrip().split()]
data = [[int(x) for x in stdin.readline().rstrip().split()] for _ in range(n)]

data = sorted(data)
ans = 0
current = 0
i = 0
while True:
    if m > current + data[i][1]:
        ans += data[i][0] * data[i][1]
        current += data[i][1]
        i += 1
    else:
        ans += data[i][0] * (m - current)
        print(ans)
        exit()

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

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin >> t;
    while (t--) {
        int n;
        cin >> n;
        cin.ignore();
        string s;
        int ac = 0, wa = 0, tle = 0, re = 0;
        for (int i = 0; i < n; i++) {
            cin >> s;
            if (s == "AC") ac++;
            else if (s == "WA") wa++;
            else if (s == "RE") re++;
            else tle++;
        }
        cout << "AC x " << ac << "\nWA x " << wa << "\nTLE x " << tle << "\nRE x " << re;
    }
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

string s, t;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> s >> t;
	if(t.substr(0, (int)t.size()-1) == s) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h> 
using namespace std; 
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

int main(void) {
    io;
    int N,K,X,Y;
    cin >> N >> K >> X >> Y;
    long long total = 0;
    for (int i = 1; i <= N; i++) {
        if (i <= K) {
            total += X;
        } else {
            total += Y;
        }
    }
    cout << total << endl;
    return 0;
}



Measured memory_bytes: 3616
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
const int MAXN=1e2+10;
int a[MAXN],n,m;
bool cmp(int &a,int &b){
    return a>b;
}
int main(){
    scanf("%d %d",&n,&m);
    int sum=0;
    for(int i=1;i<=n;i++) scanf("%d",&a[i]),sum+=a[i];
    sort(a+1,a+n+1,cmp);
    int i;
    for(i=1;i<=m;i++){
        if(4*m*a[i]<sum){
            break;
        }
    }
    i--;
    if(i<m){
        printf("No");
    }else{
        printf("Yes");
    }
    return 0;
}


Measured memory_bytes: 256
import copy
N, M = map(int, input().split())
XY = []
for _ in range(M):
    x, y = map(int, input().split())
    XY.append([x - 1, y - 1])

ball_num = [1] * N
is_red = [False] * N
is_red[0] = True

for i in range(M):
    s = XY[i][0]
    g = XY[i][1]
    if is_red[s]:
        if ball_num[s] == 1:
            ball_num[s] -= 1
            ball_num[g] += 1
            is_red[s] = False
            is_red[g] = True
        else:
            ball_num[s] -= 1
            ball_num[g] += 1
            is_red[g] = True
    else:
        ball_num[s] -= 1
        ball_num[g] += 1

print(sum(is_red))

Measured memory_bytes: 65112
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.function.LongSupplier;

public class Main{ // 

	static class ConsoleScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			try {
				while (!st.hasMoreElements())
					st = new StringTokenizer(br.readLine());
				return st.nextToken();
			} catch (IOException e) {
				throw new AssertionError(e);
			}
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

	static LongSupplier now = new LongSupplier() {
		private long t = System.currentTimeMillis();

		@Override
		public long getAsLong() {
			long a = t;
			t = System.currentTimeMillis();
			long ans = t - a;
			return ans;
		}
	};

	public static void main(String args[]) {
		ConsoleScanner cin = new ConsoleScanner();
		PrintWriter cout = new PrintWriter(System.out);
		solve(cin, cout);
		cout.flush();
	}

	static int tr(Object... objects) {
		System.out.println("tr:" + Arrays.deepToString(objects));
		return 0;
	}

	private static void solve(ConsoleScanner cin, PrintWriter cout) {
		// assert solve(1) == 1;

		int n = cin.nextInt();

		int[] a = new int[n];
		for (int i = 0; i < a.length; i++)
			a[i] = cin.nextInt();

		now.getAsLong();

		int ans = solve(n, a);
		cout.println(ans);

		assert 0 == tr("elapsed", now.getAsLong());
	}

	private static int solve(int n, int[] a) {
		int max_ai = 100000;
		int[] cnt = new int[max_ai + 2];
		for (int x : a)
			cnt[x] += 1;
		int ans = -1;
		for (int i = 1; i <= max_ai; i++)
			ans = Math.max(ans, cnt[i - 1] + cnt[i] + cnt[i + 1]);
		return ans;
	}

}


Measured memory_bytes: 36504
#line 2 "../../library/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pl = pair<ll, ll>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)
#define rep3(i, l, r) for(ll i = l; i < (ll)r; i++)
#define per(i, n) for(ll i = (ll)n-1; i >= 0; i--)
#define per3(i, l, r) for(ll i = (ll)r-1; i >= (ll)l; i--)
#define all(v) begin(v), end(v)
template<class T, class U> inline void cmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> inline void cmin(T &a, U b) { if (a > b) a = b; }
constexpr char el = '\n';
template<class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<class T, class U> istream &operator>>(istream &is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) os << v[i] << (i+1 != v.size() ? " " : ""); return os; }
template<class T> istream &operator>>(istream &is, vector<T> &v) { for(T &i : v) is >> i; return is; }
struct IoSetup {
  IoSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); }
} io_setup;
#line 2 "c.cpp"

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

  vl ans(n);
  
  rep3(i, 1, n+1) {
    rep3(j, i, n+1) {
      rep3(k, j, n+1) {
        ll sum = i*i+j*j+k*k+i*j+j*k+k*i;
        if (sum > n) break;
        if (sum <= n) {
          if (i == k) {
            ans[sum-1]++;
          } else if (i == j or j == k) {
            ans[sum-1] += 3;
          } else {
            ans[sum-1] += 6;
          }
        }
      }
    }
  }

  for (auto&& i : ans) {
    cout << i << el;
  }
}


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

int main() {
    int A , B , C , D;
    cin >> A >> B >> C >> D;
    cout << max(A * B , C * D) << endl;
}

Measured memory_bytes: 256
k,n=gets.split(' ').map(&:to_i)
a=gets.split(' ').map(&:to_i)
#tajigen = Array.new(4) { Array.new(2,0) }
maxmarge=k-a[n-1]+a[0]

for i in 1..n-1
  if a[i] - a[i-1] > maxmarge
    maxmarge = a[i] - a[i-1]
  end
end

puts k-maxmarge


Measured memory_bytes: 16900
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
int calc(int N){
  if(N==0){
    return 0;

  }
  else{
    return N*calc(N-1);
  }
}

int main() {
  int N,M,K;
  cin>>N>>M>>K;
  bool judge=false;
  rep(s,M+1){
    rep(t,N+1){
      if((N*s+M*t-2*s*t)==K){
        judge=true;
      }
    }
  }
  if(judge){
    cout<<"Yes"<<endl;

  }
  else{
    cout<<"No"<<endl;
  }
return 0;
}

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

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 ll INF = 1LL<<60;

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

    vector<ll> dp(n + 1, INF);
    dp[0] = 0;

    for(int i = 1; i <= n; i++) {
        int power = 1;
        while(power <= i) {
            chmin(dp[i], dp[i - power] + 1);
            power *= 6;
        }
        power = 1;
        while(power <= i) {
            chmin(dp[i], dp[i - power] + 1);
            power *= 9;
        }
    }

    cout << dp[n] << endl;
    
    return 0;
}



Measured memory_bytes: 1024
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 09/08/20 03:55:25
// -----------------------------------

#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using ll = long long;

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

  int n,m; cin>>n>>m;
  vector<string> grid(n); for (auto& l:grid) cin>>l;

  atcoder::mf_graph<int> mfg(n*m+2);
  int qs = n*m, qg = n*m+1;
  constexpr int dir[2][2] = {
      {1, 0}, {0, 1},
  };
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (grid[i][j] == '#') continue;
      if ((i+j)%2) {
        mfg.add_edge(qs, i*m+j, 1);
      } else {
        mfg.add_edge(i*m+j, qg, 1);
      }
      for (auto [dx, dy] : dir) {
        int x = i + dx, y = j + dy;
        if (x >= n or y >= m or
            grid[x][y] == '#')
          continue;
        int s = i*m+j, t = x*m+y;
        if ((i+j)%2 == 0)
          swap(s, t);
        mfg.add_edge(s, t, 1);
      }
    }
  }
  int ans = mfg.flow(qs, qg);
  for (auto [s, t, c, f] : mfg.edges()) {
    if (f == 0 or s == qs or t == qg) continue;
    if (s > t) swap(s, t);
    if (s/m == t/m) {
      grid[s/m][s%m] = '>';
      grid[t/m][t%m] = '<';
    } else if (s%m == t%m) {
      grid[s/m][s%m] = 'v';
      grid[t/m][t%m] = '^';
    }
  }
  cout << ans << endl;
  for (auto& l : grid)
    cout << l << endl;

  return 0;
}


Measured memory_bytes: 5388
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int[] english = new int[26];
		Arrays.fill(english,0);
		
		while(stdIn.hasNext()){
			String str = stdIn.nextLine();
			for(int i=0;i<str.length();i++){
				if(str.charAt(i)>='a' && 'z'>=str.charAt(i)){
					english[(int)str.charAt(i)-(int)'a']++;
				}
				else if(str.charAt(i)>='A' && 'Z'>=str.charAt(i)){
					english[(int)str.charAt(i)-(int)'A']++;
				}
			}	
		}
		
		for(int i=(int)'a';i<=(int)'z';i++){
			System.out.println((char)i+" : "+english[i-(int)'a']);
		}
	}

}

Measured memory_bytes: 17148
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  string s;
  cin >> s;

  int c[3];
  fill(c, c + 3, 0);
  for(char ch: s){
    c[ch - 'a']++;
  }

  int d = max(abs(c[0] - c[1]), 
      max(abs(c[0] - c[2]), abs(c[1] - c[2])));
  if(d <= 1) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MAX max<ll>
#define MIN min<ll>
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll devc(ll x, ll y) { return (x + y - 1) / y; }

struct Edge {
    ll from, to, weight;
    Edge() : from(0), to(0), weight(0) {}
    Edge(ll f, ll t, ll w) : from(f), to(t), weight(w) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

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

void add_arrow(Graph &g, ll a, ll b, ll w = 1){
    g[a].emplace_back(a, b, w);
}

//ダイクストラ法
//グラフgの1点sからの最短距離をO((E + V) log V)で構築
vector<ll> dijkstra(Graph &g, ll s){
    vector<ll> dist(g.size(), INF);
    priority_queue<P, vector<P>, greater<P>> que;
    dist[s] = 0;
    que.emplace(dist[s], s);
    
    while(!que.empty()){
        ll cost, idx;
        tie(cost, idx) = que.top();
        que.pop();
        if(dist[idx] < cost) continue;
        for(auto &e : g[idx]){
            auto next_cost = cost + e.weight;
            if(dist[e.to] <= next_cost) continue;
            dist[e.to] = next_cost;
            que.emplace(dist[e.to], e.to);
        }
    }
    return dist;
}

void dfs(Graph& g, vec& visited, vec& node, ll now){
    visited[now] = true;
    for(auto e : g[now]) if(!visited[e.to]){
        node[e.to] += node[now];
        dfs(g, visited, node, e.to);
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll N, Q;
    cin >> N >> Q;
    Graph G(N);
    vec node(N);
    rep(i, N - 1){
        ll a, b;
        cin >> a >> b;
        --a, --b;
        add_edge(G, a, b);
    }

    rep(_, Q){
        ll p, x;
        cin >> p >> x;
        node[--p] += x;
    }
    vec visited(N, false);
    dfs(G, visited, node, 0);
    cout << node[0];

    for (ll i = 1; i < N; ++i) cout << " " << node[i];
    print("");

    return 0;
}

Measured memory_bytes: 35840
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,a,b) for(ll i=(a)-1;i>=(b);i--)

int main() {
    ll N, K;
    cin >> N >> K;
    struct Sushi {
        ll id;
        ll t;
        ll d;
        static bool comp(Sushi lhs, Sushi rhs) {
            return lhs.d > rhs.d || (lhs.d == rhs.d && lhs.id < rhs.id);
        }
    };
    vector<Sushi> sushis(N);
    rep(i,0,N) {
        cin >> sushis[i].t >> sushis[i].d;
        sushis[i].id = i;
    }
    unordered_map<ll, Sushi> most_delicious;
    rep(i,0,N) {
        ll t = sushis[i].t;
        ll d = sushis[i].d;
        if (most_delicious.find(t) == most_delicious.end() || most_delicious[t].d < d) {
            most_delicious[t] = sushis[i];
        }
    }
    vector<Sushi> most_deli_vec;
    for (const auto& kv : most_delicious) {
        most_deli_vec.push_back(kv.second);
    }
    ll type_cnt = most_deli_vec.size();
    sort(most_deli_vec.begin(), most_deli_vec.end(), Sushi::comp);
    sort(sushis.begin(), sushis.end(), Sushi::comp);
    set<Sushi, decltype(&Sushi::comp)> top(&Sushi::comp);
    ll top_sum = 0;
    rep(i,0,K) {
        top.insert(sushis[i]);
        top_sum += sushis[i].d;
    }
    ll ans = top_sum;
    ll types_ensure_sum = 0;
    rep(x,1,min(K, type_cnt)+1) {
        Sushi add = most_deli_vec[x-1];
        types_ensure_sum += add.d;
        if (top.find(add) != top.end()) {
            top.erase(add);
            top_sum -= add.d;
        } else {
            auto back = prev(top.end());
            top_sum -= back->d;
            top.erase(back);
        }
        ll ans_loc = x * x + types_ensure_sum + top_sum;
        ans = max(ans, ans_loc);
    }
    cout << ans << endl;
}



Measured memory_bytes: 15256
#include <iostream>

using namespace std;

int main()
{
    int A,a,b,c,d;
    cin>>A;
    a=A%10;
    A/=10;
    b=A%10;
    A/=10;
    c=A%10;
    A/=10 ;
    d=A%10;
    if((a==b && b==c )||(b==c && c==d) ){
        cout<<"Yes";
    }
    else
        cout<<"No";
    return 0;
}


Measured memory_bytes: 256
from sys import setrecursionlimit
setrecursionlimit(100000)

N,K = map(int,input().split())
A = tuple(map(int,input().split()))

dp = [False]*(K+1)

for n,v in enumerate(dp):
  if not v:
    for a in A:
      if n+a <= K:
        dp[n+a] = True

print('First' if dp[K] else 'Second')

Measured memory_bytes: 40560
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)

//変数
int N;
string S;

//解法
void solve() {

	int ans = 0;

	for (int i = 1; i < N; i++) {

		vector<bool> front(26, false), back(26, false);

		for (int j = 0; j < i; j++) {
			front[S[j] - 'a'] = true;
		}
		for (int j = i; j < N; j++) {
			back[S[j] - 'a'] = true;
		}

		int sum = 0;
		rep(j, 26) {
			if (front[j] && back[j]) sum++;
		}
		ans = max(ans, sum);
	}
	cout << ans;
	return;
}

int main() {
	//入力
	cin >> N >> S;
	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
P = [11, 31, 41, 61, 71, 101, 131, 151, 181, 191, 211, 241, 251, 271, 281, 311, 331, 401, 421, 431, 461, 491, 521, 541, 571, 601, 631, 641, 661, 691, 701, 751, 761, 811, 821, 881, 911, 941, 971, 991, 1021, 1031, 1051,
1061, 1091, 1151, 1171, 1181, 1201, 1231, 1291, 1301, 1321, 1361, 1381, 1451]
n = int(input())
for i in range(n):
    print(P[i], end = " ")
print()

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

int gcd(int a, int b) {
  if (a <= 0) return b;
  return gcd(b%a, a);
}

int lcm(int a, int b) {
  return a / gcd(a, b) * b;
}

int main() {
  int a, b;
  while (cin >> a >> b) {
    cout << gcd(a, b) << " " << lcm(a, b) << endl;
  }
  return 0;
}

Measured memory_bytes: 3048
#include<iostream>
#include<fstream>
#include<string>
#include<cstring>
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<queue>
#include<list>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#include<cstdio>
#include <iomanip>


using namespace std;


template<class T>bool chmax(T &a, const T &b) { return (a<b) ? (a = b, 1) : 0; }
template<class T>bool chmin(T &a, const T &b) { return (b<a) ? (a = b, 1) : 0; }

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

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

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

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

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

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

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

const int N = 1234567;

int a[N], pr[N], ne[N], pos[N];

int main() {
	int n;
	scanf("%d", &n);

	//大きい要素順に取り出せるように要素を指定すると、ai上での添字が返って
	//くるようにする。0,n+1を番兵として1,2,…nに要素を格納していく。
	for (int i = 1; i <= n; i++) {
		scanf("%d", a + i);
		pos[a[i]] = i;
	}

	//各番号の前後をもっておきたい。初期化。
	for (int i = 0; i <= n + 1; i++) {
		pr[i] = i - 1;
		ne[i] = i + 1;
	}


	long long ans = 0;

	//大きい要素から順番に空の区間に加えていく。
	for (int i = n; i >= 1; i--) {
		int j = pos[i];
		ans += i * 1LL * (j - pr[j]) * (ne[j] - j);

		//これから先入ってくる要素は、すでにある要素より小さい。
		//つまり今ある要素は以降挿入される要素を最小値区間にかならず含まれる。

		//要素を挿入した区間は拡張される。

		//左端として、挿入した要素の右端を持つ区間は、挿入した要素の左端まで拡張
		pr[ne[j]] = pr[j];

		//右端も同様
		ne[pr[j]] = ne[j];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9216
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
#include <memory>
#include <time.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
const double EPS = 1e-9;
const double PI  = acos(-1.0);


typedef vector<double> vd;
typedef vector<vd> vvd;

int main(){
	cout.precision(30);
	int n;
	cin>>n;
	vi a(n);
	REP(i,n){
		cin>>a[i];
	}

	const int MAX=200000;
	vvd dp(n,vd(MAX+1,INT_MAX));
	REP(i,MAX+1){
		dp[0][i]=(double)abs(i-a[0])/a[0];
	}
	REP(i,n-1){
		FOR(j,1,MAX+1){
			for(int k=1;k<=MAX&&j*k<=MAX;k++){
				double confusion=(double)abs(j*k-a[i+1])/a[i+1];
				dp[i+1][j*k]=min(dp[i+1][j*k],max(dp[i][j],confusion));
			}
		}
	}

	double ans=INT_MAX;
	REP(i,MAX){
		ans=min(ans,dp[n-1][i]);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 33740
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <complex>
#define repi(i,x,n) for(int i = x; i < n; i++)
#define rep(i,n) repi(i,0,n)
#define int long long
using namespace std;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
const double EPS = 1e-8;

#define int long long

struct point{
    int x,y,z;
    int r, l;
};

long double eps = 1e-5;
int N, Q;
vector<point> P;
point A, B, C;

int solve(){
    long double a = sqrt(B.x*B.x + B.y*B.y + B.z*B.z);
    long double  b, ab, res = 0;
    long double c, d, e;

    for(int i = 0; i < N; i++){
        C.x = P[i].x - A.x;
        C.y = P[i].y - A.y;
        C.z = P[i].z - A.z;
        b = sqrt(C.x*C.x + C.y*C.y + C.z*C.z);
        ab =  B.x*C.x + B.y*C.y + B.z*C.z;
        c = b*(ab/(a*b));
        d = b*b - c*c;

	//	cout<<"a = "<<a<<" b = "<<b<<" c = "<<c<<endl;
	//	cout<<"ab -> "<<ab<<endl;
	//cout<< "cos -> "<<ab/(a*b)<<endl;
	   
	if(c > a ||  ab/(a*b)  < 0 ) continue;
	
        if(d < P[i].r*P[i].r + EPS) res += P[i].l;
	//	cout<<" d = "<<d<<" "<<P[i].r*P[i].r<<endl;
    }

    return res;
}

signed main(void)
{
    //  cin.tie(0);
    // ios::sync_with_stdio(false);


    cin>>N>>Q;

    P.resize(N);

    for(int i = 0; i < N; i++){
        cin>>P[i].x>>P[i].y>>P[i].z>>P[i].r>>P[i].l;
    }

    for(int i = 0; i < Q; i++){
        cin>>A.x>>A.y>>A.z>>B.x>>B.y>>B.z;
        B.x -= A.x;
        B.y -= A.y;
        B.z -= A.z;
        // B = A;
        //cout<<"i = "<<i<<endl;
        cout<<solve()<<endl;
    }

    return 0;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define pb push_back
typedef long long ll;
typedef long double la;
using namespace std;

int main(){
    int n,count=0,flag=0;
    cin >> n;
    ll a[n];
    rep(i,n){
        cin >> a[i];
    }
    while(1){
        rep(i,n){
            if(a[i] % 2 != 0){
                cout << count << endl;
                return 0;
            }
            a[i] /= 2;
        }
        count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b&&b==c)cout<<"No"<<endl;
  else if(a!=b&&b!=c&&c!=a)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

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

int const N = 1000000;
char s[N + 1];
int n, q;

ll go(int k){
	ll an = 0, sm = 0;
	int b = 0;
	deque<pair<int, int> > dq;
	f(i, 0, n){
		if (s[i] == 'D')dq.push_back(make_pair(i, b)), sm += b;
		else if (s[i] == 'M')++b;
		else if (s[i] == 'C'){
			while (!dq.empty() && i - dq.front().first >= k)sm -= dq.front().second, dq.pop_front();
			an += (ll)b * dq.size() - sm;
		}
	}
	return an;
}

int main(){
	scanf("%d%s%d", &n, s, &q);
	f(i, 0, q){
		int t;
		scanf("%d", &t);
		printf("%lld\n", go(t));
	}
}

Measured memory_bytes: 9464
#include <stdio.h>
int main()
{
  int N, K;
  int d;
  int buk[101];
  int temp;
  int i;
  int j;
  int counter = 0;
  for(i = 0; i < 101; ++i)
    buk[i] = 0;
  
  scanf("%d %d", &N, &K);
  for(i = 0; i < K; ++i){
    scanf("%d", &d);
    for(j = 0; j < d; ++j){
      scanf("%d", &temp);
      ++buk[temp - 1];
    }
  }
  
  for(i = 0; i < N; ++i){
    if(buk[i] == 0)
      ++counter;
  }
  printf("%d\n", counter);
  return 0;
}

Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vvi vector<vector<int>> 
#define vi vector<int> 
#define vpii vector<pair<int,int>> 
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define ffor(i,n) for(int i = 0; i < n; ++i)
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vi a(n);
    ffor(i,n) cin >> a[i];
    sort(all(a));
    int count = 0;
    for(int i = n - 1; i >= 1; --i){
        int l = 0, r = i - 1;
        while(l < r){
            if(a[l] + a[r] > a[i]){
                count += (r - l);
                r--;
            }else{
                ++l;
            }
        }
    }
    cout << max(0LL,count);
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        
        while (in.hasNextInt()) {//注意while处理多个case
        	int N = in.nextInt();
        	int A = in.nextInt();
        	int B = in.nextInt();
        	String participants = in.nextLine();
        	participants = in.nextLine();
        	int totNum = 0;
        	int overseas = 0;
        	for(int i = 0; i < participants.length(); i++){
        		if (participants.charAt(i) == 'c') {
					System.out.println("No");
				}else if (participants.charAt(i) == 'a') {
					if (totNum < A + B) {
						++totNum;
						System.out.println("Yes");
					}else{
						System.out.println("No");
					}
				}else {
					if (totNum < A+B && overseas < B) {
						System.out.println("Yes");
						++totNum;
						++overseas;
					}else{
						System.out.println("No");
					}
				}
        	}
        }
        in.close();
    }
}

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

int main(){
    int N; cin >> N;
    int F[N][10];
    int P[N][11];
    ll ans = -1e15;

    for(int i = 0; i < N; i++){
        for(int j = 0; j < 10; j++){
            cin >> F[i][j];
        }
    }
    for(int i = 0; i < N; i++){
        for(int j = 0; j < 11; j++){
            cin >> P[i][j];
        }
    }

    for (int bits = 1; bits < (1<<10); bits++) {
       ll sum = 0;
       for (int i = 0; i < N; i++) {
          int cnt = 0;
          for (int j = 0; j < 10; j++) {
             if (((bits>>j)&1) && F[i][j]) cnt++;
          }
          sum += P[i][cnt];
       }
       ans = max(ans, sum);
    }

    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 256
import scala.io.StdIn

object Main extends App {

  var Array(x1,y1,x2,y2) = StdIn.readLine().split(' ').map(_.toDouble)
  val result = scala.math.sqrt(scala.math.pow(x1-x2, 2) + scala.math.pow(y1-y2,2))
  
  println(f"$result%.8f")
  
}



Measured memory_bytes: 44248
n=int(input())
a=list(map(int, input().split()))
c=0
for i in range(n):
    m=i
    for j in range(i,n):
        if a[j]<a[m]:
            m=j
    a[i],a[m]=a[m],a[i]
    if i!=m:c+=1
print(*a)
print(c)


Measured memory_bytes: 5608
#include <cstdio>

int
main(void)
{
  int ns[3], i, j, tmp;
  std::scanf("%d %d %d", &ns[0], &ns[1], &ns[2]);
  // ns[0] = 3, ns[1] = 1, ns[2] = 2;

  for (i = 0; i < 2; i++) {
    for (j = i; j < 3; j++) {
      if (ns[i] > ns[j]) {
        tmp = ns[i];
        ns[i] = ns[j];
        ns[j] = tmp;
      }
    }
  }
  
  std::printf("%d %d %d\n", ns[0], ns[1], ns[2]);

  return 0;
}



Measured memory_bytes: 2744
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
#include<list>

using namespace std;

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

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n,ll mod = MOD){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%mod;
        }
        x = (x*x)%mod;
        n >>= 1;
    }
    return ret;
}

ll mygcd(ll a,ll b){
    if(b == 0)return a;
    return mygcd(b,a%b);
}

ll twoPow(ll shiftNum){
    return (1LL << (shiftNum - 1));
}

// prepare for main routine
bool dfs(const int current, const int target, const int preEdge, vector<int> &usedEdge, vector<bool> &visited, const vector<list<pair<int, int>>> edge){
    visited[current] = true;

    if(current == target){
        usedEdge.push_back(preEdge);
        return true;
    }

    for(const auto E : edge[current]){
        if(!visited[E.first]){
            if(dfs(E.first, target, E.second, usedEdge, visited, edge)){
                if(preEdge >= 0){
                    usedEdge.push_back(preEdge);
                }
                return true;
            }
        }
    }

    return false;
}

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

    vector<list<pair<int, int>>> edge(N+1);
    for(int i = 0; i < N - 1; i++){
        int a,b;
        cin >> a >> b;
        edge[a].push_back(make_pair(b, i));
        edge[b].push_back(make_pair(a, i));
    }

    int M;
    cin >> M;

    vector<int> u(M),v(M);
    for(int i = 0; i < M; i++){
        cin >> u[i] >> v[i];
    }

    // existing edge between vertex u_i and vertex v_i for all element of query
    vector<vector<bool>> coveredEdge(M, vector<bool>(N-1, false));

    for(int i = 0; i < M; i++){
        vector<int> usedEdge;
        vector<bool> visited(N+1, false);

        dfs(u[i], v[i], -1, usedEdge, visited, edge);

        for(const auto E : usedEdge){
            coveredEdge[i][E] = true;
        }
    }

    // subsets of satisfied query after painting a edge black
    vector<int> querySubsets(N-1);

    for(int i = 0; i < N - 1; i++){
        int bit = 0;
        for(int j = 0; j < M; j++){
            if(coveredEdge[j][i]){
                bit += (1 << j);
            }
        }
        querySubsets[i] = bit;
    }

    // dp table for bitDp
    vector<vector<ll>> dp(N, vector<ll>((1 << M),0));
    dp[0][0] = 1;

    for(int i = 0; i < N - 1; i++){
        for(int j = 0; j < (1 << M); j++){
            dp[i + 1][j | querySubsets[i]] += dp[i][j];
            dp[i + 1][j] += dp[i][j];
        }
    }

    cout << dp[N-1][(1 << M) - 1] << endl;

    return 0;
}

Measured memory_bytes: 418432
N,M=map(int,input().split())
S=input()
i=N
flg=0
ans=[]
while i>0:
  j=M
  if i-M<0:
    ans.append(i)
    i=0
  else:
    while j>=0:
      if j>0 and S[i-j] == '0':
        ans.append(j)
        i-=j
        j=0
      elif j==0:
        flg=1
        i=0
      j-=1
if flg==1:
  print(-1)
else:
  print(*reversed(ans))

Measured memory_bytes: 6384
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int r = sc.nextInt();
      if(n >= 10){
      	System.out.println(r);
      } else {
        System.out.println(r+100*(10-n));
      }
    }
}


Measured memory_bytes: 35680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {
	if (b==0) return a;
    else{
    	return gcd(b,a%b);
    }
}
 
int main() {
	ll a,b,c;
  	cin >> a >> b >> c;
	if(a==b){
      cout << c << endl;
    }
  	else if(a==c){
      cout << b << endl;
    }
  	else if(b==c){
      cout << a << endl;
      
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;

const int N = 9;
int a[N][N];

vector<int> F(int x,int y)
{
	vector<int> r;
	int i,j;
	for(i=0;i<3;++i)
		for(j=0;j<3;++j)
			r.push_back(a[x/3*3+i][y/3*3+j]);
	return r;
}
int main(void)
{
	int n,i,j,k,x=0;
	bool b;
	vector<int>v;
	
	scanf("%d",&n);
	while(n--)
	{
		for(i=0;i<N;++i)
			for(j=0;j<N;++j)
				scanf("%d",&a[i][j]);

		printf("%s",(x++?"\n":""));
		for(i=0;i<N;++i)
		{
			for(j=0;j<N;++j)
			{
				b=false;
				v=F(i,j);
				if(count(v.begin(),v.end(),a[i][j])>1 ||
					count(a[i],a[i]+N,a[i][j]) > 1)
					b=true;
				else
				{
					for(k=0;k<N;++k)
					{
						if(k==i)continue;
						if(a[i][j] == a[k][j]) b=true;
					}
				}
				printf("%c%d",(b?'*':' '),a[i][j]);
			}
			putchar('\n');
		}
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
using namespace std;
#define ll long long int
const ll mod = 1e9 + 7;


int main() {
  int n;
  string s;
  cin >> n >> s;
  vector< ll > sum(26);
  for ( int i = 0; i < n; ++i ) {
    char x = s[i];
    for (int j = 0; j < 26; ++j){
      char y = 'a' + j;
      if ( x == y) ++sum[j];  
    }
  }

  ll ans = 1;
  for (int i = 0; i < 26; ++i){
    ans *= sum[i] + 1;
    ans %= mod;
  }

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


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

int main()
{
    int a, b;
    string as,bs, str_a, str_b;
    cin >> a >> b;
    for (int i = 0; i < b;i++){
        as = to_string(a);
        str_a.insert(0, as);
    }
    for (int i = 0; i < a; i++)
    {
        bs = to_string(b);
        str_b.insert(0, bs);
    }
    if(str_a<str_b){
        cout << str_a << endl;
    }
    else{
        cout << str_b << endl;
    }
}


Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <time.h>
#include <random>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define LONG_INF 10000000000000000
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
#define int long long
	int n;
	cin >> n;
	vector<int> hoge;
	REP(i, n) {
		int tmp;
		cin >> tmp;
		hoge.push_back(tmp);
	}
	int ans = 1;
	int now = -1;
	int before = -1;
	for (int i = 0;i < hoge.size();++i) {
		if (now == -1) {
			now = hoge[i];
		}
		else if (before == -1) {
			if (hoge[i] != now) {
				before = now;
				now = hoge[i];
			}
		}
		else {
			if (now - before > 0) {
				if (hoge[i] - hoge[i - 1] < 0) {
					ans++;
					now = hoge[i];
					before = -1;
				}
			}
			else {
				if (hoge[i] - hoge[i - 1] > 0) {
					ans++;
					now = hoge[i];
					before = -1;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  string s; cin >> s;
  const string t = "ACGT";
  set<char> st;
  for (auto &c : t) st.insert(c);
  int ans = 0, cnt = 0;
  for (auto &c : s) {
    if (st.count(c)) {
      ans = max(ans, ++cnt);
    } else cnt = 0;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  cout<<min(a+b,min(b+c,c+a))<<endl;
}


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 ll;
const int INF = 1e9;

int main() {
  int n;
  string s;
  cin >> n >> s;
  int cnt = 0, maxc = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'I')
      cnt++;
    else
      cnt--;

    maxc = max(maxc, cnt);
  }

  cout << maxc << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int[] X = new int[N];
        Map<Integer, Integer> map = new HashMap<>();
        for(int i = 0; i < N; i++){
            X[i] = sc.nextInt();
            map.put(i, X[i]);
        }
        sc.close();
        Arrays.sort(X);

        for(int i = 0; i < N; i++){
            if(map.get(i) <= X[N/2-1]){
                System.out.println(X[N/2]);
            } else {
                System.out.println(X[N/2-1]);
            }
        }
        
    }
}

Measured memory_bytes: 115568