akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#include <set>
#include <iterator>
using namespace std;
using namespace __gnu_pbds;


#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define INF INT_MAX
#define matrix vector<vector<ll> >

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )
#define maxbits 9
#define maxmask (1ll<<maxbits)
typedef tree<pll, null_type, less<pll>, rb_tree_tag,
             tree_order_statistics_node_update>
    new_data_set;
const int  N=200000 +10, M=(ll)1e9+1 ;
const int mod =998244353 ,sz=5 ;

ll dig(ll x){
    return float(log10(x))+1;
}
void work(){
    string s;
    cin >> s;

    ll pos1;
    ll cnt=0;
    vl ans(s.length(),0);
    ll l,r;
    l=r=0;
    for(ll i=0;i<s.length();++i){
        if(s[i]=='R' && s[i+1]=='L')
            pos1=i;
        cnt++;
        if(s[i]=='L')
            l++;
        else
            r++;
        if(i==s.length()-1 || (s[i]=='L' && s[i+1]=='R')){
            ll rem=cnt-2*min(r,l);
//            cout << l << " " << r << " " << rem << " " << cnt << "\n";
            if(l>=r){
                    if(min(l,r)&1){
                        ans[pos1]=min(l,r)+rem-(rem/2);
                        ans[pos1+1]=min(l,r)+rem/2;
                    }
                    else{
                        ans[pos1]=min(l,r)+rem/2;
                        ans[pos1+1]=min(l,r)+rem-(rem/2);
                    }
            }
            else{
                if(min(l,r)&1){
                    ans[pos1]=min(l,r)+rem/2;
                    ans[pos1+1]=min(l,r)+rem-rem/2;
                }
                else{
                ans[pos1]=min(l,r)+rem-(rem/2);
                ans[pos1+1]=min(l,r)+rem/2;
                }
            }
            cnt=0;
            l=r=0;
        }
    }
    for(ll i=0;i<ans.size();i++)
        cout << ans[i] << " ";
    return;
}

int main(){
 ios_base::sync_with_stdio(0);
 cin.tie(0);
    ll t;
//    cin >> t;
    t=1;
    while(t--){
            work();
    }
   return 0;

}


Measured memory_bytes: 1488
MOD = 10**9 + 7

