akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define repf(i, x, n) for (int i = (int)(x); i < (int)(n); i++)
#define repfr(i, x, n) for (int i = (int)(x)-1; i >= (int)(n); i--)
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;
}
#define INF 1e9
using ll = int64_t;
#define waru 1000000007

std::int64_t gcd(std::int64_t a, std::int64_t b) {
  // a >= b && b != 0
  std::int64_t c;
  do {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}
std::int64_t gcd_s(std::int64_t aa, std::int64_t bb) {
  std::int64_t a = max(aa, bb);
  std::int64_t b = min(aa, bb);
  std::int64_t c;
  if (b == 0) {
    return -1;
  }
  do {
    c = a % b;
    a = b;
    b = c;
  } while (c);

  return a;
}
void rle(std::vector<std::pair<char, std::int64_t>> &data, std::string str) {
  char now = str[0];
  std::int64_t count = 0;
  for (std::int64_t i = 0; i < str.size() + 1; i++) {
    if (i == str.size()) {
      data.push_back(make_pair(str[i - 1], count));
      break;
    } else if (now != str[i]) {
      data.push_back(make_pair(now, count));
      now = str[i];
      count = 0;
    }
    count++;
  }

  return;
}

#define MAX_NUM 1000000
int n;
array<int, MAX_NUM> h;
int move_counter;
int move_counter_max;

void Main() {
  //自動整形防止用コメント
  std::cin >> n;
  rep(i, n) { std::cin >> h[i]; }

  rep(i, n - 1) {
    if (h[i] >= h[i + 1]) {
      move_counter++;
    } else {
      chmax(move_counter_max, move_counter);
      move_counter = 0;
    }
  }

  chmax(move_counter_max, move_counter);

  std::cout << move_counter_max << '\n';

  return;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 640
n = int(input())
d = input().split(" ")

ans = 0
count = 1

for i in range(n-1):
	if(d[i] != d[i+1]):
		ans += int(count/2);
		count = 1;

	else:
		count += 1

if(count > 1):
	ans += int(count/2)

print(ans)

Measured memory_bytes: 3060
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int x = sc.nextInt();
    int y = sc.nextInt();

    int[] ans = new int[n-1];
    int m;

    for(int i=1;i<n;i++){
      for(int j=i+1;j<n+1;j++){
        m = Math.min(j-i,Math.abs(i-x)+Math.abs(j-y)+1);
        ans[m-1]++;
        //System.out.println("i="+i+ "" + "j="+j +" " + "dis"+m);
      }
    }

    for(int a:ans)
    System.out.println(a);
  }
}

Measured memory_bytes: 22356
#include<stdio.h>

#define MAX 100
#define INF 2000000000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, cost[MAX][MAX];

void tani(void);

int main(){
  int i, j, x, a, u;

  scanf("%d", &n);

  for(i = 0; i < n; i++){
    for(j = 0; j < n; j++){
      cost[i][j] = INF;
    }
  }

  for(i = 0; i < n; i++){
    scanf("%d %d", &u, &x);
    for(j = 0; j < x; j++){
      scanf("%d", &a);
      scanf("%d", &cost[u][a]);
    }
  }
  tani();

  return 0;
}

void tani(){
  int i, u, min, v;
  int d[MAX], color[MAX];

  for(int i = 0; i < n; i++){
    d[i] = INF;
    color[i] = WHITE;
  }
  d[0] = 0;
  color[0] = GRAY;

  while(1){
    min = INF;
    u = -1;
    for(i = 0; i < n; i++){
      if(min > d[i] && color[i] != BLACK){
        u = i;
        min = d[i];
      }
    }
    if(u == -1) break;
    color[u] = BLACK;
    for(v = 0; v < n; v++){
      if(color[v] != BLACK && cost[u][v] != INF){
        if(d[v] > d[u] + cost[u][v]){
          d[v] = d[u] + cost[u][v];
          color[v] = GRAY;
        }
      }
    }
  }

  for(i = 0; i < n; i++){
    printf("%d ", i);
    if(d[i] == INF) printf("-1\n");
    else printf("%d\n", d[i]);
  }
}



Measured memory_bytes: 2108
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn=100100;
struct Node
{
    int l,r;
    friend bool operator <(const Node n1,const Node n2)
    {
        return n1.r==n2.r?n1.l>n2.l:n1.r<n2.r;
    }
}nodes[maxn];
int n,m;

