akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.lang.*;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int[] alp = new int[26];
		for (int i = 0; i < s.length(); i++) {
			alp[s.charAt(i) - 'a']++;
		}
		int count = 10000;
		for (int i = 0; i < 26; i++) {
			String ss = s;
			if (alp[i] != 0) {
				int cou = 0;
				while (contain(ss, (char) ('a' + i))) {
					ss = change(ss, (char) ('a' + i));
					cou++;
				}
				count = Math.min(cou, count);
			}
		}
		System.out.println(count);
	}
	static String change(String s, char a) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < s.length() - 1; i++) {
			if (s.charAt(i) == a || s.charAt(i + 1) == a) {
				sb.append(a);
			} else {
				sb.append(s.charAt(i));
			}
		}
		return sb.toString();
	}
	static boolean contain(String s, char a) {
		for (int i = 0; i < s.length(); i++) {
			if (s.charAt(i) != a) {
				return true;
			}
		}
		return false;
	}
}

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


int main() {
  int n;
  cin >> n;
  
   cout<<n*(n+1)/2<<endl;
 
}



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

const int N = 1e5 + 5, mod = 1e9 + 7;

int main()
{
    //ios::sync_with_stdio(false);cin.tie(nullptr);ios_base::sync_with_stdio(false);
    int n, x, ans = 0;
    multiset<int> s;
    cin >> n;
    while (n--)
    {
        cin >> x;
        if (s.empty())
            s.insert(x),
            ans++;
        else
        {
            auto it = s.lower_bound(x);
            if (it == s.end())
            {
                it--;
                s.erase(it);
                s.insert(x);
            }
            else
            {
                if (it == s.begin())
                {
                    if (*it < x)
                        s.erase(it),
                        s.insert(x);
                    else
                        s.insert(x),
                        ans++;
                }
                else
                {
                    it--;
                    s.erase(it),
                    s.insert(x);
                }
            }
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define SHOW(x) cout << #x << ": " << x << endl;
template<class T> ll sumArr(const T& a){ return accumulate(all(a), 0LL);}
template<class T> auto minArr(const T& a){ return *min_element(all(a));}
template<class T> auto maxArr(const T& a){ return *max_element(all(a));}
template<class T> void DEBUG_PRINT(T tmp){cout<<tmp<<endl;}
template<class T1,class... T2> void DEBUG_PRINT(T1 tmp,T2... tmp2){cout<<tmp<<" ";DEBUG_PRINT(tmp2...);}
ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;


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

    int x,n,ans = iINF,dis = iINF;
    cin>>x>>n;
    vector<int>p(n);
    rep(i,n)cin>>p[i];

    rep(i,-1,102){
        bool flag = false;
        rep(j,n){
            if(i == p[j])flag = true;
        }
        if(flag)continue;
        if(dis > abs(x - i)){
            ans = i;
            dis = abs(x - i);
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

int n;
int left(int i) {
  return 2*i;
}
int right(int i) {
  return 2*i+1;
}
void maxHeapify(vector<int> &A, int i) {
  int l = left(i);
  int r = right(i);
  int largest = i;
  // A[largest] = max(A[i],A[l],A[r])
  if(l <= n) {
    if(A[l] > A[i])
      largest = l;
  }
  if(r <= n) {
    if(A[r] > A[largest])
      largest = r;
  }

  if(largest != i) {
    swap(A[i],A[largest]);
    // for leaf...
    maxHeapify(A,largest);
  }
}
void buildMaxHeap(vector<int> &A) {
  for(int i=n/2;i>=1;i--) {
    maxHeapify(A,i);
  }
}
int main() {
  cin >> n;
  vector<int> heaps(n+1);
  for(int i=1;i<=n;i++) {
    cin >> heaps[i];
  }
  buildMaxHeap(heaps);
  for(int i=1;i<=n;i++) {
    cout << " " << heaps[i];
  }
  cout << endl;
}

Measured memory_bytes: 3112
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>

using namespace std;

int main(){
    int R;
    cin>>R;
    if(R<1200) cout<<"ABC"<<endl;
    if(R>=1200 && R<2800) cout<<"ARC"<<endl;
    if(R>=2800) cout<<"AGC"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define M 1000000007

char s[100001], ts;
int a[3][3], c = 1;

int add(int x, int y)
{
	int t = x + y;
	if(t >= M) t -= M;
	return t;
}

int main() 
{
	int i, i1, i2;
	int s0 = 0, s1 = 0, s2 = 0, f;
	
	scanf("%s", s);
	i = strlen(s) - 1;
	for(; i >= 0; i--){
		for(i1 = 0; i1 < 3; i1++){
			for(i2 = 0; i2 < 3; i2++) a[i1][i2] = 0;
		}
		ts = s[i], f = (ts == '?');
		if(f || ts == 'A'){
			a[0][0] = add(s0, s1);
			a[0][1] = s1;
			a[0][2] = s2;
		}
		if(f || ts == 'B'){
			a[1][0] = s0;
			a[1][1] = add(s1, s2);
			a[1][2] = s2;
		}
		if(f || ts == 'C'){
			a[2][0] = s0;
			a[2][1] = s1;
			a[2][2] = add(s2, c);
		}
		if(f) c = add(add(c, c), c);
		s0 = add(a[2][0], add(a[1][0], a[0][0]));
		s1 = add(a[2][1], add(a[1][1], a[0][1]));
		s2 = add(a[2][2], add(a[1][2], a[0][2]));
	}
	printf("%d\n", s0);
			
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main(void)
{
  int a,b;
  int swap;
	cin >> a >> b;
 
  if ((a + b) % 2 == 0)
  {
    cout << (a + b) / 2;
  }
  else
  {
  	cout << "IMPOSSIBLE";
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include <math.h>


int main(void)
{
	long int i, j;
	long int m, d;
	long int sum;
	long int max;
	long int count;
	long int flg;
	long int a[32];
	long int l[100] = {0};
	long int r[100] = {0};
	
	scanf("%ld%ld", &m, &d);
	
	sum = 0;
	for(i = 1; i <= m; i++) {
		for(j = 1; j <= d; j++) {
			if( (j % 10 >= 2) && (j / 10 >= 2) && ( (j % 10) * (j / 10) == i) ) {
				sum++;
			}
		}
	}
	
	printf("%ld\n", sum);
	
	return 0;
}


Measured memory_bytes: 128
def solve():
  n = int(input())
  a = list(int(i) for i in input().split())
  a.sort()
  t = 0
  suma = 0
  for i in range(n):
    if a[i] > 2*suma:
      t = i
    
    suma += a[i]
  print(n-t)

  
solve()

Measured memory_bytes: 14320
#include <cstdio>
#include <algorithm>

using namespace std;

const int maxn = 2e5 + 10;
const int M = 22;

int pre[maxn][22], lst[22];
int a[maxn];

int main()
{
	int n;
	scanf("%d", &n);
	long long ans = 0;
	for (int i = 1; i <= n; ++ i)
	{
		scanf("%d", a + i);
		int Mx = 0;
		for (int j = 0; j < M; ++ j)
		{
			pre[i][j] = lst[j];
			if (a[i] >> j & 1)
			{
				lst[j] = i;
				Mx = max(Mx, pre[i][j]);
			}
			else
			{
				Mx = max(Mx, pre[pre[i][j]][j]);
			}
		}
		ans += i - Mx;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 18176
#include <stdlib.h>
#include<iostream>
#include<bits/stdc++.h>
#include<cmath>
#define ll long long
const int INF=0x3f3f3f3f;
#define mod 1000000007
using namespace std;
//priority_queue
int x[10003],y[10003];
int main()
{

int n,k,nn;
cin>>n>>k;nn=(n-1)*(n-2)/2;
 int ans=0;
 int b=2;
for(int i=2;i<=n;i++)
{
    x[++ans]=1;
    y[ans]=i;
}
if(nn>k)
{
    for(int i=2;i<n&&nn>k;i++)
   {
     for(int j=i+1;j<=n&&nn>k;j++)
    {
        x[++ans]=i;
        y[ans]=j;
        nn--;
        if(nn==k)break;
    }
}}
 if(nn!=k){
    cout<<-1;
 }
 else {cout<<ans<<endl;
    for(int i=1;i<=ans;i++)
        cout<<x[i]<<" "<<y[i]<<endl;
 }
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <string>

using namespace std;

const int mod = 1000000007;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

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

    long height[n];
    for (long i = 0; i < n; i++)
    {
        cin >> height[i];
    }
    
    long minHeight = 0;
    for (long i = 0; i < n; i++)
    {
        if (height[i] < minHeight)
        {
            cout << "No" << endl;
            return 0;
        }
        
        if (height[i] > minHeight)
        {
            minHeight = height[i] - 1;
        }
    }
    
    cout << "Yes" << endl;
    
}

Measured memory_bytes: 1024
while True:
  try:
    a,b,c,d,e,f=map(float,input().split())

    if (a*e-b*d)!=0:
      x=(c*e-f*b)/(a*e-b*d)
      if b!=0:
        y=(c-a*x)/b
      elif e!=0:
        y=(f-d*x)/e
    elif (b*d-e*a)!=0:
      y=(c*d-f*a)/(b*d-e*a)
      if a!=0:
        x=(c-b*y)/a
      elif d!=0:
        x=(f-e*y)/d
    if x==-0:
      x=x+0.0
    if y==-0:
      y=y+0.0
    print(f"{x:.3f}",f"{y:.3f}")
  except EOFError:
    break


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long mod2 = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  long long X, Y;
  cin >> X >> Y;

  int ans = 1;
  while (true)
  {
    X *= 2;
    if (X > Y) break;
    ans++;
  }

  cout << ans << endl;
}

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

int main() {
    int n;
    long long t = 0;
    cin >> n;
    vector<pair<long ,long>> tasks(n);
    for(int i = 0;i < n;i++){
        cin >> tasks[i].second >> tasks[i].first;
    }
    sort(tasks.begin(),tasks.end());
    for(int i = 0;i < n;i++){
        t += tasks[i].second;
        if(tasks[i].first < t){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

int main() {
  string A, B, C;
  cin >> A >> B >> C;

  if (A[A.size() - 1] == B[0] && B[B.size() - 1] == C[0]) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
const long long MOD = 1000000007;
const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;
typedef long long ll;
 
int main(){
    int N;
    cin >> N;

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

    vector<ll> min_h(N, 1), max_h(N, 0);
    min_h[0] = max_h[0] = T[0];
    for(int i=1;i<N;i++){
        if(T[i - 1] < T[i]){
            min_h[i] = max_h[i] = T[i];
        }else{
            max_h[i] = max_h[i - 1];
        }
    }

    for(int i=N-1;i>=0;i--){
        if(A[i] > A[i + 1]){
            if(min_h[i] > A[i] || max_h[i] < A[i]){
                cout << 0 << endl;
                return 0;
            }
            min_h[i] = max_h[i] = A[i];
        }else{
            max_h[i] = min(max_h[i], max_h[i + 1]);
            if(min_h[i] > max_h[i]){
                cout << 0 << endl;
                return 0;
            }
        }
    }

    ll ans = 1;
    for(int i=0;i<N;i++){
        ans = (ans * (max_h[i] - min_h[i] + 1)) % MOD;
    }
    assert(ans > 0);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3328
#include<cstdio>
#include<cstring>
#include<queue>
#include<algorithm>
using namespace std;
int n,m,ne[4][2]={0,1,0,-1,1,0,-1,0};
bool vis[103][103];
char mmp[103][103];
void dfs(int x,int y,char c)
{
    for(int i=0;i<4;i++){
        int tx=x+ne[i][0];
        int ty=y+ne[i][1];
        if(tx<0||tx>=n||ty<0||ty>=m||vis[tx][ty])
            continue;
        if(mmp[tx][ty]==c){
            vis[tx][ty]=true;
            dfs(tx,ty,c);
        }
    }
}
int main()
{
    while(scanf("%d %d",&n,&m)&&n&&m){
        int sum=0;
        char ch;
        memset(vis,0,sizeof(vis));
        for(int i=0;i<n;i++)
            scanf("%s",&mmp[i]);
        for(int i=0;i<n;i++){
            for(int j=0;j<m;j++){
                if(!vis[i][j]){
                    vis[i][j]=true;
                    sum++;
                    ch=mmp[i][j];
                    dfs(i,j,ch);
                }
            }
        }
        printf("%d\n",sum);
    }
	return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <math.h>
#include <bitset>

using namespace std;

void solve() {
    string str = "abcdefghijklmnopqrstuvwxyz";
    string t;
    cin >> t;
    int i = 0;
    while(true){
        if(t == str.substr(i,1)){
            cout << str.substr(i+1,1);
            break;
        } else {
            i++;
        }
    }
}

int main() {
    solve();
    return 0;
}

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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))
#define deg2rad(x) (((x)*PI) / (180.0))
#define rad2deg(x) (((x) * (180.0)) / PI)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);
template <class T> T mod(T a, T m);

int main(int argc, char* argv[]) {
  long long N;
  scanf("%lld", &N);
  string S;
  cin >> S;

  ll ans = 0;
  rep(i, 0, 1000) {
    vector<ll> count(3);
    ll num = i;
    count[2] = num % 10;
    num /= 10;
    count[1] = num % 10;
    num /= 10;
    count[0] = num % 10;

    int index = 0;
    rep(j, 0, sz(S)) {
      if (S[j] - '0' == count[index]) {
        index++;
      }
      if (index == 3) {
        ans++;
        break;
      }
    }
  }

  put(ans);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[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;
}

template <class T> inline T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}

template <class T> T mod(T a, T m) { return (a % m + m) % m; }


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

using namespace std;

int main(){
    string S; cin >> S; int ones = 0, zeros = 0;
    for (int i = 0; i < S.size(); i++) (S[i] == '0') ? ++zeros : ++ones;
    cout << ((zeros < ones) ? zeros : ones) * 2 << endl;
    return 0;
}


Measured memory_bytes: 512
import Control.Applicative

main = do
    [a, b] <- map read . words <$> getLine
    let x = area a b
        y = circumference a b
    putStrLn $ show x ++ " " ++ show y

area :: Int -> Int -> Int
area a b = a * b

circumference :: Int -> Int -> Int
circumference a b = (a + b) * 2

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

using namespace std;

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

  int h, n;
  cin >> h >> n;
  while (n--) {
    int x;
    cin >> x;
    h -= x;
  }
  cout << (h <= 0 ? "Yes" : "No");

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
int f(int a,int b)
{
	int na=to_string(a).length();
	int nb=to_string(b).length();
	return max(na,nb);
}
int32_t main()
{
	int n;
	cin>>n;
	int ans=1e18;
	//set<int> s;
	for(int i=1;i<=sqrt(n);i++)
	{
		if(n%i==0)
		{
			ans=min(ans,f(i,n/i));
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define PB push_back
#define MP make_pair

LL N,M;
LL ans = 0;
vector<LL> yaku;
LL now = 1;
void dfs(int i){
	if(i == yaku.size()){
		//cout << now << endl;
		if(now-1 > 0 && M%(now-1) == M/(now-1)) ans += now-1;
		return;
	}
	int s = upper_bound(yaku.begin(), yaku.end(), yaku[i]) - lower_bound(yaku.begin(), yaku.end(), yaku[i]);
	int nx = upper_bound(yaku.begin(), yaku.end(), yaku[i]) - yaku.begin();
	dfs(nx);
	for(int j=1; j<=s; j++){
		now *= yaku[i];
		dfs(nx);
	}
	for(int j=1; j<=s; j++){
		now /= yaku[i];
	}
}
int main(){
	cin >> N;
	M = N;
	for(int i=2; i<=sqrt(M)+1; i++){
		while(N%i == 0){
			yaku.PB(i);
			N /= i;
		}
	}
	if(N > 1) yaku.PB(N);
	//for(int i=0; i<yaku.size(); i++) cout << yaku[i] << endl;
	dfs(0);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

int main(){
	ll A; long double B; 
	cin>>A>>B;
	ll ans = A*B;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3732
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	int a=0;
	for(int i=1;i<=4;i++)
	{
		cin>>s[i];
		if(s[i]=='-')
			a--;
		if(s[i]=='+')
			a++;
	}
	cout<<a;
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 文字列の入力
s = input()
B_num = s.count('B')
length = len(s)

target = 'B'
index = -1
num = 0
v_sum = 0
while True:
    index = s.find(target, index + 1)
    if index == -1:
        break
    num += 1
    v_sum += (length-1)-(B_num- num)-index
print (v_sum)

Measured memory_bytes: 3500
using System;
using System.Linq;

class Program
{
    //ABC043_C
    static void Main()
    {
        int n = scan()[0];
        var a = scan();
        long a1 = 0;
        long a2 = 0;
        int ave = (int)a.Average();
        foreach(var t in a)
        {
            a1+=(long)Math.Pow(t-ave,2);
        }
        foreach(var t in a)
        {
            a2+=(long)Math.Pow(t-ave-1,2);
        }
        if(a1>a2) Console.WriteLine(a2);
        else Console.WriteLine(a1);
    }
    static int[] scan()
    {
        return Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
    }
}

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

int main() {
    int k, n, max_r;
    int a[200000];
    cin >> k >> n;

    cin >> a[0];
    for (int i = 1; i < n; i++) {
        cin >> a[i];
        max_r = max(max_r, a[i] - a[i-1]);
    }

    max_r = max(max_r, a[0] + (k - a[n-1]));

    cout << k - max_r << endl;
}

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

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> A(m);
    copy_n(istream_iterator<int>(cin), m, A.begin());

    cout << max(-1, n - accumulate(A.begin(), A.end(), 0)) << endl;
}

Measured memory_bytes: 3648
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>
#include<stack>
#include<tuple>
#include<numeric>
#include<cassert>

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back
#define DEBUG false

using namespace std;

using ll = long long;
using P = pair<int,int>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60;
const int MAX_N=302;
const ll lmod = 1e9+7;

ll d[MAX_N][MAX_N],a[MAX_N][MAX_N];

int main(){
  int N;
  cin >> N ;
  rep(i,N) rep(j,N){
    scanf("%lld",&d[i][j]);
    a[i][j] = d[i][j];
  }
  rep(i,N) rep(j,N) rep(k,N){
    a[j][i] = a[i][j] = min(a[i][j],a[i][k]+a[k][j]);
  }
  rep(i,N) rep(j,N){
    if(d[i][j]!=a[i][j]){
      cout << "-1" << endl;
      return 0;
    }
  }
  rep(i,N-1) REP(j,i+1,N) rep(k,N){
    if(k==i || k==j) continue;
    // cout << i << "," << j << "," << k << endl;
    if(a[i][j]==a[i][k]+a[k][j]){
      d[i][j] = 0;
    }
  }
  ll ans = 0;
  rep(i,N-1) REP(j,i+1,N) ans += d[i][j];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1664
#include <cstdio>
//#include <iostream>
//#include <algorithm>
//#include <cstring>
//#include <queue> //priority_queue 优先队列
#include <map>
#include <set> //multiset  set<int,greater<int>>大到小
//#include <vector>// ::iterator it;
//#include <stack>
//#include <cmath> // auto &Name : STLName  Name.
//#include <utility>
//#include <sstream>
//#include <string>
#define mod 1000000007
#define mod9 998244353
typedef unsigned long long ull;
typedef long long ll;
typedef double db;
typedef long double ld;
const db eps=1e-10;
const int INF = 0x3f3f3f3f;
const ll inf=0x3f3f3f3f3f3f3f3f;
const int N=1e6+5;
using namespace std;


ll t,n,m,k,cnt=0;
ll a[65]={0};
ll sum=0;
ll ksm(ll a,ll b){
    ll c=mod;
    ll ans=1;
    a=a%c;
    while(b>0){
        if(b%2) ans=(ans*a)%c;
        b=b/2;
        a=(a*a)%c;
    }
    return ans;
}
int main(){
    scanf("%lld",&n);
    k=n;
    while(n--){
        scanf("%lld",&m);
        for(ll i=0;m;i++){
            ll x=m%2;
            m/=2;
            if(x) a[i]++;
        }
    }
    for(ll i=0;i<65;i++){
        sum=(sum+((a[i]*(k-a[i]))%mod)*ksm(2,i))%mod;
    }
    printf("%lld\n",sum);
    return 0;
}

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

void fnInput(vector<int>& rvnMaxHeap)
{
  int nMaxSiz;
  cin >> nMaxSiz;
  rvnMaxHeap.resize(nMaxSiz + 1);

  for (int i = 1; i < nMaxSiz + 1; ++i)
    cin >> rvnMaxHeap[i];
}

void fnMaxHeapify(vector<int>& rvnMaxHeap, int nx)
{
  int nLeft = nx * 2;
  int nRigt = nLeft + 1;
  int nLarg = nx;

  if (nLeft < rvnMaxHeap.size()  &&
      rvnMaxHeap[nLarg] < rvnMaxHeap[nLeft])  
    nLarg = nLeft;
  if (nRigt < rvnMaxHeap.size()  &&
      rvnMaxHeap[nLarg] < rvnMaxHeap[nRigt])
    nLarg = nRigt;

  swap(rvnMaxHeap[nx], rvnMaxHeap[nLarg]);
  if (nx != nLarg)
    fnMaxHeapify(rvnMaxHeap, nLarg);
}

void fnMaximumHeap(vector<int>& rvnMaxHeap)
{
  for (int i = (rvnMaxHeap.size() - 1) / 2; i > 0; --i)
    fnMaxHeapify(rvnMaxHeap, i);
}

void fnResult(const vector<int>& cnrvnMaxHeap)
{
  for (int i = 1; i < cnrvnMaxHeap.size(); ++i)
    cout << " " << cnrvnMaxHeap[i];

  cout << endl;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> vnMaxHeap; 

  fnInput(vnMaxHeap);
  fnMaximumHeap(vnMaxHeap);
  fnResult(vnMaxHeap);
  return 0;
}

Measured memory_bytes: 4984
import std.stdio : write, writeln;
import std.array;
import std.range;

void main(){
	const heisei = 19890108;
	const showa = 19261225;
	const taisho = 19120730;
	const meiji = 18680908;
	while(hasNext){
		string y = next!string();
		string m = next!string();
		string d = next!string();
		
		if(m.length<2){
			m = "0" ~ m;
		}
		if(d.length<2){
			d = "0" ~ d;
		}
		
		int a = (y ~ m ~ d).to!int;
		
		if(heisei <= a){
			writeln = heisei.stringof ~ " " ~ (y.to!int - heisei.to!string.take(4).array.to!int + 1).to!string ~ " " ~ m.to!int.to!string ~ " " ~ d.to!int.to!string;
		}else if(showa <= a){
			writeln = showa.stringof ~ " " ~ (y.to!int - showa.to!string.take(4).array.to!int + 1).to!string ~ " " ~ m.to!int.to!string ~ " " ~ d.to!int.to!string;
		}else if(taisho <= a){
			writeln = taisho.stringof ~ " " ~ (y.to!int - taisho.to!string.take(4).array.to!int + 1).to!string ~ " " ~ m.to!int.to!string ~ " " ~ d.to!int.to!string;
		}else if(meiji <= a){
			writeln = meiji.stringof ~ " " ~ (y.to!int - meiji.to!string.take(4).array.to!int + 1).to!string ~ " " ~ m.to!int.to!string ~ " " ~ d.to!int.to!string;
		}else{
			writeln = "pre-meiji";
		}
	}
}


import std.stdio : readln, chomp;
import std.conv : to;
import std.string : split;
shared string[] input;
shared string delim = " ";
T next(T)()
in
{
	assert(hasNext());
}
out
{
	input.popFront;
}
body
{
	return input.front.to!T;
}

void next(T)(ref T v){
	v = next!T();
}

bool hasNext(){
	if(input.length > 0){
		return true;
	}
	
	string str = readln;
	if(str.length > 0){
		input ~= str.chomp.split(delim);
		return true;
	}else{
		return false;
	}
}


void dbg(T...)(T vs)
{
	import std.stdio : stderr;
	foreach(v; vs)
		stderr.write(v.to!string ~ " ");
	stderr.write("\n");
}

T clone(T)(T v){
	T v_;
	static if(isInputRange!(T)){
		foreach(ite; v){
			v_ ~= ite.clone;
		}
	}else{
		v_ = v;
	}
	
	return v_;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl);
#define cop(a) for(auto x:(a)){cout << x << endl;}


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

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; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        // comment this out when you use scanf or printf
        // cin.tie(0); ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(15);
    };
}fastio;

int main(){

    int a;
    string s;
    cin >> a >> s;
    if(a >= 3200)
        ppp(s)
    else
        ppp("red");

    return 0;
}


Measured memory_bytes: 256
n = int(input())
red  = [list(map(int,input().split())) for _ in range(n)]
blue = [list(map(int,input().split())) for _ in range(n)]
red.sort
blue.sort()
ans = 0

for x, y in blue:
    correct = [z for z in red if (z[0] < x) & (z[1] < y)]
    if correct:
        correct.sort(key=lambda x:x[1])
        red.remove(correct[-1])
        ans += 1

print(ans)


Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	H, W := ReadInt(), ReadInt()
	S := make([]string, H)
	for i := 0; i < H; i++ {
		S[i] = ReadString()
	}
	dx := []int{1, 0, -1, 1, -1, 1, 0, -1}
	dy := []int{1, 1, 1, 0, 0, -1, -1, -1}
	for y := 0; y < H; y++ {
		l := make([]byte, W)
		for x := 0; x < W; x++ {
			if S[y][x] == '#' {
				l[x] = '#'
				continue
			}
			c := 0
			for i := 0; i < 8; i++ {
				nx, ny := x+dx[i], y+dy[i]
				if 0 <= nx && nx < W && 0 <= ny && ny < H {
					if S[ny][nx] == '#' {
						c++
					}
				}
			}
			l[x] = byte(c + '0')
		}
		fmt.Println(string(l))
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 1852
#include <algorithm>
#include <complex>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;
using std::cerr;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::stack;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

typedef long long int ll;
const int MOD = 1e9 + 7;

int main() {
    string s;
    cin >> s;

    int cnt = 0;
    int win  = 0;
    int lose = 0;
    for (size_t i = 0; i < s.length(); i++) {
        if (s[i] == 'p') {
            if(cnt > 0){
                cnt--;
            }else{
                cnt++;
                lose++;
            }
        } else {
            if(cnt > 0){
                win++;
                cnt--;
            }else{
                cnt++;
            }
        }
    }

    cout << (win - lose) << endl;

    return 0;
}


Measured memory_bytes: 512
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val a = sc.nextInt()
  val b = sc.nextInt()
  val c = sc.nextInt()

  println(agc014a(a, b, c))
}

private fun agc014a(a: Int, b: Int, c: Int): Int {
  var tmpa = a
  var tmpb = b
  var tmpc = c
  var count = 0
  while (tmpa % 2 == 0 && tmpb % 2 == 0 && tmpc % 2 == 0) {
    count++
    val aa = tmpb / 2 + tmpc / 2
    val bb = tmpa / 2 + tmpc / 2
    val cc = tmpb / 2 + tmpa / 2
    tmpa = aa
    tmpb = bb
    tmpc = cc

    if (tmpa == a && tmpb == b && tmpc == c) return -1
  }

  return count
}


Measured memory_bytes: 29352
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <vector>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>

#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define rep_r(i,s,n)for(int i = n-1;i>=s;i--)
#define rep_re(i,s,n)for(int i = n;i>=s;i--)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;
static const ll INF = 1e25;
static const ll MAX_N = 100001;

int  main() {
	ll a, b; cin >> a >> b;
	if (b == 1) {
		cout << 0 << endl;
		return 0;
	}
	//repe(a, 2, 20) {
	//	repe(b, 1, 20) {
	ll curB = a;
	ll ans = 1;

	while (curB < b) {
		ans++;

		curB--;
		curB += a;
	}
	cout << ans << endl;
	//cout << a << ":" << b << ":" << ans << endl;
//}
//	}

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace kakomon
{
    class Program
    {
        static void Main(string[] args)
        {
            abc145_b();
        }

        static void abc145_b()
        {
            // B - Echo
            int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();

            if (n % 2 == 1)
            {
                Console.WriteLine("No");
                return;
            }

            int mid = (int)(n / 2);
            string t0 = s.Substring(0, mid);
            string t1 = s.Substring(mid);
            if (t0 == t1) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}

Measured memory_bytes: 13140
def mod_comb_k(n, k, p):
    """二項係数 0(1)

    Args:
        n (int): 添字
        k (int): 添字
        p (int): 除数

    Returns:
        int: nCk mod p
    """
    if n < k or n < 0 or k < 0:
        return 0
    else:
        return fact[n] * fact_inv[k] * fact_inv[n-k] % p

def com_init(n, p):
    """二項係数の計算の前処理 O(N)

    Args:
        n (int): 上限値
        p (int): 除数
    """
    for i in range(n):
        fact.append(fact[-1] * (i+1) % p)

    fact_inv[-1] = pow(fact[-1], p-2, p)
    for i in range(n-1, -1, -1):
        fact_inv[i] = fact_inv[i+1] * (i+1) % p


s = int(input())

mod = 10 ** 9 + 7

fact = [1]
fact_inv = [0] * (s+1)
com_init(s, mod)

res = 0
for i in range(1, s//3+1):
    res = (res + mod_comb_k(s-i*2-1, i-1, mod)) % mod

print(res)

Measured memory_bytes: 64760
def kakeru(i):
    for a in range(K+1):
        if i*2**a >= K:
            #print(i)
            #print(a)
            return a


N, K = map(int, input().split())
result = 0

for i in range(1,N+1):
    x = kakeru(i) if i < K else 0
    #print(x)
    pulas = (1/N)*((0.5)**x) if x > 0 else 1/N
    result += pulas
    #print(pulas)

print(result)

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

int main(){
  string s,a,b,c;
  cin >> s;
  a = s.substr(0,s.size()/2);
  reverse(s.begin(), s.end());
  b = s.substr(0,s.size()/2);
  if (a==b){
    c = a;
    reverse(c.begin(), c.end());
    if (c==a){
       cout << "Yes" << endl;}
    else{cout << "No" <<endl;}
  }
  else{cout << "No" << endl;}
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {


    public static void main(String args[]){

        Scanner src = new Scanner(System.in);

        int a = src.nextInt();
        int b = src.nextInt();
        int c = src.nextInt();
        int d  = src.nextInt();

        long max = (long)a*(long)c;

        max = Math.max((long)b*(long)d,max);
        max = Math.max((long)a*(long)d,max);
        max = Math.max((long)b*(long)c,max);

        System.out.println(max);

    }
}


Measured memory_bytes: 27088
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define llp 1000000007
#define mod 1000000007

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;

int dp[15000];
int32_t main(){
	ios::sync_with_stdio(false);
    memset(dp,0,sizeof(dp));
    int R,G,B,N;
    cin>>R>>G>>B>>N;
    int Gmax=(N/(G))+1;
    int Bmax=(N/B)+1;
    for(int i=0;i<=(Gmax);i++){
        for(int j=0;j<=(Bmax);j++){
            int ans=i*G+j*B;
            dp[ans]+=1;
        }
    }
    int Rmax=(N/R)+1;
    int Ans=0;
    for(int i=0;i<=(Rmax);i++){
        int ans=N-(i*R);
        if(ans<0)continue;
        else{
            Ans+=dp[ans];
        }
    }
    cout<<Ans<<"\n";




	return 0;
}

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

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

/*最小公倍数*/
int main(){
 cin >> A >> B;
 cout << A * B / gcd(A, B) << endl;
  
}


Measured memory_bytes: 256
n = int(input())
taro = 0
hanako = 0
for _ in range(0,n):
    t, h = input().split()
    if (t>h):
        taro += 3
    elif (t==h):
        taro += 1
        hanako += 1
    else:
        hanako += 3
print('{} {}'.format(taro, hanako))



Measured memory_bytes: 5596
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <cstdio>
#include <queue>
#include <vector>

using namespace std;

template<class T> void gc(T &x)
{
    int k, m = 0;
    x = 0;
    while (true)
    {
        k = getchar_unlocked();
        if (k == '-')
        {
            m = 1; break;
        }
        if ('0' <= k && k <= '9')
        {
            x = k - '0';
            break;
        }
    }
    while (true)
    {
        k = getchar_unlocked();
        if (k < '0' || k > '9') break;
        x = x * 10 + k - '0';
    }
    if (m) x = -x;
}

int main()
{
    int N, K;

    gc(N);
    gc(K);

    long long int a;

    queue<long long int> qi;
    vector<long long int> viA;
    vector<long long int> viB;

    long long int sumTotal = 0LL;
    long long int sumA = 0LL;
    long long int sumB = 0LL;

    for (int i = 0; i < N; i++)
    {
        gc(a);

        qi.push(a);

        sumA += a;
        sumTotal += max(a, 0LL);

        if (i >= K - 1)
        {
            viA.push_back(sumA);
            long long int qf = qi.front();
            sumA = sumA - qf;
            qi.pop();

            sumB += max(qf, 0LL);
            viB.push_back(sumB);
        }
        else
        {
            viA.push_back(0LL);
        }
    }

    while (!qi.empty())
    {
        sumB += max(qi.front(), 0LL);
        viB.push_back(sumB);
        qi.pop();
    }

    long long int score = 0LL;
    for (int i = K - 1; i < N; i++)
    {
        long long int b = i - K >= 0 ? viB[i - K] : 0;
        score = max(max(viA[i], 0LL) + b + sumTotal - viB[i], score);
    }

    printf("%lld\n", score);
    return 0;
}


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

using namespace std;

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

  int n;
  while(cin>>n,n){
      char a[52]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
      int k[n+1];
      for(int i=0;i<n;i++)cin>>k[i];
      string s;cin>>s;
      int len=s.length();
      for(int i=0;i<len;i++){
          int idx;
          if(s[i]>='a')  idx=(s[i]-'a');
          else idx=s[i]-'A'+26;
          idx=((idx+52-k[i%n])%52);
          cout<<a[idx];
      }
      cout<<endl;
  }
}

Measured memory_bytes: 3220
import math


import math


def main():
    N, K = map(int, input().split())
    ans = 0
    for i in range(N): 
        tmp = K / (i+1)
        a = math.log2(tmp)
        if a < 0:
            a = 0
        elif not a.is_integer():
            a = int(a) + 1
        '''
        if tmp.is_integer():
            tmp = int(tmp)
            if not (tmp and ):
                a = int(math.log2(tmp))
        else:
            a = int(math.log2(tmp)) + 1
        '''
        ans += 0.5 ** a
    ans /= N

    # print('{:.15f}'.format(ans))
    print(ans);


main()
    


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int i;
  vector<int> vec(n);
  int min,max;
  for(i=0;i<n;i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  cout << vec.at(n-1)-vec.at(0);
}

Measured memory_bytes: 256
const input = require("fs").readFileSync("/dev/stdin", "utf8")
;(input => {

    let N = input - 0
    const char = ['a', 'a' ,'a' , 'a','a']

    let n = ''
    while (N !== 0) {
        const c = N % 26 || 26
        n = String.fromCharCode(c + 96) + n
        N -= c
        N /= 26
    }

    console.log(n)

})(input)



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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
//const ll MOD = 1000000007;
const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'

// 1825

int main() {
  int a, p;
  cin >> a >> p;
  p += a * 3;
  cout << p / 2 << endl;
    

}


Measured memory_bytes: 256
#include<stdio.h>

#define N 10000
#define Q 500

int S[N];
int T[Q];

int search(int *,int,int);

int main(){
  int C=0;
  int n,q;
  int i;

  /*Input*/
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }

  for(i=0;i<q;i++){
    if(search(S,n,T[i])==1) C++;
  }

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

  return 0;
}

int search(int *S,int n,int t){
  int i=0;

  S[n]=t;
  while(S[i]!=t){
    i++;
  }
  if(i!=n) return 1;
  return 0;
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
 
signed main() {
	ios::sync_with_stdio(0), cin.tie(0);
    
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; ++i) cin >> a[i];
 
    map<int, int> occ;
    for (int i=0; i<n; ++i) ++occ[a[i]];
 
    int res = 0;
    for (auto pr : occ) {
        int x = pr.first;
        if (occ[x] < x) res += occ[x];
        else res += occ[x] - x;
    }
    cout << res;
}

Measured memory_bytes: 5120
#include<iostream>
 #include<stdio.h>
 #include<cstdlib>
 #include<cstdio>
 #include<string>
 #include<math.h>
 #include<time.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<fstream> 
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 #include<memory>
 
 using namespace std;

 int main()
 {
   int n,k; 
   while(cin>>n>>k)
   {
     int a=1;
     int result=1;
     while((n)&&(a<k))
     {
       result*=2;      
       a*=2;
       n--;             
     } 
     if(n==0) cout<<result<<endl;
     else
     {
       result=result+n*k;
       cout<<result<<endl;    
     }
   } 
   return 0;
 }
 


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.concurrent.ForkJoinPool;

public class Main {


    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] nums = new int[n];
        int[] dp = new int[n];
        for (int i = 0; i < n; i++) {
            nums[i] = scan.nextInt();
            dp[i] = Integer.MAX_VALUE;
        }

        dp[0] = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j <= i + 2; j++) {
                if(j < n) {
                    dp[j] = Math.min(dp[j], dp[i] + Math.abs(nums[j] - nums[i]));
                }
            }
        }
        System.out.println(dp[n - 1]);
    }

}


Measured memory_bytes: 51944
//49
#include<iostream>
#include<iomanip>

using namespace std;

int main(){
  for(int i=1,n;cin>>n,n;i++){
    int g[10][10];
    int y=0,x=0,d=0;
    for(int j=1;j<=n*n;j++){
      g[y][x]=j;
      int dy[]={-1,1};
      int dx[]={1,-1};
      int ny=y+dy[d];
      int nx=x+dx[d];
      d^=1;
      if(n<=nx){
	nx=x;
	ny=y+1;
      }else if(n<=ny){
	ny=y;
	nx=x+1;
      }else if(ny<0){
	ny=y;
      }else if(nx<0){
	nx=x;
      }else{
	d^=1;
      }
      x=nx;
      y=ny;
    }
    cout<<"Case "<<i<<':'<<endl;
    for(int y=0;y<n;y++){
      for(int x=0;x<n;x++){
	cout<<setw(3)<<right<<g[y][x];
      }
      cout<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, b) for (int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x) cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}
template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
	rep(i, v.size()) { os << v[i] << (i == v.size() - 1 ? "" : " "); }
	return os;
}
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S>& p) {
	os << '(' << p.first << ',' << p.second << ')';
	return os;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
	for (T& x : v) { is >> x; }
	return is;
}

int memo[100005];

int dfs(int cur, vector<vector<int>>& g) {
	if (memo[cur] != -1) return memo[cur];
	int res = 0;
	for (auto to : g[cur]) { res = max(res, dfs(to, g)); }
	return memo[cur] = res + 1;
}

signed main() {
	int n, m;
	cin >> n >> m;

	vector<vector<int>> g(n);
	vector<int> indeg(n, 0);
	rep(i, m) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		g[a].emplace_back(b);
		indeg[b]++;
	}

	int ans = 0;
	rep(i, n) memo[i] = -1;
	rep(i, n) {
		if (indeg[i] == 0) { ans = max(ans, dfs(i, g)); }
	}
	cout << ans - 1 << endl;
}


Measured memory_bytes: 11904