def egcd(a, b):
    if a == 0:
        return (b, 0, 1)
    else:
        g, y, x = egcd(b % a, a)
        return (g, x - (b // a) * y, y)

def modinv(a, m):
    g, x, y = egcd(a, m)
    if g != 1:
        raise Exception('modular inverse does not exist')
    else:
        return x % m


n = int(input())
L = n+1
inv = [None]*(n+2)

for i,a in enumerate(map(int,input().split())):
  if inv[a-1] is None:
    inv[a-1] = i
  else:
    m = n - i + inv[a-1]
    break


b = 1
for i in range(2,m+1):
  b *= i
  b %= MOD

a = b
for i in range(m+1, L+1):
  a *= i
  a %= MOD

ik = modinv(a,MOD)

for i in reversed(range(L+1)):
  inv[i] = ik
  ik *= i
  ik %= MOD

r1 = [(a*inv[k]*inv[L-k])%MOD for k in range(L//2+1)]
r2 = [(b*inv[k]*inv[m-k])%MOD for k in range(m//2+1)]



# C(n+1,k) - C(m,k-1)
# C(n,k) = n!/(k!(n-k)!)

for k in range(1, m+2):
  print((r1[min(k,L-k)]-r2[min(k-1,m-k+1)])%MOD)

for k in range(m+2,n+2):
  print(r1[min(k,L-k)]%MOD)

Measured memory_bytes: 13812
n, k = gets.split.map(&:to_i)
h    = gets.split.map(&:to_i)

dp = [10**12] * (10**5+10)
dp[0] = 0

(n-1).times do |i|
  k = n-i-1 if k > n-i-1
  k.times do |j|
    dp[i+j+1] = dp[i] + (h[i+j+1] - h[i]).abs  if dp[i+j+1] > dp[i] + (h[i+j+1] - h[i]).abs 
  end
end
 
 
p dp[n-1]

Measured memory_bytes: 10764
#include<stdio.h>

int main(void){

  int n,i,j,k,b,c,a[1001];
  
  while(1){

    scanf("%d",&n);
    if(n==0){
      break;
    }
    for(i=0;i<n;i++){
      scanf("%d",&a[i]);
    }

    b=a[0]-a[1];
    if(b<0){
      b=-b;
    }
    
    for(j=0;j<n;j++){
      for(k=j+1;k<n;k++){
	c=a[j]-a[k];
	if(c<0){
	  c=-c;
	}

	if(b>c){
	  b=c;
	}
      }
    }
    printf("%d\n",b);
  }
  

  return 0;
}

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

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

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long 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 unsigned long long ULL;
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;
int main() {
    std::cin >> N;
    std::vector<ULL> L(N+1);
    L[0] = 2;
    L[1] = 1;
    FOR(i, 2, N+1) {
        L[i] = L[i-1] + L[i-2];
    }
    std::cout << L[N] << std::endl;
}

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


int main() {
    long long int W, H, x, y;
    std::cin >> W >> H >> x >> y;

    std::cout << double(W * H) / 2.0;

    if (x * 2 == W && y * 2 == H) {
        std::cout << " 1" << std::endl;
    } else {
        std::cout << " 0" << std::endl;
    }
}


Measured memory_bytes: 3768
#include <iostream>

using namespace std;

int main() {
    int n,  q, ans = 0;
    cin >> n;
    int s[n];
    for (int i = 0; i < n; ++i) {
        cin >> s[i];
    }
    cin >> q;
    int t[q];
    for (int j = 0; j < q; ++j) {
        cin >> t[j];
    }
    for(int i = 0; i < q; i++){
        for(int j = 0; j < n; j++){
            if(t[i] == s[j]){
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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




int main(){
    int r;cin >> r;
    cout<<3*r*r<<endl;
}



Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
#include <queue>
using namespace std;

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

int MOD = 1000000007;
const int MAX = 2000000;

typedef long long ll;

ll fact[MAX], fact_inv[MAX];

// 繰り返し二乗法
ll power(ll a, ll b) {
	ll res = 1;
	while (b > 0) {
		if (b & 1) res = res * a%MOD;
		a = a * a%MOD;
		b >>= 1;
	}
	return res;
}

ll comb(ll n, ll r) {
	return (fact[n] * fact_inv[r]) % MOD*fact_inv[n - r] % MOD;
}

int a, b;
int h, w;

int64_t pattern(int w, int h) {
	return comb(w + h, h);
}

int main(){

	int n = 1000000;
	// cin>>n;
	fact[0] = 1;
	// 階乗の計算
	REP(i, n) fact[i + 1] = fact[i] * (i + 1) % MOD;
	fact_inv[n] = power(fact[n], MOD - 2);
	// 逆元の計算
	FORR(i, 0, n) fact_inv[i] = fact_inv[i + 1] * (i + 1) % MOD;

	int dis = 0;

	cin >> h >> w >> a >> b;
	int y = h - 1 - a;
	int x = b;
	int64_t sum = 0;
	while (y >= 0 && x < w) {
		int64_t temp1 = pattern(x, y);
		temp1 %= MOD;
		int64_t temp2 = pattern(w-x-1, h-y-1);
		temp2 %= MOD;
		sum += (temp1*temp2) % MOD;
		sum %= MOD;
		y--; x++;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 18688
# 貪欲法 + 山登り法 + スワップ操作
import time
s__ = time.time()
limit = 1.9
#limit = 10

from numba import njit
import numpy as np

d = int(input())
cs = list(map(int, input().split()))
cs = np.array(cs, dtype=np.int64)
sm = [list(map(int, input().split())) for _ in range(d)]
sm = np.array(sm, dtype=np.int64)

@njit('i8(i8[:], i8)', cache=True)
def total_satisfaction(ts, d):
    ls = np.zeros(26, dtype=np.int64)
    s = 0
    for i in range(d):
        t = ts[i]
        t -= 1
        s += sm[i][t]
        ls[t] = i + 1

        dv = cs * ((i+1) - ls)
        s -= dv.sum()
    return s

@njit('i8[:]()', cache=True)
def greedy():
    ts = np.array([0] * d, dtype=np.int64)
    for i in range(d):
        mx = -1e10
        mxt = None
        for t in range(1, 26+1):
            ts[i] = t
            s = total_satisfaction(ts, i + 1)
            if s > mx:
                mx = s
                mxt = t
        ts[i] = mxt
    return ts

@njit('i8(i8, i8[:])', cache=True)
def loop(mxsc, ts):
    it = 50
    rds = np.random.randint(0, 4, (it,))
    rdd = np.random.randint(1, d, (it,))
    rdq = np.random.randint(1, 26, (it,))
    rdx = np.random.randint(1, 12, (it,))
    for i in range(it):
        bk1 = 0
        bk2 = 0
        if rds[0] == 0:
            # trailing
            di = rdd[i]
            qi = rdq[i]

            bk1 = ts[di]
            ts[di] = qi
        else:
            # swap
            di = rdd[i]
            xi = rdx[i]
            if di + xi >= d:
                xi = di - xi
            else:
                xi = di + xi
            
            bk1 = ts[di]
            bk2 = ts[xi]
            ts[di] = bk2
            ts[xi] = bk1

        sc = total_satisfaction(ts, d)

        if sc > mxsc:
            #print(mxsc, '->', sc)
            mxsc = sc
        else:
            # 最大値を更新しなかったら戻す
            if rds[0] == 0:
                ts[di] = bk1
            else:
                ts[di] = bk1
                ts[xi] = bk2

    return mxsc

ts = greedy()
mxsc = total_satisfaction(ts, d)
mxbk = mxsc

s_ = time.time()
mxsc = loop(mxsc, ts)
e_ = time.time()

consume = s_ - s__
elapsed = e_ - s_
#print('consume:', consume)
#print('elapsed:', elapsed)

if consume < limit:
    lp = int((limit - consume)/ elapsed)
    #print('loop', lp)
    for _ in range(lp):
        mxsc = loop(mxsc, ts)

for t in ts:    print(t)
#print(mxbk, mxsc)
#print(time.time() - s__)


Measured memory_bytes: 122792
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
 
using namespace std;
 
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) begin(a),end(a)
 
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
 
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
 
ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
 
int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


vector<vector<int>> G;

void dfs(int v,vector<bool> &visited,int &res ){
  bool end = true;
  rep(i,visited.size()) if(!visited[i] && i != v) end = false;
  if(end){
    res++;
    return;
  }

  visited[v] = true;
  for(auto nv : G[v]){
    if(visited[nv]) continue;
    dfs(nv,visited,res);
  }
  visited[v] = false;
  
}

int main(){
  string s;
  cin >> s;
  int N = s.size();
  int z=0,o=0;
  rep(i,N){
    if(s[i] == '0') z++;
  }
  o = N - z;
  cout << min(o,z) * 2 << endl;
}

  
                           

                                                          






Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

int N, K;
vector<int> adj[2048];

int ans[2048][2048];

void upd(int u) {
  for (int i = 1; i <= K; ++i) {
    chmax(ans[u][i], ans[u][i - 1]);
  }
}

void solve(int u, int p = -1) {
  vector<int> sum(K + 1, 0);
  for (const int v : adj[u]) {
    if (v != p) {
      solve(v, u);
      for (int k = 0; k <= K; ++k) {
        sum[k] += ans[v][k];
      }
    }
  }
  ans[u][0] = 1;
  upd(u);

  for (const int v : adj[u]) {
    if (v != p) {
      for (int k = 0; k <= K - 2; ++k) {
        chmax(ans[u][k + 1], 1 + ans[v][k] + sum[min(k, K - k - 2)] - ans[v][min(k, K - k - 2)]);
      }
      chmax(ans[u][K], 1 + ans[v][K - 1]);
    }
  }
  upd(u);
}

int main() {
  N = in();
  K = in();
  for (int i = 0; i < N - 1; ++i) {
    int a = in() - 1;
    int b = in() - 1;
    adj[a].push_back(b);
    adj[b].push_back(a);
  }

  for (int i = 0; i < N; ++i) {
    fill(ans[i], ans[i] + 2048, 0);
  }

  solve(0);

  int res = N;
  for (int i = 0; i < N; ++i) {
    chmin(res, N - ans[i][K]);
  }

  printf("%d\n", res);

  return 0;
}


Measured memory_bytes: 28816
from collections import deque
N,M=map(int,input().split())
G=[[] for i in range(N)]
for i in range(M):
    a,b=map(int,input().split())
    G[a-1].append(b-1)
K=[0 for i in range(N)]
for i in range(N):
    for p in G[i]:
        K[p]+=1
q=deque(i for i in range(N) if K[i]==0)
res=[]
while q:
    v1=q.popleft()
    res.append(v1)
    for v2 in G[v1]:
        K[v2]-=1
        if K[v2]==0:
            q.append(v2)
if len(res)==N:
    print(-1)
    exit()
X={i for i in range(N)}
for st in range(N):
    before=[-1 for i in range(N)]
    q=deque([st])
    flag=0
    while(q):
        r=q.popleft()
        for p in G[r]:
            if before[p]==-1:
                before[p]=r
                q.append(p)
            if before[st]!=-1:
                Y={st}
                tmp=before[st]
                while(tmp!=st):
                    Y.add(tmp)
                    tmp=before[tmp]
                if len(Y)<len(X):
                    X={i for i in Y}
                flag=1
                break
        if flag:
            break
print(len(X))
for i in X:
    print(i+1)

Measured memory_bytes: 49240
module Main where

import Control.Applicative
import Control.Monad
import Data.List

count :: String -> String -> Int
count xs ys = length $ filter (`elem` ys) (nub xs)

solve :: String -> Int
solve xs = maximum $ zipWith count (inits xs) (tails xs)

main :: IO ()
main = do
    getLine
    ss <- getLine
    print $ solve ss

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

void
solver(char *s)
{
    int b=5*100000+2;
    int i;
    int p=0, mp=0;
    long long sum=0;

    s[strlen(s)+1] = '\0';
    s[strlen(s)] = ' ';

    p=0;
    for (i=0; i<strlen(s)-1; i++) {
        if (s[i]==s[i+1]) {
            p++;
            sum += p;
        }
        else {
            p++;
            if (s[i]=='>') {
                sum += mp>p?mp:p;
            }
            else if(s[i]=='<' && s[i+1]==' ')
                sum += p;
            mp=p;
            p=0;            
        }
    }

    printf("%lld\n", sum);
}

int
main(int argc, char *argv[])
{
    char s[5*100000+2];

    bzero(s, sizeof(s));
    scanf("%s", s);
    solver(s);
    return 0;
}

Measured memory_bytes: 640
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Scanner;

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

		int n = sc.nextInt();
		int[] a = new int[n];
		HashMap<Integer, Integer> hm = new HashMap<>();

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			hm.put(a[i], hm.getOrDefault(a[i], 0) + 1);
		}

		long ans = 0l;

		for (Iterator<Map.Entry<Integer, Integer>> it = hm.entrySet().iterator(); it.hasNext();) {
			Map.Entry<Integer, Integer> entry = it.next();
			int key = entry.getKey();
			int val = entry.getValue();
			if (key > val) {
				ans += (long) val;
			} else if (key < val) {
				ans += (long) val - key;
			}
		}
		System.out.println(ans);

		sc.close();
	}
}

Measured memory_bytes: 63172
n = int(input())
NIL = -1
class Node():
    def __init__(self):
        self.D = [0] * 10000
        self.H = [0] * 10000
        self.parent = [0] * 10000
        self.left = [0] * 10000
        self.right = [0] * 10000
        
    def setdepth(self, u, d):
        if u == NIL:
            return
        self.D[u] = d
        self.setdepth(self.left[u], d + 1)
        self.setdepth(self.right[u], d + 1)
    
    def setheight(self, u):
        h1 = 0
        h2 = 0
        if T.left[u] != NIL:
            h1 = self.setheight(T.left[u]) + 1
        if T.right[u] != NIL:
            h2 = self.setheight(T.right[u]) + 1
        self.H[u] = max(h1, h2)
        return self.H[u]
    
    def getsibling(self, u):
        if self.parent[u] == NIL:
            return NIL
        if self.left[self.parent[u]] != u and self.left[self.parent[u]] != NIL:
            return self.left[self.parent[u]]
        if self.right[self.parent[u]] != u and self.right[self.parent[u]] != NIL:
            return self.right[self.parent[u]]
        return NIL
    
    def printf(self, u):
        if self.parent[u] == NIL:
            s = 'root'
        elif self.left[u] == NIL and self.right[u] == NIL:
            s = 'leaf'
        else:
            s = 'internal node'
        
        deg = 0
        if self.left[u] != NIL:
            deg += 1
        if self.right[u] != NIL:
            deg += 1
        
        print('node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}'\
              .format(u, self.parent[u], self.getsibling(u), deg, self.D[u], self.H[u], s))
        
        
T = Node()
for i in range(n):
    T.parent[i] = NIL

for i in range(n):
    v, l, r = (int(x) for x in input().split())
    T.left[v] = l
    T.right[v] = r
    if l != NIL:
        T.parent[l] = v
    if r != NIL:
        T.parent[r] = v

for i in range(n):
    if (T.parent[i] == NIL):
        root = i

T.setdepth(root, 0)
T.setheight(root)

for i in range(n):
    T.printf(i)


Measured memory_bytes: 5792
a, b, c, k = map(int, input().split())
ans = 0
 
if k - a >= 0:
  k -= a
  if k - b >= 0:
    k -= b
    if k - c >= 0:
      ans = a - c
    else:
      ans = a - k
  else:
    ans = a
else:
  ans = k
  
print(ans)

Measured memory_bytes: 9176
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define fi first
#define se second
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template <class T> inline void dump(T &v){irep(i, v){cout<<(*i)<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-11;



int main() {
    
    int h, w, K;
    cin >> h >> w >> K;
    vvll v(h + 1, vll(w + 1));
    vector<vvll> dp(h + 1, vvll(w + 1, vll(4, 0)));
    rep(i, K) {
        int r, c, V;
        cin >> r >> c >> V;
        v[r][c] += V;
    }
    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            rep(k, 4) { chmax(dp[i][j][0], dp[i - 1][j][k]); }
            rep(k, 4) {
                if (!v[i][j] || k == 3) {
                    chmax(dp[i][j][k], dp[i][j - 1][k]);
                } else {
                    chmax(dp[i][j][1], dp[i][j][0] + v[i][j]);
                    chmax(dp[i][j][k + 1], dp[i][j - 1][k] + v[i][j]);
                    chmax(dp[i][j][k], dp[i][j - 1][k]);
                }
            }
        }
    }
    fin(max({dp[h][w][0], dp[h][w][1], dp[h][w][2], dp[h][w][3]}));
    
}


Measured memory_bytes: 707172
#include <iostream>

using namespace std;


int main(){
    int K, T;
    long long maxN = -1;
    long long sum, tmp;

    sum = tmp = 0;

    cin >> K >> T;

    for (int i = 0; i < T; i++){
        cin >> tmp;
        if (tmp > maxN){
            maxN = tmp;
        }

        sum += tmp;

    }

    long long res = 2 * maxN - sum - 1;

    if (res <= 0){
        cout << "0" << endl;
    }
    else{
        cout << res << endl;
    }

    return 0;
}


Measured memory_bytes: 888
from typing import List


class UnionFind:
    """Union Find (Disjoint Set): O(α(N))
    References:
        https://github.com/atcoder/ac-library/blob/master/atcoder/dsu.hpp
        https://tumoiyorozu.github.io/single-file-ac-library/document_en/dsu.html
    """

    __slots__ = ["_data_size", "_roots"]

    def __init__(self, data_size: int) -> None:
        self._data_size = data_size
        self._roots = [-1] * data_size

    def __getitem__(self, x: int) -> int:
        """Find the group (root) of vertex x in O(α(n)) amortized."""
        while self._roots[x] >= 0:
            x = self._roots[x]
        return x

    def is_connected(self, x: int, y: int) -> bool:
        """Return whether two vertices x and y are connected in O(α(n)) amortized."""
        return self[x] == self[y]

    def unite(self, x: int, y: int) -> None:
        """Unite two groups of vertices x and y in O(α(n)) amortized."""
        x, y = self[x], self[y]
        if x == y:
            return
        if self._roots[x] > self._roots[y]:
            x, y = y, x
        self._roots[x] += self._roots[y]
        self._roots[y] = x


def unionfind():
    # https://judge.yosupo.jp/problem/unionfind
    # https://atcoder.jp/contests/practice2/tasks/practice2_a
    N, Q, *TUV = map(int, open(0).read().split())
    tree = UnionFind(N)
    res = []
    for t, u, v in zip(*[iter(TUV)] * 3):
        if t:
            res.append(int(tree.is_connected(u, v)))
        else:
            tree.unite(u, v)
    print("\n".join(map(str, res)))


if __name__ == "__main__":
    unionfind()


Measured memory_bytes: 146700
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
bool prime[MAX];
int prime_numbers[9999999],pos;
void sieve()
{
    prime[0]=1;
    prime[1]=1;
    for(int i=4; i<=MAX; i+=2)
        prime[i]=1;
    int root = sqrt(MAX);
    for(int i=3; i<=root; i+=2)
    {
        if(prime[i]==0)
        {
            for(int j=i*i; j<=MAX; j+=i)
            {
                prime[j]=1;
            }
        }
    }
    prime_numbers[pos++]=2;
    for(int i=3; i<MAX; i+=2)
        if(prime[i]==0)
            prime_numbers[pos++]=i;
}
ll sum(ll n)
{
    return (n*(n-1))/2;
}
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    sieve();
    ll n;
    cin>>n;
    map<int,int>mp;
    vector<ll>v;
    for(int i=0; i<pos; i++)
    {
        int cnt=0;
        int temp=prime_numbers[i];
        if(temp>n)
            break;
        while(temp<=n)
        {
            int cur=n/temp;
            cnt+=cur;
            temp*=prime_numbers[i];
        }
        if(cnt>1)
        {
            v.push_back(cnt+1);
        }
    }
    ll ans=0;
    sort(all(v));
    int sz=v.size();
    for(int i=0; i<sz; i++)
    {
        ll cnt=0;
        if(v[i]>=3)
            for(int j=0; j<sz; j++)
            {
                if(v[j]>=5 && j!=i)
                    cnt++;
            }
        ans+=sum(cnt);
    }
    for(int i=0; i<sz; i++)
    {
        ll cnt=0;
        if(v[i]>=5)
            for(int j=0; j<sz; j++)
            {
                if(v[j]>=15 && j!=i)
                    cnt++;
            }
        ans+=cnt;
    }
    for(int i=0; i<sz; i++)
    {
        int cnt=0;
        if(v[i]>=3)
            for(int j=0; j<sz; j++)
            {
                if(v[j]>=25 && j!=i)
                    cnt++;
            }
        ans+=cnt;
    }
    for(int i=0; i<sz; i++)
    {
        int cnt=0;
        if(v[i]>=75)
            ans++;
    }
    cout<<ans<<endl;




    return 0;
}


Measured memory_bytes: 4928
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<ll> p(n+1);
    FOR(i,1,n+1) cin>>p[i];
    FOR(i,1,n+1) cout<<(ll)3e4*i<<' ';
    cout<<endl;
    vector<ll> x(n+1);
    FOR(i,1,n+1) x[p[i]]=i;
    FOR(i,1,n+1) cout<<(ll)3e4*(n-i)+x[i]<<' ';
    cout<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int n;
ll a[200001];
int main(){
	ios::sync_with_stdio(0);
	cin>>n;
	rep(i,n)
	cin>>a[i];
	sort(a,a+n);
	reverse(a,a+n);
	ll ans=a[0];
	int nn=n-2;
	forn(i,1,n){
		if(nn==0)
		break;
		if(nn==1){
			ans+=a[i];
			break;
		}
		nn-=2;
		ans+=a[i]*2;
	}
	cout<<ans;
	re 0;
}

Measured memory_bytes: 5216
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007;

signed main() {
string s;
cin>>s;
int n=s.length()+1;
int a[n]={},b[n]={};
for(int i=1;i<n;i++){
  if(s[i-1]=='<'){
    a[i]=a[i-1]+1;
  }
}
for(int i=n-1;i>=0;i--){
  if(s[i]=='>'){
    b[i]=b[i+1]+1;
  }
}
int ans=0;
for(int i=0;i<n;i++)ans+=max(a[i],b[i]);
cout<<ans;


return 0;
}


Measured memory_bytes: 8708
// 2020-07-15 21:03:38
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  int m, k;
  cin >> m >> k;
  if(m == 0) {
    if(k == 0) {
      cout << "0 0" << '\n';
    } else {
      cout << -1 << '\n';
    }
    return;
  }
  if(m == 1) {
    if(k == 0) {
      cout << "0 0 1 1" << '\n';
    } else {
      cout << -1 << '\n';
    }
    return;
  }
  int lim = 1<<m;
  if(lim <= k) {
    cout << -1 << '\n';
    return;
  }
  vector<int> ans;
  rep(i, lim) if(i != k) ans.emplace_back(i);
  ans.emplace_back(k);
  REPCM(i, lim-1, 0) if(i != k) ans.emplace_back(i);
  ans.emplace_back(k);
  bool first = true;
  for(const int a : ans) {
    if(first) first = false; else cout << ' ';
    cout << a;
  }
  cout << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 4212
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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() {
  int n, m;
  cin >> n >> m;
  map<int, int> mp;
  rep (i, n) {
    mp[i] = 0;
  }

  rep (i, m) {
    int a, b;
    cin >> a >> b;
    mp[a - 1]++;
    mp[b - 1]++;
  }
  rep (i, n) {
    P(mp[i]);
  }

  return 0;
}

Measured memory_bytes: 256
N = int(input())
A_lst = [int(x) for x in input().split()]
B_lst = [0]
for i in range(1, N + 1):
    B_lst.append(A_lst[i - 1] + B_lst[i - 1])
B_lst.sort()
dic = {}
for i in B_lst:
    if not i in dic.keys():
        dic[i] = 1
    else:
        dic[i] += 1
ans = 0
for n in dic.values():
    ans += n * (n - 1) // 2
print(ans)


Measured memory_bytes: 41068
#include <bits/stdc++.h>
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using ll = long long;
const int INF = 0x3f3f3f3f;
using namespace std;

int n, arr[100001][3];
ll dp[100001][3];
int main()
{
    IOS
    //bfreopen("balalance.in", "r", stdin);
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> arr[i][0] >> arr[i][1] >> arr[i][2];
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j != k) {
                    dp[i][k] = max(dp[i][k], arr[i][k] + dp[i-1][j]);
                }
            }
        }
    }
    cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << endl;


    return 0;
}


Measured memory_bytes: 3840
a, b, c, d = [int(x) for x in input().split(' ')]

max_mul = -1 * 10**18

max_mul = max(max_mul, a * c)
max_mul = max(max_mul, a * d)
max_mul = max(max_mul, b * c)
max_mul = max(max_mul, b * d)

print(max_mul)

Measured memory_bytes: 9172
//#include "stdafx.h"
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define e "\n"
#define MaRiaMa { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); }
#define fix(n) cout << fixed << setprecision(n)
using namespace std;
int main()
{
	MaRiaMa;
	int k = 1;
	string s;
	cin >> s;
	for (int i = 0; i < 4; i++)
	{

		if (s[i] == s[i + 1])
		{
			k++;
			if (k >= 3)
			{
				cout << "Yes";
				return 0;
			}
		}
		else
			k = 1;
	}
	cout << "No";
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,k,n)       for(i=k;k<=n?i<=n:i>=n;k<=n?i++:i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
const int inf =         1e18;
const int mod =         1e9+7;
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
void _p() {cout << "]\n";}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p,int m = inf) {int ans=1;x%=m;while(p>0){if(p&1)ans=(ans*x)%m;p=p>>1;x=(x*x)%m;}return ans;}
int inv(int x,int m=mod){return po(x,m-2,m)%m;}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
#else 
#define dbg(x...)
#endif
//=================================================================================




const int N=1e6+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r,f;








void sol()
{   
    cin>>n>>m>>k;
    in(a,n);in(b,m);
    i=j=c=x=0;
    while(i<n && x+a[i]<=k)x+=a[i++];
    c=i;

    while(j<m && i>=0)
    {
        x+=b[j++];
        while(x>k && i>0)x-=a[--i];
        if(x<=k)c=max(c,i+j);
    }
    
    
    cout<< c <<endl;
}





int32_t main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //sp(10);
    // w(t)
    sol();
    return 0;
}

Measured memory_bytes: 6304
// Beginner162.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <bits/stdc++.h>
using namespace std;

bool has7(int n)
{
	while (n > 0)
	{
		int c = n % 10;
		if (c == 7) return true;
		n /= 10;
	}
	return false;
}

int main()
{
	//A
	int n;
	cin >> n;
	bool has = has7(n);
	cout << (has ? "Yes" : "No");

	//B

	//C

	//D

	//E

	//F
}



Measured memory_bytes: 3632
import java.util.Scanner;
import java.util.Set;
import java.util.HashSet;
import java.util.Map;
import java.util.HashMap;
import java.util.Queue;
import java.util.ArrayDeque;
import java.util.Arrays;

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

    int n = sc.nextInt();
    int m = sc.nextInt();

    Map<Integer, Set<Integer>> graph = new HashMap<Integer, Set<Integer>>();
    for (int i = 0; i < n; i++) {
      graph.put(i, new HashSet<Integer>());
    }

    //辺の情報を格納する
    for (int i = 0; i < m; i++) {
      int a = sc.nextInt();
      int b = sc.nextInt();
      graph.get(a - 1).add(b - 1);
      graph.get(b - 1).add(a - 1);
    }

    Queue<Integer> q = new ArrayDeque<Integer>();
    int[] arr = new int[n];
    Arrays.fill(arr, -1);
    arr[0] = 0;
    q.add(0);
    while (!q.isEmpty()) {
      int pos = q.remove();
      for (int tmp : graph.get(pos)) {
        if (arr[tmp] != -1) {
          continue;
        }
        q.add(tmp);
        arr[tmp] = pos;
      }
    }

    for (int i = 0; i < n; i++) {
      if (arr[i] == -1) {
        System.out.println("No");
        return;
      }
    }

    System.out.println("Yes");
    for (int i = 1; i < n; i++) {
      System.out.println(arr[i] + 1);
    }
  }
}


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