int main()
{
    while (scanf("%d%d",&n,&m)!=EOF)
    {
        for (int i=0;i<m;i++)
            scanf("%d%d",&nodes[i].l,&nodes[i].r);
        sort(nodes,nodes+m);
        int maxx=0,ans=0;
        for (int i=0;i<m;i++)
        {
            if (maxx>nodes[i].l) continue;
            else maxx=nodes[i].r, ans++;
        }
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 896
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <set>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  ll d, c[26], s[365][26], t[365], ans = 0, m, x, y, v;
  set<ll> se[26];
  srand(time(NULL));
  cin >> d;
  for (int i = 0; i < 26; i++) {
    cin >> c[i];
    se[i].insert(0);
  }
  for (int i = 0; i < d; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s[i][j];
    }
  }
  for (int i = 0; i < d; i++) {
    t[i] = i % 26;
    se[t[i]].insert(i + 1);
    ans += s[i][t[i]];
    for (int j = 0; j < 26; j++) {
      ans -= (i + 1 - *se[j].rbegin()) * c[j];
    }
  }
  for (int i = 0; i < 26; i++) {
    se[i].insert(d + 1);
  }
  for (int i = 0; i < 15000000; i++) {
    x = i % d + 1;
    y = i % 26;
    v = 0LL;
    v += s[x - 1][y] - s[x - 1][t[x - 1]];
    set<ll>::iterator it = se[t[x - 1]].find(x);
    it--;
    ll z = *se[t[x - 1]].upper_bound(x);
    v -= c[t[x - 1]] * (z - x) * (x - *it);
    it = se[y].lower_bound(x);
    it--;
    v += c[y] * (*se[y].lower_bound(x) - x) * (x - *it);
    if (v > 0LL) {
      ans += v;
      se[t[x - 1]].erase(x);
      t[x - 1] = y;
      se[y].insert(x);
    }
  }
  for (int i = 0; i < d; i++) {
    cout << t[i] + 1 << endl;
  }
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main() {
  int n, m, l;
  cin >> n >> m >> l;
  vector<vector<int> > A(n, vector<int>(m, 0));
  vector<vector<int> > B(m, vector<int>(l, 0));
  vector<vector<LL> > C(n, vector<LL>(l, 0));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      cin >> A[i][j];
  for (int i = 0; i < m; i++)
    for (int j = 0; j < l; j++)
      cin >> B[i][j];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < l; j++) {
      for (int k = 0; k < m; k++)
        C[i][j] += A[i][k] * B[k][j];
    }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < l; j++) {
      if (j)
        cout << " ";
      cout << C[i][j];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3228
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
using namespace std;

int main(){
    int n, x[3], i;
    cin >> n;
    REP(i, n){
        int y[3];
        cin >> x[0] >> x[1] >> x[2];
        sort(x, x+3);
        REP(j, 3)
            y[j] = x[j] * x[j];
        if(y[2] == y[0]+y[1])
            printf("YES\n");
        else
            printf("NO\n");
    }
}



Measured memory_bytes: 3076
#include <iostream>
using namespace std;
int main(void){
    int x,y,z;
    cin>>x>>y>>z;
    if(x>=z){
        cout<<'0'<<endl;
    }

    else if((x+y)<z){
        cout<<"NA"<<endl;
    }
        else{
        cout<<z-x<<endl;
    }
}


Measured memory_bytes: 3088
n,x,y = map(int,input().split())
from collections import defaultdict,deque
gr = defaultdict(list)
for i in range(1,n):
  gr[i].append(i+1)
  gr[i+1].append(i)
gr[x].append(y)
gr[y].append(x)

res  = defaultdict(int)
for i in range(1,n+1):
  q = deque()
  q.append(i)
  vis = {}
  vis[i] = 0
  while q:
    tmp = q.popleft()
    for item in gr[tmp]:
      if item not in vis:
        vis[item] = vis[tmp]+1
        q.append(item)
  for j in range(i+1,n+1):
    res[vis[j]]+=1
for i in range(1,n):
  print(res[i])
     

Measured memory_bytes: 67740
n = int(input())
a = [0] * n
grid = [[-1 for _ in range(n)] for _ in range(n)]  # 証言を表す二次元配列
for i in range(n):
    a[i] = int(input())
    x = [0] * a[i]
    y = [0] * a[i]
    for j in range(a[i]):
        x[j], y[j] = map(int, input().split())
        grid[i][x[j] - 1] = y[j]
ans = 0
for i in range(1 << n):
    judge = [False] * n  # 誰を正直者としているか
    for j in range(n):
        if (i >> j) & 1:
            judge[j] = True
    is_ok = True  # 矛盾しているかどうか
    for j in range(n):
        if judge[j] and is_ok:
            for k in range(n):
                if grid[j][k] == -1:
                    continue
                if grid[j][k] != judge[k]:  # 矛盾
                    is_ok = False
    if is_ok:
        ans = max(ans, judge.count(True))
print(ans)


Measured memory_bytes: 44908
s = input()
n = len(s)
st = ''
i = 0
while i < n:
    if i < n - 1 and s[i] == 'B' and s[i + 1] == 'C':
        st += 'D'
        i += 1
    else:
        st += s[i]
    i += 1
ans = 0
ac = 0
for c in st:
    if c in ('B', 'C'):
        ac = 0
    elif c == 'A':
        ac += 1
    elif c == 'D':
        ans += ac
print(ans)

Measured memory_bytes: 3500
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    string s;
    cin >> s;
    ll l = 0,r = 0;
    ll pointer=0;
    ll deletion=0;
    REP(i,s.length()){
        if(s[i]=='S'){
            pointer++;
        }
        else{
            if(pointer>0) {
                pointer--;
                deletion+=2;
            }
        }
    }
    
    cout << s.length()-deletion << endl;
    return 0;
}


Measured memory_bytes: 640
# A - Airplane
import itertools
P,Q,R=list(map(int,input().split()))

m=99999
#for v in itertools.permutations([P,Q,R],2):
for v in itertools.combinations([P,Q,R],2):
    m=min(m,v[0]+v[1])
    #print(v)

print(m)



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

const int mod = 1e9 + 7;
int N , M;
char a[1005][1005];
int DP[1005][1005];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> N >> M;
    for(int i = 1; i <= N; ++i){
        for(int j = 1; j <= M; ++j){
            cin >> a[i][j];
        }
    }
    DP[1][1] = 1;
    for(int i = 1; i <= N; ++i){
        for(int j = 1; j <= M; ++j){
            if(a[i][j] == '.'){
                if(i - 1 >= 1 && a[i - 1][j] == '.')
                    DP[i][j] = (DP[i][j] + DP[i - 1][j]) % mod;
                if(j - 1 >= 1 && a[i][j - 1] == '.')
                    DP[i][j] = (DP[i][j] + DP[i][j - 1]) % mod;
            }
        }
    }
    cout << DP[N][M] << endl;
}


Measured memory_bytes: 5248
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}

