akhauriyash/Code-Regression huggingface dataset:
bingonum=[[0,0,0],[0,0,0],[0,0,0]]
bingo=[["False","False","False"],["False","False","False"],["False","False","False"]]
for i in range(3):
    bingonum[i][0],bingonum[i][1],bingonum[i][2] = map(int,input().split())

N = int(input())
b=[]
for _ in range(N):
    b.append(int(input()))
for x in range(N):
    for i in range(3):
        for j in range(3):
            if bingonum[i][j]==b[x]:
                bingo[i][j]="True"

IsBingo = "No"
for i in range(3):
    if bingo[i][0] =="True" and bingo[i][1] =="True" and bingo[i][2] =="True":
        IsBingo="Yes"
    if bingo[0][i] =="True" and bingo[1][i] =="True" and bingo[2][i] =="True":
        IsBingo="Yes"
if (bingo[0][0] =="True" and bingo[1][1] =="True" and bingo[2][2] =="True") or (bingo[0][2] =="True" and bingo[1][1] =="True" and bingo[2][0]=="True"):
    IsBingo="Yes"
print(IsBingo)

Measured memory_bytes: 3064
object Main extends App {
	val n = scala.io.StdIn.readInt
	val a = scala.io.StdIn.readLine.split(" ").map(_.toInt).sorted.reverse

	var re = 0

	for(i<-0 until n by +2){
		re += a(i)
	}

	val sum = a.sum
	println(2*re - sum)

}

Measured memory_bytes: 25424
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define true 1
#define false 0
typedef long long ll;
typedef unsigned char Uchar; 

int main(void){

int i = 0,j;
int n,x,t;
  char str[200002];
  
  scanf("%s",str);
  ll sum = 0;
  
  while(str[i] != '\0'){
    //printf("%d,",str[i] - 48);
    sum += ( str[i] - 48);
    ++i;
  }
  int c;
  if(sum % 9 == 0){
printf("Yes\n");
  }else printf("No");
  

return 0;
}

Measured memory_bytes: 1856
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
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;
}
const ll INF=1LL<<60;
ll h[100010];
ll dp[100010];

int main(){
  int N;
  cin>>N;
  for(int i=0;i<N;i++)cin>>h[i];
  for(int i=1;i<100010;i++)dp[i]=INF;
  dp[0]=0;
  for(int i=1;i<N;i++){
    chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
    if(i>1) chmin(dp[i],dp[i-2]+abs(h[i]-h[i-2]));
  }
  cout<<dp[N-1]<<endl;
}

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

#define MAX_INT 0x3f3f3f3f 
#define acc(x) setprecision(x)
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL);

void pr(vector<long long int> &p)
{
	long long int n = p.size();
	for(int i=0;i<n;i++)
	{
		cout << p[i] << " ";
	}
	cout << "\n";
}

int main()
{ 
    #ifndef ONLINE_JUDGE 
        freopen("input.txt", "r", stdin);  
        //freopen("output.txt", "w", stdout); 
    #endif
    boost;
	int n;
	cin >> n;
	vector<long long int> sum;
	vector<long long int> diff;
	for(int i=0;i<n;i++)
	{
		long long int x,y;
		cin >> x >> y;
		sum.push_back(x+y);
		diff.push_back(x-y);
	}
	sort(sum.begin(),sum.end());
	sort(diff.begin(),diff.end());
	long long int ans1 = abs(sum[n-1]-sum[0]);
	long long int ans2 = abs(diff[n-1]-diff[0]);
	long long int ans = max(ans1,ans2);
	cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 6684
#include <bits/stdc++.h>
#define rt "\n"
#define sp " "
#define test(n) cout << "test" << n << endl;
#define fixsp(n) fixed << setprecision(n)
#define defsp(n) defaultfloat << setprecision(n)
#define kyopro ios::sync_with_stdio(false);cin.tie(NULL)
#define MOD 1000000007
#define iikae auto&
#define vector3D(K, N, M, DP) vector<vector<vector<ll>>> DP(K, vector<vector<ll>>(N, vector<ll>(M)));
#define vector4D(K, N, M, O, DP) vector<vector<vector<vector<ll>>>> DP(K, vector<vector<vector<ll>>>(N, vector<vector<ll>>(M, vector<ll>(O))));
#define zenbu(a) a.begin(), a.end()
#define rzenbu(a) a.rbegin(), a.rend()
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define rem(i, N, s) for(ll i{N}; i > s; i--)
using namespace std;using ll = long long;using ld = long double;using P = pair<ll,ll>;
template<typename T> T gcd(T a, T b){return b != 0 ? gcd(b, a % b) : a;}
template<typename T> struct UnionFind{vector<T> par;UnionFind(T n) : par(n, -1){}void init(T n){par.assign(n, -1);}T root(T x){if (par[x] < 0) return x;else return par[x] = root(par[x]);}bool issame(T x, T y){return root(x) == root(y);}bool merge(T x, T y){x = root(x); y = root(y);if(x == y) return false;if(par[x] > par[y]) swap(x, y);par[x] += par[y];par[y] = x;return true;}int size(int x) {return -par[root(x)];}};
template<typename T> ll comb(T N_, T C_) {const int NUM_=400001;static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];if (fact[0]==0) {inv[1]=fact[0]=factr[0]=1;for (int i=2;i<=NUM_;++i) inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%MOD, factr[i]=factr[i-1]*inv[i]%MOD;}if(C_<0 || C_>N_) return 0;return factr[C_]*fact[N_]%MOD*factr[N_-C_]%MOD;}