const long long INF = 1000000001;

const long long MOD = 1000000009;

typedef long long ll;

const int max = 1000000; //配列の最大長

int main(void){
  int n,w;
  std::cin >> n >> w;

  int weight[n],value[n];
  for(int i=0; i<n; i++) std::cin >> value[i] >> weight[i];

  ll dp[n+1][w+1] = {};
  for(int i=0; i<n; i++){
    for(int j=0; j<=w; j++){
      if(j - weight[i] >= 0) dp[i+1][j] = dp[i+1][j - weight[i]] + value[i];
      dp[i+1][j] = std::max(dp[i+1][j],dp[i][j]);
    }
  }

  std::cout << dp[n][w] << std::endl;
  return 0;
}



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

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  int total = 0;
  for (int i = 0; i < n; i++) {
    int l, r;
    scanf("%d %d", &l, &r);
    total += r - l + 1;
  }
  printf("%d\n", total);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
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(){
	int n = 0;
	int point[2] = {0};
	int j = 0;
	string card[2][1000] = {""};
	cin >> n;
	for (int i = 0; i < n; ++i)
	{
		cin >> card[0][i] >> card[1][i];
		if(card[0][i] == card[1][i]){
			point[0] += 1;
			point[1] += 1;
		}else{
			for (int j = 0; j <= card[0][i].size(); ++j)
			{
				if(card[0][i][j] > card[1][i][j]){
					point[0] += 3;
					break;
				}else if(card[0][i][j] < card[1][i][j]){
					point[1] += 3;
					break;
				}
			}
		}
	}
	cout << point[0] << " " << point[1] << endl;
}