int main(){
	int N,M;
	cin>>N>>M;
	string S,T;
	cin>>S>>T;
	int g=gcd(N,M);
	int n=N/g,m=M/g;
	bool ok=true;
	rep(i,g){
		if(S[i*n]!=T[i*m])ok=false;
	}
	if(ok){
		lli ans=(lli)N*M/g;
		cout<<ans;
	}
	else cout<<-1;
}

Measured memory_bytes: 512
n = gets.chop
a = []
n.each_char do |c|
  a << c.to_i
end

pm = [:+, :-]

pm.repeated_permutation(3) {|op1, op2, op3|
  result = a[0].send(op1, a[1]).send(op2, a[2]).send(op3, a[3])
  if result == 7
    puts "#{a[0]}#{op1.to_s}#{a[1]}#{op2.to_s}#{a[2]}#{op3.to_s}#{a[3]}=7"
    exit
  end
}


Measured memory_bytes: 1788
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
using namespace std;
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b)
{
    return (a.second<b.second);
}
bool sortbysecll(const pll &a, const pll &b)
{
    return (a.second<b.second);
}
ll modinv(ll x, ll y, ll modulo)
{
    return ((x%modulo)*(P(y,modulo-2LL,modulo)%modulo))%modulo;
}
void vok()
{
    FAST
    FO
    FI
//    #ifndef ONLINE_JUDGE
//        freopen("input.txt","r",stdin);
//        freopen("output.txt","w",stdout);
//    #endif
}
int main()
{
    vok();
    int n;
    IN n;
    vector<int> v(n);
    bool f=true;
    loop(i,0,n)
    {
        IN v[i];
        if(v[i]%2==0)
        {
            if(v[i]%3==0 || v[i]%5==0)
            {
                
            }
            else
            {
                f=false;
            }
        }
    }
    if(f)
    {
        OUT "APPROVED"<<endl
    }
    else
    {
        OUT "DENIED"<<endl
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

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

ll N;
vector<ll> X, Y;
vector<char> U;
const string DIRECTION = "LDRU";
const ll POS_MAX = 200000;
const ll INF = 1e18;

void rotate() {
  REP(i, N) {
    ll m = POS_MAX / 2, x = X[i] - m, y = Y[i] - m;
    X[i] = -y + m, Y[i] = x + m;
    // DUMP(X[i]);
    // DUMP(Y[i]);
    REP(j, 4) {
      if (DIRECTION[j] == U[i]) {
        U[i] = DIRECTION[(j + 1) % 4];
        break;
      }
    }
    // DUMP(U[i]);
  }
}

ll solveForLine() {
  ll res = INF;
  // when L, R
  vector<vector<ll>> XsL(POS_MAX + 1), XsR(POS_MAX + 1);
  REP(i, N) {
    if (U[i] == 'L') {
      XsL[Y[i]].push_back(X[i]);
    } else if (U[i] == 'R') {
      XsR[Y[i]].push_back(X[i]);
    }
  }
  REP(i, POS_MAX + 1) {
    if (SZ(XsL[i]) == 0 || SZ(XsR[i]) == 0) {
      continue;
    }
    sort(ALL(XsL[i]));
    sort(ALL(XsR[i]));
    for (ll xr : XsR[i]) {
      // min x s.t. x > xr and x in XsL[i]
      if (XsL[i][0] > xr) {
        chmin(res, (-xr + XsL[i][0]) * 5);
        continue;
      }
      if (XsL[i].back() <= xr) {
        continue;
      }
      ll ng = 0, ok = SZ(XsL[i]) - 1;
      while (ng + 1 < ok) {
        ll m = (ok + ng) / 2;
        (XsL[i][m] > xr ? ok : ng) = m;
      }
      chmin(res, (-xr + XsL[i][ok]) * 5);
    }
  }
  return res;
}

ll solveForVertical() {
  ll res = INF;
  // when R, U
  ll sz = 2 * POS_MAX + 1;
  vector<vector<ll>> XsR(sz), XsU(sz);
  REP(i, N) {
    if (U[i] == 'R') {
      XsR[X[i] + Y[i]].push_back(X[i]);
    } else if (U[i] == 'U') {
      XsU[X[i] + Y[i]].push_back(X[i]);
    }
  }
  REP(i, sz) {
    if (SZ(XsR[i]) == 0 || SZ(XsU[i]) == 0) {
      continue;
    }
    sort(ALL(XsR[i]));
    sort(ALL(XsU[i]));
    for (ll xr : XsR[i]) {
      // min x s.t. x > xr and x in XsU[i]
      if (XsU[i][0] > xr) {
        chmin(res, (-xr + XsU[i][0]) * 10);
        continue;
      }
      if (XsU[i].back() <= xr) {
        continue;
      }
      ll ng = 0, ok = SZ(XsU[i]) - 1;
      while (ng + 1 < ok) {
        ll m = (ok + ng) / 2;
        (XsU[i][m] > xr ? ok : ng) = m;
      }
      chmin(res, (-xr + XsU[i][ok]) * 10);
    }
  }
  return res;
}

int main() {
  cin >> N;
  X = vector<ll>(N);
  Y = vector<ll>(N);
  U = vector<char>(N);
  REP(i, N) { cin >> X[i] >> Y[i] >> U[i]; }
  ll ans = INF;
  REP(_, 4) {
    chmin(ans, solveForLine());
    chmin(ans, solveForVertical());
    rotate();
  }

  if (ans == INF) {
    cout << "SAFE" << endl;
    return 0;
  }
  cout << ans << endl;
}

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

int main() {
	
	int n;
	string s,t;
	cin >> n >> s;
	t=s.substr(0,n/2);
	if(s==t+t) cout <<"Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

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


  
int main(){
  

  int H,R;
  cin >> H >> R ;
  if (H<=0 && H+R>0){
    cout << "1\n";
  }else if (H<=0 && H+R<0){
    cout << "-1\n";
  }else if (H>=0 ){
    cout << "1\n";
  }else if (H<0 && H==-1*R){
    cout << "0\n";
  }else if (H>0 && H==R){
    cout << "0\n";
  }
  
  
  
    
 return 0;
}


Measured memory_bytes: 3076
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto S = readln.chomp;
    auto DP = new long[][](2, 2019);
    long r;
    foreach (i, c; S) {
        auto n = c - '0';
        foreach (x; 0..2019) DP[i%2][x] = 0;
        DP[i%2][n] = 1;
        foreach (x; 0..2019) DP[i%2][(x * 10 + n) % 2019] += DP[(i+1)%2][x];
        r += DP[i%2][0];
    }
    writeln(r);
}

Measured memory_bytes: 2916
#include<bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using namespace std;

//ループマクロ
#define FOR(i , a , b)  for(int i = (a) ; i < (b) ; i++)
#define REP(i , n)      for(int i = 0 ; i < n ; i++)
#define REPR(i , n)     for(int i = n ; 0 <= i ; i--)
#define ROP(i, n)       for(int i = 1 ; i <= n ; i++)

//入出力
#define SCOUT(x) cout << (x) << " "
#define VECCIN(x) for(auto& ele : (x) ) cin >> ele
#define VECOUT(x) for(auto& ele : (x) ) cout << ele << " "; cout << endl;

//その他
#define ALL(obj) (obj).begin() , (obj).end() 
#define P pair<int , int>
#define V vector<int>
#define VLL vector<long long>
#define M map<int, int>
#define S set<int>
#define PQ priority_queue<int>
#define PQG priority_queue<int , V , greater<int>>

int main(void) {

	ios::sync_with_stdio(false);	cin.tie(0);
	ll x;  cin >> x;
	int keep = x % 11;
	if(keep == 0)      cout << (ll)(x / 11) * 2 << endl;
	else if(keep - 6 <= 0)  cout << (ll)(x / 11) * 2 + 1 << endl;
	else               cout << (ll)(x / 11) * 2 + 2 << endl;
		
	return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

template <typename T>
class SegmentTree {
  const T unit;
  const function<T(const T&, const T&)> op;
  vector<T> container;

 public:
  template <typename Op>
  SegmentTree(int size, const T& identity, const Op& operation)
      : unit(identity), op(operation), container(msb(size * 2 - 1)) {
    fill(container.begin(), container.end(), unit);
  }
  void update(size_t index, T value) {
    int n = container.size() / 2;
    container[index + n] = value;

    int node = (index + n) >> 1;
    while (node > 0) {
      container[node] = op(container[node << 1], container[(node << 1) + 1]);
      node >>= 1;
    }
  }
  T find(size_t s, size_t t) {
    if (s >= t) {
      return unit;
    }
    return find_inner(s, t, 0, container.size() / 2);
  }

 private:
  T find_inner(size_t s, size_t t, size_t lb, size_t ub) {
    if (s == lb && t == ub) {
      int n = container.size() / 2;
      return container[lca(n + s, n + t - 1)];
    }

    T result = unit;
    size_t mid = (lb + ub) / 2;
    if (mid > s) {
      result = op(result, find_inner(s, min(mid, t), lb, mid));
    }
    if (mid < t) {
      result = op(result, find_inner(max(s, mid), t, mid, ub));
    }

    return result;
  }
  int lca(int n0, int n1) {
    int a = n0 ^ n1;
    return n0 / msb(a);
  }
  int msb(int x) {
    x |= x >> 1;
    x |= x >> 2;
    x |= x >> 4;
    x |= x >> 8;
    x |= x >> 16;

    return x + 1;
  }
};

int main() {
  int N, K, C;
  cin >> N >> K >> C;
  string s;
  cin >> s;

  s = string("x") + s;
  s.push_back('x');

  vector<int> lwork(N + 2, 0), rwork(N + 2, 0);

  rep(i, N) {
    lwork[i + 1] = lwork[i];
    if (s[i + 1] == 'o') {
      if (i + 1 - C - 1 >= 0) {
        lwork[i + 1] = max(lwork[i + 1], lwork[i + 1 - C - 1] + 1);
      } else {
        lwork[i + 1] = 1;
      }
    }
  }

  rep(i, N) {
    rwork[N - i] = rwork[N - i + 1];
    if (s[N - i] == 'o') {
      if (N - i + C + 1 <= N + 1) {
        rwork[N - i] = max(rwork[N - i], rwork[N - i + C + 1] + 1);
      } else {
        rwork[N - i] = 1;
      }
    }
  }

  SegmentTree<int> work(
      N + 1 + C, 0, [](const int& lh, const int& rh) { return max(lh, rh); });

  for (int i = -C; i < N; i++) {
    work.update(i + C, lwork[max(i, 0)] + rwork[min(i + C + 1, N + 1)]);
  }

  rep(i, N) {
    if (C == 0) {
      if (lwork[i] + rwork[i + 2] < K) {
        cout << i + 1 << "\n";
      }
    } else {
      if (work.find(i + 1, i + 1 + C) < K) {
        cout << i + 1 << "\n";
      }
    }
  }
  return 0;
}

Measured memory_bytes: 7080
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int r = sc.nextInt();
		int g = sc.nextInt();
		int b = sc.nextInt();
		
		sc.close();
		
		if((g*10 + b)%4 == 0) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}

	}

}

