akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <list>
#include <algorithm>
using namespace std;

int main()
{
  int n, x;
  char com[20];
  list<int> v;
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
  {
    scanf("%s", com);
    if (com[0] == 'i')
    {
      scanf("%d", &x);
      v.push_front(x);
    }
    else if (com[6] == 'L')
    {
      // deleteLast
      v.pop_back();
    }
    else if (com[6] == 'F')
    {
      // deleteFirst
      v.pop_front();
    }
    else if (com[0] == 'd')
    {
      // delete
      scanf("%d", &x);
      for (list<int>::iterator it = v.begin(); it != v.end(); it++)
      {
        if (*it == x)
        {
          v.erase(it);
          break;
        }
      }
    }
  }
  int i = 0;
  for (list<int>::iterator it = v.begin(); it != v.end(); it++)
  {
    if (i++)
      printf(" ");
    printf("%d", *it);
  }
  printf("\n");

  return 0;
}


Measured memory_bytes: 34480
a,b = map(int, input().split())
string=""
if a>b:
    for i in range(a):
        string = string + str(b)
elif b>a:
    for i in range(b):
        string = string + str(a)
else:
    for i in range(b):
        string = string + str(a)
print(string)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  int r;
  cin >> r;
  if(r < 1200){
    cout << "ABC" << endl;
    return 0;
  }
  if(r < 2800){
    cout << "ARC" << endl;
    return 0;
  }
  if(r>=2800){
    cout << "AGC" << endl;
  }
  return 0;
}


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

