akhauriyash/Code-Regression huggingface dataset:
#初期化
m = (10 ** 9) + 7
S = list(input())
N = len(S)
dp = [[0 for i in range(N + 2)] for j in range(3)]
three = [0 for i in range(10 ** 5 + 1)]
three[0] = 1
for i in range(1, 10 ** 5 + 1):
	three[i] = (three[i - 1] * 3) % m

#DP
que = 0
for i in range(N):
	if S[i] == "A":
		dp[0][i + 1] = dp[0][i] + three[que]
		dp[1][i + 1] = dp[1][i]
		dp[2][i + 1] = dp[2][i]
	elif S[i] == "B":
		dp[0][i + 1] = dp[0][i]
		dp[1][i + 1] = dp[0][i] + dp[1][i]
		dp[2][i + 1] = dp[2][i]
	elif S[i] == "C":
		dp[0][i + 1] = dp[0][i]
		dp[1][i + 1] = dp[1][i]
		dp[2][i + 1] = dp[1][i] + dp[2][i]
	else:
		dp[0][i + 1] = 3 * dp[0][i] + three[que]
		dp[1][i + 1] = 3 * dp[1][i] + dp[0][i]
		dp[2][i + 1] = 3 * dp[2][i] + dp[1][i]
		que += 1
	dp[0][i + 1], dp[1][i + 1], dp[2][i + 1] = dp[0][i + 1] % m, dp[1][i + 1] % m, dp[2][i + 1] % m

print(dp[2][N])

Measured memory_bytes: 19792
#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() {
    cin.tie(0);
   	ios::sync_with_stdio(false);

    int i, j, n, m, a, out;
    cin>>n>>m;
    vector<vector<int>> mat(n, vector<int>(m));
    vector<int> vec(m);
    rep(i, n) {
        rep(j, m) {
            cin>>a;
            mat[i][j] = a;
        }
    }
    rep(j, m) {
        cin>>a;
        vec[j] = a;
    }

    rep(i, n) {
        out = 0;
        rep(j, m) {
            out += mat[i][j] * vec[j];
        }
        cout<<out<<endl;
    }
}


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

const int N = 2e5 + 5;
int n, a[N], b;
int read() {
	char c = getchar();
	int x = 0, f = 1;
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (; isdigit(c); c = getchar())
		x = x * 10 + c - 48;
	return x * f;
}

int main() {
	n = read();
	for (int i = 2; i <= n; ++i) {
		b = read();
		a[b]++;
	}
	for (int i = 1; i <= n; ++i)
		printf("%d\n", a[i]);
	return 0;
}

Measured memory_bytes: 4476
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(int argc, char **argv)
{
    int A, B, K;
    cin >> A >> B >> K;
    int count = 0;
    int m = min(A, B);
    for (int i = m; i > 0; --i) {
        if (A % i == 0 && B % i == 0) {
            count++;
            if (count == K) {
                cout << i << endl;
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
object Main {
    def next(a : Int) = {
        if (a % 2 == 0) a / 2
        else 3 * a + 1 
    }
    def solve(hist : Set[Int], a : Int, n : Int) : Unit = {
        val nxt = next(a)
        if (hist contains nxt) {
            println(n+1)
        } else {
            solve(hist + a, nxt, n+1)
        }
    }
    def main(args: Array[String]) = {
        val sc = new java.util.Scanner(System.in)
        val s = sc.nextInt
        val hist : Set[Int] = Set()
        solve(hist, s, 1)
    }
}

Measured memory_bytes: 27460
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a * b, c * d) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<pair<int, int>> v;
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    v.push_back({x, y});
  }
  auto ts = clock();
  ll mx = 0;
  do {
    ll curx = 0, cury = 0;
    ll tmx = 0;
    for (int i = 0; i < n; i++) {
      curx += v[i].first, cury += v[i].second;
      if (curx * curx + cury * cury < tmx)
        curx -= v[i].first, cury -= v[i].second;
      tmx = max(tmx, curx * curx + cury * cury);
    }
    mx = max(mx, tmx);
    random_shuffle(v.begin(), v.end());
  } while ((double)(clock() - ts) / CLOCKS_PER_SEC <= 1.9);
  printf("%.16lf", sqrt(mx));
}

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

int main(){
  int num, start, end, total=0;
  cin >> num;

  REP(i,num){
    cin >> start >> end;
    total+=(end-start+1);
    if(i==(num-1))cout << total << endl;
  }
}



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

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


	int d ,t,s;
	cin>>d>>t>>s;
	if((t*s)>=d)
		cout<<"Yes\n";
	else
		cout<<"No\n";
    return 0;
		
}

Measured memory_bytes: 3648
import Data.List

solver::Int -> Int -> [Int] -> Int
solver t a= fst.head.(sortBy (\ (_,x) -> \ (_,y) -> compare (f x) (f y))).(zip [1..])
                where f x = abs ((fromIntegral a) - (fromIntegral t) + 0.006*(fromIntegral x))

main::IO()
main=do
  _<-getLine
  ta<-getLine
  let t:a:[]= map read (words ta)
  dat<-getLine
  let d = map read (words dat)
  print (solver t a d)


Measured memory_bytes: 1404
#include<math.h>
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ll long long int
#define py printf("Yes\n")
#define pn printf("No\n")
#define in cin>>
using namespace std;
const int INF = 1001001001;