Measured memory_bytes: 22996
#include<stdio.h>
#include<limits.h>
void maxHeapify(int *,int);
void buildMaxHeap(int *);

int H;
int main(){
  int A[500001];
  int i,j,x;
  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }
  buildMaxHeap(A);
  for(i=1;i<=H;i++){
  
      printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");


  return 0;
}
void maxHeapify(int A[],int i){
  int l,r,largest,hoge;
  l=i*2;
  r=i*2+1;
  if(l<=H && A[l]>A[i])
    largest=l;
  else
    largest=i;
  if(r<=H&&A[r]>A[largest])
    largest=r;
  if(largest!=i){
 
    hoge=A[i];
    A[i]=A[largest];
    A[largest]=hoge;
    maxHeapify(A,largest);
  }
    
  
  
}
void buildMaxHeap(int A[]){
  int i;
  for(i=H/2;i>0;i--)
    maxHeapify(A,i);

}



Measured memory_bytes: 3676
#include<stdio.h>

int main()
{
    char S[4];
    scanf("%s",S);
    int i,p=0;
    for(i=0;i<strlen(S);i++)
    {
    if(S[i]=='R')
    p++;
    if(S[i]=='S'&&p>0)
    break;
    }
    printf("%d",p);
    return 0;
}

Measured memory_bytes: 2156
n=int(input())
a=list(map(int, input().split()))
for i in range(n):
	a[i]=format(a[i],'b')