const long long MOD = 1000000007;
// modint: mod 計算を int を扱うように扱える構造体
template <int MOD>
struct Fp
{
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD)
    {
        if (val < 0)
            val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator-() const noexcept
    {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator+(const Fp &r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator-(const Fp &r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator*(const Fp &r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator/(const Fp &r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp &operator+=(const Fp &r) noexcept
    {
        val += r.val;
        if (val >= MOD)
            val -= MOD;
        return *this;
    }
    constexpr Fp &operator-=(const Fp &r) noexcept
    {
        val -= r.val;
        if (val < 0)
            val += MOD;
        return *this;
    }
    constexpr Fp &operator*=(const Fp &r) noexcept
    {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp &operator/=(const Fp &r) noexcept
    {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b)
        {
            long long t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0)
            val += MOD;
        return *this;
    }
    constexpr bool operator==(const Fp &r) const noexcept
    {
        return this->val == r.val;
    }
    constexpr bool operator!=(const Fp &r) const noexcept
    {
        return this->val != r.val;
    }
    friend constexpr ostream &operator<<(ostream &os, const Fp<MOD> &x) noexcept
    {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept
    {
        if (n == 0)
            return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1)
            t = t * a;
        return t;
    }
};
using mint = Fp<MOD>;

void solve(long long N)
{

    if (N == 1)
    {
        cout << 0 << endl;
        return;
    }

    mint ans = 1;
    // 並べ方 N!
    for (ll i = 1; i <= N; i++)
    {
        //ans *= i;
    }
    // 値の決め方 10^(N)
    for (ll i = 0; i < N; i++)
    {
        ans *= 10;
    }

    // 0または9を含まないもの
    mint not0 = 1;
    for (ll i = 1; i <= N; i++)
    {
        //not0 *= i;
    }
    for (ll i = 0; i < N; i++)
    {
        not0 *= 9;
    }
    ans -= not0 * 2;

    // 0と9を含まないもの
    not0 = 1;
    for (ll i = 1; i <= N; i++)
    {
        //not0 *= i;
    }
    // 値 10^(N)
    for (ll i = 0; i < N; i++)
    {
        not0 *= 8;
    }
    ans += not0;
    cout << ans << endl;
}

signed main()
{
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3756
k = int(input())
p = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(p[k-1])

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for(int i = 1;i < n;i++)
    {
        int count = 0;
        for(char c = 'a';c <= 'z';c++)
        {
            bool flag1 = false,flag2 = false;
            for(int j = 0;j < i;j++)
            {
                if(s[j] == c)
                {
                    flag1 = true;
                }
            }
            for(int j = i;j < n;j++)
            {
                if(s[j] == c)
                {
                    flag2 = true;
                }
            }
            if(flag1 && flag2)
            {
                count++;
            }
        }
        if(count > ans)
        {
            ans = count;
        }
    }
    cout << ans;

    return 0;
}

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

int main(int argc, char const *argv[])
{
    int n,i;
    double x[11];
    string u[11];
    cin >> n;
    double sum = 0;
    for(i=1;i<n+1;++i){
        cin >> x[i] >> u[i];
        u[i]=="JPY" ? sum += x[i] : sum+=x[i]*380000;
    }
    cout << sum << endl;
    return 0;
}

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

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

  ll sum = 0;

  for(auto c : s) {
    sum += c - '0';
  }

  string ans = "No";
  if(sum % 9 == 0) {
    ans = "Yes";
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main()
{
    int a, b;
    scanf("%d%d", &a, &b);
    if(a<=0 && b>=0)
        printf("Zero\n");
    else
    {
        int p=1;
        for(int i=a; i<=b; i++)
        {
            int x;
            if(i<0)
                x=-1;
            else
                x=1;
            p*=x;
        }
        if(p<0)
            printf("Negative\n");
        else
            printf("Positive\n");
    }
    return 0;
}


Measured memory_bytes: 764
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int K = scan.nextInt();
		int p = 0;
		for(int i = 0; i < N; i++) {
			int a = scan.nextInt();
			if(a == 1) {
				p = i;
			}
		}
		scan.close();
		if(N == K) {
			System.out.println(1);
			System.exit(0);
		}

		int r = 0;
		int l = 0;
		int min = N;
		int m = K - 1;
		for(int i = 0; i < K; i++) {
			int cnt = 1;
			l = p - m + i;
			r = p + i;
			if(l > 0) {
				while(l > 0) {
					l = l - m;
					cnt ++;
				}
			}
			if(r < N - 1) {
				while(r < N - 1) {
					r = r + m;
					cnt ++;
				}
			}
			if(min > cnt) {
				min = cnt;
			}
		}
		System.out.println(min);

	}
}

Measured memory_bytes: 48084
#include<algorithm>
#include<iomanip>
#include<iostream>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<vector>
#include<bitset>
#include<cmath>
#define FOR(i,a,b) for(int i=(a); i<int(b); ++i)
#define RFOR(i,a,b) for(int i=(b)-1; i>=int(a); --i)
#define rep(i,n) FOR(i,0,n)
#define rep1(i,n) FOR(i,1,int(n)+1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
#define al(d) d.begin(),d.end()
using namespace std;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(int n){
	vector<T> vec;
	rep(i,n){
		T input;
		cin >> input;
		vec.emplace_back(input);
	}
	return vec;
}

using AdjList = vector<vector<int>>;
using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;
void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }
// Recieve edge(=(int,int)) as an adj list.
AdjList getadj(int N, int M){
	// Initialize all lists of the graph as a empty vector.
	vector<int> init;
	vector<vector<int>> graph(N,init);
	rep(i,M){
		int a, b;
		cin >> a >> b;
		graph[a-1].emplace_back(b-1);
		graph[b-1].emplace_back(a-1);
	}
// rep(i,N)
// 	putv(graph[i]);
	return graph;
}


long long Manhattan_dist(long long x1, long long y1, long long x2, long long y2){return abs(x1-x2) + abs(y1-y2);}

void out(bool ans){
	if(ans == true) cout << "yes" << endl;
	else cout << "no" << endl;
}
void Out(bool ans){
	if(ans == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}
void OUT(bool ans){
	if(ans == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}
unsigned long long gcd(const unsigned long long a, const unsigned long long b){
	return (b==0) ? a : gcd(b,a%b);
}


bool search(int x, int y);
int H,W;
vector<string> s;
int main(){
	cin >>H>>W;
	s = getv<string>(H);

	bool ans = true;
	rep(x,H){
		if(!ans) break;
		rep(y,W){
			if(!ans) break;
			if(s[x][y]=='#' && !search(x,y)) ans = false;
		}
	}
	Out(ans);
}

// 上下左右のいずれかに黒が隣接していればtrueを返す
bool search(int x, int y){
	if(0<=x-1 && s[x-1][y] == '#') return true;
	if(0<=y-1 && s[x][y-1] == '#') return true;
	if(y+1<W  && s[x][y+1] == '#') return true;
	if(x+1<H  && s[x+1][y] == '#') return true;
	return false;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); } bool DEBUG = 0; 
void log(A ...)(lazy A a){ if(DEBUG) print(a); }
void print(){ writeln(""); } void print(T)(T t){ writeln(t); } void print(T, A ...)(T t, A a){ write(t, " "), print(a); }
string unsplit(T)(T xs){ return xs.array.to!(string[]).join(" "); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; } T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
T lowerTo(T)(ref T x, T y){ if(x > y) x = y; return x; } T raiseTo(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
    int na = scan!int, nb = scan!int, m = scan!int;
    long[] as = scan!long(na);
    long[] bs = scan!long(nb);

    S[] ss;
    foreach(j; 0 .. m) ss ~= S(scan!int - 1, scan!int - 1, scan!long);

    long amin = as[0], bmin = bs[0];
    foreach(a; as) amin.lowerTo(a);
    foreach(b; bs) bmin.lowerTo(b);

    long ans = amin + bmin;
    foreach(s; ss){
        long tmp = as[s.x] + bs[s.y] - s.c;
        ans.lowerTo(tmp);
    }

    ans.writeln;
}

struct S{
    int x, y;
    long c;
}

Measured memory_bytes: 10928
def numChange(num):
    if num <= 26:
        return chr(num+96)
    elif num % 26 == 0:
        return numChange(num//26-1) + chr(122) # output(Z)
    else:
        return numChange(num//26) + chr(96+num%26)

n = int(input())
print(numChange(n))

Measured memory_bytes: 9076
#!/usr/bin/env python3

H, W = list(map(int, input().split()))
N = int(input().split()[0])
a_list = list(map(int, input().split()))

c_list = []

for i, a in enumerate(a_list):
    c_list += [i + 1] * a

for i in range(H):
    w_list = c_list[W * i : W * (i + 1)]
    if i % 2 == 1:
        w_list = reversed(w_list)
    print(" ".join([str(w) for w in w_list]))


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
ll MM = 1000000000; ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true;} return false;}
const ll INF = 1LL << 60;
using Graph = vector<vector<ll>>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1}, ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//cout << fixed << setprecision(10);

int field[100][100];
ll w, h;


void dfs(ll y, ll x){
    field[y][x] = 0;
    rep(i, 8){
        ll ny = y + ddy[i], nx = x + ddx[i];
        if(0 <= ny && ny < h && 0 <= nx && nx < w && field[ny][nx]){
            dfs(ny, nx);
        }
    }
}


int main(){
    while(1){
        cin >> w >> h;
        if(!w && !h) break;
        rep(hi, h){
            rep(wi, w){
                cin >> field[hi][wi];
            }
        }

        ll ans = 0;
        rep(hi, h){
            rep(wi, w){
                if(field[hi][wi]){
                    dfs(hi, wi);
                    ans++;
                }
            }
        }

        cout << ans << endl;
    }
}



Measured memory_bytes: 3168
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
 
 
int main() {
    int D, N;
    cin >> D >> N;
    int ans = 1;
    while (D > 0) {
        ans *= 100;
        D--;
    }
    if (N < 100) {
        cout << N * ans << endl;
    } else {
        cout << 101 * ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
// inputに入力データ全体が入る

function Main(input) {
  const resrt = Math.ceil(input / 1.08);
  const aaaa = Math.floor( resrt * 1.08);
  // console.log(aaaa + " aaaa");
  // console.log(resrt + " resrt");
  // console.log(input / 1.08 + " input / 1.08");
  
  if (aaaa == input) {
    console.log(resrt);
    
  } else {
    console.log(':(');
    
  }
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long res = 0;
    long long n;
    cin>>n;
    if (n==2)
    {
        cout<<0;
        return 0;
    }
    long long rt = sqrt(n);
    int f=1;
    if (rt * rt == n)
    f = 0;
    for (int i = 1; i < rt + f; i++)
    {
        if (n % i == 0)
        {
            if (n / i - 1 > i)
            res += n / i - 1;
        }
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
lst = list(map(int, input().split()))
cnt = 0
for i in range(N-2):
    if lst[i] < lst[i+1] and lst[i+1] < lst[i+2]:
        cnt += 1
    elif lst[i] > lst[i+1] and lst[i+1] > lst[i+2]:
        cnt += 1
print(cnt)


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

int main(){
  int TL, TA, AL, AA;
  cin >> TL >> TA >> AL >> AA;
  int T_D = TL/AA;
  if (TL%AA != 0) ++T_D;
  int A_D = AL/TA;
  if (AL%TA != 0) ++A_D;
  if (A_D > T_D) cout << "No";
  else cout << "Yes";
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

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


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var h1, m1,h2,m2,k int
	fmt.Scan(&h1, &m1,&h2,&m2,&k)

	time := (60*h2 + m2) - (60*h1+m1) 
	res := time - k

	

	fmt.Println(res)
}

Measured memory_bytes: 1752
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
#include <queue>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){

    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    queue<int> q;
    if(s[0]=='0'){
        k--;
        
    }
    q.push(0);
    int result = 0;
    FOR(i,1,n){

        if(s[i]=='0'){
            if(s[i-1]=='1'){
                k--;

            }
            if(i==n-1){
                
                result = max(n -q.front(), result);
            }
        }else{
            if(s[i-1]=='0'){
                q.push(i);
            }
            if(k<=0){
                if(i==n-1){
                    result = max(i + 1 - q.front(), result);
                }else if(s[i+1]=='0'){
                    result=max(i + 1 - q.front(), result);
                    q.pop();
                }
            }
        }

        

    }
    if(k>0){
        result = n;
    }

    cout << result << endl;
    return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <numeric>
#include <complex>

using namespace std;

typedef long long ll;

#define mp make_pair
#define pb push_back
#define PI 3.1415926535897932384626433832795

#define fill(x, v)  fillchar(x, v, sizeof(x))
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector< pii >   vpii;

#define MAXN 3010
string s, t;
int f[MAXN][MAXN];
pii back[MAXN][MAXN];

void rec(int i, int j) {
    if (!i || !j) return;

    rec(back[i][j].first, back[i][j].second);
    pii p = {i-1,j-1};
    if (back[i][j] == p) printf("%c", s[i]);
}

int main() {
    cin >> s >> t;
    s = " " + s;
    t = " " + t;
    for(int i = 1; i < s.size(); ++i)
        for(int j = 1; j < t.size(); ++j) {
            f[i][j] = f[i - 1][j];
            back[i][j] = {i - 1, j};

            if (f[i][j] < f[i][j - 1]) {
                f[i][j] = f[i][j - 1];
                back[i][j] = {i, j - 1};
            }

            if (s[i] == t[j] && f[i][j] < f[i - 1][j - 1] + 1) {
                f[i][j] = f[i - 1][j - 1] + 1;
                back[i][j] = {i - 1, j - 1};
            }
        }

    rec(s.size() - 1, t.size() - 1);

    return 0;
}

Measured memory_bytes: 106496
#include<cstdio>
int N,ans,now,tmp;
int main()
{
	scanf("%d",&N);
	while(N--)
	{
		scanf("%d",&tmp);
		if(tmp>1<<now)
			while(1<<now<tmp)
			{
				now++;
				ans++;
			}
		else
			while(1<<now>tmp)
				now--;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
#define ll long long
#define maxn 1005
using namespace std;
struct node{
	ll x,y,z,d;
}a[maxn];
bool cmp(node a,node b){
	return a.d>b.d;
}
int main(){
	int n,z;
	scanf("%d%d",&n,&z);
	for (int i=1;i<=n;i++)
		scanf("%lld%lld%lld",&a[i].x,&a[i].y,&a[i].z);
	ll ans=0;
	for (int k=0;k<8;k++){
		for (int i=1;i<=n;i++){
			a[i].d=0;
			if (k&1) a[i].d+=a[i].x;else a[i].d-=a[i].x;
			if (k&2) a[i].d+=a[i].y;else a[i].d-=a[i].y;
			if (k&4) a[i].d+=a[i].z;else a[i].d-=a[i].z;
		}
		sort(a+1,a+1+n,cmp);
		ll now=0;
		for (int i=1;i<=z;i++)
		now+=a[i].d;
		if (now>ans) ans=now;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
  int prime[25] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
  int counter[25] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
  int n = 0;
  scanf("%d",&n);
  int i,j;
  for(i=1;i<n+1;i++) {
    int itemp = i;
    for(j=0;j<25;j++) {
      while(itemp%prime[j] == 0) {
        counter[j]++;
        itemp = itemp/prime[j];
      }
    }
  }
  //for(i=0;i<25;i++) {
  //  printf("%d %d\n",prime[i],counter[i]);
  //}
  //scenario 1: 74
  //scenario 2: 4 14
  //scenario 3: 2 4 4
  //scenario 4: 2 24

  int i74 = 0;
  int i24 = 0;
  int i14 = 0;
  int i4 = 0;
  int i2 = 0;
  for(i=0;i<25;i++) {
    if(counter[i]>=2) {
      i2++;
    }
    if(counter[i]>=4) {
      i4++;
    }
    if(counter[i]>=14) {
      i14++;
    }
    if(counter[i]>=24) {
      i24++;
    }
    if(counter[i]>=74) {
      i74++;
    }
  }
  int ans = 0;
  ans += i74;
  ans += i24 * (i2 - 1);
  ans += i14 * (i4 - 1);
  ans += i4 * (i4 - 1) * (i2 - 2)/2;
  printf("%d\n",ans);
  return 0;
}


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

int main(){
  string s;
  cin>>s;
  int n=s.size();
  vector<int> a(n+1);
  rep(i,n){
    if(s[i]=='A' or s[i]=='C' or s[i]=='G' or s[i]=='T'){
      a[i]=1;
    }
  }
  int ans=0;
  int tp=0;
  rep(i,n+1){
    if(a[i]==1){
      tp++;
    }else{
      ans=max(ans,tp);
      tp=0;
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;;
#define ll long long
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b; cin >> a >> b;
  cout << max({a+b,a-b,a*b}) << endl;;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int n;
    string s;
    map<string,int>mp;
    cin>>n;
    while(cin>>s)
        mp[s]++;
    int ans=0;
    for(auto x:mp)
        ans=max(ans,x.second);
    for(auto x:mp)
        if(x.second==ans)
            cout<<x.first<<endl;
}


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

using namespace std;

template<typename T>
void cinc(T& c)
{
  for (auto&& e : c) {
    cin >> e;
  }
}

template<typename T>
void sort(T& c)
{
  sort(begin(c), end(c));
}

template<typename T>
T my_gcd(T a, T b)
{
  return b == 0 ? a : my_gcd(b, a % b);
}

int main()
{
  int n;
  cin >> n;
  vector<int64_t> v(n);
  cinc(v);
  int64_t ans = v[0];
  for (auto i = 1; i < n; i++) {
    ans = my_gcd(ans, v[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c;
  cin >> a;
  b = a / 1000;
  c = a % 10;
  if ((a - 1000*b) % 111 == 0) {
  cout << "Yes" << endl;
  }
  else if ((a - c) % 1110 == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
n = int(input())
s = input()

R=[]
G=[]
B=[]

for i in range(n):
    if s[i] == "R":
        R.append(i)
    elif s[i] == "G":
        G.append(i)
    else:
        B.append(i)

ans = len(R)*len(G)*len(B)
for i in range(n-2):
    for j in range(i+1,n-1):
        k  = 2*j-i
        if k<n:
            if (s[i]!=s[j]) and (s[i]!=s[k]) and (s[j]!=s[k]):
                ans-=1
print(ans)

Measured memory_bytes: 9124
#include <bits/stdc++.h>
#include<iostream>
#include<fstream>
#define ll long long
using namespace std;

bool vanish(int n, string s, vector<string> t, vector<string> d, int m){
    int Q = t.size();
    int x = n-1;
    int L = s.length();
    for(int i=0; i<Q; i++){
        if(t[i][0]==s[x]){
            x += (d[i][0]=='R'?1:-1);
            if(x==-1 || x==L) break;
        }
    }

    if(x==-1 && m==0){
        return true;
    }else if(x==L && m==1){
        return true;
    }else{
        return false;
    }
}

int main(){
    int N, Q;  string s;
    cin >> N >> Q >> s;
    vector<string> t(Q), d(Q);
    for(int i=0; i<Q; i++)
        cin >> t[i] >> d[i];
    
    int Lleft = 0, Lright = N+1;
    while(Lright - Lleft > 1){
        int mid = Lleft + (Lright - Lleft)/2;
        if(vanish(mid, s, t, d, 0)){
            Lleft = mid;
        }else{
            Lright = mid;
        }
        // cout << Lleft << " " << Lright << endl;
    }

    int Rleft = 0, Rright = N+1;
    while(Rright - Rleft > 1){
        int mid = Rleft + (Rright - Rleft)/2;
        if(vanish(mid, s, t, d, 1)){
            Rright = mid;
        }else{
            Rleft = mid;
        }
    }
    
    if(Rleft >= Lright){
        cout << Rleft - Lright + 1 << endl;
    }else{
        cout << 0 << endl;
    }
}


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

int main ()
{
    int n, k, m;
    while (cin >> n >> k >> m, (n || m || k)) {
        vector<int> v(n);
        for (int i = 1; i <= n; i++) {
            v[i - 1] = i;
        }
        m--;

        while (v.size() > 1) {
            v.erase(v.begin() + m);
            m = (m + k - 1) % v.size();
        }
        cout << v[0] << endl;
    }

    return 0;
}

Measured memory_bytes: 1252
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

char S[12];

int main() {

	scanf("%s", S);

	map<char, int> mp;
	mp[S[0]]++;
	mp[S[1]]++;
	mp[S[2]]++;
	mp[S[3]]++;

	if (mp.size() == 2) {
		for (auto m : mp) {
			if (m.second == 2) {
				printf("Yes\n");
				return 0;
			}
		}
	   }
	printf("No\n");

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
  int i;
  int count = 0;
  char s[100000];
  
  scanf("%s",s);
  
  for(i = 1;i < strlen(s);i++){
    if(s[i-1]==s[i]){
      if(s[i] == '0'){
        s[i] = '1';
      }else{
        s[i] = '0';
      }
      count++;
    }
  }
  printf("%d\n",count);
  return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<ll,int>;
using graph = vector<vector<P>>;
template <typename K,typename V>
using umap = unordered_map<K,V>;
template <typename V>
using uset = unordered_set<V>;
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; }
#define REP(i,n) for(int i=0;i<n;i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(v) v.begin(),v.end()

#define endl "\n"
#define INF 1'000'000'000'000 //10^12
#define MOD 1'000'000'007

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n;
  string s;
  cin >> n >> s;
  vector<int> sum(n+1,0);

  REPD(i,n){
    if(s[i] == '.'){
      sum[i] = sum[i+1]+1;
    }else{
      sum[i] = sum[i+1];
    }
  }

  int min = n+1;
  int black = 0;
  REP(i,n+1){
    chmin(min,black+sum[i]);
    if(s[i] == '#'){
      black++;
    }
  }

  cout << min << endl;

  return 0;
}


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

int main(){
	string s;
	cin >> s;
	int n=s.size(),ans=753;
	if(n==1)ans=ans-(s[0]-'0');
	else if(n==2)ans=ans-(s[0]-'0')*10+(s[1]-'0');
	for(int i=0;i+2<n;i++){
		int a=abs((s[i]-'0')*100+(s[i+1]-'0')*10+s[i+2]-'0'-753);
		ans = min(a,ans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

a = s()
if a.upper() == a:
    print('A')
else:
    print('a')

Measured memory_bytes: 77352
#include <algorithm>
#include <cmath>
#include <cstdio>
const int MAXN = 205;
int N, N2;

struct Point {
  int X, Y;

  bool operator < (const Point& o) const {
    return atan2(Y, X) < atan2(o.Y, o.X);
  }

  Point& operator += (const Point& o) {
    X += o.X;
    Y += o.Y;
    return *this;
  }

  Point operator - (const Point& o) const {
    return {X - o.X, Y - o.Y};
  }

  double size() const {
    return std::hypot(X, Y);
  }
} P[MAXN];


int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    scanf(" %d%d", &P[i].X, &P[i].Y);
  }
  std::sort(P, P+N);
  for (int i = 0; i < N; ++i) {
    P[i+N] = P[i];
  }
  N2 = 2*N;
  for (int i = 1; i < N2; ++i) {
    P[i] += P[i-1];
  }
  double ret = 0.0;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      ret = std::max((P[i+j+1] - P[i]).size(), ret);
    }
  }
  printf("%.15f\n", ret);
  return 0;
}

Measured memory_bytes: 384
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;

	char buf[L], *S , *T, c;

	char getchar() {
		if(__builtin_expect(S == T, 0)) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}

	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}

	unsigned inpu()
	{
		unsigned x = 0; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar());
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x;
	}

	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}

	char B[45], *outs=B+40, *outr=B+40;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;

		if(!a)*--outs = '0';
		else
			while(a)
				*--outs = (a % 10) + 48, a /= 10;

		if(x)
			*--outs = x;

		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;

using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
//using i128 = __int128_t;
//using u128 = __uint128_t;
using i128 = i64;
using u128 = u64;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

ll exgcd(ll a, ll b, ll &x, ll &y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll px, py;
	ll d = exgcd(b, a%b, px, py);
	x = py;
	y = px-a/b*py;
	return d;
}

template<class T>
inline void freshmin(T &a, const T &b)
{
	if (a > b) a = b;
}

template<class T>
inline void freshmax(T &a, const T &b)
{
	if (a < b) a = b;
}

const int MOD = 1000000007;
const int INF = 1000000000;
const int MAXN = 100010;
const int MAXK = 18;

int n, m;
int u[MAXN];
int F[MAXN];

int main()
{
	
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; ++ i)
	{
		int x;
		scanf("%d", &x);
		u[x] = 1;
	}
	F[0] = 1;
	for (int i = 1; i <= n; ++ i)
	{
		F[i] = i > 1 ? (F[i-1]+F[i-2])%MOD : F[i-1];
		if (u[i]) F[i] = 0;
	}
	cout << F[n] << endl;
	
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).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 (b<a) { a=b; return 1; } return 0; }
typedef long long ll;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }


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

  int N; std::cin >> N;
  std::vector<int> a(N); rep(i,N) std::cin >> a[i];
  std::sort( all(a) );

  ll ans = 1e10;
  for(int c = a[0]; c<= a[N-1]; c++) {
    ll tmp = 0;
    rep(i,N) tmp += ( (c-a[i])*(c-a[i]) );
    ans = std::min(ans, tmp);
  }
  std::cout << ans << std::endl;

  return 0;
}


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

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> p(n);
	rep(i, n) cin >> p[i];
	rep(i, n) p[i]++;
	int mx = 0;
	int s = 0;
	queue<int> q;
	rep(i, n) {
		s += p[i];
		q.push(p[i]);
		if (q.size() > k) {
			s -= q.front();
			q.pop();
		}
		if (q.size() == k) {
			mx = max(mx, s);
		}
	}
	double ans = mx;
	ans /= 2;
	printf("%.12f\n", ans);
	return 0;
} 

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

long long mod = 1000000007;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t / 2;
    } else {
        return modpow(m, n - 1) * m % mod;
    }
}



int main() {
    long long a = 0, ans = 0;
    string s;
    cin >> s;
    vector<int> as;
    reverse(s.begin(), s.end());
    for (int i = 0; i < s.size(); i++){
        if (s[i] == 'W'){
            a++;
        }
        if (s[i] == 'B'){
            as.push_back(a);
        }
    }
    for (int i = 0; i < as.size(); i++){
        ans += as[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1680
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        s: chars
    }
    let mut sum = 0;
    for i in 0..(s.len()/2) {
        if s[i] != s[s.len() - 1 - i] {
            sum+=1;
        }
    }
    println!("{}", sum);
}

Measured memory_bytes: 4352
#include<stdio.h>
#include<math.h>

int main(void)
{
	int n,k;
	int s[1024];
	double h[1024],x,bak=0,y[1024],t=0;
	for(int j=0;;j++){
		bak=0;
		t=0;
		scanf("%d",&n);
		if(n==0){
			k=j;
			break;
		}
		for(int i=0;i<n;i++){
			scanf("%d",&s[i]);
			y[i]=s[i];
			t+=y[i];
		}
		x=(double)t/(double)n;
		for(int i=0;i<n;i++){
			bak+=(y[i]-x)*(y[i]-x);
		}
		h[j]=sqrt((double)bak/(double)n);
	}
	for(int i=0;i<k;i++){
		printf("%8lf\n",h[i]);
	}
    return 0;
}

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

int main(){
 int h,w;
 int height[3000], width[3000];
 int count;
 while(1){
  cin >> h >> w;
  if( h==0 && w==0 ){
    break;
  }
  height[count]=h;
  width[count]=w;
  count++;
 }

 int output_count=0;
 while( output_count<count ){
   for( int i=0; i<height[output_count]; i++ ){
    for( int j=0; j<width[output_count]; j++ ){
     if( i%2==0 ){
      if( j%2==0 ){
        cout << "#";
      }else{
        cout << ".";
      }
     }else{
        if( j%2==0 ){
          cout << ".";
        }else{
          cout << "#";
        }
     }

      if( j==width[output_count]-1 ){
       cout << endl;
      }
     }
    }
   cout << endl;
   output_count++;
 }

 return 0;
}


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

const int maxn = 20;
int n, m;
bool swaped[maxn], used[maxn], ans;
string s[20];

bool check()
{
    memset(used, false, sizeof(used));
    for(int i = 0; i < m; i ++) {
        if(used[i])
            continue;
        for(int j = 0; j < m; j ++) {
            bool cur = true;
            if(i == j || used[j])
                continue;
            for(int k = 0; k < n; k ++) {
                if(s[k][i] != s[n - 1 - k][j]) {
                    cur = false;
                    break;
                }
            }
            if(cur) {
                used[i] = used[j] = true;
                break;
            }
        }
    }

    int cnt = 0, noused = -1;
    for(int i = 0; i < m; i ++)
        if(!used[i])
            cnt ++, noused = i;
    if((cnt >= 2 ) || (cnt && (m % 2 == 0)))
        return false;
    for(int i = 0; i < n; i ++)
        if(s[i][noused] != s[n - 1 - i][noused])
            return false;
    return true;
}

void dfs(int u, int flag)
{
    if(u == (n + 1)/ 2) {
        if(check())
            ans = true;
        return;
    }

    for(int i = u; i < n; i ++) {
        if(!swaped[i]) {
            swaped[i] = true;
            for(int j = i + 1; j < n; j ++) {
                if(swaped[j])
                    continue;
                swaped[j] = true;

                dfs(u + 1, flag);
                swap(s[i], s[j]);
                dfs(u + 1, flag);
                swap(s[i], s[j]);

                swaped[j] = false;
            }
            if(flag) {
                dfs(u + 1, false);
            }
            swaped[i] = false;
            break;
        }
    }
}

int main()
{
    scanf("%d%d", &n, &m);
    for(int i = 0; i < n; i ++)
        cin >> s[i];

    if(n & 1)
        dfs(0, true);
    else
        dfs(0, false);
    printf(ans ? "YES" : "NO");
    return 0;
}


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

void shuffle(int p,int c,int n[]){
	int tmp[50] = {0},i;
	memcpy(tmp,n,sizeof(int)*50);
	
	for(i = 0;i < c;i++){
		tmp[i] = n[p - 1 + i];
	}
	for(i = c;i < c + p -1;i++){
		tmp[i] = n[i - c];
	}
	memcpy(n,tmp,sizeof(int)*50);
	return;
}

int main(void){
int i,num,r,c,p,n[50] = {0};
	
	while(1){
	scanf("%d %d",&num,&r);
	if(num == 0 && r == 0) break;
	for(i = 0;i < num;i++){
		n[i] = i;
	}
	
	for(i = 0; i < r;i++){
		scanf("%d %d",&p,&c);
		shuffle(p,c,n);
	}
	
	printf("%d\n",num - n[0]);
}
return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
 
int main(void)
{
  int n,a[100],s=0;
  scanf("%d",&n);
  for(int i=0;i<n;i++){
      scanf("%d",&a[i]);
  }
  for(int i=0;i<n-1;i++){
      for(int j=i+1;j<n;j++){
          s+=a[i]*a[j];
      }
  }
  printf("%d",s);
  return 0;
}

Measured memory_bytes: 128
import collections

n = int(input())
l = [input() for _ in range(n)] 
c = collections.Counter(l)
mc = c.most_common()
maxlist = list()
for v, i in mc:
    if i == mc[0][1]:
        maxlist.append(v)
    else:
        break

maxlist.sort()

for j in maxlist:
    print(j)

Measured memory_bytes: 121724
N, M = map(int, input().split()) # Nはカード枚数、Mは操作回数
A = sorted(list(map(int, input().split())))
L = [tuple(map(int, input().split())) for _ in range(M)] # 左は変える枚数、右は変える値


L.sort(key=lambda x: x[1], reverse=True)

flag = True
num = 0
now = 0

while flag:
    if num >= M:
        break

    for i in range(L[num][0]): # iは変える枚数
        if now < N and L[num][1] > A[now]: # カード枚数がnowより小さくなるか、L[now][1]がA[now]より小さくなった場合他へ
            
            A[now] = L[num][1] #最小の値を更新
            now += 1 

        else:
            flag = False
            break

    num += 1

print(sum(A))


Measured memory_bytes: 22476
import java.util.Scanner;

public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);

		// 整数の入力
		int a = sc.nextInt();
		int zoro_cnt = 0;

		for (int i = 0; i < a; i++) {
			int b = sc.nextInt();
			int c = sc.nextInt();
			if (b == c) {
				zoro_cnt++;
				if (zoro_cnt >= 3) {
					break;
				}
			} else {
				zoro_cnt = 0;
			}
		}

		if (zoro_cnt >= 3) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 35864
#include<iostream>
using namespace std;
int main ()
{
int h,w;
	while(1)
	{	cin>>h>>w;
		if(h==0&&w==0)
		{
			break;
		}
		else
		{
			for(int i=0;i<h;i++)
			{
				for(int j=0;j<w;j++)
				{
				cout<<"#";
			}
			cout<<endl;
			}
		}
cout<<endl;
	}

}

Measured memory_bytes: 3100
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
while(true){
   var hw=arr.shift();
   if(hw=="0 0")break;
   hw=hw.split(" ").map(Number);
   var h=hw[0];
   var w=hw[1];
   var yx=[];
   for(var i=0;i<h;i++)yx.push(arr.shift().split(""));
   var ary=[];
   for(var i=0;i<h;i++)ary.push(yx[i].join(""));
   for(var i=0;i<w;i++){
      var str="";
      for(var j=0;j<h;j++)str+=yx[j][i];
      ary.push(str);
   }
   var H=[];
   for(var i=0;i<h;i++)H.push(i);
   while(H.length!=0){
      var v=H.shift();
      //---------------------------------------------
      var str=yx[v][0];
      var j=v;
      var x=0;
      while(true){
         j++;
         x++;
         if(j==h)j=0;
         if(x==w)x=0;
         if(x==0)H=H.filter(function(value){return (j!=value);});
         if(j==v && x==0)break;
         str+=yx[j][x];
      }
      ary.push(str);
      //---------------------------------------------
      var str=yx[v][0];
      var j=v;
      var x=0;
      while(true){
         j--;
         x++;
         if(j<0)j=h-1;
         if(x==w)x=0;
         if(j==v && x==0)break;
         str+=yx[j][x];
      }
      ary.push(str);
      //---------------------------------------------
   }
   var obj={};
   ary.forEach(function(v){
      var len=v.length;
      var vA=v;
      var vB=v.split("").reverse().join("");
      vA=vA+vA;
      vB=vB+vB;
      for(var i=0;i<len;i++){
         var strA=vA.slice(i,len+i);
         var strB=vB.slice(i,len+i);
         while(strA.length!=1){
            if(obj.hasOwnProperty(strA))obj[strA]++;
            else obj[strA]=1;
            strA=strA.slice(0,-1);
         }
         while(strB.length!=1){
            if(obj.hasOwnProperty(strB))obj[strB]++;
            else obj[strB]=1;
            strB=strB.slice(0,-1);
         }
      }
   });
   var max=0;
   var ans=[0];
   for(var k in obj){
      if(obj[k]>=2 && max==k.length)ans.push(k);
      else if(obj[k]>=2 && max<k.length){
         ans=[k];
         max=k.length;
      }
   }
   ans.sort();
   console.log(ans[0]);
}

Measured memory_bytes: 96740
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            var s = Console.ReadLine().Trim();
            if (s == "0") break;
            var ans = getAns(s);
            Console.WriteLine(ans);
        }
    }
    static int getAns(string s)
    {
        var sL = s.Length;
        var dp = new int[sL + 1, 11];
        var ans = 0;
        for (int i = 0; i < sL; i++)
        {
            var w = s[i] - '0';
            if (w != 0) dp[i + 1, w]++;
            for (int j = 0; j < 11; j++)
                dp[i + 1, (j * 10 + w) % 11] += dp[i, j];
            ans += dp[i + 1, 0];
        }
        return ans;
    }
}



Measured memory_bytes: 34276