akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_poizcy.hpp>
typedef long long   ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define mem(a,h)          memset(a, (h), sizeof(a))
#define fi first
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)
 
 
using namespace std;
//using namespace __gnu_pbds;
typedef double lldb;
typedef pair<ll, ll>  ii;
typedef pair<ll, ii>  iii;
typedef vector<ll>     vi;
typedef vector<vi>     vvi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9;
const double PI = acos(-1);
#define offset 
const ll MOD= 998244353;
#define initseg ll new_nodo=(nodo*2),mid=(iz+der)/2;
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define tam 300

int  main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    string txt;
    cin>>txt;
    set<char> s;
    forr(i,0,txt.size())
        s.insert(txt[i]);
    bool invalid=0;
    if (s.find('N')!=s.end()|| s.find('S')!=s.end())
    {
        if (s.find('N')==s.end() || s.find('S')==s.end())
            invalid=1;
    }
    if (s.find('W')!=s.end()|| s.find('E')!=s.end())
    {
        if (s.find('W')==s.end() || s.find('E')==s.end())
            invalid=1;
    }
    if (invalid)
        cout<<"No\n";
    else
        cout<<"Yes\n";
}
// PLUS ULTRA!!

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stack>
using namespace std;
#define MAXIMO(a,b) (a>b?a:b)
#define MOD(a) (a>0?a:-(a))

void disllocate(char a[], int size){ // torna a posicao 0 irrelevante para melhorar a clareza do algoritmo dinamico
  for (size_t i = size+1; i > 0; i--)
    a[i] = a[i-1];
  a[0] = 0;
}

int main(){
  char * strings = (char*)malloc(sizeof(char) * 3002), *stringt = (char*)malloc(sizeof(char) * 3002);
  scanf("%s\n", strings);
  scanf("%s\n", stringt);
  int sizes=0,sizet=0;
  while(*strings) sizes++,strings++;
  strings-=sizes;
  disllocate(strings,sizes);
  while(*stringt) sizet++,stringt++;
  stringt-=sizet;
  disllocate(stringt,sizet);
  sizes++;
  sizet++;
  // printf("%d %d\n",sizes,sizet);
  int ansatu[sizes][sizet];
  for (size_t i = 0; i < sizes; i++)
    ansatu[i][0] = 0;
  for (size_t i = 0; i < sizet; i++)
    ansatu[0][i] = 0;
  // for (size_t i = 0; i < sizes; i++) {     // debug
  //   for (size_t j = 0; j < sizet; j++) {
  //     printf("%02d ",ansatu[i][j]);
  //   }
  //   printf("\n");
  // }
  for (size_t i = 1; i < sizes; i++) {
    for (size_t j = 1; j < sizet; j++) {
      if(strings[i]==stringt[j]){
        ansatu[i][j] = 1 + ansatu[i-1][j-1];
      }else{
        ansatu[i][j] = MAXIMO(ansatu[i-1][j],ansatu[i][j-1]);
      }
    }
  }
  // printf("   ");  printf("   ");
  // for (size_t i = 1; i < sizet; i++) {
  //   printf(" %c ",stringt[i]);
  // }printf("\n");
  // strings[0] = ' ';
  // for (size_t i = 0; i < sizes; i++) {
  //   printf(" %c ",strings[i]);
  //   for (size_t j = 0; j < sizet; j++) {
  //     printf("%02d ",ansatu[i][j]);
  //   }
  //   printf("\n");
  // }
  // printf("%d", ansatu[sizes-1][sizet-1]);
  char * substring=(char*)malloc(ansatu[sizes-1][sizet-1]+1);
  substring[ ansatu[sizes-1][sizet-1] ] = 0;
  int wherami = ansatu[sizes-1][sizet-1]-1;
  // if(wherami == 0){
  //   substring[0] = strings[1];
  // }
  int i = sizes-1, j = sizet-1;
  stack<char> bugadona;
  while(i != 0 && j != 0 && wherami != -1){
    // printf("%d %d %d:\n",i,j,wherami);
    if(ansatu[i][j] == ansatu[i][j-1]){
      j--;
      // printf("horizontal\n\n");
    }else if(ansatu[i][j] == ansatu[i-1][j]){
      i--;
      // printf("vertical\n\n");
    }else /*if(ansatu[i][j] > ansatu[i-1][j-1])*/{
      bugadona.push(strings[i]);
      // substring[wherami--] = strings[i];
      // printf("Salvou %c em substring\n",substring[wherami+1]);
      i--;j--;
    }
  }
  while (!bugadona.empty()) {
    printf("%c",bugadona.top());
    bugadona.pop();
  }
  printf("\n");
}

Measured memory_bytes: 35456
#define _USE_MATH_DEFINES
#include <cmath>
#include <iostream>
#include <iomanip>