Measured memory_bytes: 1328
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

using namespace std;

int main ()
{
    long n, k, c;
    string s;
    cin >> n >> k >> c >> s;
    vector<int> left, right;
    for (int i = 0; i < n && left.size () < k;) {
        if (s[i] != 'x') {
            left.push_back (i);
            i += c + 1;
        } else {
            i++;
        }
    }
    reverse (s.begin (), s.end ());
    for (int i = 0; i < n && right.size () < k;) {
        if (s[i] != 'x') {
            right.push_back (n - i - 1);
            i += c + 1;
        } else {
            i++;
        }
    }
    reverse (right.begin (), right.end ());
    for (int i = 0; i < k; i++) {
        if (left[i] == right[i])
            cout << left[i] + 1 << "\n";
    }
}


Measured memory_bytes: 3448
// package abc174;
import java.util.*;
import java.io.*;
public class Main {
  public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int n = sc.nextInt();
   int d = sc.nextInt();
   int count = 0;
   for(int i=0;i<n;i++){
    long x = sc.nextLong();
    long y = sc.nextLong();
    if(Math.sqrt(x*x + y*y)<=d){
      count++;
    }
   }
   System.out.println(count);
  }
}


Measured memory_bytes: 59372
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>

using namespace std;

int main(){
	int N,cnt=0;
	cin>>N;
	vector<int> a(N);
	
	for(int i=0;i<N;i++){
		cin>>a[i];
	}
	for(int i=1;i<N;i++){
		if(a[i-1]==a[i]){
			a[i]+=N;
			cnt++;
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;
const int MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

signed main() {
	int N;
	string s, t;
	cin >> N >> s >> t;
	int num = 0;
	for (int i = 1; i <= N; i++) { //i文字ずらす
		bool can = true;
		for (int j = 0; j < i; j++) {
			if (s[s.size() - i + j] == t[j])continue;
			else can = false;
		}
		if (can)num = max(num, i);
	}
	int ans = 2 * N - num;
	cout << ans;
}

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

using namespace std;
using ll = long long;

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

  int n, k;
  cin >> n >> k;
  vector<int> h(n + 1);
  for (int i = 0; i < n; i++)
    cin >> h[i + 1];
  h[0] = h[1];

  vector<int> dp(n + 1, 1e9);
  dp[0] = 0;

  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= k; j++) {
      if (i + j > n)
        break;
      dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
    }
  }

  cout << dp[n] << endl;

  return 0;
}


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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greater<int>()

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;

