akhauriyash/Code-Regression huggingface dataset:
#define DEBUG 0
/**
 * File    : B2.cpp
 * Author  : Kazune Takahashi
 * Created : 2019-6-29 23:18:43
 * Powered by Visual Studio Code
 */
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <functional>
#include <random>
#include <chrono>
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
using ll = long long;
void Yes()
{
  cout << "Yes" << endl;
  exit(0);
}
void No()
{
  cout << "No" << endl;
  exit(0);
}
const int MAX_SIZE = 1000010;
class mint
{
public:
  static ll MOD;
  ll x;
  mint() : x(0) {}
  mint(ll x) : x(x % MOD) {}
  mint operator-() const { return x ? MOD - x : 0; }
  mint &operator+=(const mint &a)
  {
    if ((x += a.x) >= MOD)
    {
      x -= MOD;
    }
    return *this;
  }
  mint &operator-=(const mint &a) { return *this += -a; }
  mint &operator*=(const mint &a)
  {
    (x *= a.x) %= MOD;
    return *this;
  }
  mint &operator/=(const mint &a) { return (*this *= power(MOD - 2)); }
  mint operator+(const mint &a) const { return mint(*this) += a; }
  mint operator-(const mint &a) const { return mint(*this) -= a; }
  mint operator*(const mint &a) const { return mint(*this) *= a; }
  mint operator/(const mint &a) const { return mint(*this) /= a; }
  bool operator<(const mint &a) const { return x < a.x; }
  bool operator==(const mint &a) const { return x == a.x; }
  const mint power(ll N)
  {
    if (N == 0)
    {
      return 1;
    }
    else if (N % 2 == 1)
    {
      return *this * power(N - 1);
    }
    else
    {
      mint half = power(N / 2);
      return half * half;
    }
  }
};
ll mint::MOD = 1e9 + 7;
istream &operator>>(istream &stream, mint &a) { return stream >> a.x; }
ostream &operator<<(ostream &stream, const mint &a) { return stream << a.x; }
mint inv[MAX_SIZE];
mint fact[MAX_SIZE];
mint factinv[MAX_SIZE];
void init()
{
  inv[1] = 1;
  for (int i = 2; i < MAX_SIZE; i++)
  {
    inv[i] = (-inv[mint::MOD % i]) * (mint::MOD / i);
  }
  fact[0] = factinv[0] = 1;
  for (int i = 1; i < MAX_SIZE; i++)
  {
    fact[i] = mint(i) * fact[i - 1];
    factinv[i] = inv[i] * factinv[i - 1];
  }
}
mint choose(int n, int k)
{
  if (n >= 0 && k >= 0 && n - k >= 0)
  {
    return fact[n] * factinv[k] * factinv[n - k];
  }
  return 0;
}
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
// const double epsilon = 1e-10;
// const ll infty = 1000000000000000LL;
// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