/* ここからコード開始 */

int main(){
  kyopro;
  ll n;
  cin >> n;
  vector<ll> p(n);
  for(auto&& i : p){
    cin >> i;
  }
  ll sum{};
  rep(i, 1, n-1){
    if(p.at(i) != max({p.at(i-1), p.at(i), p.at(i+1)}) && p.at(i) != min({p.at(i-1), p.at(i), p.at(i+1)})){
      sum++;
    }
  }
  cout << sum << rt;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <list>
#include <cstdio>
#include <cmath>
using namespace std;
int main()
{
	string s = "CODEFESTIVAL2016";
	string ss;
	cin >> ss;
	int cnt = 0;
	for (int i=0; i<ss.length(); i++)
		if (s[i]!=ss[i])
			cnt++;
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
#define int long long

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

    int x;
    cin >> x;

    const int ans = lcm(x, 360) / x;
    cout << ans << endl;
}


Measured memory_bytes: 3648
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1;
	while (b) {
		if (b & 1) { res = res * a%MOD; }
		a = a * a%MOD;
		b >>= 1;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑

int main() {
	long long n, a, b, c, d, e;
	cin >> n >> a >> b >> c >> d >> e;
	long long mon = min({ a,b,c,d,e });
	cout << 4 + (n + mon - 1) / mon << endl;
}

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

using namespace std;

#define MOD 1000000007

typedef long long Int;

Int n, num, cnt[216000];
Int a[216000], fact[216000];
Int c;
Int pow(Int n, Int p){
  if(p == 0)return 1;
  Int res = pow(n,p/2);
  res *= res;res %= MOD;
  if(p%2)res *= n;
  return res % MOD;
}

Int inv(Int x){
  return pow(x, MOD-2);
}

Int init(){
  fact[0] = 1;
  for(int i = 1;i < 216000;i++)fact[i] = fact[i-1]*i % MOD;
}

Int nCk(Int n, Int k){
  if(k < 0 || k > n)return 0;
  Int res = fact[n];
  res *= inv(fact[n-k]);res %= MOD;
  res *= inv(fact[k]);res %= MOD;
  return res;
}

Int solve(Int x){
  Int res = nCk(n+1, x) - nCk(c, x-1);res %= MOD;
  if(res < 0)res += MOD;
  return res;
}

int main(){
  init();
  cin >> n;
  for(int i = 0;i <= n;i++){
    cin >> a[i];
    if(cnt[a[i]]++){
      num = a[i];
    }
  }
  Int l = -1, r = -1;
  for(int i = 0;i <= n;i++){
    if(a[i] == num){
      if(l == -1)l = i;
      else r = i;
    }
  }
  c = l + n - r;
  for(int i = 1;i <= n+1;i++){
    cout << solve(i) << endl;
  }
  return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

template<typename T>
class RangeAddQuery {
public:
    explicit RangeAddQuery(int n) : N(calcN_(n)) {
        mVal.assign(2*N+1, 0);
    }
    void update(int l, int r, T value){
        updateImpl_(l, r, value, 0, 0, N);
    }
    T get(int idx){
        int i = N + idx - 1;
        auto res = mVal[i];
        while(i > 0){
            i = (i-1)/2;
            res += mVal[i];
        }
        return res;
    }
private:
    int calcN_(int n){
        int res = 1;
        while(res < n) res *= 2;
        return res;
    }
    void updateImpl_(int l, int r, T value, int idx, int rangeL, int rangeR){
        if(r <= rangeL || rangeR <= l) return;
        if(l <= rangeL && rangeR <= r){
            mVal[idx] += value;
        } else {
            int rangeM = (rangeL+rangeR)/2;
            updateImpl_(l, r, value, 2*idx+1, rangeL, rangeM);
            updateImpl_(l, r, value, 2*idx+2, rangeM, rangeR);
        }
    }
    const int N;
    vector<T> mVal; 
};

int main(){
    int N, D, A;
    while(cin >> N >> D >> A){     
        RangeAddQuery<long long> raq(N);
        vector<pair<long long, long long>> vp(N);
        for(auto& p : vp) cin >> p.first >> p.second;
        sort(vp.begin(), vp.end());
        for(int i=0;i<N;i++){
            raq.update(i, i+1, vp[i].second);
        }
        long long res = 0;
        int end = 0;
        for(int i=0;i<N;i++){
            while(end < N && vp[end].first <= vp[i].first + 2*D) ++end;
            int cur = raq.get(i);
            if(cur <= 0) continue;
            long long req = (cur + A - 1) / A;
            raq.update(i, end, -(req*A));
            res += req;
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 7424
#include<algorithm>
#include<bits/allocator.h>
#include<bits/basic_ios.h>
#include<bits/basic_string.h>
#include<bits/basic_string.tcc>
#include<bits/c++config.h>
#include<bits/char_traits.h>
#include<bits/cpp_type_traits.h>
#include<bits/cxxabi_forced.h>
#include<bits/ios_base.h>
#include<bits/locale_classes.h>
#include<bits/localefwd.h>
#include<bits/ostream_insert.h>
#include<bits/postypes.h>
#include<bits/range_access.h>
#include<bits/stl_algobase.h>
#include<bits/stl_function.h>
#include<bits/stl_iterator.h>
#include<bits/stl_iterator_base_funcs.h>
#include<bits/stl_iterator_base_types.h>
#include<bits/stringfwd.h>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwchar>
#include<cwctype>
#include<debug/debug.h>
#include<deque>
#include<exception>
#include<ext/atomicity.h>
#include<ext/numeric_traits.h>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<valarray>
#include<vector>
using namespace std;
int digit(int n){
	int h=0;
	while (n!=0){
		h+=n%10;
		n/=10;
	}
	return h;
}
int main()
{
	int n,a,b,sum=0;
	cin>>n>>a>>b;
	for (int i=1;i<=n;i++) if(digit(i)<=b&&digit(i)>=a) sum+=i;
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

int ans, N;
char S[55];

int main(void) {
    scanf("%d", &N);
    scanf("%s", S);

    rep(i, 0, N-2) {
        if (S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C') ans++;
    }
   

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

	return 0;
}


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

int main(){
  int N,answer=1;
  cin >> N;
  vector<int> t(N);
  for(int i=0; i<N; i++){
    cin >> t.at(i);
  }
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  int x=t.at(0);
  for(int j=0; j<N; j++){
    if(t.at(j)<x){
      answer++;
      x=t.at(j);
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <unordered_set>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <map>
#include <ctime>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 100001
#define MACRO(a) for(int a = 1; a < 1001; a++)

using namespace std;

int alpha[26];

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

	vector<int> vec1, vec2;
	string str; cin >> str;
	for (int i = 0; i < str.size(); i++)
		alpha[str[i] - 'a'] += 1;
	for (int i = 0; i < 26; i++)
		vec1.push_back(alpha[i]);
	for (int i = 0; i < 26; i++)
		alpha[i] = 0;
	cin >> str;
	for (int i = 0; i < str.size(); i++)
		alpha[str[i] - 'a'] += 1;
	for (int i = 0; i < 26; i++)
		vec2.push_back(alpha[i]);
	sort(vec1.begin(), vec1.end());
	sort(vec2.begin(), vec2.end());

	for (int i = 0; i < vec1.size(); i++)
	{
		if (vec1[i] != vec2[i])
		{
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
	return 0;
}

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

using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define all(v) v.begin(),v.end()
#define ve vector
#define vi vector<int>
#define vi2 vector<vi>
#define vl vector<long long>
#define vl2 vector<vl>

template <class T> T maxAny(T a, T b){
    if(a > b) return a;
    else return b;
}

template <class T> T minAny(T a, T b){
    if(a > b) return b;
    else return a;
}

int main(){
    string n;
    cin >> n;
    int sum = 0;
    rep(i, n.size()){
        sum += n[i]-'0';
        sum %= 9;
    }
    if(sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3756
# frozen_string_literal: true

_ = gets.to_i
# group_byで数字ごとに集計する
a = gets.split.map(&:to_i).group_by(&:itself).map { |k, v| [k, v.count] }.to_h
sum = a.map { |k, v| k * v }.sum
q = gets.to_i
b = []
c = []
(1..q).map { |_n| tmp = gets.split.map(&:to_i); b << tmp[0]; c << tmp[1] }

q.times do |n|
  unless a[b[n]].nil?
    diff = a[b[n]] * (c[n] - b[n])
    sum += diff
    if a[c[n]].nil?
      a[c[n]] = a[b[n]]
    else
      a[c[n]] += a[b[n]]
    end
    a.delete(b[n])
  end
  # pp a
  puts sum
end


Measured memory_bytes: 35284
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;
  cin >> a >> b;
  if(a + b == 24)
    cout << 0 << endl;
  else if(a + b < 24)
    cout << a + b << endl;
  else 
    cout << a + b - 24 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
using namespace std;
typedef long long ll;
const int INF=1000000000;
const int MOD=1000000007;

int main()
{
 ll n;
 cin >> n;
  ll ans[100000]={};
  for(int x=1;x<101;x++){
      for(int y=1;y<101;y++){
          for(int z=1;z<101;z++){
            ans[x*x+y*y+z*z+x*y+y*z+z*x]++;
  		}
  	}
  }
 for(int i=1;i<n+1;i++){
   cout << ans[i] << endl;
 }
  return 0;
}

Measured memory_bytes: 4304
#include<bits/stdc++.h>
using namespace std;
int mod=1000000007,dp[100001];
bool a[100001];
int main(){
	dp[0]=1;
    int i,n,m,x;
    cin>>n>>m;
    for(i=0;i<=n;i++){
    	a[i]=1;
	}
    if(m>0){
        for(i=0;i<m;i++){
            cin>>x;
            a[x]=0;
        }
    }
    if(a[1]==1){
    	dp[1]=1;
	}else dp[1]=0;
    for(i=2;i<=n;i++){
        dp[i]=0;
        if(a[i]==1){
        	dp[i]+=dp[i-1]%mod+dp[i-2]%mod;
		}
        dp[i]%=mod;
    }
   	cout<<dp[n];
   	return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<algorithm>
#include<cstdint>
#include<set>

int const MAXN = 2e5;
int a[MAXN], b[MAXN];
int c[MAXN-1], d[MAXN+MAXN-2];

int64_t const B1 = 1e8+7;
int64_t const B2 = 1e9+7;

int main() {
  int N; std::cin >> N;
  for(int i = 0; i < N; ++i) std::cin >> a[i];
  for(int i = 0; i < N; ++i) std::cin >> b[i];
  for(int i = 0; i < N-1; ++i) c[i] = a[i]^a[i+1];
  for(int i = 0; i < 2*N-2; ++i) d[i] = b[i%N]^b[(i+1)%N];
  std::set<int> ans;
  // Rolling-Hash
  int64_t c1 = 0, c2 = 0, d1 = 0, d2 = 0, bP1 = 1, bP2 = 1;
  for(int i = 0; i < N-1; ++i) {
    c1 = c1*B1 + c[i];
    c2 = c2*B2 + c[i];
    d1 = d1*B1 + d[i];
    d2 = d2*B2 + d[i];
    bP1 *= B1;
    bP2 *= B2;
  }
  if(c1 == d1 && c2 == d2) ans.insert(0);
  for(int i = 1; i < N; ++i) {
    d1 = d1*B1 + d[N-2+i] - d[i-1]*bP1;
    d2 = d2*B2 + d[N-2+i] - d[i-1]*bP2;
    if(c1 == d1 && c2 == d2) ans.insert(N-i);
  }
  // ans
  for(auto k: ans) {
    int x = a[0]^b[(N-k)%N];
    std::cout << k << " " << x << std::endl;
  }
  return 0;
}



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

pair<int, int> a[111111];
char res[5];

int main(void)
{
	int n, m, i, ans = 0, penalty = 0;

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

	while (m--)
	{
		int id;

		scanf("%d %s", &id, &res[1]);

		if (strcmp(&res[1], "AC") == 0)
			a[id].first = 1;
		else
		{
			if (!a[id].first)
				a[id].second++;
		}
	}

	for (i = 1; i <= n; i++)
		if (a[i].first)
		{
			++ans;
			penalty += a[i].second;
		}

	printf("%d %d", ans, penalty);
	return 0;
}

Measured memory_bytes: 1024
# include <iostream>
using namespace std;
const int N=56;
int a[N]={0,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};
int n;
void work (void)
{
	int i;
	for (i=1;i<=n;i++)
	cout<<a[i]<<" ";
}
int main (void)
{
	cin>>n;
	work ();
	return 0;
}


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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
	string s, t;
    while (cin >> s >> t) {
        int flag = 0;
    	int tsize = t.size(), ssize = s.size();
   		for (int i = 0; i < ssize; i++) {
        	char a = s[ssize - 1];
        	s = a + s;
        	s = s.substr(0, ssize);
        	if (s == t) {
            	flag = 1, cout << "Yes\n";
            	break;
        	}
    	}
    	if (flag == 0) cout << "No\n";
    }
    return 0;
}

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

int main()
{
  int64_t n,k,ans;
  ans=0;
  cin>>n>>k;
  vector<int64_t> hp(n);
  for(int i=0;i<n;i++)
  {
    cin>>hp.at(i);
  }
  sort(hp.begin(), hp.end());
  if(n<=k)
    cout<<ans<<endl;
  else
  {
    for(int i=0;i<k;i++)
    {
      hp.pop_back();
    }
    for(int i=0;i<n-k;i++)
    {
      ans+=hp.at(i);
    }
    cout<<ans<<endl;
  }
}

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

int main() {
  int N, L, R;
  int Sum = 0;
  cin >> N;
  
  for ( int i = 0 ; i < N ; i++ ) {
    cin >> L >> R;
    Sum = Sum + R - L + 1;
  }
  
  cout << Sum << endl;
}


Measured memory_bytes: 256
fun intList() = readLine()?.split(" ")?.map(String::toInt) ?: TODO()
fun longList() = readLine()?.split(" ")?.map(String::toLong) ?: TODO()
fun main() {
    val (x, y, a, b, c) = intList()
    val p = longList().sorted()
    val q = longList().sorted()
    val r = longList()
    val apples = p.takeLast(x) + q.takeLast((y)) + r
    val t = apples.sorted().takeLast(x + y).sum()
    println(t.toString())
}


Measured memory_bytes: 70680
#include<bits/stdc++.h>
using namespace std;
int main()
{


        string s;
        cin>>s;
        int m=s.length(),c=0,i,j;
        for(i=0;i<m;i++)
        {
            if(s[i]!=s[m -1-i])
            {
                c++;
            }

        }
        cout<<c/2<<endl;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<P> vp;

const int MAX_LEN = 1000005;

string s;

void dfs(int& cur, string& t)
{
    if(cur >= len(s)-1){
        return;
    }
    while(cur < len(s)-1){
        if(isdigit(s[cur])){
            int st = cur;
            while(isdigit(s[cur])){
                cur++;
            }
            int num = stoi(s.substr(st,cur-st));
            if(isalpha(s[cur])){
                rep(i,num){
                    t.pb(s[cur]);
                }
                cur++;
            }else{
                if(cur >= len(s)-1){
                    return;
                }
                cur++;
                string u;
                dfs(cur,u);
                rep(i,num){
                    t += u;
                    if(len(t) >= MAX_LEN){
                        return;
                    }
                }
            }
        }else{
            while(isalpha(s[cur])){
                t.pb(s[cur]);
                cur++;
            }
            if(s[cur] == ')'){
                cur++;
                return;
            }
        }
    }
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1){
        int n;
        cin >> s >> n;
        if(s == "0" && n == 0){
            break;
        }
        s.pb('%');
        string t;
        int num = 0;
        dfs(num,t);
        if(len(t) <= n){
            cout << "0\n";
        }else{
            cout << t[n] << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 7868
import numpy as np
N = int(input())
T, A = (int(x) for x in input().split())

result = [int(N) for N in input().split()]

list = []
for num in range(N):
    list.append(abs(T-0.006*result[num]-A))

m = np.argmin(list) + 1

print(m)

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }


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

    int N; cin >> N;
    double a = ceil(N / 1.08);
    if (N <= a * 1.08 && a * 1.08 < N + 1) {
        cout << a << endl;
    } else {
        cout << ":(" << endl;
    }
}

Measured memory_bytes: 256
// atcoder/abc138/E/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

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

  string s, t;
  while (cin >> s >> t) {
    {
      set<char> vis(s.begin(), s.end());
      bool f = true;
      each (c, t) f = f && vis.count(c);
      unless (f) {
        cout << -1 << endl;
        continue;
      }
    }

    const int N = 1e5 + 5;
    static map<char, lli> next[N];
    static map<char, lli> prev[N];
    for (int i = 0; i < N; ++i) {
      prev[i].clear();
      next[i].clear();
    }
    map<char, lli> last;

    last.clear();
    for (int i = s.size() - 1; 0 <= i; --i) {
      next[i] = last;
      last[s[i]] = i;
    }

    last.clear();
    for (int i = 0; i < s.size(); ++i) {
      prev[i] = last;
      if (last.count(s[i]) == 0) {
        last[s[i]] = i;
      }
    }

    lli x = 0, y = 0, z = 0;
    if (s[0] != t[0]) {
      char c = t[0];
      if (next[x].count(c)) {
        x = next[x][c];
      } else if (prev[x].count(c)) {
        x = prev[x][c];
      } else {
        x = x;
      }
      y = x;
    }

    for (int i = 1; i < t.size(); ++i) {
      char c = t[i];
      if (next[x].count(c)) {
        y = next[x][c];
      } else if (prev[x].count(c)) {
        y = prev[x][c];
        ++z;
      } else {
        y = x;
        ++z;
      }
      x = y;
    }
    cout << y + z * s.size() + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 334800
def gcd(x, y):
    while y > 0:
        r = x%y
        x = y
        y = r
    return x

def lcm(x, y):
    return x//gcd(x, y)*y

n = int(input())
a = list(map(int, input().split()))

l = 1
for x in a:
    l = lcm(x, l)

ans = 0
for x in a:
    ans += l//x

print(ans%(10**9+7))

Measured memory_bytes: 4084
#!/usr/bin/env python3
a, b, c = map(int, input().split())
answer = 0
while not (a == b == c):
    a, b, c = sorted([ a, b, c ])
    if a + 2 <= c:
        a += 2
    else:
        a += 1
        b += 1
    answer += 1
print(answer)


Measured memory_bytes: 2940
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    N = int(input())
    items = list(sorted(list(Counter(map(int, input().split())).items())))
    ans = 0
    for i in range(len(items)):
        n = items[i][1]
        if i >= 1:
            if abs(items[i][0] - items[i - 1][0]) == 1:
                n += items[i - 1][1]
        if i < len(items) - 1:
            if abs(items[i][0] - items[i + 1][0]) == 1:
                n += items[i + 1][1]
        ans = max(ans, n)

    print(ans)


if __name__ == '__main__':
    main()


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

int main(void){

char s[200001],t[200001];

scanf("%s",&s);scanf("%s",&t);

int i=0,count=0;

if(strlen(s)==strlen(t)){
while(s[i]!='\0'||t[i]!='\0'){
if(s[i]!=t[i]){count++;}
i++;
}
}

printf("%d",count);

return 0;
}


Measured memory_bytes: 2092
#include <bits/stdc++.h> 
using namespace std; 
  
// function to construct new array 
void constructXOR(int A[], int n) 
{ 
    // calculate xor of array 
    int XOR = 0; 
    for (int i = 0; i < n; i++) 
        XOR ^= A[i]; 
  
    // update array 
    for (int i = 0; i < n; i++) 
        A[i] = XOR ^ A[i]; 
} 
  
// Driver code 
int main() 
{ 
    int n;
    cin>>n;
    int A[n];
    for (int i=0;i<n;i++){
        cin>>A[i];
    }
    constructXOR(A, n); 
  
    // print result 
    for (int i = 0; i < n; i++) 
        cout << A[i] << " "; 
    return 0; 
} 

Measured memory_bytes: 4380
#include <iostream>
using namespace std;
int main(void){
    int N,A;
    cin >> N >> A;
    int L = A;
    int R = N + A - 1;
    int ate;
    if(L >= 0){
        ate = L;
    }else if(R <= 0){
        ate = R;
    }else{
        ate = 0;
    }
    
    cout << (L + R) * N / 2 - ate<< endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
int main(){   
   int a,b,k;
   cin>>a>>b>>k;
   vector<int> s;
   rep(i,min(a,b)){
      if(a%(i+1)==0 && b%(i+1)==0){
         s.push_back(i+1);
         }
      }

   rep(i,k-1){
      s.pop_back();
   }
   cout<<s.back();

return 0;
}

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

#define int long long

const int N = 1e5+5;
int a[N];
vector<int> v[N];

int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n, m;
	cin >> n >> m;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	int tot = 0;
	for(int i = 1; i <= m; i++) {
		int x, y;
		cin >> x >> y;
		v[x].push_back(y);
		v[y].push_back(x);
	}

	for(int i = 1; i <= n; i++) {
		bool flag = true;
		for(int it : v[i]) {
			if(a[i] <= a[it]) {
				flag = false;
			} 
		}
		if(flag)tot++;
	}

	cout << tot << '\n';
				
	return 0;
}


Measured memory_bytes: 10284
#include <bits/stdc++.h>
// iostream is too mainstream
#include <cstdio>
// bitch please
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <cmath>
#include <iomanip>
#include <time.h>
#define dibs reserve
#define OVER9000 1234567890
#define ALL_THE(CAKE,LIE) for(auto LIE =CAKE.begin(); LIE != CAKE.end(); LIE++)
#define tisic 47
#define soclose 1e-8
#define chocolate win
// so much chocolate
#define patkan 9
#define ff first
#define ss second
#define abs(x) (((x) < 0)?-(x):(x))
#define uint unsigned int
#define dbl long double
#define pi 3.14159265358979323846
using namespace std;
// mylittledoge

using cat = long long;

#ifdef DONLINE_JUDGE
	// palindromic tree is better than splay tree!
	#define lld I64d
#endif

int main() {
	cin.sync_with_stdio(0);
	cin.tie(0);
	cout << fixed << setprecision(10);
	int N;
	cin >> N;
	vector<int> A(N);
	for(int i = 0; i < N; i++) cin >> A[i];
	vector<cat> S(N+1, 0), Si(N+1, 0);
	for(int i = 0; i < N; i++) S[i+1] = S[i]+A[i];
	for(int i = N-1; i >= 0; i--) Si[i] = Si[i+1]+A[i];
	vector<cat> less2(N+1), less2i(N+1);
	int a = 0;
	for(int i = 0; i <= N; i++) {
		while(a < i && 2*S[a+1] <= S[i]) a++;
		less2[i] = S[a];
		if(a < i) less2[i] = max(less2[i], S[i]-S[a+1]);
	}
	a = N;
	for(int i = N; i >= 0; i--) {
		while(a > i && 2*Si[a-1] <= Si[i]) a--;
		less2i[i] = Si[a];
		if(a > i) less2i[i] = max(less2i[i], Si[i]-Si[a-1]);
	}
	cat ans = -1;
	for(int i = 0; i < N; i++) {
		cat v[4];
		v[0] = less2[i], v[1] = S[i]-less2[i];
		v[2] = less2i[i], v[3] = Si[i]-less2i[i];
		cat mx = v[0], mi = v[0];
		for(int j = 1; j < 4; j++) mx = max(mx, v[j]);
		for(int j = 1; j < 4; j++) mi = min(mi, v[j]);
		if(ans == -1 || ans > mx-mi) ans = mx-mi;
	}
	cout << ans << "\n";
	return 0;}

// look at my code
// my code is amazing


Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ft first
#define se second
#define endll "\n"
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll a,b,c,d;cin>>a>>b>>c>>d;
    int a1=ceil((double)c/b);
    int a2=ceil((double)a/d);
    if(a1<=a2){
        cout<<"Yes"<<endll;
    }
    else cout<<"No"<<endll;
}



Measured memory_bytes: 3652
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(15000)
n = int(sys.stdin.readline())

ret = []
inp = sys.stdin.readlines()
G = [None]*(n)
d = [0]*(n)
f = [0]*(n)
def dfs(i,t):
  if d[i] != 0:
    return t
  t = t+1
  d[i] = t
  for j in G[i]:
    t = dfs(j,t)
  f[i] = t+1
  return f[i]
for i in range(n):
  v = list(map(int,inp[i].split()))
  G[v[0]-1] = list(map(lambda x: int(x-1),v[2:]))
#print(G)
t = 0
for j in range(n):
  t = dfs(j,t)

for i in range(n):
  print(i+1,d[i],f[i])


Measured memory_bytes: 5656
#include <bits/stdc++.h>
using namespace std;
 
int main() {

vector<int> abc(3);

for(int i=0;i<3;i++){
  cin >> abc.at(i);
}

sort(abc.begin(),abc.end());
  
if(abc.at(0)==5&&abc.at(1)==5&&abc.at(2)==7) cout << "YES" << endl;
  
else cout << "NO" << endl;
    
return 0;
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;
 
int main() {
    int N, K; cin >> N >> K;

    if(K == 1) {
        cout << 0 << endl;
    }
    else {
        int ma = N - (K - 1);
        int mi = 1;
        cout << ma - mi << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll n;cin>>n;
    vector<ll>t(n+1);
    t[0]=1;
    REP(i,1,n+1)t[i]=t[i-1]*i;
    set<ll>st1,st2;
    ll a=1,b=1;
    vector<ll>p(n),q(n);
    rep(i,n)cin>>p[i];
    rep(i,n)cin>>q[i];
    rep(i,n-1){
        ll cnt=0;
        REP(j,1,p[i]){
            if(st1.find(j)==st1.end())cnt++;
        }
        st1.insert(p[i]);
        a+=t[n-1-i]*cnt;
    }
    rep(i,n-1){
        ll cnt=0;
        REP(j,1,q[i]){
            if(st2.find(j)==st2.end())cnt++;
        }
        st2.insert(q[i]);
        b+=t[n-1-i]*cnt;
    }
    cout<<abs(a-b)<<endl;
}

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

signed main(){
	long long k;
	cin>>k;
	long long ans=0;
	for(long long i=2;i<=k+1;i++) {
		ans=ans*10+7;
		if(ans%k==0){
			cout<<i-1;
			return 0;
		}
		ans=ans%k;
	}
	cout<<"-1";
	return 0;
}


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


pair<double,double> u_search(pair<double,double> x,pair<double,double> y){
    double rad60 = M_PI * 60.0 / 180.0;
    double sin60 = sin(rad60),cos60 = cos(rad60);
    pair<double,double> dif = make_pair(y.first - x.first,y.second - x.second);
    double kaiten_x = dif.first * cos60 - dif.second * sin60;
    double kaiten_y = dif.first * sin60 + dif.second * cos60;
    pair<double,double> u = make_pair(y.first + kaiten_x,y.second+kaiten_y);
    return u;
}


void korh(pair<double,double>p1,pair<double,double>p2,int n,int count){
    count++;
    if(count <= n){
        pair<double,double> s,u,t;
        s.first = (p1.first * 2.0 + p2.first * 1.0) / 3.0;
        s.second = (p1.second * 2.0 + p2.second * 1.0) / 3.0;
        korh(p1,s,n,count);
        printf("%.8f %.8f\n",s.first,s.second);
        u = u_search(p1,s);
        korh(s,u,n,count);
        printf("%.8f %.8f\n",u.first,u.second);
        t.first = (p1.first * 1.0 + p2.first * 2.0) / 3.0;
        t.second = (p1.second * 1.0 + p2.second * 2.0) / 3.0;
        korh(u,t,n,count);
        printf("%.8f %.8f\n",t.first,t.second);
        korh(t,p2,n,count);
    }
}



int main(){
    int n;
    cin >> n;
    pair<double,double> p1 = make_pair(0,0);
    pair<double,double> p2 = make_pair(100,0);
    int count = 0;
    printf("%.8f %.8f\n",p1.first,p1.second);
    korh(p1,p2,n,count);
    printf("%.8f %.8f\n",p2.first,p2.second);
}


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

typedef long long LL;

const int N = 100;
const int MOD = 1e9 + 7;

char temp[2][N], s[2][N];

int main()
{
    int n;
    cin>>n;
    cin>>temp[0]>>temp[1];

    s[0][0] = temp[0][0];
    s[1][0] = temp[1][0];

    int j = 1;
    for(int i = 1; i < n; i++)
    {
        if(temp[0][i] == temp[0][i-1])
            continue;
        s[0][j] = temp[0][i];
        s[1][j] = temp[1][i];
        j++;
    }

    n = j;
    s[0][n] = s[1][n] = '\0';

    //cout<<n<<"\n"<<s[0]<<"\n"<<s[1]<<"\n";

    LL ans = (s[0][0] == s[1][0] ? 3 : 3 * 2);
    for(int i = 1; i < n; i++)
    {
        if(s[0][i] == s[1][i])
        {
            if(s[0][i-1] == s[1][i-1])
            {
                ans = (ans * 2) % MOD;
            }
            else
            {
                ans = (ans * 1) % MOD;
            }
        }
        else
        {
            if(s[0][i-1] == s[1][i-1])
            {
                ans = (ans * 2) % MOD;
            }
            else
            {
                ans = (ans * 3) % MOD;
            }
        }
    }

    cout<<ans % MOD<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int  main(){
 int a,b;
 cin >> a>>b;
 int c[a];
 int count =0;
 rep(i,a){
    cin >> c[i];
 }
 for(int i=0;i<a;i++){
    if(c[i]>=b){
       count ++;
    }
 }
 cout << count << endl;
return 0;
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITP1_5_B
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int[] line;

            while (true)
            {
                line = ReadIntAr();
                if (line[0] == 0 && line[1] == 0) return;

                for (int i = 0; i < line[0]; i++)
                {
                    string tmp;
                    if (i == 0 || i == line[0] - 1)
                    {
                        tmp = new string('#', line[1]);
                    }
                    else
                    {
                        tmp = "#";
                        tmp += new string('.', line[1] - 2);
                        tmp += "#";
                    }
                    Console.WriteLine("{0}",tmp);
                }
                Console.WriteLine("");
            }


        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }

    }

}



Measured memory_bytes: 17936
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define zep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	
	ll x, a, b;
	cin >> x >> a >> b;
	print((x-a)%b)
	return 0;
}

Measured memory_bytes: 256
p = 10**9+7
def pow(x,m):
    if m==0:
        return 1
    if m==1:
        return x
    if m%2==0:
        return (pow(x,m//2)**2)%p
    else:
        return (x*pow(x,(m-1)//2)**2)%p
L = input().strip()
N = len(L)
C = [0 for _ in range(N)]
for i in range(1,N):
    if L[i-1]=="1":
        C[i] = C[i-1]+1
    else:
        C[i] = C[i-1]
tot = 0
for i in range(N):
    if L[i]=="1":
        tot = (tot+pow(3,N-1-i)*pow(2,C[i]))%p
if L[N-1]=="0":
    tot = (tot+pow(2,C[N-1]))%p
else:
    tot = (tot+pow(2,C[N-1]+1))%p
print(tot)

Measured memory_bytes: 131744
N,T = map(int,input().split())
t = list(map(int,input().split()))
def f(t,t1):
    return min(t - t1,T)
t.append(0)
t.sort()
ans = 0
for i in range(N):
    x = t[i+1]
    y = t[i]
    ans += f(x,y)
ans += T
print(ans)

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

int ppow(int a,int b){
	int res=1;
	while(b){
		if(b&1)res*=a;
		a*=a;
		b>>=1;
	}
	return res;
}

int main(){
	int a,n,m;cin>>a>>n>>m;
	int x;
	int cnt=0;
	for(int i=1;(x=ppow(i+a,n))<=m;i++){
		int sum=0;
		int a=x;
		while(a){
			sum+=a%10;
			a/=10;
		}
		if(sum==i)cnt++;
	}
	cout<<cnt<<endl;
}



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

int main() {
	ll n,m,l[100010];
	cin>>n>>m;
	vector<vector<ll>>a(100010);
	for(ll i=0;i<n;i++){
		a[i].push_back(i);
		l[i]=i;
	}
	for(ll i=0;i<m;i++){
		ll x,y,z;
		cin>>x>>y>>z;
		x--;y--;
		// from x to y
		x=l[x],y=l[y];
		if(x==y){
			continue;
		}
		if(a[x].size()>a[y].size()){
			swap(x,y);
		}
		while(a[x].size()!=0){
			ll now=a[x].back();
			//cout << now<<" "<<i<<endl;
			
			a[x].pop_back();
			l[now]=y;
			a[y].push_back(now);
		}
	}
	ll cnt=0;
	for(ll i=0;i<n;i++){
		if(a[i].size()){
			cnt++;
		}
	}
	cout <<cnt;
	// your code goes here
	return 0;
}

Measured memory_bytes: 13688
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////

int main() {
	ll A[3];
	rep(i, 3) cin >> A[i];
	sort(A, A + 3);

	if (A[0] == 5 && A[1] == 5 && A[2] == 7) { cout << "YES"; }
	else { cout << "NO"; }

	system("PAUSE");
}

Measured memory_bytes: 504
import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;
int read() { return readln.chomp.to!int; }
int[] reads() { return readln.split.to!(int[]); }


void main() {
    readln;
    writeln(reads.map!(i => i=i-1).sum);
}

Measured memory_bytes: 380
N = int(input())
xy = [[] for i in range(N)]

for i in range(N):
    A = int(input())
    for j in range(A):
        x, y = map(int, input().split())
        xy[i].append([x, y])

res = 0
for i in range(2 ** N):
    cnt = 0
    for j in range(N):
        ok = True
        if i >> j & 1:
            cnt += 1
            for k in range(len(xy[j])):
                if (i >> (xy[j][k][0] - 1) & 1) != xy[j][k][1]:
                    ok = False
                    break
        if ok == False:
            cnt = 0
            break
    res = max(res, cnt)
print(res)


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

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

    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    A--, B--, C--, D--;
    string S;
    cin >> S;

    for (int i = 1; i < N; ++i) {
        if (S.at(i - 1) == '#' && S.at(i) == '#' && ((A <= i && i <= C) || B <= i && i <= D)) {
            cout << "No" << endl;
            exit(0);
        }
    }
    if (C > D) {
        for (int i = B; i <= D; ++i) {
            if (S.at(i - 1) == '.' && S.at(i) == '.' && S.at(i + 1) == '.') {
                cout << "Yes" << endl;
                exit(0);
            }
        }
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 592
def main():
# input
    n = int(input())
    b = [i for i in map(int, input().split())]

# loop
    ans = b[0]
    for i in range(n-2):
        ans += min(b[i], b[i+1])
    ans += b[-1]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

//重みある時
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

int main() {
    string s;
    cin >> s;
    int cnt = 0;
    for (int i = 0; i < s.size(); ++i) {
        if(s[i] != s[s.size()-1-i]) cnt++;
    }
    cout << cnt/2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <complex>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
typedef double D;
typedef complex<D> P;
struct edge{
	int u,v;
	D dist;
};
bool comp(const edge &l,const edge &r){
	return l.dist>r.dist;
}
vector<edge> es;
int N,M;
P p[10000];
int par[10000];
void init(int n){rep(i,n) par[i]=i;}
int find(int x){
	if(x==par[x]) return x;
	return par[x]=find(par[x]);
}
bool same(int x,int y){return find(x)==find(y);}
void unite(int x,int y){
	x=find(x),y=find(y);
	par[x]=y;
}
int main(){
	cin>>N>>M;
	rep(i,N){
		D x,y;
		cin>>x>>y;
		p[i]=P(x,y);
	}
	rep(i,M){
		int a,b;
		cin>>a>>b;
		a--,b--;
		es.pb({a,b,abs(p[a]-p[b])});
	}
	sort(all(es),comp);
	init(N);
	D ans=0;
	for(edge e:es){
		if(same(e.u,e.v)) ans+=e.dist;
		else unite(e.u,e.v);
	}
	printf("%.12f\n",ans);
}

Measured memory_bytes: 2024
n = int(input())
s = str(input())
ans_max = 0
for i in range(n):
    ans = 0
    s1 = s[0:i]
    s2 = s[i:n]
    for k in range(i):
        if s1[k] in s2:
             s1 = s1.replace(s1[k]," ")
             ans += 1
    if ans_max < ans:
        ans_max = ans
print(ans_max)

Measured memory_bytes: 3064
n = int(input())
s = input()
count_list = []
for i in range(1,n):
    count = 0
    left_list = set(s[:i])
    right_list = set(s[i:])
    for moji in left_list:
        if moji in right_list:
            count += 1
    count_list.append(count)
print(max(count_list))

Measured memory_bytes: 3060