int main() {
  double a, b, x;
  std::cin >> a >> b >> x;
  
  if (a * a * b / 2 >= x) {
    double c = 2 * x / a / b;
    auto angle = std::atan(c/b) / M_PI * 180.0;
    std::cout << std::setprecision(10) << std::fixed <<  90.0d - angle << std::endl;
  } else {
    double d = 2 * x / a / a - b;
    auto angle = std::atan((b-d)/a) / M_PI * 180.0;
    std::cout << std::setprecision(10) << std::fixed <<  angle << std::endl;
  }
}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
vector<string>split(string s, char c = ' ') {
	vector<string>vec;
	string h = "";
	for (int i = 0; i < s.size();) {
		int j = i;
		while (j < s.size() && s[j] != ' ') {
			h += s[j++];
		}
		if (h.size() > 0) vec.push_back(h);
		h = "";
		i = j + 1;
	}
	return vec;
}
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int x1, y3, x2, y2;
signed main(){
	cin >> x1 >> y3 >> x2 >> y2;
	cout << x2 + y3 - y2 << " " << y2 + x2 - x1 << " " << x1 + y3 - y2 << " " << y3 + x2 - x1 << endl;
}

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

int main(){
  ll N,K;
  cin >>N>>K;
  ll a,b,c;
  cin >>a>>b>>c;
  string T;
  cin >> T;
  ll ans=0;
  for(int i=0;i<N;i++){
    if(i<K){
      if(T[i]=='r'){
        ans+=c;
        continue;
      }
      if(T[i]=='s'){
        ans+=a;
        continue;
      }
      if(T[i]=='p'){
        ans+=b;
        continue;
      }
    }
    else{
      if(T[i]==T[i-K]){
        T[i]='o';
        continue;
      }
      else{
        if(T[i]=='r'){
          ans+=c;
          continue;
        }
        if(T[i]=='s'){
          ans+=a;
          continue;
        }
        if(T[i]=='p'){
          ans+=b;
          continue;
        }
      }
    }
  }
  cout << ans <<endl;
}
    

Measured memory_bytes: 3712
package main

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

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var x int
	con.Scan(&x)
	lo := 1
	hi := int(1e9)
	mi := 0
	for lo+1 < hi {
		mi = (lo + hi) / 2
		if mi*(mi+1)/2 > x {
			hi = mi
		} else {
			lo = mi
		}
	}
	if lo*(lo+1)/2 != x {
		lo++
	}
	con.Println(lo)
	return nil
}


Measured memory_bytes: 640
// abc118_b
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N, M;
    cin >> N >> M;

    vector<vector<bool>> x;
    x.assign(N, vector<bool>(M));

    REP(i, N){
        int k;
        cin >> k;
        REP(j, k){
            int a;
            cin >> a; a--;
            x[i][a] = true;
        }
    }


    int ans = 0;
    REP(j, M){
        bool flag = true;
        REP(i, N){
            flag &= x[i][j];
        }
        ans += int(flag);
    }

    print(ans);

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"regexp"
)

func main() {
	var s string
	_, _ = fmt.Scan(&s)
	for i := len(s); i > 0; i-- {
		r, _ := regexp.Compile(fmt.Sprintf("[ACGT]{%d}", i))
		if r.Match([]byte(s)) {
			fmt.Println(i)
			return
		}
	}
	fmt.Println(0)
}

Measured memory_bytes: 768
#include <iostream> 

using namespace std; 
int main(){ 
 
  int n;cin>>n;
  
  for(int i=1;i<1e5;i++){
    int k=i*1.08;
    if( k==n){
      cout<<i<<endl;
      return 0;}
    }
  cout<<":("<<endl;


}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

typedef long long ll;

#define rep(i,n) for(int i=0;i<(n);i++)

#define MAX_E 2000
#define MAX_V 1000
#define INF (1e18)
struct edge{ll from,to,cost;};

edge es[MAX_E];

ll d[MAX_V];
ll V,E;

bool shortest_path(ll s) {
    fill(d,d+V,INF);

    d[s] = 0;

    rep(i,V) {
        bool update = false;
        rep(j,E) {
            edge e = es[j];
            if(d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                update = true;
            }
        }
        if( !update) break;
        if(update && i == V - 1) {
            return false;;
        }
    }
    return true;
}

ll r;
int main() {
    cin >> V >> E >> r;
    rep(i,E) {
        ll s,t,dd;
        cin >> s >> t >> dd;
        es[i] = (edge){s,t,dd};
    }

    if(shortest_path(r)) {
        rep(i,V) {
            if(d[i] < INF)
                cout << d[i] << endl;
            else 
                cout << "INF" << endl;
        }
    }else {
        cout << "NEGATIVE CYCLE" << endl;
    }

    return 0;
}


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

vector<int> move_y={1,0,-1,0};
vector<int> move_x={0,1,0,-1};
int H,W;
long long ans=0;