const int INF = 1001001001;
const int MOD = 1000000007;
const long long INFL = (1LL << 60);
const double EPS = 1e-9;

int main() {
  int N, M;
  map<string, int> m;
  cin >> N;
  rep(i, N) {
    string s;
    cin >> s;
    m[s]++;
  }
  cin >> M;
  rep(i, M) {
    string t;
    cin >> t;
    m[t]--;
  }

  int res = 0;
  for (auto p : m) res = max(res, p.second);

  cout << res << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a,b,c,x,y,z;
    scanf("%d%d%d",&a,&b,&c);
    if(a > b){
        x=a;
        a=b;
        b=x;
            }
    if(b > c){
        y=b;
        b=c;
        c=y;
    }
    if(a > b){
        z=a;
        a=b;
        b=z;
    }
    printf("%d %d %d\n",a,b,c);
    return(0);
    
}

Measured memory_bytes: 596
#include <iostream>
#include <string>
#include <array>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <cctype>
#include <map>
#include <stdio.h>
#include <string.h>


#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

using namespace std;

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

    int n, m;
    int l[100001], r[100001];
    int mem[100001];
    int ans = 0;
    int count = 0;

    memset(mem,0,sizeof(mem));

    cin >> n >> m;
    for(int i = 0; i < m; i ++){
        cin >> l[i] >> r[i];
    }

    for(int i = 0; i < m; i ++){
        count ++;
        for(int j = l[i]; j <= r[i]; j ++){
            mem[j]  ++;
        }
    }

    for(int i = 1; i <= n; i ++){
        if(mem[i] == m) ans ++;
    }
    cout << ans;

    return 0;
}









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