#count1に1をカウントして入れる
#popは右側に行うとはやいらしいので気にせず行う
total=0
count1=0
for k in range(60):
	count1=0
	for i in range(n):
		if k<len(a[i]):
			if a[i][-1-k]=='1':
				count1+=1
	total+=count1*(n-count1)*(2**k)
	total=total%(10**9+7)
print(total)

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

int main() {
	int n;long long a[110];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	long long ans = 0;
	for (int i = 0; i < n - 1; i++) {
		for (int j = i; j < n; j++) {
			ans = max(abs(a[i] - a[j]), ans);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <math.h>
#include <unordered_map>
#include <algorithm>

using namespace std;
int main()
{
  int X, A;
  cin >> X >> A;
  if (X<A) cout << 0 << endl;
  else cout << 10 << endl;
  return 0;
}


Measured memory_bytes: 256
package main

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

func main() {
	N, K := nextInt(), nextInt()
	As := nextInts(N)
	ans := solve(As, K)
	for i := 0; i < N; i++ {
		fmt.Printf("%d ", ans[i])
	}
}

func solve(As []int, K int) []int {
	N := len(As)

	if K >= N {
		for i := 0; i < N; i++ {
			As[i] = N
		}
		return As
	}

	for k := 0; k < K; k++ {
		Bs := make([]int, N+1)
		for i := 0; i < N; i++ {
			l := Max(0, i-As[i])
			r := Min(N, i+As[i]+1)
			Bs[l]++
			Bs[r]--
		}
		filled := true
		for i := 0; i < N; i++ {
			Bs[i+1] += Bs[i]
			if Bs[i] != N {
				filled = false
			}
		}
		Bs = Bs[:N]
		if filled {
			return Bs
		}
		As = Bs
	}
	return As
}

func Max(xs ...int) int {
	max := xs[0]
	for _, x := range xs[1:] {
		if max < x {
			max = x
		}
	}
	return max
}
func Min(xs ...int) int {
	min := xs[0]
	for _, x := range xs[1:] {
		if min > x {
			min = x
		}
	}
	return min
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer(make([]byte, 256), 1e9)
	sc.Split(bufio.ScanWords)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}


Measured memory_bytes: 13492
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, w;
ll vs[110];
ll wss[110];
int main() {
	cin>>n>>w;
	for(int i=1; i<=n; ++i) {
		cin>>wss[i]>>vs[i];
	}
	ll dp[n + 10][w + 10];
	memset(dp, 0, sizeof dp);
	for(int i=1; i<=n; ++i) {
		for(int k=1; k<=w; ++k) {
			if(k - wss[i] >= 0) {
				dp[i][k] = max(
					dp[i - 1][k],
					vs[i] + dp[i - 1][k - wss[i]]
				);
			} else dp[i][k] = dp[i - 1][k];
		}
	}
	cout<<dp[n][w]<<endl;
	/*for(int i=0; i<=n; ++i) {
		for(int k=0; k<=w; ++k) {
			cout<<dp[i][k]<<" ";		
		} cout<<endl;
	}*/
	return 0;
}

Measured memory_bytes: 86144
n, m, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
b = gets.split.map(&:to_i)

a_index = -1
a_sum = 0

b_index = -1
b_sum = 0

while b_index < m - 1
  b_index += 1
  b_sum += b[b_index]
  if b_sum > k
    b_sum -= b[b_index]
    b_index -= 1
    break
  end
end

ans = b_index + 1

while a_index < n - 1
  a_index += 1
  a_sum += a[a_index]
  break if a_sum > k
  while a_sum + b_sum > k
    b_sum -= b[b_index]
    b_index -= 1
  end
  ans = [ans, (a_index + 1) + (b_index + 1)].max()
end

p ans


Measured memory_bytes: 41796
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
int main() {
    int N, K; cin >> N >> K;
    vector<int>A(N);
    rep(i, N) {
        cin >> A[i];
        if (A[i] == K) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    if (N == 1) {
        if (A[0] != K)cout << "IMPOSSIBLE" << endl;
        else cout << "POSSIBLE" << endl;
        return 0;
    }
    sort(A.begin(), A.end());
    int B=gcd(A[0],A[1]);
    REP(i, N - 1)B = gcd(B, A[i + 1]);
    rep(i,N){
        if (A[i] % B == K % B && K <= A[i]) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}

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

int main() {
  const ll lim = 1e18;
  int N;
  cin >> N;
  vector<ll> A(N);
  ll mul = 1;
  bool flag = false;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (A[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  for (int i = 0; i < N; i++) {
    if (A[i] > lim / mul) flag = true;
    else mul *= A[i];
  }
  if (flag) mul = -1;

  cout << mul << endl;
}

Measured memory_bytes: 4048
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var buff []byte

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextFloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func nextInts(n int) (r []int) {
	r = make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt64

func maxInt(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func minInt(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func absInt(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buff, bufio.MaxScanTokenSize*1024)
	log.SetFlags(log.Lshortfile)
}

func main() {
	n := nextInt()
	k := nextInt()
	a := nextInts(n)
	for i := 0; i < k; i++ {
		b := make([]int, n+1)
		for j := 0; j < n; j++ {
			left := maxInt(0, j-a[j])
			right := minInt(n, j+a[j]+1)
			b[left]++
			b[right]--
		}
		v := 0
		for j := 0; j < n; j++ {
			v += b[j]
			a[j] = v
		}
		if minInt(a...) == n {
			break
		}
	}
	for i := 0; i < n; i++ {
		if i < n-1 {
			fmt.Print(a[i], " ")
		} else {
			fmt.Println(a[i])
		}
	}
}


Measured memory_bytes: 9948
from collections import Counter
n = int(input())
D = list(map(int,input().split()))
m = int(input())
T = list(map(int,input().split()))
sd = set(D)
st = set(T)
cntd = Counter(D)
cntt = Counter(T)
ok = True
for t in T:
    if t not in sd:
        ok = False
    elif cntt[t] > cntd[t]:
        ok = False
if ok:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 73340
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("C:\\Users\\BOG\\CLionProjects\\EZZ\\kek.txt");ofstream out("board.out");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid<int> u1(5, 10); u1(rnd);

ll a,k,sz;
vec<ll> m, nxt, lst, fir, emp;

void solve(){
    for(ll c = a-1-((sz-1)%a); sz;){
        ll p = nxt[c], nowdel = p==c ? a+1 : p>c ? p-c+1 : a+(p-c+1);
        if(nowdel<=sz) sz-=nowdel;
        else{
            lst = vec<ll>(3e5, 0);
            vec<ll> o;
            for(; c<a; c++){
                ll n = m[c];
                if(lst[n]==0){
                    lst[n] = 1;
                    o.pb(n);
                }
                else{
                    for(; o.back()!=n;){
                        lst[o.back()] = 0;
                        o.pop_back();
                    }
                    o.pop_back();
                    lst[n] = 0;
                }
            }
            for(ll i : o) cout<<i<<" ";
            return;
        }
        c = (p+1)%a;
    }
}

int main() {
    fast;
    cin>>a>>k;
    sz = a*k;
    m = vec<ll>(a);
    nxt = vec<ll>(a, -1);
    lst = vec<ll>(3e5, -1);
    fir = vec<ll>(3e5, -1);
    emp = vec<ll>(a, -1);
    for(int q=0; q<a; q++) cin>>m[q];
    for(int q=0; q<a; q++){
        if(fir[m[q]]==-1) fir[m[q]] = q;
        if(lst[m[q]]!=-1) nxt[lst[m[q]]] = q;
        lst[m[q]] = q;
    }
    for(int q=0; q<a; q++) if(nxt[q]==-1) nxt[q] = fir[m[q]];
    ll pred=0, per=0, cntdel=0, predd=0, perd=0;
    vec<ll> wasdel;
    for(ll xod=0, c=0; ; xod++){
        ll p = nxt[c];
        cntdel += p==c ? a+1 : p>c ? p-c+1 : a+(p-c+1);
        //cout<<"DEL: "<<cntdel<<endl;
        if(emp[p]==-1) emp[p] = xod, wasdel.pb(cntdel);
        else{
            per = xod - emp[p];
            pred = xod-per;
            predd = pred==0 ? 0 : wasdel[pred-1];
            perd = wasdel.back()-predd;
            break;
        }
        c = (p+1)%a;
    }
    //cout<<"PRED DEL: "<<predd<<endl;
    //cout<<"PER DEL: "<<perd<<endl;
    if(sz>=predd) sz-=predd, sz%=perd;
    solve();
}

Measured memory_bytes: 16072
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
	int A[3];
	cin >> A[0] >> A[1] >> A[2];
	sort(A, A + 3);
	cout << A[0] + A[1] + A[2] * 10 << endl;
	return 0;
}

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

const ll INF = 1LL << 60;

ll M;
vector<ll> d, c;
int main() {
    cin >> M;
    d.resize(M);
    c.resize(M);

    rep(i, M) {
        cin >> d[i] >> c[i];
    }
    ll ans = accumulate(c.begin(), c.end(), 0LL) - 1;

    ll tmp = 0;
    rep(i, M) {
        tmp += d[i] * c[i];
    }

    // if (tmp >= 10) {
        ans += (tmp - 1) / 9;
    // }

    cout << ans << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>

#define abs(a) ((a) < 0 ? -(a):(a))

using namespace std;
int main()
{
  long long int n, i, sum=0, mid;
  long long int a[200000];

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

  sort(a, a+n);

  mid = a[n/2];
  
    for(i=0; i<n; i++){
      sum+=abs(a[i]-(mid));
    }
  cout << sum << endl;
  
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
/**
*   author: j o s e m a g o
*   date:
**/
using namespace std;
#pragma GCC optimize ("Ofast")
#define f first
#define s second
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mset(a,v) memset(a,v,sizeof(a))
#define pb push_back
#define sz(x) ((int)(x).size())
#define rsz resize
#define ln "\n"

typedef double db;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
const ld PI = 2*acos(0.0);
const int MOD = 1000000007;
const int JJJ = 100009;




int main(){

  //freopen("input.in","r",stdin);
  //freopen("input.out","w",stdout);

    ios_base::sync_with_stdio(0); cin.tie(0);

    int N;
    cin >> N;
    vector<int>h(N);
    for(int i = 0;i < N;i++){
        cin >> h[i];
    }
    vector<int>dp(N,INT_MAX);
    dp[0] = 0;
    dp[1] = abs(h[0]-h[1]);
    for(int i = 2;i < N;i++){
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<dp[N-1];







    return 0;
}

Measured memory_bytes: 1024
#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>;

void Main()
{
  ll A,B,C,X,Y;
  cin >> A >> B >> C >> X >> Y;
  ll minPrice;
  // それぞれ購入
  minPrice = A*X + B*Y;
  // 少ない数だけセットで購入
  ll setPrice = C * min(X,Y) * 2;
  if (X < Y) setPrice += (Y-X) * B;
  else setPrice += (X-Y) * A;
  minPrice = min(minPrice, setPrice);
  // 全てセットで購入
  minPrice = min(minPrice, C*max(X,Y)*2);
  
  cout << minPrice << endl;
}

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

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

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

	int n,m;
	cin >> n >> m;
	
	int x,y;
	cin >> x >> y;
	
	int t_x, t_y;
	cin >> t_x >> t_y;
	x--, y--;
	t_x--, t_y--;
	
	vector< vector< char > > grid(n, vector< char >(m));	
	for(int i = 0;i < n;++i)
		for(int j = 0;j < m;++j)
			cin >> grid[i][j];

	vector< vector< long long > > sp(n, vector<long long>(m,-1));
	priority_queue< pair< long long, pair<int, int> > > pq;
	pq.push( { 0, { x, y} });
	
	vector<int> X0 = {1,-1,0,0}; 
 	vector<int> Y0 = {0,0,1,-1};
	
	vector<int> X1 = {-2,-2,-2,-2,-2,-1,-1,-1,-1,0,0,1,1,1,1,2,2,2,2,2};
	vector<int> Y1 = {-2,-1,0,1,2,-2,-1,1,2,-2,2,-2,-1,1,2,-2,-1,0,1,2};
	
	while(pq.empty() ^ 1){
		int cx = pq.top().second.first;
		int cy = pq.top().second.second;
		int cost = pq.top().first * -1;
	
		pq.pop();
		if(cx < 0 || cx >= n || cy < 0 || cy >= m || grid[cx][cy] == '#' || sp[cx][cy] != -1) 
			continue;
		sp[cx][cy] = cost;
		if(cx == t_x && cy == t_y){
			cout << cost;
			return 0;
		}	
		for(int i = 0;i < 4;++i)
			pq.push( { -cost , { cx + X0[i], cy + Y0[i]} } );
		
		for(int i = 0;i < 20;++i)
			pq.push( { -(cost+1),{ cx + X1[i], cy + Y1[i]} } );
		
	};
	
	cout << sp[t_x][t_y];
}


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

bool solve(int, int[], int[]);

int main()
{
	int n;
	scanf("%d", &n);
	int *s{new int[n]};
	for (int i = 0; i < n; i++)
	{
		char tmp;
		scanf(" %c", &tmp);
		s[i] = tmp == 'x';
	}
	int *is_wolf{new int[n]};

	if (solve(n, s, is_wolf))
	{
		for (int i = 0; i < n; i++)
			if (is_wolf[i])
				printf("W");
			else
				printf("S");
		printf("\n");
	}
	else
		printf("-1\n");

	delete[] is_wolf;
	delete[] s;
	return 0;
}

bool solve(int n, int s[], int is_wolf[])
{
	for (int last = 0; last < 2; last++)
		for (int front = 0; front < 2; front++)
		{
			std::fill(is_wolf, is_wolf + n, 0);
			is_wolf[0] = front;
			is_wolf[n - 1] = last;
			for (int i = 0; i < n; i++)
			{
				if ((is_wolf[(i + n - 1) % n] + is_wolf[i]) % 2 != s[i])
					is_wolf[(i + 1) % n] = 1;
				else
					is_wolf[(i + 1) % n] = 0;
			}
			if ((is_wolf[0] + is_wolf[n - 1] + is_wolf[1]) % 2 == s[0]
				&& (is_wolf[0] + is_wolf[1] + is_wolf[2]) % 2 == s[1]) return true;
		}

	return false;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

#define F first
#define S second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    ll a, b;
    cin >> a >> b;
    if (a + b >= 10) {
        cout << "error" << endl;
    }else{
        cout << a + b << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>

int main() {
	int testcases {};
	std::cin >> testcases;
	double bawahinpt{}, sumbawah{};
	while (testcases--) {
		std::cin >> bawahinpt;
		sumbawah += 1/bawahinpt;
	}
	sumbawah = 1/sumbawah;
	std::cout << sumbawah;
	return 0;
}

//aa

Measured memory_bytes: 256
import collections


N = int(input())
S = [None] * N
for i in range(N):
    S[i] = input()

count = collections.Counter(S)
max_n = max(count.values())
# print(max_n)

keys = [k for k, v in count.items() if v == max_n]
keys.sort()

for s in keys:
    print(s)


Measured memory_bytes: 97616
#include<iostream>
#include<vector>
#include<cmath>
#include<limits>
#include<cfenv>
using namespace std;

int main()
{
  int N, D;

  cin >> N >> D;
  vector<vector<int> > v(N, vector<int>(D, 0));

  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < D; j++)
    {
      cin >> v[i][j];
    }
  }

  int count = 0;

  for (int i = 0; i < N; i++)
  {
    for (int j = i + 1; j < N; j++)
    {
      double sum;
      if (i == j)
        continue;


      for (int k = 0; k < D; k++)
      {
        sum += abs(v[i][k] - v[j][k]) * abs(v[i][k] - v[j][k]);
      }


      double root = sqrt(sum);
      long long ce = ceil(root);
      long long fl = floor(root);

      if(ce == fl){
        count++;
      }
      sum = 0;
    }
  }

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

Measured memory_bytes: 256
def cross1(arr,s):
    for i in range(3):
        if arr[i][i] not in s:
            return False
    return True
def cross2(arr,s):
    for i in range(3):
        if arr[i][2-i] not in s:
            return False
    return True
def calc(arr, s):
    for r in range(3):
        pos = True
        for c in range(3):
            if arr[r][c] not in s:
                pos = False
                break
        if pos:
            return True
    
    for c in range(3):
        pos = True
        for r in range(3):
            if arr[r][c] not in s:
                pos = False
                break
        if pos:
            return True
    if cross1(arr,s) or cross2(arr,s):
        return True
    return False
        


if __name__ == "__main__":
    arr = []
    for i in range(3):
        arr.append(list(map(int,input().split())))
    # print(arr)
    s = set()
    n = int(input())
    for _ in range(n):
        s.add(int(input()))

    print("Yes" if calc(arr, s) else "No")
    


Measured memory_bytes: 3064
N = int(input())
A = list(map(int, input().split()))

mon = 1000
kabu = 0

for i in range(N-1):
  if A[i] <= A[i+1]:
    kabu, mon = divmod(mon, A[i])
    mon += kabu * A[i+1]
    
print(mon)

Measured memory_bytes: 8956
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; i--)
#define loop(i, r, n) for (int i = (r); i < (n); i++)
#define pb push_back
#define all(in) in.begin(),in.end()

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

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main(){
    ll x, k, d; cin >> x >> k >> d;
    ll count = abs(x)/d;
    if(x == 0){
        cout << (k%2 == 0 ? 0 : d) << endl;
        return 0;
    }
    if(k <= count){
        if(x > 0) cout << x - k * d << endl;
        if(x < 0) cout << abs(x + k * d) << endl;
        return 0;
    }
    else{
        k -= count;
        if(x > 0) cout << (k%2 == 0 ? abs(x - count * d) : abs(x - (count+1) * d)) << endl;
        if(x < 0) cout << (k%2 == 0 ? abs(x + count * d) : abs(x + (count+1) * d)) << endl;
        return 0;
    }
}

Measured memory_bytes: 3632
import math
n, k = map(int, input().split())
prb = 0
#出た目をiとするとi*2**a > kとなる最小のaを知りたい
for i in range(1, n+1):
    if i < k:
        power = math.ceil(math.log2(k/i))
        prb += (1/n)*((1/2)**(power))
    else:
        prb += 1/n
print(prb)

Measured memory_bytes: 3060
using System.Linq;
using System.Collections.Generic;
using System;

public class Yado
{
    public int d { get; set; }
    public int p { get; set; }
}

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            var wk = new List<Yado>();
            string[] line = Console.ReadLine().Trim().Split(' ');
            var n = int.Parse(line[0]);
            var m = int.Parse(line[1]);
            if (n == 0 && m == 0) break;
            for (int i = 0; i < n; i++)
            {
                string[] line2 = Console.ReadLine().Trim().Split(' ');
                var d = int.Parse(line2[0]);
                var p = int.Parse(line2[1]);
                wk.Add(new Yado { d = d, p = p });
            }
            var yados = wk.OrderByDescending(x => x.p).ToList();
            var nexti= -1;
            for (int i = 0; i < n; i++)
            {
                if (m - yados[i].d > 0) m -= yados[i].d;
                else { nexti = i+1; break; }
            }
            var ret = 0;
            if (nexti == -1) goto end;
            for (int i = nexti; i < n; i++)
                ret += yados[i].d * yados[i].p;
            ret += (yados[nexti - 1].d - m) * yados[nexti - 1].p;
            end:;
            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 11148
#include <stdio.h>
#include <math.h>
int main(void){
   
    int n,count = 1;
    char str[101],f,e;
    
    n = scanf("%s", str);
    int i = 0;
    
    f = str[0];
    
    for(i = 1; i < 101; i++) {
        if(str[i] == '\0'){
            e = str[i-1];
            count -= 2;
            break;
        } 
        count++;
    }
    if(count < 0) count = 0;
    
    printf("%c", f);
    printf("%d", count);
    printf("%c\n", e);
    
    return 0;
}


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

void CheckNum(int i);

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

	int i = 1;
	while(true){

		if(i % 3 == 0){
			cout << " " << i;
		}else{
			int x = i;
			while(0 < x){
				if(x % 10 == 3){
					cout << " " << i;
					break;
				}
				x /= 10;
			}
		}

		if(n < ++i) break;
	}

	cout << endl;
	return 0;
}

Measured memory_bytes: 1164
#include<algorithm>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<iostream>
#include<istream>
#include<map>
#include<math.h>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
using namespace std;
int n,k,ans;
string s;
int main(){
    string s;
    cin>>n>>k>>s;
    vector<pair<int, bool> > v(n);
    int i=0,j=0,ans=0;
    while(j<n){
        while(j<n&&s[j]=='1') ++j;
        ans=max(ans,j-i);
        while(j<n&&s[j]=='0') ++j;
        --k;
        if(k < 0){
            while(i<n&&s[i]=='1') ++i;
            while(i<n&&s[i]=='0') ++i;
        }
        ans=max(ans, j - i);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
using namespace std;
int main(){
    int X, A, B;
    cin >> X >> A >> B;
    if(A >= B){
        cout << "delicious" << endl;
    }else if(A + X >= B){
        cout << "safe" << endl;
    }else{
        cout <<"dangerous" << endl;
    }

}


Measured memory_bytes: 256
n,q=map(int,input().split())
s=input()
lr=[list(map(int,input().split())) for _ in range(q)]
count=0
l=[0]*n
for i in range(1,n):
  if s[i-1]=="A" and s[i]=="C":
    count+=1
  l[i]=count
for i in range(q):
  print(l[lr[i][1]-1]-l[lr[i][0]-1])

Measured memory_bytes: 30680