void bfs(vector<string> &S,vector<vector<bool>> &visited,int y,int x){
  long long cnt_b=1;
  long long cnt_w=0;

  visited.at(y).at(x)=true;
  queue<pair<int,int>> que_yx;
  que_yx.push(make_pair(y,x));
  while(!que_yx.empty()){
    int y=que_yx.front().first;
    int x=que_yx.front().second;
    que_yx.pop();
    for(int i=0;i<4;i++){
      int ny=y+move_y.at(i);
      int nx=x+move_x.at(i);
      if(ny<0 || ny>=H || nx<0 || nx>=W)  continue;
      if(visited.at(ny).at(nx)) continue;
      if(S.at(ny).at(nx)==S.at(y).at(x))  continue;
      visited.at(ny).at(nx)=true;
      que_yx.push(make_pair(ny,nx));
      if(S.at(ny).at(nx)=='#')  cnt_b++;
      else  cnt_w++;
    }
  }
  ans+=cnt_b*cnt_w;
}

int main(){
  cin >> H >> W;
  vector<string> S(H);
  for(int i=0;i<H;i++)  cin >> S.at(i);

  vector<vector<bool>> visited(H,vector<bool>(W,false));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(visited.at(i).at(j)) continue;
      if(S.at(i).at(j)=='.')  continue;
      bfs(S,visited,i,j);
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 512
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Debug = System.Diagnostics.Debug;
using static System.Math;
using static Reader;
using System.Runtime.CompilerServices;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

static class P
{
    static void Main()
    {
        BIT<int> bit = new BIT<int>(NextInt + 1, 0, (x, y) => x + y);
        int q = NextInt;
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < q; i++)
        {
            if (NextInt == 0)
            {
                var l = NextInt;
                var r = NextInt;
                var x = NextInt;
                bit.Operate(l, x);
                bit.Operate(r + 1, -x);
            }
            else
            {
                builder.AppendLine(bit.Query(NextInt).ToString());
            }
        }
        Console.Write(builder.ToString());
    }

}

static class Reader
{
    const int BUF_SIZE = 1 << 12;
    static Stream Stream = Console.OpenStandardInput();
    static byte[] Buffer = new byte[BUF_SIZE];
    static int ptr = BUF_SIZE - 1;
    static void Move() { if (++ptr >= Buffer.Length) { Stream.Read(Buffer, 0, BUF_SIZE); ptr = 0; } }
    public static int NextInt
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            int res = 0; while (Buffer[ptr] < 48) Move();
            do { res = res * 10 + (Buffer[ptr] ^ 48); Move(); } while (48 <= Buffer[ptr]);
            return res;
        }
    }
}

class BIT<T>
{
    public readonly int Size;
    T Identity;
    T[] Elements;
    Func<T, T, T> Merge;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public BIT(int size, T identity, Func<T, T, T> merge)
    {
        Size = size;
        Identity = identity;
        Merge = merge;
        Elements = new T[Size + 1];
        for (int i = 0; i < Elements.Length; i++)
            Elements[i] = identity;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public T Query(int r)
    {
        T res = Identity;
        for (; r > 0; r -= r & -r)
            res = Merge(res, Elements[r]);
        return res;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public void Operate(int i, T x)
    {
        for (; i < Elements.Length; i += i & -i)
            Elements[i] = Merge(Elements[i], x);
    }
}





Measured memory_bytes: 19976
use proconio::*;
use std::collections::*;

#[fastout]
fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }

    let mut ok = vec![false; 1000001];
    let mut cnt = vec![0; 1000001];
    for b in a {
        ok[b] = true;
        cnt[b] += 1;
    }

    let mut ans = 0;
    for i in 0..=1000000 {
        if !ok[i] {
            continue;
        }
        if cnt[i] == 1 {
            ans += 1;
        }
        for j in 2.. {
            if i * j > 1000000 {
                break;
            }
            ok[i * j] = false;
        }
    }

    println!("{}", ans);
}


Measured memory_bytes: 9780
void main()
{
    long[] tmp = readln.split.to!(long[]);
    long x = tmp[0], y = tmp[1];

    writeln(log2(y/x).to!long + 1);
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define rep(i,a,b,c)            for(ll i=(a);i<=(b);i+=(c))
#define repb(i,a,b,c)           for(ll i=(a);i>=(b);i-=(c))
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
//#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define sll                     set<ll>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define umcl                    um<char,ll>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define ln                      cout<<"\n";
#define endl                    "\n"
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define isvowel(a)              (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define show(w,size)            {for(ll i=0;i<size;i++) cout<<w[i]<<" ";cout<<"\n";}
#define print(a)                cout<<a<<"\n";
#define mset(dp,no)             memset(dp,no,sizeof(dp))
#define input(a,n)              rep(i,0,n-1,1) cin>>a[i];
#define countbit                __builtin_popcount                                           //Number of setbits in decimal notation
#define lb(v,val)               lower_bound(all(v),val)-v.begin()
#define ub(v,val)               upper_bound(all(v),val)-v.begin()
#define SS                      stringstream
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

ll poww(ll b,ll e){if(e==0)return 1;else if(e%2==0){ll a=pow(b,e/2);return a*a;}else {ll a=pow(b,e/2);return b*a*a;}}
ll powm(ll x,ll y,ll m=MOD){x=x%m;ll res=1;while(y){if(y&1)res=res*x;res%=m;y=y>>1;x=x*x;x%=m;}return res;}
ll modInverse(ll a,ll m=MOD){if(m==1)return 0;ll m0=m,y=0,x=1;while(a>1){ll q=a/m,t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0) x+=m0;return x;}

int main()
{
	fastIO
	string s;
	cin>>s;
	ll sz=s.size();
	rep(i,0,sz-1,1)
		cout<<'x';
	return 0;
}




Measured memory_bytes: 256
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    String str = scan.nextLine();
    int money = Integer.parseInt(str);
    int happy = 0;
    happy += (money / 500) * 1000;
    happy += ((money % 500)/5) * 5;
    System.out.println(happy);
  }
}