int main()
{
  // init();
  int N;
  cin >> N;
  vector<int> p(N);
  for (auto i = 0; i < N; i++)
  {
    cin >> p[i];
  }
  int ans = 0;
  for (auto i = 1; i < N - 1; i++)
  {
    if (p[i - 1] < p[i] && p[i] < p[i + 1])
    {
      ans++;
    }
    else if (p[i - 1] > p[i] && p[i] > p[i + 1])
    {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 23680
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

int gcd(int A, int B) {
	if (B == 0) return A;
	return gcd(B, A % B);
}

int main() {
	ios::sync_with_stdio(false);


	int N;
	cin >> N;
	int A[100000];
	rep(i, N) cin >> A[i];


	int B[100000], C[100000];
	B[0] = A[0];
	rep1(i, N - 2) B[i] = gcd(A[i], B[i - 1]);
	C[0] = A[N - 1];
	rep1(i, N - 2) C[i] = gcd(A[N - i - 1], C[i - 1]);
	int kotae = max(C[N - 2], B[N - 2]);

	rep(i, N - 2){
		kotae = max(kotae, (gcd(B[i], C[N - i - 3])));
	}
	
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 1408
//Author: A_S_M_M@sud_P@rvez
#include<bits/stdc++.h>
using namespace std;
#define    MP ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define    For(i,n) for(int i=0;i<n;i++)
#define    rFor(i,n) for(int i=n-1;i>=0;i--)
#define    forn(i,n) for(int i=1;i<=n;i++)
#define    fors(i,s) for(int i=0;i<s.size();i++)
#define    all(v) v.begin(),v.end()
#define    gcd(a, b) __gcd(a , b)
#define    lcm(a,b) (a*(b/__gcd(a,b)))
#define    test   int t;cin>>t;for(int l=0;l<t;l++)
#define    min3(a,b,c)     min(a,min(b,c))
#define    max3(a,b,c)     max(a,max(b,c))
#define    min4(a,b,c,d)   min(min(a,b),min(c,d))
#define    max4(a,b,c,d)   max(max(a,b),max(c,d))
#define    Max(a)  *max_element(a,a+sizeof(a)/sizeof(a[0]))
#define    Min(a)  *min_element(a,a+sizeof(a)/sizeof(a[0]))
#define    nl     "\n"
#define    End    return 0 
#define    gt     greater<int>()
#define    ll     long long 
#define    mp     make_pair
#define    pb     push_back
#define    vi     vector<int>
#define    vl     vector<ll>
#define    mod    1000000007
#define    sp(n)  fixed<<setprecision(n)
#define    pi     acos(-1)

int main()
{
MP;
    int c=0,mx=0;
    test
    {
        int a,b;
        cin>>a>>b;
        if(a==b)c++;
        else c=0;
        mx=max(mx,c);
    }
    if(mx>=3)cout<<"Yes";
    else cout<<"No";
    
End;
}


Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main() {
  int n, res = 0;
  cin >> n;
  for (int i = 1; i <= n; i += 2) {
    int cnt = 0;
    for (int j = 1; j <= i; ++j) if (i % j == 0) cnt++;
    if (cnt == 8) res++;
  }
  cout << res << endl;
}


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

int main(){
	int h1, m1, h2, m2, k;
	scanf("%d %d %d %d %d", &h1, &m1, &h2, &m2, &k);
	int t1= h1*60+m1;
	int t2= h2*60+m2;
	printf("%d", t2-t1-k);
//	else if(tot>study){
//		printf("%d\n", )
//	}
	
	
	return 0;
}



Measured memory_bytes: 1732
N=int(input())
a=list(map(int,input().split()))
cnt={}
for e in a:
  if e in cnt:
    cnt[e]+=1
  else:
    cnt[e]=1
ans=0
for e in a:
  if cnt[e]==0:
    continue
  else:
    if cnt[e] > e:
      ans+=cnt[e]-e
    elif cnt[e] < e:
      ans+=cnt[e]
    cnt[e]=0
print(ans)


Measured memory_bytes: 17780
n,q = map(int,input().split())

s=input()

dp = [0]*n

for i in range(1,n):
    if s[i-1] == 'A' and s[i] == 'C':
        dp[i] = dp[i-1] + 1
    else:
        dp[i] = dp[i-1]
#print(dp)
for _ in range(q):
    a, b = (int(x) for x in input().split())
    print(dp[b-1]-dp[a-1])

Measured memory_bytes: 51544
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;

    if(a < 10 && b < 10) {
        cout << a * b << endl;
    } else {
        cout << -1 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>
#include <unordered_map>
#include <set>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;

int main()
{
  ll N;
  cin >> N;
  vector<ll> count(26, 100);
  for (auto i = 0; i < N; i++) {
    string s;
    cin >> s;
    vector<ll> tmp(26, 0);
    for (char c : s) tmp[c-'a']++;
    for (auto i = 0; i < count.size(); i++) {
//      cout << "count[" << i << "]=" << count[i] << " tmp=" << tmp[i] << endl;
      count[i] = min(count[i], tmp[i]);
    }
  }
  string res = "";
  for (auto i = 0; i < count.size(); i++) {
    for (auto j = 0; j < count[i]; j++) {
      res += (char)('a' + i);
    }
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

N,M = map(int,input().split())
k = [0 for i in range(M)]
s = [[] for i in range(M)]
for i in range(M):
    input_list = [int(i) for i in input().split()]
    k[i] = input_list[0]
    s[i] = input_list[1:]

p = [int(i) for i in input().split()]

def tobinary(i):
    l = [0 for j in range(N)]
    for k in range(N):
        l[k] = i % 2
        i //= 2
    return l

ans = 0
for i in range(2**N):
    swich = tobinary(i)
    for m in range(M):
        cnt = 0
        for k_i in range(k[m]):
            if swich[s[m][k_i]-1]:
                cnt += 1
        if cnt % 2 == p[m]:
            blight = True
        else:
            blight = False
            break
    if blight == True:
        ans += 1

print(ans)


Measured memory_bytes: 6864
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

def rand_letter(size):
    ascii_original='ox'
    digits_original='01'

    digits='0123456789'
    ascii_lowercase='abcdefghijklmnopqrstuvwxyz'
    ascii_uppercase='ABCDEFGHIJKLMNOPQRSTUVWXYZ'

    # 好きなものを使ってね
    psuedo = ascii_original

    return ''.join([random.choice(psuedo) for i in range(size)])

N = getN()
S = input()
lista = ['SS', 'SW', 'WS', 'WW']

def judge(string):
    alta = copy.deepcopy(string)
    for i in range(1, N - 1):
        if alta[-1] == "S" and alta[-2] == "S":
            if S[i] == "o":
                alta.append('S')
            else:
                alta.append("W")
        elif alta[-1] == "S" and alta[-2] == "W":
            if S[i] == "o":
                alta.append('W')
            else:
                alta.append("S")
        elif alta[-1] == "W" and alta[-2] == "S":
            if S[i] == "o":
                alta.append('W')
            else:
                alta.append("S")
        else:
            if S[i] == "o":
                alta.append('S')
            else:
                alta.append("W")

    return alta

def judge_2(before, now, after, j):
    if now == "S":
        if j == "o":
            if before == after:
                return True

        else:
            if before != after:
                return True

    else:
        if j == "o":
            if before != after:
                return True

        else:
            if before == after:
                return True
    return False

for i in lista:
    opt = judge(list(i))
    if judge_2(opt[-2], opt[-1], opt[0], S[-1]) and judge_2(opt[-1], opt[0], opt[1], S[0]):
        print(''.join(opt))
        exit()
print(-1)

Measured memory_bytes: 104508
const fs = require('fs')
const reader = (s: string) => s.split('\n').map(t => parseInt(t, 10))

function Main(input: string) {
  const [N, K, X, Y] = reader(input)

  console.log(N >= K ? K * X + (N - K) * Y : N * X)
}

Main(fs.readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 7372
#include<iostream>
#include<vector>
#include<cstdio>
using namespace std;
int p[10001];

int root(int x){
  vector <int> v;
  while(p[x]!=x){
    v.push_back(x);
    x=p[x];
  }
  for(int i=0;i<v.size();i++)p[v[i]]=x;
  return x;
}

void unite(int x,int y){
  x=root(x);
  y=root(y);
  if(x!=y){
    p[y]=x;
  }
}

bool same(int x,int y){
  x=root(x);
  y=root(y);
  if(x==y)return true;
  else return false;
}

int main(){
  int n,q,com,x,y;
  for(int i=0;i<10001;i++)p[i]=i;
  cin>>n>>q;
  for(int i=0;i<q;i++){
    scanf("%d %d %d",&com,&x,&y);
    if(com==0){
      unite(x,y);
    }else{
      if(same(x,y))printf("%d\n",1);
      else printf("%d\n",0);
    }
  }
  return 0;
}

Measured memory_bytes: 3308
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    void input() {

    }

    void solve() {
        input();
        int N;
        cin >> N;
        vector<int> b(N);
        rep(i, 0, N) cin >> b[i];

        vector<int> ans;
        for (int i = 0; i < N; ++i) {
            int idx = -1;
            for (int j = (int)b.size() - 1; j >= 0; --j) {
                if (b[j] == j + 1) {
                    idx = j;
                    break;
                }
            }
            if (idx == -1) {
                cout << -1 << endl;
                return;
            }

            ans.push_back(idx + 1);
            b.erase(b.begin() + idx);
        }

        reverse(all(ans));
        for (auto e : ans) {
            cout << e << endl;
        }


    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 888
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
int main(){
  long n,t;
  vector<long> cost,tm;
  long ii;
  cin >> n >> t;
  cost.resize(n);
  tm.resize(n);

  for(ii=0;ii<n;ii++){
	cin >> cost[ii] >> tm[ii];
  }

  long pos=-1,cst=LONG_MAX;

  for(ii=0;ii<n;ii++){
	if(tm[ii]<=t){
	  if(cst>=cost[ii]){
		cst = cost[ii];
	  }
	}
  }

  if(cst == LONG_MAX){
	cout << "TLE" << endl;
  }
  else{
	cout << cst << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
typedef pair<int,int> P;
int tosc(int h, int m,int s){
  return h*3600 + m * 60 + s;
}

int main(){
  int n;
  while(cin>>n,n){
    vector<P> v;
    REP(i,n){
      int h,m,s;
      scanf("%d:%d:%d",&h,&m,&s);
      int m1 = tosc(h,m,s);
      scanf("%d:%d:%d",&h,&m,&s);
      int m2 = tosc(h,m,s);
      v.push_back(make_pair(m1,m2));
    }
    sort(v.begin(),v.end());
    int ans = 0;
    priority_queue<int, vector<int>, greater<int> > que;
    REP(i,n){
      if(que.empty() || que.top() > v[i].first){
        ans++;
      }else{
        que.pop();
      }
      que.push(v[i].second);
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define mod 1000000007
using namespace std;
ll binpow(ll x,ll y)/* (x^y)%p in O(log y) */{ll res=1;while (y > 0){if(y&1)res=(res*x);y = y>>1;x=(x*x);}return res;}
ll binpowmod(ll x,ll y,ll p)/* (x^y)%p in O(log y) */{ull res=1;x=x%p;while (y > 0){if(y&1)res=(res*x)%p;y = y>>1;x=(x*x)%p;}return res;}
ll mod_inverse(ll n,ll p)/* Returns n^(-1) mod p */{return binpowmod(n,p-2,p);}
ll gcd(ll x,ll y)
{
    if(y==0)
        return x;
    return gcd(y,x%y);
}
bool comp(pair<int,int> x,pair<int,int> y)
{
    return x.first<y.first;
}
bool comp_pairs_by_s(pair<ll,ll> &x ,pair<ll,ll> &y)
{
    return x.second<y.second;
}
bool isPowerOfTwo (ll x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
}

class cmp      //comparator for priority_queue 
{               //declaration: priority_queue<int,vector<int>,cmp>
public:         
    bool operator()(pair<int,int> A,pair<int,int> B)
    {
        if(abs(A.first-A.second)==abs(B.first-B.second))
            return A.first>B.first;
        return abs(A.first-A.second)<abs(B.first-B.second);
    }
};
int prime[10000007]={0};
void sieve(void)
{
 int i,j;
 for(i=0;i<10000007;i++)
        prime[i]=i;
 prime[0]=0,prime[1]=0;
 for(i=2;i<=sqrt(10000007);i++){
     if(prime[i]==i){
         for(j=i*i;j<10000007;j+=i){
            if(prime[j]==j)
                prime[j]=i;
         }
     }
 }
    
}
void swap(ll &x,ll &y){
    int temp=x;
    x=y;
    y=temp;
}
  
unsigned int onesComplement(unsigned int n) 
{ 
   // Find number of bits in the given integer 
   int number_of_bits = floor(log2(n))+1; 
  
   // XOR the given integer with poe(2,  
   // number_of_bits-1 and print the result  
   return ((1 << number_of_bits) - 1) ^ n; 
}
void solve()
{   
    ll n;
    cin>>n;
    sieve();
    ll ans=1;
    for(ll i=2;i<=n;++i){
        ll num=i;
        ll cntdiv=1;
        while(num!=1){
            ll div=prime[num];
            int cnt=0;
            while(num%div==0)
                cnt++,num/=div;
            cntdiv*=(cnt+1);
        }
        ans+=i*cntdiv;
    }
    cout<<ans;
}

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


Measured memory_bytes: 42616
import java.io.*;

public class Main {
	public static void main (String[] args) throws IOException
	{
		BufferedReader input = new BufferedReader (new InputStreamReader(System.in));
		
		String[] sidesStr = input.readLine().split(" ");
		
		int length = Integer.parseInt(sidesStr[0]);
		
		int side = Integer.parseInt(sidesStr[1]);
		
		System.out.println(length * side + " " + (length * 2 + side * 2));
	}
}



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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n,q;
    string s;
    cin>>n>>s>>q;
    Vec Q(q);
    rep(i,q)cin>>Q[i];

    rep(i,n){
        if(s[i]!='D'&&s[i]!='M'&&s[i]!='C'){
            s[i] = '.';
        }
    }
    rep(qu,q){
        ll a=0;
        ll b=0;
        ll cb = 0;
        ll ans=0;
        ll &k = Q[qu];
        rep(i,n){
            if(i-k>=0){
                if(s[i-k]=='D'){
                    a--;
                    b -= cb;
                }
                if(s[i-k]=='M'){
                    cb--;
                }
            }

            if(s[i]=='D'){
                a++;
            }
            if(s[i]=='M'){
                b+= a;
                cb++;
            }

            if(s[i]=='C'){
//                dbg(i);
//                dbg(a);
//                dbg(b);
//                dbg(ans);
                ans+=b;
            }

        }
        cout<<ans<<endl;
    }


    return  0;
}


Measured memory_bytes: 1948
#include<iostream> 
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a ; i ++)

int main(void){
  int M[10][3];
  int n,a,d,m,k;
  cin>>n>>a>>d>>m;
  rep(i,m){
    rep(j,3)
      cin>>M[i][j];  
  }
  cin>>k;
  for(int i = m-1 ; i >= 0; i --){
    //rep(j,3)cout<<M[i][j]<<" ";
    //cout<<endl;
    if(M[i][1] == k || M[i][2] == k){
      if(M[i][0]){ // 1 true
	k = M[i][2];
      }else{ // 0 false
	if(M[i][1]== k){
	  k = M[i][2];
	}else {
	  k = M[i][1];
	}
      }
    }
    //*/
  } 
  cout<<a+d*(k-1)<<endl;
}

  

Measured memory_bytes: 1160
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cassert>
using namespace std;
inline int read(){
	int re=0,flag=1;char ch=getchar();
	while(!isdigit(ch)){
		if(ch=='-') flag=-1;
		ch=getchar();
	}
	while(isdigit(ch)) re=(re<<1)+(re<<3)+ch-'0',ch=getchar();
	return re*flag;
}
char a[2010],b[2010];int n,ans=1e9;
int minn[2010],maxn[2010],ch[2010];
void solve(){
	int i,j,diff,tot,tmp;
	for(i=0;i<n;i++){
		minn[i]=maxn[i]=0;
		while(b[(i+maxn[i])%n]!='1') maxn[i]++;
		while(b[(i+minn[i]+n)%n]!='1') minn[i]--;
	}
	for(j=0;j<n;j++){
		for(i=0;i<n;i++) ch[i]=0;
		diff=0;
		for(i=0;i<n;i++){
			if(a[i]!=b[(i+j)%n]){
				ch[-minn[i]]=max(ch[-minn[i]],maxn[i]-j);
				diff++;
			}
		}
		tot=1e9;tmp=0;
		for(i=n-1;i>=0;i--){
			tot=min(tot,tmp+i);
			tmp=max(tmp,ch[i]);
		}
		ans=min(ans,tot*2+diff+j);
	}
}
int main(){
	scanf("%s%s",a,b);int i,fa=0,fb=0;
	n=strlen(a);
	for(i=0;i<n;i++) fa|=(a[i]=='1');
	for(i=0;i<n;i++) fb|=(b[i]=='1');
	if(!fb){
		if(fa) puts("-1");
		else puts("0");
		return 0;
	}
	solve();
	reverse(a,a+n);reverse(b,b+n);
	solve();
	cout<<ans<<'\n';
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
const int x='R'+'G'+'B';
int n,a[4000][90];
char s[10001];
long long m;
int main(){
    scanf("%d",&n);
    getchar();
    for(int i=0;i<n;++i){
        s[i]=getchar();
        ++a[i][s[i]];
        if(i){
            a[i]['R']+=a[i-1]['R'];
            a[i]['G']+=a[i-1]['G'];
            a[i]['B']+=a[i-1]['B'];
        }
    }
    for(int i=0;i<n;++i){
        for(int j=i+1;j+1<n;++j){
            if(s[i]==s[j])continue;
            if(a[n-1][x-s[i]-s[j]]-a[j][x-s[i]-s[j]]){
                m+=a[n-1][x-s[i]-s[j]]-a[j][x-s[i]-s[j]];
                if(j+j-i<n&&s[j+j-i]!=s[i]&&s[j+j-i]!=s[j]){
                    --m;
                }
            }
        }
    }
    printf("%lld\n",m);
}

Measured memory_bytes: 3088
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

#define REP(i,n) for(int i=0;(i)<(n);(i)++)
#define ll long long


int main() {
	int N;
	int T[102];
	int M;
	int P, X;
	int sum = 0;
	cin >> N;
	REP(i, N) {
		cin >> T[i];
		sum += T[i];
	}

	cin >> M;
	REP(i, M) {
		cin >> P >> X;
		cout << sum + X - T[P - 1] << endl;
	}


	return 0;
}

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

using ll = long long;
using pll = pair<ll, ll>;

ll N, M, L;
vector<ll> K;
vector<ll> sum;
vector<vector<ll>> dp;

ll rec(int l, int r, vector<vector<ll>>& dp)  {
    int mi = min(l, r);
    int ma = max(l ,r);
    if(ma == N-1) {
        return (sum[K[ma]] - sum[K[mi]-1]) / L;
    }
    ll& res = dp[l][r];
    if(res != -1) {
        return res;
    }
    res = rec(ma+1, r, dp) + (sum[K[ma+1]] - sum[K[l]-1]) / L;
    res = min(res, rec(l, ma+1, dp) + (sum[K[ma+1]] - sum[K[r]-1]) / L);
    return res;
}

int main() {
    cin >> N >> M >> L;
    vector<ll> S(M);
    K.resize(N);
    for(int i=0; i<N; ++i) {
        cin >> K[i];
    }
    sort(K.begin(), K.end());
    sum.resize(M+1);
    for(int j=0; j<M; ++j) {
        cin >> S[j];
        sum[j+1] = sum[j] + S[j];
    }
    dp.resize(N);
    for(int i=0; i<N; ++i) {
        dp[i].assign(N, -1);
    }
    cout << rec(0, 1, dp) + (sum[K[1]] - sum[K[0]-1])/L << endl;
}


Measured memory_bytes: 35808
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  string s;
  cin >> s;
  rep(i,s.size()) s[i] = 'x';
  cout << s << endl;
  return 0;
}

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

int main(){
	int x, y;
	cin >> x >> y;
	cout << x + y/2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using P = pair<int, int>;
using LL = long long;

#define ALL(a) (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN_LL(v) LL v;cin>>v;
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<endl
#define MOD 1000000007

int main() {
  IN(N); IN(C);

  int D[C][C];
  REP(i, C) {
    REP(j, C) {
      cin >> D[i][j];
    }
  }
  int c[N][N];
  REP(i, N) {
    REP(j, N) {
      cin >> c[i][j];
      c[i][j] -= 1;
    }
  }
  int colors[3][C]; // (i+j)%3の値がそれぞれ0,1,2であるものの色の個数
  REP(i, C)
    colors[0][i] = colors[1][i] = colors[2][i] = 0;

  REP(x, N) {
    REP(y, N) {
      ++colors[(x + y) % 3][c[x][y]];
    }
  }
  int ans = 1000000000;
  REP(i, C) {
    // x+y%3 == 0
    REP(j, C) {
      // x+y%3 == 1
      if (j == i)
        continue;
      REP(k, C) {
        // x+y%3 == 2
        if (k == i || k == j)
          continue;
        int d = 0;
        REP(color, C)
          d += D[color][i] * colors[0][color] + D[color][j] * colors[1][color] + D[color][k] * colors[2][color];
        ans = min(d, ans);
      }
    }
  }
  OUT(ans);

  return 0;
}


Measured memory_bytes: 1280
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(1e9+7)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
ll gcd(ll A,ll B) {if(!B)return A;return gcd(B,A%B);}
ll a[17][17];
ll dp[(1<<16)+1];
ll pre[(1<<16)+1];
int n;
void rec(int mask,int g_mask,vector<ll>&taken,int cnt){
	if(cnt == (int)(taken.size())){
		dp[mask^g_mask] = max(dp[mask^g_mask],dp[mask]+pre[g_mask]);
	}else{
	rec(mask,g_mask,taken,cnt+1);
	rec(mask,g_mask^(1<<taken[cnt]),taken,cnt+1);
}
}
int main()
{
	owo
	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin>>a[i][j];
		}
	}
	for(int i=0;i<(1<<n);i++)dp[i] = -INF;
	dp[0] = 0;
	for(int mask=0;mask<(1<<n);mask++){
		vector<ll>group;
		for(int j=0;j<n;j++){
			if(mask&(1<<j))group.pb(j);
		}
		int sz = group.size();
		for(int i=0;i<sz;i++)
			for(int j=i;j<sz;j++)
			    pre[mask]+=a[group[i]][group[j]];
		//cout<<pre[mask]<<'\n';
	}
	for(int mask=0;mask<(1<<n);mask++){
		vector<ll>taken;
		for(int j=0;j<n;j++){
			if(!(mask & (1<<j)))taken.pb(j);
		}
		rec(mask,0,taken,0);
		//cout<<dp[mask]<<'\n';
	}
	cout<<dp[(1<<n)-1];
}


Measured memory_bytes: 4688
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n, m, k;
    cin >> n >> m >> k;
    vector<int> a(n), b(m);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];

    vector<ll> asum(n+1), bsum(m+1);
    rep(i, n) asum[i+1] += asum[i] + a[i];
    rep(i, m) bsum[i+1] += bsum[i] + b[i];

    int ans = 0;
    rep(i, n+1) {
        if (asum[i] > k) continue;
        int j = upper_bound(all(bsum), k - asum[i]) - bsum.begin();
        chmax(ans, i+j-1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 7856
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

ll n;
ll a[100010];

ll sum[100010];

int main(){

  n = in();
  REP( i , n ){
    a[i] = in();
  }
  REP( i , n ){
    sum[i+1] = sum[i] + a[i];
  }

  ll ans = INFLL;
  
  ll res = 0;
  ll cur = 0;
  FOR( i , 1 , n+1 ){
    ll c = cur + sum[i];
    if( i % 2 == 1 ){
      // +
      if( c <= 0 ){
        ll add = -c + 1;
        cur += add;
        res += add;
      }
    } else {
      // -
      if( c >= 0 ){
        ll sub = c + 1;
        cur -= sub;
        res += sub;
      }
    }
  }
  chmin( ans , res );

  res = 0;
  cur = 0;
  FOR( i , 1 , n+1 ){
    ll c = cur + sum[i];
    if( i % 2 == 0 ){
      // +
      if( c <= 0 ){
        ll add = -c + 1;
        cur += add;
        res += add;
      }
    } else {
      // -
      if( c >= 0 ){
        ll sub = c + 1;
        cur -= sub;
        res += sub;
      }
    }
  }
  chmin( ans , res );

  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
 int main ()
   {
        long int a, i;
        scanf("%li", &a);
         if (a>0)
            {
                if (a%500==0)
                {
                    long int b=a*2;
                printf("%li", b);
                }
            }
           if (a%500 !=0)
           {
               long int x, y,z, m, n, o;
               x= a%500;
               y=a-x;
               z=y*2; 
              m=x/5;
               n= m*5;
               o=z+n;
               printf("%d", o);

           }
       if (a==0)
            {
             printf("0\n");
            }
   return 0;
   }


Measured memory_bytes: 128
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	vector<int> x(3), y(3);
	rep(i, 3) cin >> x[i] >> y[i];
	vector<double> a(3);
	rep(i, 3) {
		int dx = x[i] - x[(i + 1) % 3];
		int dy = y[i] - y[(i + 1) % 3];
		a[i] = sqrt(dx * dx + dy * dy);
	}
	double s = 0;
	rep(i, 3) s += x[i] * y[(i + 1) % 3] - y[i] * x[(i + 1) % 3];
	s = abs(s);
	double lb = 0, ub = 10000;
	rep(t, 300) {
		double r = (lb + ub) / 2;
		bool ok = false;
		rep(t, 3) {
			double S = 0;
			S += (a[0] + a[1]) * r + (a[2] + r * 2) * r;
			if (s / a[2] - r <= 0) S += 1e18;
			S += (s / a[2] - r) * r * 2;
			if (S <= s) ok = true;
			rotate(a.begin(), a.begin() + 1, a.end());
		}
		if (ok) lb = r;
		else ub = r;
	}
	printf("%.15f\n", lb);
}


Measured memory_bytes: 256
#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	A = getlist()
	if sum(A) >= 22:
		print("bust")
	else:
		print("win")
	


if __name__ == '__main__':
	main()

Measured memory_bytes: 38256
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase


def main():
    n,a,b,c=map(int,input().split())
    d={}
    d['A']=a
    d['B']=b
    d['C']=c

    ss=[input() for _ in range(n)]

    ans=[0]*n
    for i in range(n):
        s=ss[i]
        pos=0
        if d[s[0]]>d[s[1]]:
            pos=0
        elif d[s[1]]>d[s[0]] or i==n-1:
            pos=1
        elif s[0] in ss[i+1]:
            pos=1
        else:
            pos=0

        d[s[pos]]-=1
        d[s[pos^1]]+=1
        ans[i]=ord(s[pos^1])
    
        # print(d)

        if d['A']<0 or d['B']<0 or d['C']<0 :
            print("No")
            exit(0)
    print("Yes")
    print("\n".join(chr(x) for x in ans))

# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Measured memory_bytes: 87500
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char c = sc.next().charAt(0);

        if(c==Character.toUpperCase(c)){
            System.out.println("A");
        }else{
            System.out.println("a");
        }
        //String s=String.valueOf(char);  

        // if(Character.isUpperCase(char)){
        //     System.out.println("A");
        // }else{
        //     System.out.println("a");
        // }

        sc.close();
    }
}

Measured memory_bytes: 35588
from collections import deque

d=deque()

N=int(input())

for n in range(N):
    a=input()
    if a=="deleteFirst":
        d.popleft()
    elif a=="deleteLast":
        d.pop()
    else:
        a,b=a.split()
        if a=="insert":
            d.appendleft(b)
        elif a=="delete":
            if d.count(b):
                d.remove(b)
                
print(' '.join(list(d)))



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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

int N;
std::vector<PII> a;
VLL ans(100001, 0);
int main() {
    std::cin >> N;
    a.resize(N + 5);
    REP(i, N) {
        std::cin >> a[i].first;
        a[i].second = i;
    }
    std::sort(a.begin(), a.end(), std::greater<PII>());

    int min = std::numeric_limits<int>::max();
    for(int i=1; i<N+1; ++i) {
        min = std::min(a[i-1].second, min);
        ans[min] += (LL)i * (a[i-1].first - a[i].first);
    }
    REP(i, N) {
        std::cout << ans[i] << std::endl;
    }
}

Measured memory_bytes: 2688
h2 = 50
w2 = 50
ans = [["." for x in range(w2 * 2)] for y in range(h2 * 2)]

a, b = map(int, input().split())
a -= 1
if a != 0:
    b -= 1

cnt = 0
for y in range(h2):
    for x in range(w2):
        cnt += 1
        if cnt <= a:
            ans[y * 2][x * 2 + 1] = "#"
            ans[y * 2 + 1][x * 2] = "#"
            ans[y * 2 + 1][x * 2 + 1] = "#"
        elif a < cnt <= a + b:
            ans[y * 2 + 1][x * 2 + 1] = "#"


print(h2 * 2, w2 * 2)
for s in ans:
    print("".join(s))

Measured memory_bytes: 3188
#include <iostream>
#include <cmath>
using namespace std;
int main(){
  long long N;
  cin >> N;
  long long ans = N+1;
  for(long long i=1;i<=sqrt(N);i++){
      if(N%i == 0){
          long long temp = i+N/i;
          if(temp<ans) ans = temp;
      }
  } 
  cout << ans-2 << endl;
}

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


int main() {
  int n; cin >> n;
  int cnt = 0;
  vector<int> mt(n);
  for(int i = 0; i < n; i++){
    cin >> mt[i];
  }
  int v = -1;
  for(int i = 0; i < n; i++){
    if(mt[i] >= v){
      cnt++;
    }
    v = max(v,mt[i]);
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX(X,Y) ((X)>(Y)?(X):(Y))
#define MIN(X,Y) ((X)<(Y)?(X):(Y))

int main(void){
    int n, a, odd = 0, even = 0;
    
    scanf("%d", &n);
    for (int i=0; i<n; i++){
        scanf("%d", &a);
        a%2==0 ? even++ : odd++;
    }
    puts(odd%2==0 ? "YES" : "NO");
    return 0;
}

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

int main()
{
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> ab(m);
  for (int i = 0; i < m; ++i)
  {
    cin >> ab[i].first >> ab[i].second;
  }
  sort(ab.begin(), ab.end());
  pair<int, int> c = ab[0];
  int cnt = 1;
  for (int i = 1; i < m; ++i)
  {
    if (c.second <= ab[i].first)
    {
      cnt++;
      c = ab[i];
    }
    c = make_pair(ab[i].first, min(c.second, ab[i].second));
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    int a,b,c=0;
    bool flag=false;
    while(n--){
        scanf("%d %d",&a,&b);
        if(a==b) c++;
        else c=0;
        if(c==3) flag=true;
    }
    if(flag) puts("Yes");
    else puts("No");

}



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

using namespace std;

int main(){
    string S;
    int ans = 0,anss=0;
    cin >> S;
    for(int i=0;i<3;i++){
        if(S[i] == 'R'){
            ans++;
        }else{
            ans = 0;
        }
        anss = max(ans,anss);
    }

    cout << anss << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
string ho[111];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll h,w;cin>>h>>w;
  for(int i=0;i<h;i++){
    cin>>ho[i];
  }
  ll ans = 0;
  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++){
      if(ho[i][j] == '#')continue;
      for(int ii = 0;ii < h;ii++){
	for(int jj = 0;jj < w;jj++){
	  if(ho[ii][jj] == '#')continue;
	  bool vis[h+1][w+1];
	  for(int iii = 0;iii<h;iii++)
	    for(int jjj = 0;jjj < w;jjj++)
	      vis[iii][jjj] = false;
	  queue<tuple<ll,ll,ll>>que;
	  que.push(make_tuple(i,j,0));
	  while(!que.empty()){
	    ll x,y,t;
	    tie(x,y,t) = que.front();
	    que.pop();
	    if(x == ii && y == jj){
	      ans = max(ans,t);
	      break;
	    }
	    if(x + 1 < h){
	      if(ho[x+1][y] == '.' && vis[x+1][y] == false){
		vis[x+1][y] = true;
		que.push(make_tuple(x+1,y,t+1)); 
	      }
	    }
	    if(y + 1 < w){
	      if(ho[x][y+1] == '.' && vis[x][y+1] == false){
		vis[x][y+1] = true;
		que.push(make_tuple(x,y+1,t+1)); 
	      }
	    }
	    if(x - 1 >= 0){
	      if(ho[x-1][y] == '.' && vis[x-1][y] == false){
		vis[x-1][y] = true;
		que.push(make_tuple(x-1,y,t+1)); 
	      }
	    }
	    if(y - 1 >= 0){
	      if(ho[x][y-1] == '.' && vis[x][y-1] == false){
		vis[x][y-1] = true;
		que.push(make_tuple(x,y-1,t+1)); 
	      }
	    }
	  }
	}
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(){
	
	for(int n;cin>>n,n;){
		vector<string>V(n);
		for(int i=0;i<n;i++)cin>>V[i];
		int ans = -1;
		for(int k=1;k<=55;k++){
			set<string>S;
			for(int i=0;i<n;i++){
				string s="";
				for(int j=0;j<V[i].size() && s.size()<k;j++){
					if(j==0){
						s+=V[i][j];
					}
					else if(V[i][j-1]=='a' || V[i][j-1]=='i' || V[i][j-1]=='u' || V[i][j-1]=='e' || V[i][j-1]=='o'){
						s+=V[i][j];
					}
				}
				S.insert(s);
			}
			if(S.size()==n){
				ans=k;
				break;
			}
		}
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3168