int main()
{
    int a,b,ans=0;
    in a>>b;
    for(int i=a;i<=b;i++)
    {
        int v=i%10,w=i/10000%10;
        int x=i/10%10,y=i/1000%10;
        if(v==w&&x==y)ans++;
    }
    cout<<ans<<endl;
}


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

#define F first 
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 100010, M = 1010;

int n, k;
PII res[N];

int main()
{
	cin >> n >> k;
	
	int tot = (n - 1) * (n - 2) / 2;
	if (tot < k)
	{
		puts("-1");
		return 0;
	}
	
	int m = 0;
	for (int i = 2; i <= n; i ++ ) res[m ++ ] = {i, 1};
	for (int i = 2; i <= n; i ++ )
		for (int j = i + 1; j <= n && tot > k; j ++ , tot -- )
			res[m ++ ] = {i, j};
		
	cout << m << endl;	
	for (int i = 0; i < m; i ++ ) cout << res[i].F << ' ' << res[i].S << endl;
    return 0;
}

Measured memory_bytes: 3620
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

const INF = int.max / 2;
 
void main() {
    int M, N;
    scanf("%d %d\n", &M, &N);
    int[] P = new int[M];
    foreach (i; 0 .. M) {
        scanf("%d\n", &P[i]);
    }
    int[] C = new int[N];
    int[] E = new int[N];
    foreach (i; 0 .. N) {
        scanf("%d %d\n", &C[i], &E[i]);
    }
    int[][] dp = new int[][](N + 1, M + 1); // N逡ェ逶ョ縺セ縺ァ縺ョ邂ア縺ァ蜷郁ィ亥ョケ驥上′M縺ィ縺ェ繧狗ョア縺ョ縺上∩縺ゅｏ縺帙?縺?■,譛?ｂ螳峨＞縺上∩縺ゅｏ縺帙?蛟、谿オ
    foreach (ref l; dp) l[] = INF;
    dp[0][0] = 0;
    foreach (i; 1 .. N + 1) {
        foreach (j; 0 .. M + 1) {
            dp[i][j] = min(dp[i][j], dp[i - 1][j]);
            dp[i][j] = min(dp[i][j], dp[i - 1][max(0, j - C[i - 1])] + E[i - 1]);
        }
    }
    P.sort!"a > b";
    int[] S = new int[M + 1];
    S[0] = 0;
    foreach (i; 1 .. M + 1) {
        S[i] = S[i - 1] + P[i - 1];
    }
//    writeln(S);
//    foreach (l; dp) l.writeln;
    int Ans = 0;
    foreach (i; 0 .. M + 1) {
        Ans = max(Ans, S[i] - dp[N][i]);
    }
    writeln(Ans);
}

Measured memory_bytes: 22280
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b;
    c = a+b;

    if(c<a-b)
        c = a-b;
    if(c<a*b)
        c = a*b;
    
    cout<<c<<endl;
    return 0;
}

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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> A(N);
    int64_t ans=0; 
  for(int h=0;h<N;h++){
    cin >> A.at(h);
    ans+=A.at(h);
  }
  sort(A.begin(),A.end());
  
  vector<pair<int, int> > pairs(M);
  for(int i=0;i<M;i++){
    cin >> pairs[i].second >> pairs[i].first;
  }
  sort(pairs.begin(), pairs.end());
  
  vector<int> D(N);
  int sum2 = 0;
  for(int k=0;k<M;k++){
    for(int j=0;j<pairs[M-k-1].second;j++){
      if(sum2<N){
        D.at(sum2)=pairs[M-k-1].first;
        sum2++;
      }else{
        break;
      }
    }
  }
  
  for(int k=0;k<N;k++){
    if(D.at(k)>A.at(k)){  
    ans+=D.at(k)-A.at(k);
    }else{
      break;
    }
  }
	cout << ans <<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <utility>
#include <queue>

using namespace std;

#define rep(i,x) for(int i=0;i<x;++i)
#define fst first
#define scd second

using pii = pair<int, int>;

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

int H, W;

int M[1005][1005];
int cnt[1005][1005];
int visit[1005][1005];