Measured memory_bytes: 23124
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		//station info
		HashMap<Integer, Character> stations = new HashMap<Integer, Character>();
		for(int i = 0; i < 26; i++){
			stations.put(i, (char) ('a'+i));
		}
		for(int i = 0; i < 26; i++){
			stations.put(i + 26, (char) ('A'+i));
		}
		
		while(true){
			int n = Integer.parseInt(br.readLine());
			
			if(n == 0){
				break;
			}
			
			int[] keys = new int[n];
			
			String[] tmpArray = br.readLine().split(" ");
			
			for(int i = 0; i < n; i++){
				keys[i] = Integer.parseInt(tmpArray[i]);
			}
			
			String str = br.readLine();
			
			for(int i = 0; i < str.length(); i++){
				char tmpStation = str.charAt(i);
				
				int tmpId = 0;
				if(Character.isUpperCase(tmpStation)){
					tmpId = tmpStation - 'A' + 26;
				}
				else {
					tmpId = tmpStation - 'a';
				}
				
				tmpId -= keys[i%keys.length];
				if(tmpId < 0){
					tmpId += 52;
				}
//				tmpId %= 52;
				
				System.out.print(stations.get(tmpId));
			}
			System.out.println();
		}
	}

}

Measured memory_bytes: 26052
import itertools
import sys

def main():
  input = sys.stdin.readline
  n, m, r = map(int, input().split())
  R = [int(x) for x in input().split()]
  inf = pow(10, 9)+7

  roads = [[inf]*n for _ in range(n)]
  for i in range(m):
    a, b, c = map(int, input().split())
    roads[a-1][b-1] = c
    roads[b-1][a-1] = c

  for k in range(n):
    for i in range(n):
      for j in range(n):
        if roads[i][j] > roads[i][k]+roads[k][j]:
          roads[i][j] = roads[i][k]+roads[k][j]

  ans = inf
  for value in itertools.permutations(R):
    sub = 0
    for k in range(r-1):
      sub += roads[value[k]-1][value[k+1]-1]
    if ans > sub:
      ans = sub

  print(ans)

if __name__ == "__main__":
  main()

Measured memory_bytes: 4692
# -*- coding: utf-8 -*-
a = []
for i in range(3):
    a.append([int(i) for i in input().split()])
n = int(input())
b = []
for i in range(n):
    b.append(int(input()))

"""
c = [a[0][0], a[0][1], a[0][2]]
d = [a[1][0], a[1][1], a[1][2]]
e = [a[2][0], a[2][1], a[2][2]]
f = [a[0][0], a[1][0], a[2][0]]
g = [a[0][1], a[1][1], a[2][1]]
h = [a[0][2], a[1][2], a[2][2]]
i = [a[0][0], a[1][1], a[2][2]]
j = [a[2][0], a[1][1], a[0][2]]
"""

tmp = []
tmp2 = 0
tmp3 = 0
for i in range(n):
    for j in range(3):
        for k in range(3):
            if b[i] == a[j][k]:
                tmp.append([j,k])
                tmp2 += j
                tmp3 += k

count1 = 0
count2 = 0
count3 = 0
count4 = 0
count5 = 0
count6 = 0
flag = "No"
for i in range(len(tmp)):
    if tmp[i][0] == 0:
        count1 += 1
    if tmp[i][0] == 1:
        count2 += 1
    if tmp[i][0] == 2:
        count3 += 1
    if tmp[i][1] == 0:
        count4 += 1
    if tmp[i][1] == 1:
        count5 += 1
    if tmp[i][1] == 2:
        count6 += 1
if count1 >= 3 or count2 >= 3 or count3 >= 3 or count4 >= 3 or count5 >= 3 or count6 >= 3:
    flag = "Yes"