int main() {
	int a[5],b[]={1,2,3},aa=0,bb=0,cc=0;
	while(1){
		cin>>a[0];
		if(a[0]==0){
			break;
		}
		for(int i=1;i<5;i++){
			cin>>a[i];
		}
		
		for(int j=0;j<5;j++){
			if(b[0]==a[j]){
				aa++;
			}
			else if(b[1]==a[j]){
				bb++;
			}
			else if(b[2]==a[j]){
				cc++;
			}
		}
		
		if(aa>0 && bb>0 && cc==0){
			for(int i=0;i<5;i++){
				if(a[i]==1){
					cout<<1<<endl;
				}
				else{cout<<2<<endl;}
			}
		}
		else if(cc>0 && bb>0 && aa==0){
			for(int i=0;i<5;i++){
				if(a[i]==2){
					cout<<1<<endl;
				}
				else{cout<<2<<endl;}
			}
		}
		else if(cc>0 && aa>0 && bb==0){
			for(int i=0;i<5;i++){
				if(a[i]==3){
					cout<<1<<endl;
				}
				else{cout<<2<<endl;}
			}
		}
		else {
			for(int i=0;i<5;i++){
				cout<<3<<endl;
			}
		}
		aa=0;
		bb=0;
		cc=0;
		
		
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3028
import sys
input=sys.stdin.readline
h,w=map(int,input().split())
s=[list(input()) for i in range(h)]
u=[[0]*w for i in range(h)]
d=[[0]*w for i in range(h)]
l=[[0]*w for i in range(h)]
r=[[0]*w for i in range(h)]
for i in range(h):
  for j in range(w):
    if s[i][j]=='#':
      d[i][j]=0
      l[i][j]=0
    else:
      if i!=0:
        d[i][j]+=d[i-1][j]+1
      else:
        d[i][j]=1
      if j!=0:
        l[i][j]+=l[i][j-1]+1
      else:
        l[i][j]=1
for i in range(h)[::-1]:
  for j in range(w)[::-1]:
    if s[i][j]=='#':
      r[i][j]=0
      u[i][j]=0
    else:
      if i!=h-1:
        u[i][j]+=u[i+1][j]+1
      else:
        u[i][j]=1
      if j!=w-1:
        r[i][j]+=r[i][j+1]+1
      else:
        r[i][j]=1
ans=0
for i in range(h):
  for j in range(w):
    if s[i][j]=='.':
      ans=max(ans,u[i][j]+d[i][j]+l[i][j]+r[i][j]-3)
print(ans)

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

#define ll long long
#define mod 1000000007
#define pb push_back
#define pi pair<ll,ll>
#define vi vector<ll>
#define vpi vector< pi >
const int N=100010;

int main()
{
	int n,k;
	cin>>n>>k;
	if(n>=2*k-1) cout<<"YES";
	else cout<<"NO";
	return 0;
}

Measured memory_bytes: 256