int main()
{
    cin >> H >> W;

    rep(i, H) rep(j, W) {
        cin >> M[i][j];
    }

    vector<pii> last;

    rep(i, H) rep(j, W) {
        bool f = true;

        rep(k, 4) {
            int ny = i + dy[k], nx = j + dx[k];

            if (ny < 0 || ny >= H || nx < 0 || nx >= W) continue;

            if (M[i][j] > M[ny][nx]) f = false;
        }

        if (f) {
            last.push_back(pii(i, j));
        }
    }

    int visit_count = 0;

    for (pii &p : last) {
        visit_count += 1;

        queue<pii> q;

        rep(i, 4) {
            int y = p.fst + dy[i], x = p.scd + dx[i];

            if (y < 0 || y >= H || x < 0 || x >= W) continue;

            if (M[p.fst][p.scd] < M[y][x]) {
                q.push(pii(y, x));
            }
        }

        while (q.size()) {
            pii p = q.front(); q.pop();

            if (visit[p.fst][p.scd] == visit_count) continue;
            visit[p.fst][p.scd] = visit_count;
            cnt[p.fst][p.scd] += 1;

            rep(i, 4) {
                int ny = p.fst + dy[i], nx = p.scd + dx[i];

                if (ny < 0 || ny >= H || nx < 0 || nx >= W) continue;

                if (M[p.fst][p.scd] < M[ny][nx]) {
                    if (cnt[ny][nx] == 2) continue;
                    q.push(pii(ny, nx));
                }
            }
        }
    }

    int ans = 0;

    rep(i, H) {
        rep(j, W) {
            if (cnt[i][j] >= 2) {
                //cout << "v: " << M[i][j] << endl;
                ans++;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 14928
M[30];D(i,n,d){for(M[d]=d>0&&M[d-1]<n?M[d-1]:n;M[d]>0;M[d]--)if(n>M[d])D(i,n-M[d],d+1);else for(i=0;i<=d;i++)printf(d-i?"%d ":"%d\n",M[i]);}main(n){for(;scanf("%d",&n),n;)D(0,n,0);exit(0);}

Measured memory_bytes: 600
import numpy as np
from numba import jit
import random
verbose = False
rand = False

if rand:
    N, K = random.choice(range(10)), random.choice(range(10))
    A = np.array(random.choices(range(10**9), k=N))
else:
    N, K = list(map(int, input().split()))
    A = np.array(list(map(int, input().split())), dtype=np.int64)

ul = np.ceil(np.sum(A)/(K+1))
ll= np.floor(np.max(A)/(K+1))

EPS = 1 / 10**6

@jit(nopython=True)
def cut(A, c, N):
    return (np.sum(np.ceil(A/c))-N)

c = np.ceil((ul+ll)/2)
mx = np.max(A)
while True:
    if ul-ll <= 1:
        break
    nk = cut(A, c, N)
    if verbose:
        print('c:', c, 'nk:', nk, 'ul - ll:', ul, '/', ll)
    prev = c
    if nk  >K: # more cuts than target; larger logs can be made
        ll = c
        c = np.floor((ul + c)/2)
    else: #i.e. nk < K, less cuts than target
        ul = c
        c = np.ceil((c + ll)/2)
        
if cut(A, ll+EPS, N) >= K:
    print(np.min((np.max(A), int(ul))))
else:
    print(int(ll))
    


Measured memory_bytes: 115384
#include <iostream>
#include <cstdio>
#define REP(i, a, n) for(int i = a; i <= n; i++)
using namespace std;


int N;
double d, x;
double e = 0;

int main(void) {
  cin >> N >> d >> x;

  while(N) {
    double dn = ((d * (N + 1) * 2) + (x * 5)) / (N * 2);
    double xn = (x * (N * 2 + 4)) / (N * 2);
    double de = ((d * 2) + ((N * 2 - 1) * x)) * 0.5;
    N--; d = dn; x = xn; e += de;
  }

  printf("%.20lf\n", e);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rnfor(i,a,b) for(ll (i) = (a) - 1; (i) >= (b); --(i))
#define ll long long
#define mod (1000000007)
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
const ll inf = 1e9;

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

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

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    rep1(i, k)r = r * n-- / i;
    return r;
}

struct UnionFind {
    vector<ll> par;

    UnionFind(ll N) : par(N) {
        rep0(i, N) par[i] = i;
    }

    ll root(ll x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(ll x, ll y) {
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

int main(){
    ll n,m;
    cin >> n >> m;
    vector<ll> a(n);
    priority_queue<pair<ll, ll>> q;
    rep0(i, n)cin >> a[i];
    sort(all(a));
    rep0(i, m){
        ll b,c;
        cin >> b >> c;
        q.push(make_pair(c, b));
    }
    rep0(i, n){
        if(q.top().first > a[i] && !q.empty()){
            a[i] = q.top().first;
            if(q.top().second - 1 <= 0)q.pop();
            else{
                q.push(make_pair(q.top().first, q.top().second - 1));
                q.pop();
            }
        }else{
            break;
        }
    }
    ll ans = 0;
    rep0(i, n)ans += a[i];
    pf(ans);
    return 0;
}


Measured memory_bytes: 3188
from collections import deque

ope = ["+","-","*","/"]

l = input().split()

d = deque()
while l:
    x = l.pop(0)
    if x in ope:
        n1 = d.pop()
        n2 = d.pop()
        val = str(n2)+x+str(n1)
        d.append(eval(val))
    else:
        d.append(x)
    
print(d.pop())


Measured memory_bytes: 5968
#include <iostream>
#include <cstdio>
#include <bitset>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
#include <limits>

using namespace std;
using ll=long long;
using vint=vector<int>;
using pint=pair<int,int>;

const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

#define rep(i,n) for(int i=0;i<int(n);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,i,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

void solve(){
	int A, B;
	cin >> A >> B;
	int count = 0;
	REP(i, A, B+1){
		string str = to_string(i);
		string rev = str;
		reverse(rev.begin(), rev.end());
		if(str == rev){
			count++;
		}
	}
	cout << count << endl;
}

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

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

int main(){
   int H, W;
   std::cin >> H >> W;
   std::vector<std::string> a(H);
   for (int i=0; i<H; i++){
      std::cin >> a.at(i);
   }
   std::vector<bool> hflag(H);
   std::vector<bool> wflag(W);
   std::string wd;
   //std::string ws;
   for (int i=0; i<W; i++){
      wd = wd + ".";
      //ws = ws + "#";
   }
   for (int i=0; i<H; i++){
      //if ((a.at(i) == wd) || (a.at(i) == ws)){
      if (a.at(i) == wd){
         hflag.at(i) = true;
      } else{
         hflag.at(i) = false;
      }
   }
   for (int j=0; j<W; j++){
      for (int i=0; i<H; i++){
         if (a.at(i).at(j) == '#'){
            wflag.at(j) = false;
            break;
         } else{
            wflag.at(j) = true;
         }
      }
   }
   for (int i=0; i<H; i++){
      if (hflag.at(i) == true){
         continue;
      }
      else{
         for (int j=0; j<W; j++){
            if (wflag.at(j) == true){
               continue;
            } else{
               std::cout << a.at(i).at(j);
            }
         }
         std::cout << std::endl;
      }
   }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};


int main(){
    int N;cin >> N;
    vector<int> vec;
    for(int i = 0;i < N;i++){
        int c;cin >> c;
        vec.push_back(c);
    }
    int m = vec.front();
    for(int i = 0;i < N;i++){
        if(m - vec.at(i) >= 2){
            cout<<"No"<<endl;
            return 0;
        }
        m = max(m, vec.at(i));
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

using pi = pair<int,int>;
using P = pair<int,pi>;

struct BIT2D{
    int H,W;
    vector<vector<ll>> bit;

    BIT2D(int h, int w){
        H = h;
        W = w;
        bit = vector<vector<ll>>(h+1,vector<ll>(w+1));
    }

    void add(int y, int x, ll w){
        for(int j=y; j<=H; j+=j&-j){
            for(int i=x; i<=W; i+=i&-i){
                bit[j][i] += w;
            }
        }
    }

    ll sum(int y, int x){
        ll ret = 0;
        for(int j=y; j>0; j-=j&-j){
            for(int i=x; i>0; i-=i&-i){
                ret += bit[j][i];
            }
        }
        return ret;
    }

    ll sum(int ly, int lx, int ry, int rx){
        return sum(ry,rx) - sum(ry,lx-1) - sum(ly-1,rx) + sum(ly-1,lx-1);
    }
};

int main()
{
    int h,w,T,Q;
    scanf(" %d %d %d %d", &h, &w, &T, &Q);

    BIT2D yet(h,w),done(h,w);
    queue<P> que;
    while(Q--)
    {
        int t,c,h1,w1;
        scanf(" %d %d %d %d", &t, &c, &h1, &w1);

        while(!que.empty())
        {
            P now = que.front();
            if(now.fi+T <= t)
            {
                que.pop();
                int py = now.se.fi, px = now.se.se;
                yet.add(py,px,-1);
                done.add(py,px,1);
            }
            else break;
        }

        if(c==2)
        {
            int h2,w2;
            scanf(" %d %d", &h2, &w2);
            printf("%lld %lld\n", done.sum(h1,w1,h2,w2), yet.sum(h1,w1,h2,w2));
        }
        else
        {
            if(c==0)
            {
                if(yet.sum(h1,w1,h1,w1)+done.sum(h1,w1,h1,w1)==0)
                {
                    yet.add(h1,w1,1);
                    que.push({t,{h1,w1}});
                }
            }
            else
            {
                if(done.sum(h1,w1,h1,w1)==1) done.add(h1,w1,-1);
            }
        }
    }

    return 0;
}

Measured memory_bytes: 66728
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
#include<stdio.h>
using namespace std;
int main(){
    while (1){
        int h, w;
        cin >> h >> w ;
        if (h == 0 && w == 0){

            break;
        } else{
            int i, j;
            for(i = 0; i < h; i++){
                if (i == 0 or i == h-1){
                    for(j = 0; j < w; j++){

                        cout << "#" ;
                        if (j == w-1){
                            cout << "\n";
                        }
                    }
                } else{
                    for(j = 0; j < w; j++){
                        if (j == 0 or j == w -1){
                            cout << "#" ;
                        } else{
                            cout << ".";
                        }
                        
                        if (j == w-1){
                            cout << "\n";
                        }
                    }
                }

            }
            cout << "\n";
        }
    }
    return 0;
}


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

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

struct SegmentTree {
	vector<int> max_val;
	vector<int> min_val;
	int size;

	SegmentTree(int n, vector<int> &a) {
		size = 1;
		while (size < n) size *= 2;
		max_val = vector<int>(2*size - 1, 0);
		min_val = vector<int>(2*size - 1, 1 << 30);
		for (int i = n + size - 2; i >= 0; i--) {
			if (i >= size - 1) {
				max_val[i] = a[i - size + 1];
				min_val[i] = a[i - size + 1];
			} else {
				max_val[i] = max(max_val[i*2 + 1], max_val[i*2 + 2]);
				min_val[i] = min(min_val[i*2 + 1], min_val[i*2 + 2]);	
			}
		}
	}
	int getMax(int a, int b, int k, int l, int r) {
		if (a <= l && r <= b) return max_val[k];
		if (r <= a || b <= l) return 0;
		int vl = getMax(a, b, k*2 + 1, l, (l + r) / 2);
		int vr = getMax(a, b, k*2 + 2, (l + r) / 2, r);
		return max(vl, vr);
	}
	int getMax(int a, int b) {
		return getMax(a, b, 0, 0, size);
	}
	int getMin(int a, int b, int k, int l, int r) {
		if (a <= l && r <= b) return min_val[k];
		if (r <= a || b <= l) return 1 << 30;
		int vl = getMin(a, b, k*2 + 1, l, (l + r) / 2);
		int vr = getMin(a, b, k*2 + 2, (l + r) / 2, r);
		return min(vl, vr);
	}
	int getMin(int a, int b) {
		return getMin(a, b, 0, 0, size);
	}
};
int len[200000];
int main() {
	int N, K;
	cin >> N >> K;
	vector<int> P(N);
	for (int i = 0; i < N; i++) cin >> P[i];
	SegmentTree seg(N, P);
	len[N - 1] = 1;
	for (int i = N - 2; i >= 0; i--) {
		if (P[i] < P[i + 1]) {
			len[i] = len[i + 1] + 1;
		} else {
			len[i] = 1;
		}
	}
	int ans = 0;
	bool remain = 0;
	int l = 0;
	while (l + K <= N) {
		if (len[l] >= K) {
			remain = 1;
			l++;
			continue;
		}
		ans++;
		int r;
		for (r = l + 1; r + K <= N; r++) {
			if (r == l + K) break;
			bool ok = 1;
			if (len[l] < r - l) ok = 0;
			if (len[l + K] < r - l) ok = 0;
			int minVal = seg.getMin(r, l + K);
			int maxVal = seg.getMax(r, l + K);
			if (P[r - 1] > minVal) ok = 0;
			if (P[l + K] < maxVal) ok = 0;
			if (!ok) break;
		}
		l = r;
	}
	if (remain) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 5888
// Problem : E - Almost Everywhere Zero
// Contest : AtCoder - AtCoder Beginner Contest 154
// URL : https://atcoder.jp/contests/abc154/tasks/abc154_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//mst,pq,mp,st,q
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
int k;
string n;
int ns;
int arr[105];
int dp[105][5][2];
void help(string &s)
{
	ns = s.size();
	for(int i =0;i<ns;++i)
	arr[i+1] = (s[i]-'0');
}
int help1(int pos,int cnt,int flag)
{
	if(cnt>k)
	return 0;
	if(pos==ns+1)
	{
		return cnt==k;
	}
	int &ans = dp[pos][cnt][flag];
	if(ans!=-1)
	return ans;
	ans = 0;
	if(!flag)
	{
		for(int i=0;i<=arr[pos];++i)
		{
			if(i!=0)
			ans+= help1(pos+1,cnt+1,flag|(i<arr[pos]));
			else
			ans+=help1(pos+1,cnt,flag|(i<arr[pos]));
			if(ans>=mod)
			ans-=mod;
		}
	}
	else
	{
		for(int i=0;i<=9;++i)
		{
			if(i!=0)
			ans+= help1(pos+1,cnt+1,flag);
			else
			ans+=help1(pos+1,cnt,flag);
			if(ans>=mod)
			ans-=mod;
		}
	}
	return ans;
}
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
    	cin>>n>>k;
    	help(n);
    	memset(dp,-1,sizeof(dp));
    	int ans = help1(1,0,0);
    	cout<<ans;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
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; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;cin >> s;
    int n=s.size();
    vector<int> a(n+1);
    a[0]=1;
    for(int i=1;i<n;i++){
        a[i]=a[i-1]*10%2019;
    }
    vector<int> c(n+1);
    for(int i=0;i<n;i++){
        int p=s[i]-'0';
        c[i+1]=(c[i]*10%2019+p)%2019;
    }
    for(int i=0;i<=n;i++){
        (c[i]*=a[n-i])%=2019;
    }
    vector<ll> b(2019);
    for(int i=0;i<=n;i++){
        b[c[i]]++;
    }
    ll ans=0;
    for(int i=0;i<2019;i++){
        ans+=b[i]*(b[i]-1)/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 5164
#include <bits/stdc++.h>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vstr=vector<string>;
void yes(bool c) { if (c)print("Yes"); else print("No"); };

int N,M;
ll ans = 0;

void solve() {
	cin >> N >> M;
    vector<vector<int>> d(100000);
	rep(i,N) {
        int a,b;cin >> a >> b;
        d[a].pb(b);
    }

    priority_queue<int> pq;
    per(i,M){
        for(auto t:d[M-i]){
            pq.push(t);
        }
        if(!pq.empty()) {
            ans += pq.top();
            pq.pop();
        }

    }
	print(ans);
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);

    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}

Measured memory_bytes: 5632
n, m = list(map(int, input().split()))
lr = [[0] * 2] * m

for i in range(m):
    lr[i] = list(map(int, input().split()))

min = 0
max = n

for i in range(m):
    if (min < lr[i][0]):
        min = lr[i][0]

    if (lr[i][1] < max):
        max = lr[i][1]

if (max == min):
    print(1)
elif (max < min):
    print(0)
else:
    print(max - min + 1)


Measured memory_bytes: 54488
import heapq
N, M = map(int, input().split())
A = [-a for a in map(int, input().split())]
heapq.heapify(A)
for _ in range(M):
    x = -heapq.heappop(A)
    heapq.heappush(A, -(x // 2))
ans = -sum(A)
print(ans)

Measured memory_bytes: 20332
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

template <typename T>
void print_vec(const vector<T>& v, bool is_reverse=false, ll num=0){
  if(num == 0) num = (ll)v.size();
  cout << endl; cout << "i=  ";for(ll i=0; i<num; i++) cout << i << "   ";cout << endl;  
  cout << "    ";
  if(is_reverse) for(ll i=num-1; i>=0; i--){ cout<<v[i]; if(i!=0) cout<<"   ";}
  else for(ll i=0; i<num; i++){ cout<<v[i]; if(i!=num-1) cout<<"   ";}
  cout << endl;
}

template <typename T>
void print_pairvec(const vector<T> &v, ll num=0){
  if(num == 0) num = (ll)v.size();
  cout << endl; for(ll i=0; i<num; i++){ cout << v[i].first << " " << v[i].second << endl;}
}

template <typename T>
void print_vec2(const vector<vector<T>>& v){
  cout << endl; cout << "       ";
  for(ll i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(ll i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(ll j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}
// UnionFind
// coding: https://youtu.be/TdR816rqc3s?t=726
// comment: https://youtu.be/TdR816rqc3s?t=6822
struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

int main(){
  ll N, M;
  cin >> N >> M;

  UnionFind tree(N);
  for(int i=0; i<M; i++){
    int a, b;
    cin >> a >> b;
    a--; b--;
    tree.unite(a, b);
  }

  int ans = 0;
  for(int i=0; i<N; i++){
    ans = max(ans, tree.size(i));
  }
  cout << ans << endl;

  // vector<vector<ll>> vec(N);
  // for(int i=0; i<M; i++){
  //   int a, b;
  //   cin >> a >> b;
  //   a-- ; b--;
  //   vec[a].push_back(b);
  //   vec[b].push_back(a);
  // }

  
  // const ll INF = 1e8;
  // using P = pair<int, int>;
  // vector<ll> person(N, INF);  
  // for(int i=0; i<N; i++){
  //   if(person[i] != INF) continue;
  //   ll num = 1;
  //   stack<P> st;
  //   st.push(P(i, -1));
  //   person[i] = 1;
  //   while(!st.empty()){
  //     ll node = st.top().first;
  //     ll parent = st.top().second;
  //     st.pop();

  //     for(int child : vec[node]){
  //       if(child == parent) continue;
  //       if(person[child] >= person[node] + 1) continue;
  //       person[child] = person[node] + 1;
  //       st.push(P(child, node));
  //     }
  //   }

    
  // }

  // ll max_group = 0;
  // for(int i=0; i<N; i++){
  //   max_group = max(max_group, person[i]);
  // }

  // cout << max_group << endl;


  // return 0;


}


Measured memory_bytes: 4052
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<29;
const double EPS = 1e-8;
const int MOD = 1000000007;

#define X first
#define Y second
#define MAXSIZE 1001
int n;
vector<pii> p;
int X[MAXSIZE][MAXSIZE];

int optimalBST(int n) {
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= n; ++j) 
      X[i][j] = i+1 == j ? 0 : INF;
    X[i][i] = 0;
  }
  for (int w = 2; w <= n; ++w) 
    for (int i = 0, j; (j = i+w) <= n; ++i) 
      for (int r = i+1; r < j; ++r) {
        int c = X[i][r] + X[r][j] + p[r-1].Y - p[j-1].Y + p[r].X - p[i].X;
        if (X[i][j] > c) X[i][j] = c;
      }
  return X[0][n];
}
main(){
	ios::sync_with_stdio(false);
	while(cin >> n){
		p.resize(n);
		REP(i, n) cin >> p[i].X >> p[i].Y;
		cout << optimalBST(n) << endl;
	}
	return 0;
}

Measured memory_bytes: 5120
<?php
list($a, $b, $c, $d, $e, $f) = ints();
$ans = [$a * 100, 0];
$max_con = 0;
for ($i = 0; $i <= $f; $i += 100 * $a) {
    for ($j = 0; $j <= $f - $i; $j += 100 * $b) {
        if ($i + $j === 0) continue;
        for ($k = 0; $k <= $f - $i - $j; $k += $c) {
            if ($k > $e * ($i + $j) / 100) break;
            $x = min($f - $i - $j - $k, ($i + $j) / 100 * $e - $k);
            $l = $d * intdiv($x, $d);
            $con = ($k + $l) / ($i + $j + $k + $l);
            if ($con > $max_con) {
                $ans = [$i + $j + $k + $l, $k + $l];
                $max_con = $con;
            }
        }
    }
}
echo implode(' ', $ans);

function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}


Measured memory_bytes: 4728
def resolve():
    '''
    code here
    '''

    import collections
    N = int(input())
    S_list = [collections.Counter(input()) for _ in range(N)]

    cnt_dict = S_list[0]

    for line in S_list:
        for item in cnt_dict.keys():
            cnt_dict[item] = min(line[item], cnt_dict[item])
        prev_dict = cnt_dict
        # print(cnt_dict)
    
    cnt_tuple = sorted(cnt_dict.items())
    # print(cnt_tuple)
    res = ''
    for i, v in cnt_tuple:
        if v > 0:
            res += i*v

    print(res)

if __name__ == "__main__":
    resolve()    



Measured memory_bytes: 3316
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}

vector<ll> pw2(51,1);vector<ll> pw10(19,1);
ll high_order_bit(ll n){
    ll tmp=1,i=-1;
    while(tmp<=n){
        tmp*=2;
        i++;
    }
    if(n==0) return 0;
    else return i;
}
vector<ll> binary_expansion(ll n){
    vector<ll> B(high_order_bit(n)+1);
    ll tmp=n;
    for(ll i=high_order_bit(n);i>=0;i--){
        B[i]=tmp/pw2[i];
        tmp%=pw2[i];
    }
    return B;
}
vector<ll> divisor(ll x){
    vector<ll> div;
    for(int i=1;i*i<=x;i++){
        if(i*i!=x && x%i==0){
            div.pb(i);
            div.pb(x/i);
        }
        else if(x%i==0) div.pb(i);
    }
    sort(all(div));
    return div;
}
vector<ll> vectorprime(ll x){
    vector<bool> is_prime(x+1);
    vector<ll> prime;
    rep(i,x+1) is_prime[i]=true;
    is_prime[0]=is_prime[1]=false;
    for(int i=2;i<=x;i++){
        if(is_prime[i]){
            prime.pb(i);
        }
        for(int j=i*2;j<=x;j+=i) is_prime[j]=false;
    }
    return prime;
}
ll binary_search(vector<ll> v,ll key){ //key以上が初めて出てくる添字(0-index)
    int l=0,r=sz(v)-1;
    while(r-l>=1){
        int i=(l+r)/2;
        //cout<<l<<" "<<r<<" "<<i<<endl;
        if(v[i]<key) l=i+1;
        else r=i;
    }
    if(v[l]>=key) return l;
    else return INF;
}

int main(){
    ll N; cin>>N;
    ll i=1;
    while(i*i<=N){
        i++;
    }
    cout<<(i-1)*(i-1);
}


Measured memory_bytes: 3524
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define s(x, n) memset(x, n, sizeof(x));
#define pb(x) push_back(x)
#define MAXN 1000001
int spf[MAXN];

int hash1[MAXN];

void buildsieve()
{
    spf[1] = 1;
    for (ll i = 2; i < MAXN; i++)
    {
        spf[i] = i;
    }
    for (ll i = 4; i < MAXN; i += 2)
    {
        spf[i] = 2;
    }
    for (ll i = 3; i * i < MAXN; i++)
    {
        if (spf[i] == i)
        {
            for (int j = i * i; j < MAXN; j += i)
            {
                if (spf[j] == j)
                    spf[j] = i;
            }
        }
    }
}
void getFactorization(int x)
{
    int temp;
    while (x != 1)
    {
        temp = spf[x];
        if (x % temp == 0)
        {
            hash1[spf[x]]++;
            x = x / spf[x];
        }
        while (x % temp == 0)
            x = x / temp;
    }
}

bool check(int x)
{
    int temp;
    while (x != 1)
    {
        temp = spf[x];
        if (x % temp == 0 && hash1[temp] > 1)
            return false;
        while (x % temp == 0)
            x = x / temp;
    }
    return true;
}

int main()
{
#ifdef WIN32
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

#ifndef WIN32
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#endif
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    string ans = "not coprime";
    int c = a[0];
    for (int i = 1; i < n; i++)
    {
        c = __gcd(c, a[i]);
        if (c == 1)
        {
            ans = "setwise coprime";
            break;
        }
    }
    buildsieve();
    for (int i = 0; i < n; i++)
        getFactorization(a[i]);
    bool flag = true;
    for (int i = 2; i < MAXN; i++)
    {
        if (hash1[i] > 1)
        {
            flag = false;
            break;
        }
    }
    if (flag)
    {
        ans = "pairwise coprime";
    }
    cout << ans;
    return 0;
}


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

using namespace std;

int main()
{
    long long N;

    cin >> N;
    long long result = 100;
    long long count = 0;
    while(result < N)
    {
        result *= 1.01;
        count++;
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main() {
    
    //入力
    int D;
    cin>>D;
    
    string S;
    //処理
    if(D==25){
        S="Christmas";
    }
    if(D==24){
        S="Christmas Eve";
    }
    if(D==23){
        S="Christmas Eve Eve";
    }
    if(D==22){
        S="Christmas Eve Eve Eve";
    }
    
    //出力
    cout<<S<<endl;
}


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

int A[3][3];
bool AA[3][3] = {false};
int N, b;

bool bingo(){
  for(int i = 0; i < 3; i++){
    if(AA[i][0] && AA[i][1] && AA[i][2]) return true;
    if(AA[0][i] && AA[1][i] && AA[2][i]) return true;
  }

  if(AA[0][0] && AA[1][1] && AA[2][2]) return true;
  if(AA[0][2] && AA[1][1] && AA[2][0]) return true;

  return false;

}
      

int main(){
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      cin >> A[i][j];
    }
  }

  cin >> N;

  for(int k = 0; k < N; k++){
    cin >> b;
    for(int i = 0; i < 3; i++){
      for(int j = 0; j < 3; j++){
        if(A[i][j] == b) AA[i][j] = true;
      }
    }
  }

  if(bingo()) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;





}

Measured memory_bytes: 256
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include<set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000;

using ll = long long;
using namespace std;

int main(){
    string s; cin >> s;
    string alpha="abcdefghijklmnopqrstuvwxyz";
    set<char> str;
    for (int i=0; i<s.size();i++) str.insert(s[i]);
    for (int i=0; i<=alpha.size(); i++){
        decltype(str)::iterator it = str.find(alpha[i]);
        if(i==26) cout << "None" << endl;
        else if (it != str.end()) {
        }
        else {
            cout << alpha[i] << endl;
            break;
            }

        }
    }

Measured memory_bytes: 512
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <functional>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define REP(i,n) for(int i=0,_n=(n);(i)<(int)_n;++i)
#define RANGE(i,a,b) for(int i=(int)a,_b=(int)(b);(i)<_b;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define PRINT1(table, D0) REP(d0, D0) cout<<table[d0]<<" "; cout<<"\n";
#define PRINT2(table, D0, D1) REP(d0, D0) { REP(d1, D1) cout<<table[d0][d1]<<" "; cout<<"\n"; }
#define PRINT3(table, D0, D1, D2) REP(d0, D0) { REP(d1, D1) { REP(d2, D2) cout<<table[d0][d1][d2]<<" "; cout<<"\n"; } cout<<"\n"; }
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	while(cin>>s) {
		string ans;
		REP(bits, 1<<3) {
			VI w(4);
			REP(i, 4) w[i] = s[i]-'0';
			REP(i, 3) if(bits>>i&1) w[i+1] *= -1;
//			DD(w);
			ll v = accumulate(ALL(w), 0LL);
			if(v==7) {
				ans = s[0];
				REP(i, 3) ans += string(bits>>i&1 ? "-" : "+") + s[i+1];
				ans += "=7";
//				DD(ans);
			}
		}
		
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
use proconio::{input, fastout};

#[fastout]
fn main() {
  input!{
    n: i64,
    a: [i64;n]
  }
  let mut ans = 0;
  for i in 0..n {
      if (i+1) as usize%2 == 1 && a[i as usize]%2 == 1{
        ans += 1;
      }
  }
  println!("{}",ans);
}


Measured memory_bytes: 2116
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>
#include<queue>
#include<deque>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000000001
using namespace std;
typedef long long ll;


int main(){

  int n;std::cin >> n;
  int tmp;
  int med;
  std::vector<int> b;
  rep(i,0,n){
    std::cin >> tmp;
    b.push_back(tmp-(i+1));
  }
  sort(all(b));
  med = b[(n)/2];
  ll res = 0;
  rep(i,0,n){
    res += abs(b[i]-med);
  }
  std::cout << res << '\n';

}


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

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

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  int N;
  cin >> N;
  vector<ll> v(N);

  ll sum = 0;
  ll even_sum = 0;
  for(int i = 0; i < N; i++){
    cin >> v.at(i);
    sum += v.at(i);
    if(i%2==0){
      even_sum += v.at(i);
    }
  }

  // 山iからi+1に流れた量をxiとして、答えは2*xiになる
  // x1+x2+... = 
  sum = sum / 2;
  ll x1 = even_sum - sum;
  vector<ll> ans;
  ans.push_back(2*x1);
  for(int i = 0; i < N-1; i++){
    x1 = v.at(i) - x1;
    ans.push_back(2*x1);
  }

  for(int i = 0; i < ans.size(); i++){
    if(i == ans.size() -1){
      cout << ans[i] << endl;
    } else { 
      cout << ans[i] << " ";
    }
  }

}



Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rept(i,x,y) for(int i=x;i<=y;i++)
#define per(i,x,y) for(int i=y;i>=x;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
//	ios::sync_with_stdio(false);
//	cin.tie(0);
const int maxx = 2e5+7;
const int maxn = 1e9+7;
typedef long long ll;
using namespace std;
inline int read(){
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
ll t,n;
string s;
int main(){
	cin>>s;
	int op=s.length();
	rep(i,0,op){
		if(s[i]=='?'){
			s[i]='D';
		}
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 3764
#include <iostream>

using namespace std;

int gcd(int x, int y) {
  int tmp;
  while (x) {
    tmp = x;
    x = y % tmp;
    y = tmp;
  }
  return y;
}

int main() {
  int x, y;
  cin >> x >> y;
  cout << gcd(x, y) << endl;
  return 0;
}



Measured memory_bytes: 3088
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, C: "List[int]", S: "List[int]", F: "List[int]"):
    def f(i: int, s: int):
        if i == N - 1:
            return s
        s = max(s, S[i])
        return f(i + 1, -(-s // F[i]) * F[i] + C[i])
    for i in range(N):
        print(f(i, 0))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    C = [int()] * (N - 1)  # type: "List[int]"
    S = [int()] * (N - 1)  # type: "List[int]"
    F = [int()] * (N - 1)  # type: "List[int]"
    for i in range(N - 1):
        C[i] = int(next(tokens))
        S[i] = int(next(tokens))
        F[i] = int(next(tokens))
    solve(N, C, S, F)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define Mod 998244353
#define pi 3.14159265358979323846
#define endl '\n'
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;

int main()
{
    int n;
    cin>>n;
    int cnt=0;
    bool flg=false;
    
    for(int i=1;i<=n;i++)
    {
        int x,y;
        cin>>x>>y;
        if(x==y) cnt++;
        else cnt=0;
        if(cnt>=3) flg=true;
    }
    if(flg) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


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

#define ll long long
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define ff first
#define ss second

using namespace std;

const double pi = acos(-1);
const int N = 1e6 + 6, mod = 998244353, M = 1e7 + 7;
const ll MAX = 5e18;

int n, ans = 1;
string s;

int main()
{
    cin >> n >> s;
    for(int i = 1; i < n; i++){
        if(s[i] != s[i - 1])
            ans++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 512