else:
    tmp4 = 0
    tmp5 = 0
    for i in range(len(tmp)):
        if (tmp[i][0] == 0 and tmp[i][1] == 0) or (tmp[i][0] == 1 and tmp[i][1] == 1) or (tmp[i][0] == 2 and tmp[i][1] == 2):
            tmp4 += 1
        if (tmp[i][0] == 0 and tmp[i][1] == 2) or (tmp[i][0] == 1 and tmp[i][1] == 1) or (tmp[i][0] == 2 and tmp[i][1] == 0):
            tmp5 += 1
    if tmp4 >= 3 or tmp5 >= 3:
        flag = "Yes"
print(flag)


Measured memory_bytes: 3192
import itertools
def resolve():
    N = int(input())
    P = tuple(map(int, input().split()))
    Q = tuple(map(int, input().split()))
    i, a, b = 0, 0, 0
    for p in itertools.permutations(range(1, N+1)):
        i += 1
        if P == Q:
            a = b = 0
            break
        elif p == P:
            a = i
        elif p == Q:
            b = i

    print(abs(a-b))

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(){
  int n, k, x, y, pay = 0;
  cin >> n >> k >> x >> y;
  for(int i = 1; i <= n; i++){
    if(i <= k){
      pay += x;
    }else{
      pay += y;
    }
  }
  cout << pay << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scanf("%d\n", &N)

	min := int(10e7)
	ans := 0
	for i := 0; i < N; i++ {
		var n int
		fmt.Scan(&n)
		if min >= n {
			min = n
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5504
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int N; cin >> N;
  int A[2][N]; 
  rep(i, N) cin >> A[0][i];
  rep(i, N) cin >> A[1][i];
  int result = 0;
  rep(i, N) {
    int tmp = 0;
    rep(j, N) {
      if (i == j) tmp += A[0][j]+A[1][j];
      else if ( j < i ) tmp += A[0][j];
      else tmp += A[1][j];
    }
    result = max(result, tmp);
  }
  cout << result << endl;
  return 0;
}

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

using namespace std;
int main()
{
    int n;
    cin >> n;
    int *a = new int[n];
    long *counts = new long[n];
    memset(counts, 0, n * sizeof(long));
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        counts[--a[i]]++;
    }

    long sum = 0;
    for (int i = 0; i < n; i++)
        sum += counts[i] * (counts[i] - 1) / 2;

    for (int i = 0; i < n; i++)
    {
        cout << sum - (counts[a[i]] * (counts[a[i]] - 1) / 2) + ((counts[a[i]] - 1) * (counts[a[i]] - 2) / 2) << endl;
    }

    delete[] a;
    delete[] counts;
}

Measured memory_bytes: 4992
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
    out << '(' << p.first << ',' << p.second << ')';
    return out;
}

template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
    in >> p.first >> p.second;
    return in;
}

template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
    for (T &x : v)
        in >> x;
    return in;
}

template <class T>
ostream& operator << (ostream& out, const vector<vector<T>> &v)
{
    for (const vector<T> &x : v)
        out << x << '\n';
    return out;
}

template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
    for (const T &x : v)
        out << x << ' ';
    return out;
}

long long gcd (long long a, long long b)
{
    if (b > a)
        swap(a, b);
    return (b ? gcd(b, a % b) : a);
}

using ll   = long long;
using pii  = pair<int, int>;
using pll  = pair<long long, long long>;
using tiii = pair<pair<int, int>, int>;
using vi   = vector<int>;
using vl   = vector<long long>;
using vvi  = vector<vector<int>>;
using vvl  = vector<vector<long long>>;

#define F          first
#define S          second
#define First      first.first
#define Second     first.second
#define Third      second
#define mp         make_pair
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define per(i,b,a) for (int i = (b); i > (a); i--)
#define all(x)     x.begin(), x.end()
#define ret(x)     return cout << x, 0;
#define throwex    throw runtime_error ("Found the error.");

const int h = 1000000007;

signed main()
{
    ios::sync_with_stdio(false);
    #ifdef ONLINE_JUDGE
    cin.tie(nullptr);
    cout.tie(nullptr);
    cerr.setstate(ios::failbit);
    #endif

    int n;
    cin >> n;
    vl a(n+1);
    cin >> a;
    vl s = a;
    for(int i = n - 1; i > -1; i--)
        s[i] += s[i+1];
    ll nodes = 1, ans = 0;
    rep(i,0,n+1)
    {
        if(nodes < a[i])
            ret(-1);
        nodes = min(nodes, s[i]);
        ans += nodes;
        nodes -= a[i];
        nodes *= 2;
    }
    ret(ans);
}


Measured memory_bytes: 4692
from collections import deque
n = int(input())
d = deque()

for i in range(n):
    line = input().split()
    if len(line) == 2:
        command, ele = line
    else:
        command = line[0]

    if command == 'insert':
        d.appendleft(ele)
    elif command == 'delete':
        if ele in d:
            d.remove(ele)
    elif command == 'deleteFirst':
        d.popleft()
    elif command == 'deleteLast':
        d.pop()

print(' '.join(list(d)))

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

int main() {
  vector<int> V(5);
  int result;
  for (int i = 0; i < 5; ++i) {
    cin >> V.at(i);
    if (V.at(i) == 0) {
      result = i + 1;
      break;
    }
  }
  cout << result << endl;
  return 0;
}


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

int lcs(char x[], char y[]){
  int m,n;
  int i,j;
  int c[1001][1001];

  m = strlen(x);
  n = strlen(y);

  for(i=0;i<=m;i++) c[i][0] = 0;
  for(j=0;j<=n;j++) c[0][j] = 0;

  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(x[i-1]==y[j-1]) c[i][j] = c[i-1][j-1]+1;
      else if(c[i-1][j]>=c[i][j-1]) c[i][j] = c[i-1][j];
      else c[i][j] = c[i][j-1];
    }
  }
  return c[m][n];
}

int main(){
  int q,i;
  char x[1000],y[1000];

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%s",x);
    scanf("%s",y);
    printf("%d\n",lcs(x,y));
  }


  return 0;
}



Measured memory_bytes: 5684
while line = gets do
    
    if line == nil
        break
    end
    
    n = line.to_i
    
    count = 0
    
    for a in 0..9 do
        for b in 0..9 do
            for c in 0..9 do
                for d in 0..9 do
                    count += 1 if a + b + c + d == n
                end
            end
        end
    end 
    puts count
end


Measured memory_bytes: 6864
#![allow(dead_code, unused_imports, non_snake_case)]

use std::io::*;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::str::FromStr;

const MOD: i32 = 1_000_000_007;

fn main() {
    let x: u64 = input();
    let y = x / 11;
    if x % 11 == 0 {
        println!("{}", y * 2);
    } else if x % 11 <= 6 {
        println!("{}", y * 2 + 1);
    } else {
        println!("{}", y * 2 + 2);
    }
}

trait Read {
    fn read(s: &str) -> Self;
}

fn input<T: Read>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    T::read(buf.trim_right())
}

macro_rules! read_impl {
    ($($t:ty)*) => ($(
        impl Read for $t {
            fn read(s: &str) -> $t{
                s.parse().unwrap()
            }
        }
    )*)
}
read_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }

impl Read for String {
    fn read(s: &str) -> Self {
        s.to_string()
    }
}

impl Read for Vec<char> {
    fn read(s: &str) -> Self {
        s.chars().collect()
    }
}

impl<T: Read> Read for Vec<T> {
    fn read(s: &str) -> Self {
        s.split_whitespace().map(T::read).collect()
    }
}

impl<A: Read, B: Read> Read for (A, B) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]))
    }
}

impl<A: Read, B: Read, C: Read> Read for (A, B, C) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]))
    }
}

impl<A: Read, B: Read, C: Read, D: Read> Read for (A, B, C, D) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]), D::read(tokens[3]))
    }
}

Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while (true) {
			int m = scan.nextInt();
			int f = scan.nextInt();
			int r = scan.nextInt();

			if ((m == -1) && (f == -1) && (r == -1)) {
				break;
			}
			else {

				if (m == -1 || f == -1) {
					System.out.println("F");
				}
				else if (80 <= m + f) {
					System.out.println("A");
				}
				else if ((65 <= m + f) && (m + f < 80)) {
					System.out.println("B");
				}
				else if ((50 <= m + f) && (m + f < 65)) {
					System.out.println("C");
				}
				else if ((30 <= m + f) && (m + f < 50) && (r >= 50)) {
					System.out.println("C");
				}
				else if ((30 <= m + f) && (m + f < 50)) {
					System.out.println("D");
				}
				else if ((m + f < 30)) {
					System.out.println("F");
				}
			}
		}
	}
}

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

int cnt;
vector<int> g;

void insertionSort(vector<int> &a, int n, int g) {
	for (int i = g; i < n; i++) {
		int v = a[i];
		int j = i - g;
		while ((j >= 0) && (a[j] > v))
		{
			a[j + g] = a[j];
			j = j - g;
			cnt++;
		};
		a[j + g] = v;
	}
}

void shellSort(vector<int> &a, int n) {
	cnt = 0;
	for (int h = 1;;) {
		if (h > n)
			break;
		g.push_back(h);
		h = 3 * h + 1;
	}
	for (int i = g.size()-1; i >=0; i--) {
		insertionSort(a, n, g[i]);
	}
}

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	shellSort(a, n);
	//cout << endl;
	cout << g.size() << endl;
	for (int i = g.size() - 1; i >= 0; i--) {
		if (i != 0) {
			cout << g[i] << " ";
		}
		else
		{
			cout << g[i] << endl;
		}
	}
	cout << cnt << endl;
	for (int i = 0; i < n; i++) {
		cout << a[i] << endl;
	}
	return 0;
	
}


Measured memory_bytes: 6796
import java.util.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        int num = Integer.parseInt(line);

        int count = 0;
        boolean ret = false;
        for (int i = 0; i < num; i++) {
            line = sc.nextLine();
            String[] lines = line.split(" ", 0);
            int a = Integer.parseInt(lines[0]);
            int b = Integer.parseInt(lines[1]);
            if (a == b) {
                count++;
                if (count == 3) {
                    ret = true;
                }
            } else {
                count = 0;
            }
        }

        if (ret) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35868
n = int(input())
a = list(map(int,input().split()))
a.sort()
b = [0]
c = [0]
for i in range(n):
    if i%2:
        b.append(a[i])
        c.append((24-a[i])%24)
    else:
        c.append(a[i])
        b.append((24-a[i])%24)
b.sort()
c.sort()
mn1=24
mn2=24
for i in range(n):
    mn1 = min(mn1,b[i+1]-b[i])
    mn2 = min(mn2,c[i+1]-c[i])
mn1 = min(mn1,b[0]+24-b[-1])
mn2 = min(mn2,c[0]+24-c[-1])
print(max(mn1,mn2))

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

long long dp[25000001];
using namespace std;
int main() {
    int N;
    int a[3], b[3];
    cin >> N;
    cin >> a[0] >> a[1] >> a[2];
    cin >> b[0] >> b[1] >> b[2];

    int diffs[3] = {a[0]-b[0], a[1]-b[1], a[2]-b[2]};
    int idx[3] = {0, 1, 2};
    sort(idx, idx+3, [&](int i1, int i2){return diffs[i1] < diffs[i2];});
    
    /*
    g * i + s * j + b * k < N
    max gd * i + sd * j + bd * k

        
    max gd * i + sd * j + bd * k
        g * i + s * j + b * k + _ = N
        i,j,k,_ >= 0
    
    max Z
              g * i + s * j + b * k + _ = N
        Z - (gd * i + sd * j + bd * k) = 0
        i,j,k,_ >= 0
    */
    // phase 1-2
    for (int k=0; k<3; k++) {
        if (diffs[idx[k]] < 0) {
            for (int i=N; i >= 0; i--) {
                if (i == N || dp[i] > 0) {
                    int target = i - a[idx[k]];
                    if (target >= 0) {
                        dp[target] = (dp[target] > dp[i] + b[idx[k]]) ? dp[target] : (dp[i] + b[idx[k]]);
                    }
                }
            }
        }
    }
    long long maxV = 0;
    for (long long i = 0; i <= N; i++) {
        long long v = i + dp[i];
        if (maxV < v) maxV = v;
    }

    for (long long i=0; i<=maxV; i++) dp[i] = 0;
    // phase 2-3
    for (int k=0; k<3; k++) {
        if (diffs[idx[k]] > 0) {
            for (int i=maxV; i >= 0; i--) {
                if (i == maxV || dp[i] > 0) {
                    int target = i - b[idx[k]];
                    if (target >= 0) {
                        dp[target] = (dp[target] > dp[i] + a[idx[k]]) ? dp[target] : (dp[i] + a[idx[k]]);
                    }
                }
            }
        }
    }
    long long maxV2 = 0;
    for (long long i = 0; i <= maxV; i++) {
        long long v = i + dp[i];
        if (maxV2 < v) maxV2 = v;
    }
    cout << maxV2 << endl;

}


Measured memory_bytes: 195584
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;



void solve()
{
    ll X;
    scanf("%lld", &X);
    int sum = 0;
    int i;
    for (i = 1; i <= 100000; i++) {
        sum += i;
        if (sum >= X) {
            printf("%d\n", i);
            return;
        }
    }

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


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

const int MAX_N = 1e5;
const int MAX_V = 1e9;
int N;
int X[MAX_N], L[MAX_N];

P ps[MAX_N];

int solve(){
    rep(i,N) ps[i] = P(X[i] + L[i], X[i] - L[i]);
    sort(ps, ps + N);
    int cur = -MAX_V;
    int ans = 0;
    rep(i,N){
        if(cur <= ps[i].second){
            ans ++;
            cur = ps[i].first;
        }
    }
    return ans;
}

int main(){
    cin >> N;
    rep(i,N) cin >> X[i] >> L[i];

    int ans = solve();
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s,x,y;
    cin>>s;
    int a=0,b;
    for(int i=1;i<s.size()/2;i++){
        b=1;
        for(int j=0;j<i;j++){
            if(s[j]!=s[i+j]) b=0;
        }
        if(b) a=i*2;
    }
    cout<<a<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;

int main(void) {
    ll A, B, K;
    scanf("%lld%lld%lld", &A, &B, &K);

    ll Ares, Bres;
    if(K <= A) {
        Ares = A - K;
        Bres = B;
    } else if(K <= A + B) {
        Ares = 0;
        Bres = B - (K - A);
    } else {
        Ares = 0;
        Bres = 0;
    }
    printf("%lld %lld\n", Ares, Bres);

    return 0;
}

Measured memory_bytes: 1688
#include <iostream>
#include <vector>

#define ll long long
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++)cin >> a[i];

    vector<ll> sum(n + 1);
    for (int i = 0; i < n; i++)sum[i + 1] = sum[i] + a[i];

    vector<ll> left_onlyplus_sum(n + 1);
    for (int i = 0; i < n; i++)left_onlyplus_sum[i + 1] = left_onlyplus_sum[i] + max(0, a[i]);
    vector<ll> right_onlyplus_sum(n + 1);
    for (int i = n; i > 0; i--)right_onlyplus_sum[i - 1] = right_onlyplus_sum[i] + max(0, a[i - 1]);

    ll ret = 0;
    for (int i = 0; i + k <= n; i++)
        ret = max(ret, left_onlyplus_sum[i] + max(0LL, sum[i + k] - sum[i]) + right_onlyplus_sum[i + k]);

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 2944
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) {
        String line = readLine(System.in);
        String[] input = line.split(" ");
        int w = Integer.parseInt(input[0]);
        int h = Integer.parseInt(input[1]);
        int x = Integer.parseInt(input[2]);
        int y = Integer.parseInt(input[3]);
        int r = Integer.parseInt(input[4]);

        boolean flag = true;
        if (x - r < 0) {
            flag = false;
        }
        if (y - r < 0) {
            flag = false;
        }
        if (x + r > w) {
            flag = false;
        }
        if (y + r > h) {
            flag = false;
        }

        String result = flag ? "Yes" : "No";
        System.out.println(result);
    }

    private static String readLine(InputStream in) {
        String line = null;
        BufferedReader reader = null;

        try {
            reader = new BufferedReader(new InputStreamReader(in));
            line = reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            if (reader != null) {
                try {
                    reader.close();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
        }

        return line;
    }
}

Measured memory_bytes: 17056
N = gets.to_i
S = gets.chomp.chars

def create_cumulative_sum(arr)
  ret = []
  x = 0
  arr.each do |a|
    ret.push(x)
    x += yield(a)
  end
  ret.push(x)
end

def range_sum(arr, i, j)
  arr[j] - arr[i]
end

E = create_cumulative_sum(S){|c|c=="E" ? 1 : 0}
W = create_cumulative_sum(S){|c|c=="W" ? 1 : 0}

count = 3 * 10 ** 5
N.times do |i|
  c = range_sum(W, 0, i) + range_sum(E, i+1, N)
  count = c if count > c
end

puts count

Measured memory_bytes: 32324
s = input()
res = 0
prv, tmp = '!', '!'
n = len(s)
piv = 0
while piv < n:
    tmp = prv
    if s[piv] != prv:
        res += 1
        prv = s[piv]
        piv += 1
    else:
        res += 1
        prv = s[piv:piv + 2]
        piv += 2
    # print(prv)
print(res - int(prv == tmp))

Measured memory_bytes: 3500
###############################################################################

from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


###############################################################################


def main():
    s = input()

    if s[0] != 'A':
        print('WA')
        return

    count = 0
    for c in s[2:-1]:
        if c == 'C':
            count += 1
    if count != 1:
        print('WA')
        return

    if s[1].isupper():
        print('WA')
        return

    if s[-1].isupper():
        print('WA')
        return

    for c in s[2:-1]:
        if c != 'C' and c.isupper():
            print('WA')
            return

    print('AC')


if __name__ == '__main__':
    main()
 

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

vector<long long> a, b;
long long n;

bool solve();

int main() {
  cin >> n;
  a.resize(n);
  b.resize(n);
  for(int i = 0; i < n; ++i) cin >> a[i];
  for(int i = 0; i < n; ++i) cin >> b[i];
  if(solve())
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

bool solve() {
  long long num = 0, one = 0;
  for(int i = 0; i < n; ++i) {
    one += max(a[i] - b[i], 0LL);
    num += max((b[i] - a[i]) / 2, 0LL);
  }
  return num >= one;
}

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

int main() {
    int s;
    cin >> s;
    int ans = 1;
    set<int> se;
    se.insert(s);
    while(true){
        if(s%2==0){
            s /= 2;
            ans++;
            if(se.count(s)) break;
            se.insert(s);
        }
        else{
            s = 3*s + 1;
            ans++;
            if(se.count(s)) break;
            se.insert(s);
        }
    }
    cout << ans ;
}

Measured memory_bytes: 256
using System;
namespace _0001
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            int b = int.Parse(Console.ReadLine());
            int c = int.Parse(Console.ReadLine());
            int d = int.Parse(Console.ReadLine());
            int e = int.Parse(Console.ReadLine());
            int f = int.Parse(Console.ReadLine());
            int g = int.Parse(Console.ReadLine());
            int h = int.Parse(Console.ReadLine());
            int i = int.Parse(Console.ReadLine());
            int j = int.Parse(Console.ReadLine());
            int[] mountain = new int[] { a, b, c, d, e, f, g, h, i, j };
            Array.Sort(mountain);
            Console.WriteLine(mountain[9].ToString());
            Console.WriteLine(mountain[8].ToString());
            Console.WriteLine(mountain[7].ToString());
        }
    }
}

Measured memory_bytes: 9380