akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,a,b) for (int i=(a); i<=int(b); i++)
#define lc (o << 1)
#define rc (o << 1 | 1)
#define mid ((l + r) >> 1)
using namespace std;

const int maxn = 200005;
int p[maxn];
struct SegmentTree {
	int e, mn[maxn<<2];
	void build(int o, int l, int r) {
		if (l == r) { mn[o] = l * 2 - e; return; }
		build(lc, l, mid); build(rc, mid+1, r);
		mn[o] = p[mn[lc]] < p[mn[rc]] ? mn[lc] : mn[rc];
	}
	int query(int o, int l, int r, int x, int y) {
		if (l == x && y == r) return mn[o];
		if (y <= mid) return query(lc, l, mid, x, y);
		if (mid < x) return query(rc, mid+1, r, x, y);
		int L = query(lc, l, mid, x, mid);
		int R = query(rc,  mid+1, r, mid+1, y);
		return p[L] < p[R] ? L : R;
	}
} T[2];
struct node {
	int l, r, p, q, a, b;
	bool operator < (const node &x) const {
		return a > x.a;
	}
} tmp;
priority_queue<node> Q;
int n;

void calc(int l, int r) {
	node res; 
	res.l = l; res.r = r;
	if (l&1) {
		res.p = T[1].query(1, 1, n/2, (l+1)/2, (r+1)/2);
		res.q = T[0].query(1, 1, n/2, (res.p+2)/2, (r+1)/2);
	}
	else {
		res.p = T[0].query(1, 1, n/2, (l+1)/2, r/2);
		//printf("%d\n", res.p);
		res.q = T[1].query(1, 1, n/2, (res.p+2)/2, (r+1)/2);
	}
	res.a = p[res.p]; res.b = p[res.q];
	Q.push(res);
}

int main() {
	scanf("%d", &n);
	T[0].e = 0; T[1].e = 1;
	rep (i, 1, n) scanf("%d", &p[i]);
	T[0].build(1, 1, n/2);
	T[1].build(1, 1, n/2);
	calc(1, n);
	while (!Q.empty()) {
		tmp = Q.top(); Q.pop();
		printf("%d %d ", tmp.a, tmp.b);
		if (tmp.l < tmp.p) calc(tmp.l, tmp.p-1);
		if (tmp.p + 1 < tmp.q) calc(tmp.p+1, tmp.q-1);
		if (tmp.q < tmp.r) calc(tmp.q+1, tmp.r);
	}
	return 0;
}

Measured memory_bytes: 8436
#pragma GCC optimize ("Ofast")
#include "bits/stdc++.h"
	
#define int long long
#define double long double 
#define PI 3.141592653589793
#define FAST ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
// Use for file I/O;
#define FIN string _fname = "paintbarn"; \
			string _is = _fname + ".in", _os = _fname + ".out"; \
			freopen(_is.c_str(), "r", stdin); \
			freopen(_os.c_str(), "w", stdout);

using namespace std;

const int INF = 4e18 + 10;
const int INF2 = 2e18 + 10;
const int INF3 = 2e10;
const int MAXN = 305;
const int LOGN = 19;
const int MOD = 1e9 + 7;
const int EPS = 1e-9;
const int MULT = 2e5;
const int MCNST = MOD * MOD * 8;

int32_t main() {
	FAST;

	int k;
	cin >> k;

	int ans = 1;

	vector<int> p(k + 1, 0);
	for (int i = 0; i < k; i++) {
		p[i + 1] = (p[i] * 10 + 7) % k; 
	}

	for (int i = 1; i <= k; i++) {
		if (!p[i]) {cout << i; return 0;}
	}
	cout << -1;
}

Measured memory_bytes: 11060
import java.util.Scanner;

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


    Scanner sc = new Scanner(System.in);
    // get a integer

    int a = sc.nextInt();
//    System.out.println(" integer is " + N);
    int b = sc.nextInt();
    int digitOfB = (int) (Math.log10(b) +1);
    int concatenationOfAb = (int) (a * Math.pow( 10, digitOfB ) + b);
    int sqrt =(int) Math.sqrt(concatenationOfAb);
    if(sqrt*sqrt == concatenationOfAb ){
      System.out.print("Yes");
    }else {
      System.out.print("No");
    }

  };

}


Measured memory_bytes: 23508
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;
#define MAX 105
vector<int> V[MAX];

int d[MAX], f[MAX];

int t;

void search(int v) {
	if (d[v] != 0)return;
	d[v] = t++;

	for (int i = 0; i < V[v].size(); i++) {
		search(V[v][i]);
	}
	f[v] = t++;
}

int main() {
	t = 1;
	int n;
	cin >> n;
	for (int i = 1; i < n + 1; i++) {
		int u, k;
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			int s;
			cin >> s;
			V[u].push_back(s);
		}
	}
	for (int i = 1; i < n + 1; i++) {
		if (d[i] == 0)search(i);
	}
	for (int i = 1; i < n + 1; i++) {
		cout << i << ' ' << d[i] << ' ' << f[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 3168
#include <iostream>
using namespace std;
using ll=long long;
ll n,m,s[1000000],S[1000001],t[1000000],T[1000001],a,mod=1e9+7,ans=1;
int main(void){
    cin>>n>>m;
    for(int i=0;i<n;i++){cin>>a;s[a-1]++;}
    for(int i=0;i<m;i++){cin>>a;t[a-1]++;}
    for(int i=n*m-1;i>=0;i--)S[i]+=S[i+1]+s[i];
    for(int i=n*m-1;i>=0;i--)T[i]+=T[i+1]+t[i];
    for(int i=n*m;i>=1;i--){
        //cout<<s[i]<<" "<<t[i]<<" "<<ans<<endl;
        if(s[i-1]==1&&t[i-1]==1)ans*=1;
        else if(s[i-1]==1){ans*=T[i];ans%=mod;}
        else if(t[i-1]==1){ans*=S[i];ans%=mod;}
        else if(s[i-1]>1||t[i-1]>1){cout<<0<<endl;return 0;}
        else {ans*=max(0LL,S[i]*T[i]-(n*m-i));ans%=mod;}
        //cout<<ans<<endl;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 20736
local mfl, mce, mmi = math.floor, math.ceil, math.min
local SegTree = {}
SegTree.updateAll = function(self)
  for i = self.stagenum - 1, 1, -1 do
    for j = 1, self.cnt[i] do
      self.stage[i][j] = self.func(self.stage[i + 1][j * 2 - 1], self.stage[i + 1][j * 2])
    end
  end
end
SegTree.create = function(self, n, func, emptyvalue)
  self.func, self.emptyvalue = func, emptyvalue
  local stagenum, mul = 1, 1
  self.cnt, self.stage, self.size = {1}, {{}}, {}
  while mul < n do
    mul, stagenum = mul * 2, stagenum + 1
    self.cnt[stagenum], self.stage[stagenum] = mul, {}
  end
  for i = 1, stagenum do self.size[i] = self.cnt[stagenum + 1 - i] end
  self.stagenum = stagenum
  for i = 1, mul do self.stage[stagenum][i] = emptyvalue end
  self:updateAll()
end
SegTree.getRange = function(self, left, right)
  if left == right then return self.stage[self.stagenum][left] end
  local start_stage = 1
  while right - left + 1 < self.size[start_stage] do
    start_stage = start_stage + 1
  end
  local ret = self.emptyvalue
  local t1, t2, t3 = {start_stage}, {left}, {right}
  while 0 < #t1 do
    local stage, l, r = t1[#t1], t2[#t1], t3[#t1]
    table.remove(t1) table.remove(t2) table.remove(t3)
    local sz = self.size[stage]
    if (l - 1) % sz ~= 0 then
      local newr = mmi(r, mce((l - 1) / sz) * sz)
      table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, newr)
      l = newr + 1
    end
    if sz <= r + 1 - l then
      ret = self.func(ret, self.stage[stage][mce(l / sz)])
      l = l + sz
    end
    if l <= r then
      table.insert(t1, stage + 1) table.insert(t2, l) table.insert(t3, r)
    end
  end
  return ret
end
SegTree.setValue = function(self, idx, value, silent)
  self.stage[self.stagenum][idx] = value
  if not silent then
    for i = self.stagenum - 1, 1, -1 do
      local dst = mce(idx / 2)
      local rem = dst * 4 - 1 - idx
      self.stage[i][dst] = self.func(self.stage[i + 1][idx], self.stage[i + 1][rem])
      idx = dst
    end
  end
end
SegTree.new = function(n, func, emptyvalue)
  local obj = {}
  setmetatable(obj, {__index = SegTree})
  obj:create(n, func, emptyvalue)
  return obj
end

local n = io.read("*n")
local st = SegTree.new(n, function(a, b) return a + b end, 0)
local c = 0
for i = 1, n do
  local p = io.read("*n")
  st:setValue(p, 1)
  local a = st:getRange(p, n)
  if a == i then c = c + 1 end
end
print(c)


Measured memory_bytes: 9216
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N):
    return math.ceil(N / 2) - 1


def main():
    N = read_int()
    print(slv(N))


if __name__ == '__main__':
    main()


Measured memory_bytes: 62444
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;


//mod演算ライブラリ
//mod=1000000007

LL add(LL a,LL b){
  return (a+b)%mod;
}

LL sub(LL a,LL b){
  return (a+mod-b)%mod;
}

LL mul(LL a,LL b){
  return ((a % mod) * (b % mod)) % mod;
}

LL power(LL x,LL y){//繰り返し二乗法 単品利用可
  if(y==0)return 1;
  else if(y==1)return x%mod;
  else if(y%2==0){
    LL tmp=power(x, y/2) % mod;
    return tmp*tmp%mod;
  }else {
    LL tmp=power(x, y/2) % mod;
    return ((tmp*tmp)%mod)*x%mod;
  }
}

LL dvs(LL a,LL b){
  return mul(a,power(b,mod-2));
}

const int SIZE_mod=200005;
int invfact[SIZE_mod];
int fact[SIZE_mod];

LL factset(int a){//aまでの階乗%mod表を作成
  fact[0]=1;
  FORQ(i,1,a){
    fact[i]=mul(fact[i-1],i);
  }
}

LL cmbset(int a){//1~aまでの階乗と階乗数の逆元のmod(mod)を用意 O(a)
  factset(a);
  invfact[a]=power(fact[a],mod-2);
  invfact[0]=1;
  FORD(i,a,1){
    invfact[i]=mul(invfact[i+1],i+1);
  }

}

LL cmb(int n,int r){//nCr%mod  (cmbset後に使用)
  if(n<r||r<0||n<0)return 0;
  return mul(fact[n],mul(invfact[r],invfact[n-r]));
}

LL prm(int n,int r){//nPr%mod
    return mul(cmb(n,r),fact[n]);
}

LL homo(int n,int r){//nHr%mod
  return cmb(n+r-1,r);
}


int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
	string s;
	cin>>s;
	const int n=s.length();
	vector<vector<int>> dp(n+1,vector<int>(13,0));
	dp[0][0]=1;
	FOR(i,0,n){
		FOR(k,0,13){
			const int t=dp[i][k];
			FOR(j,0,10){
				if(s[i]=='0'+j||s[i]=='?'){
					dp[i+1][(k*10+j)%13]=add(dp[i+1][(k*10+j)%13],t);
				}
			}
		}
	}
	cout<<dp[n][5]<<endl;

	return 0;
}


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

#define M /* your task*/6700417
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
  return 0;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return /* your task */key%M;}
int h2(int key){ return /* your task */1+key%(M-1); }

int find(char str[]){
  /* your task */
  long long key, hash;
  long long i;
  key = getKey(str);

  for ( i=0 ;; i++ ){
    hash =  (h1(key)+i*h2(key))%M;
    if(strcmp(H[hash],str) == 0) return 1;
    else if(strlen(H[hash]) == 0){
      return 0;
    }
  }
  return 0;
}

int insert(char str[]){
  /* your task */
  long long key,hash;
  long long  i;
  key = getKey(str);

  for(i=0;;i++){
    hash = (h1(key)+i*h2(key))%M;
    if(strcmp(H[hash],str) == 0 ) return 1;
    else if( strlen(H[hash]) == 0 ){
      strcpy(H[hash], str);
      return 0;
    }
  }
  return 0;
}

int main(){
  int i, n, h;
  char str[L], com[9];
  for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
  scanf("%d", &n);
    
  for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);
	
    if ( com[0] == 'i' ){
      insert(str);
    } else {
      if (find(str)){
	printf("yes\n");
      } else {
	printf("no\n");
      }
    }
  }

  return 0;
}



Measured memory_bytes: 93344
#include<bits/stdc++.h>
#include<iomanip>
#define fast {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define ar array
#define mxn 700
#define mod 1000000007
#define ld long double
#define pb push_back
#define inf 1e18
#define fi first
#define se second
typedef long long int ll;
using namespace std;
int main(void){
	fast;
	int n;
	ll a1=-inf,a2=-inf,a3=inf,a4=inf,x,y,i;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>x>>y;
		a1=max(a1,x+y);
		a2=max(a2,x-y);
		a3=min(a3,x+y);
		a4=min(a4,x-y);
	}
	cout<<max(a1-a3,a2-a4);
}


Measured memory_bytes: 3628
import heapq, collections

n = int(input())
distance = collections.defaultdict(dict)
for _ in range(n - 1):
    a, b, c = map(int, input().split())
    distance[a - 1][b - 1] = c
    distance[b - 1][a - 1] = c
q, k = map(int, input().split())
k -= 1
queries = []
for _ in range(q):
    x, y = map(int, input().split())
    queries.append((x - 1, y - 1))

d = [float('inf')] * (n + 1)
d[k] = 0
queue = [(0, k)]
while queue:
    cost, current = heapq.heappop(queue)
    for nxt in distance[current]:
        if cost + distance[current][nxt] < d[nxt]:
            d[nxt] = cost + distance[current][nxt]
            heapq.heappush(queue, (d[nxt], nxt))

for x, y in queries:
    print(d[x] + d[y])

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

int main(void){
  int n,h,w;
  int count = 0;
  cin >> n >> h >> w;
  vector<int> H(n);
  vector<int> W(n);
  for(int j = 0; j < n; j++) {
    cin >> H[j] >> W[j];
  }
  for(int i = 0; i < n; i++) {
    if((H[i]>=h)&&(W[i]>=w)){
      count++;
    }
  }
  cout << count;
}


Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


def main():
    S = input()
    print(S.count("1"))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = (int) 2e5 + 5;
int n;
int a[maxn];

int read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  return true;
}

long long s[maxn];

void solve() {
  s[0] = 0;
  for (int i = 0; i < n; i++) {
    s[i + 1] = s[i] + a[i];
  }
  map<long long, int> mp;
  long long res = 0;
  for (int i = 0; i <= n; i++) {
    res += mp[s[i]];
    mp[s[i]]++;
  }
  printf("%lld\n", res);
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 15104
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a,b,s[1001],t[2000],ans;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>t[i];
        s[t[i]]++;
    }
    for(int i=0;i<1000;i++){
        s[i+1]+=s[i];
    }
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            a=max(t[i],t[j]);
            b=min(t[i],t[j]);
            //cout<<a<<b<<" "<<s[min(1000LL,a+b-1)]-s[a-b]<<endl;
            ans+=s[min(1000LL,a+b-1)]-s[a-b];
            if(a-2*b<0)ans--;
            ans--;
        }
    }
    cout<<ans/3<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
#define M 200000

ll cnt = 0;
int A[M], L[M / 2 + 1], R[M / 2 + 1];
 
int merge(int l, int m, int r){
    int n1 = m - l, n2 = r - m, i, j;
    for(i = 0;i < n1;i++)L[i] = A[i + l];
    for(i = 0;i < n2;i++)R[i] = A[i + m];
    i = j = 0;
    for(int k = 0;k < r - l;k++){
        if(j == n2 || (i < n1 && L[i] <= R[j]))A[k + l] = L[i++];
        else A[k + l] = R[j++], cnt += n1 - i;
    }
}

int mergeSort(int l, int r){
    if(l + 1 < r){
        int m = (l + r) / 2;
        mergeSort(l, m);
        mergeSort(m, r);
        merge(l, m, r);
    }
}
 
int main(){
    int n;
    scanf("%d", &n);
    for(int i = 0;i < n;i++)scanf("%d", &A[i]);
	mergeSort(0, n);
	printf("%lld\n", cnt);
     
    return 0;
}

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

int main() {
  int a,b;
  int x;
  int p;
  
  cin >> a >> b;
  x = (a+b)/2;
  p = (a+b)%2;
  
  if (p==0) {
    cout << x << endl;
  }
  else{
    cout << x+1 <<endl;
  }
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <cstdio>
typedef long long ll;
inline ll gcd(ll a, ll b) {
  return b != 0 ? gcd(b, a % b) : a;
}
int main(){
    int n;
    ll ans=1,x;
    scanf("%d",&n);
    while(n--){
      scanf("%lld",&x);
      ans=ans/gcd(ans,x)*x;
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>

using namespace std;
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
//typedef boost::multiprecision::cpp_int bigint;

ll H, W, D;
vector<pll> where;
vector<ll> DP;

int main() {
	cin >> H >> W >> D;
	where.resize(H * W);
	for (ll y = 0; y < H; y++) {
		for (ll x = 0; x < W; x++) {
			ll l;
			cin >> l;
			where[--l] = pll(x, y);
		}
	}
	DP.resize(W * H);
	for (ll n = 0; n < W * H; n++) {
		if (n < D)DP[n] = 0;
		else {
			ll plus = abs(where[n].first - where[n - D].first) + abs(where[n].second - where[n - D].second);
			DP[n] = DP[n - D] + plus;
		}
	}
	ll Q;
	cin >> Q;
	for (ll q = 0; q < Q; q++) {
		ll L, R;
		cin >> L >> R;
		cout << DP[--R] - DP[--L] << endl;
	}
	return 0;
}

Measured memory_bytes: 3200
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<stack>
#include<set>
#include<fstream>
#include<map>
#include<vector>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int> P;
string s[52];
int dx[] = { 0,1,0,-1 }, dy[] = { 1,0,-1,0 };
signed main() {
	int h, w; cin >> h >> w;
	rep(i, h)cin >> s[i];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j] == '#') {
				int cnt = 0;
				rep(k,4) {
					int l = k;
						int ni = i + dx[k], nj = j + dy[l];
						if (0 <= ni&&ni < h && 0 <= nj&&nj < w&&s[ni][nj] == '#')cnt++;
				
				}
				if (cnt == 0) {
					puts("No");
					return 0;
				}
			}
		}
	}
	puts("Yes");
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        if (scanner.hasNextLine()) {
            String[] array = scanner.nextLine().split(" ");
            int N = Integer.parseInt(array[0]);
            int M = Integer.parseInt(array[1]);

            int maxL = 0;
            int minR = N;
            for (int i = 0; i < M; ++i) {
                array = scanner.nextLine().split(" ");
                int L = Integer.parseInt(array[0]);
                int R = Integer.parseInt(array[1]);
                if (L > maxL) {
                    maxL = L;
                }
                if (R < minR) {
                    minR = R;
                }
            }
            if (minR >= maxL) {
                System.out.println(minR - maxL + 1);
            } else {
                System.out.println(0);
            }
        }
    }
}

Measured memory_bytes: 105140
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;

const ll linf = 1LL << 62;
const int inf = 99999999;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };
const ll atcoder = 1e9 + 7;

#define Endl endl
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back
#define pr(x) cout << x << endl
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define rep(i,n) for(int i= 0;i<n;i++)
#define FOR(i,a,b) for(int i = a;i<b;i++)

template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

ll gcd(ll a, ll b) {//最大公約数
	if (a < b)swap(a, b);
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

ll lcm(ll a, ll b) {//最小公倍数
	if (a < b)swap(a, b);
	return (a / gcd(a, b))*b;
}

int main() {

	int n; cin >> n;
	vector<string> s(110);
	rep(i, n)cin >> s[i];

	int m; cin >> m;
	vector<string> t(110);
	rep(i, m)cin >> t[i];

	int ans = 0;

	rep(i,n) {
		int cnt = 0;
		rep(j, n) 
			if (s[i] == s[j])cnt++;
		rep(j, m)
			if (s[i] == t[j])cnt--;
		chmax(ans, cnt);
	}

	pr(ans);

//	system("pause");
	return 0;
}



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

int main() {
  string N;
  cin >> N;
  if((N[0]==N[1]&&N[1]==N[2])||(N[1]==N[2]&&N[2]==N[3])){
  	cout << "Yes" << endl;
  }
	else {
    cout << "No" << endl;
  }
}  
  


Measured memory_bytes: 3592
def goal_check(start,goal):
  distance = abs(start[1]-goal[1]) + abs(start[2]-goal[2])
  time = goal[0] - start[0]
  if time < distance: return False
  if (time-distance)%2 == 1: return False
  return True


N = int(input())
ans = "Yes"
dest = []
dest.append([0,0,0])
for i in range(N):
    dest.append(list(map(int,(input().split()))))
    
dest.sort(key=lambda point: point[0]) #O(NlogN)

for p,q in zip(dest[:-1],dest[1:]):
  if goal_check(p,q):
    pass
  else:
    ans = "No"
    break

print(ans)

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

#define INF 1e+9
    int dp[700][20100];
int main(){

  while(1){
    int N,M;
    cin >> N >> M;
    if(!N and !M) break;

    vector<int> c(M);
    for(int i=0; i<M; i++)
      cin >> c[i];
  
    vector<int> x(N+1);
    x[0] = 128;
    for(int i=1; i<=N; i++)
      cin >> x[i];

    // DP

    for(int i=0; i<600; i++)
      for(int j=0; j<20100; j++)
	dp[i][j] = INF;

    dp[128][0] = 0;
    
    for(int i=0; i<N; i++){
      for(int j=0; j<=255; j++){
	if(dp[j][i] != INF){
	  for(int dy : c){
	    int ny = j+dy;
	    if(ny < 0) ny = 0;
	    if(ny > 255) ny = 255;
	    dp[ny][i+1] = min(dp[ny][i+1],dp[j][i] + (x[i+1]-ny)*(x[i+1]-ny));
	  }
	}
      }
    }
  
    int ans = INF;
    for(int j=0; j<=255; j++){
      ans = min(dp[j][N],ans);
    }
    cout << ans << endl;

  }


}

Measured memory_bytes: 50280
#include <iostream>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;

int main()
{
    int a ,b;
    cin >> a >> b ;
    if(a%2==1 && b%2==1 ){
        cout << "Yes";
    }else{
        cout << "No";
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MAX_XYZ = 1005;
ll A[MAX_XYZ],B[MAX_XYZ],C[MAX_XYZ],AB[MAX_XYZ*MAX_XYZ],ABC[MAX_XYZ*3005];

int main()
{
	ll X,Y,Z,K;
	cin >> X >> Y >> Z >> K;
	rep(i,X)
	{
		cin >> A[i];
	}
	rep(i,Y)
	{
		cin >> B[i];
	}
	rep(i,Z)
	{
		cin >> C[i];
	}
	int cnt = 0;
	rep(i,X)
	{
		rep(j,Y)
		{
			AB[cnt] = A[i] + B[j];
			cnt++;
		}
	}
	sort(AB,AB+X*Y);
	reverse(AB,AB+X*Y);
	cnt = 0;
	rep(i,min(K,X*Y))
	{
		rep(j,Z)
		{
			ABC[cnt] = AB[i] + C[j];
			cnt++;
		}
	}
	sort(ABC,ABC+cnt);
	reverse(ABC,ABC+cnt);
	rep(i,K)
	{
		cout << ABC[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 31744
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007

using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1'000'000'000'000'000'000ll;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}

int main()
{
	fast();
	ll a,b;
	cin>>a>>b;
	cout<<lcm(a,b);	
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <iomanip>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    string s;
    int k;
    cin>>s>>k;
    int h=s.size();
    int r=min(5,h);
    vector<string>a;
    for(int i=1;i<=r;i++){
        for(int j=0;j<=h-i;j++){
            a.push_back(s.substr(j,i));
        }
    }
    sort(a.begin(),a.end());
    a.erase(unique(a.begin(),a.end()),a.end());
    cout << *(a.begin()+k-1);
}



Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define vec vector
#define rep(i,n) for (int i=0; i<(n); i++)
#define reps(i,s,n) for (int i=(s); i<(n); i++)
#define rep1(i,n) for (int i=1; i<=(n); i++)
#define repr(i,s,n) for (int i=(s)-1; i>=(n); i--)
#define print(a) cout << a << endl
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define Yes "Yes"
#define YES "YES"
#define No "No"
#define NO "NO"


int main() {
  ll N,X,M;
  cin >> N >> X >> M;
  vec<int> A(M,0);
  vec<ll> S(M,0);
  ll ans = 0,cnt = 1;
  while (N > 0) {
    N--;
    ans += X;
    if (A[X] != 0)
      break;
    A[X] = cnt;
    cnt++;
    S[X] = ans;
    X = (X*X)%M;
  }
  if (X != 0 && N > 0) {
    ll l = cnt-A[X];
    ans += N/l * (ans-S[X]);
    N %= l;
    while (N > 0) {
      N--;
      X = (X*X)%M;
      ans += X;
    }
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 4500
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>
 
#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000
 
using namespace std;
 
int main(void) {
	char x, y;
 
	cin >> x >> y;
 
	if (x == y) {
		cout << "=" << endl;
	}
	else if (x < y) {
		cout << "<" << endl;
	}
	else {
		cout << ">" << endl;
	}
 
 
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <list>
using namespace std;

#define MOD 1000000007
#define p(x) cout << x << endl;
#define el cout << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

    int a, b, c;
    cin >> a >> b >> c;

    int num_1 = a + b;
    int num_2 = a + c;
    int num_3 = b + c;

    cout << min({num_1, num_2, num_3}) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,K;
    cin>>N>>K;
    if(K>(N-1)*(N-2)/2){
        cout<<-1<<endl;
    }
    else{
        cout<<N-1+(N-1)*(N-2)/2-K<<endl;
        for(int i=0;i<N-1;i++){
            cout<<1<<" "<<i+2<<endl;
        }
        int count=0; 
        int s=2;
        while(count<(N-1)*(N-2)/2-K){
            for(int i=s+1;i<=N;i++){
                cout<<s<<" "<<i<<endl;
                count++;
                if(count==(N-1)*(N-2)/2-K){
                    return 0;
                }
            }
            s++;
        }
    }
}

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

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair

#define PQ(T) priority_queue<T>
#define RPQ(T) priority_queue<T,vector<T>,greater<T>>

template<class T> inline void amin(T & a, T const & b) { a = min(a, b); }
template<class T> inline void amax(T & a, T const & b) { a = max(a, b); }

inline ll square(ll x) { return x * x; }
inline ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }
template <typename T>
inline T mod(T a, T b) { return ((a % b) + b) % b; }


const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

#define INTSPACE 12
char _buf[INTSPACE*1000000 + 3];

int loadint() {
    if (fgets(_buf, INTSPACE+3, stdin)==NULL) return 0;
    return atoi(_buf);
}

int loadvec(vector<int>& v, int N=-1) {
    if (N == 0) {
        v.clear();
        return 0;
    }
    if (N == -1) {
        N = loadint();
        if (N==0) return 0;
    }
    int bufsize = INTSPACE*N + 3;
    if (fgets(_buf, bufsize, stdin)==NULL) return 0;
    v.resize(N);

    int i=0;
    bool last = false;
    for (char *p=&_buf[0]; ;) {
        char *q = p;
        while (*q > ' ') ++q;
        if (*q == 0x0D || *q == 0x0A) last = true;
        *q = 0;
        v[i++] = atoi(p);
        if (last || i == N) break;
        p = q+1;
    }
    return i;
}
void read_cr() {
    fgets(_buf, 256, stdin);
}

int solve(int N, vi& a) {
    int g = 0;
    rep(i,N) g = gcd(g, a[i]);
    return g;
}

int main() {
    vi a;
    int N = loadvec(a);
    cout << solve(N,a) << endl;
    return 0;
}


Measured memory_bytes: 1664
import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()


h,w = na()
ss = []
for i in range(h):
    s = list(ns())
    ss.append(s)

dp = [[0]*w for i in range(h)]

for i in range(h):
    for j in range(w):
        if i == 0 and j == 0:
            if ss[i][j] == '#':
                dp[0][0] = 1
            continue
        a = i-1 if h>0 else 0
        b = j-1 if w>0 else 0
        c = 100000000 if j == 0 else dp[i][b]+1 if ss[i][j] == '#' and ss[i][j] != ss[i][b] else dp[i][b]
        d = 100000000 if i == 0 else dp[a][j]+1 if ss[i][j] == '#' and ss[i][j] != ss[a][j] else dp[a][j]
        dp[i][j] = min(c,d)

print(dp[h-1][w-1])

Measured memory_bytes: 3192
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;


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

		Scanner sc = new Scanner(new InputStreamReader(System.in));
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if((a==5 && b==5 && c==7)||(a==5 && b==7 && c==5)||(a==7 && b==5 && c==5)){
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

// const ll mod = 1e9+7;

// void chmod(ll &M){
//     if(M >= mod) M %= mod;
//     else if(M < 0){
//         M += (abs(M)/mod + 1)*mod;
//         M %= mod;
//     }
// }

int main(){
    int N; cin >> N;
    vector<int> p(N+1);

    vector<pair<int, int>> v;
    for(int i=1; i<=N; ++i){
        cin >> p[i];
        if(i != p[i]) v.push_back(make_pair(i, p[i]));
    }

    if(v.size() <= 2) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl        '\n'
#define db          double
#define ld          long double
#define ll          long long
#define ull         unsigned long long
#define sqr(x)      (x) * (x)
#define gcd(a, b)   __gcd(a, b)
#define lcm(a, b)   ((a/gcd(a,b)) * b)
#define pf(x) 		push_front(x)
#define pb(x)       push_back(x)
#define eb(x)		emplace_back(x)
#define all(x)      (x).begin(), (x).end()
#define rall(x) 	(x).rbegin(), (x).rend()
#define sz(x) 		(int)x.size()
#define debug(x) 	cerr << #x << " = " << (x) <<endl
#define unsyncIO    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ld PI = acos((ld)-1);
const int MOD = 1e9+7;
const ll INF = 1e18; 

using namespace std;

int main()
{
  	unsyncIO;
    //freopen("/home/taalpatar_shepai/Documents/my_codes/out.txt", "w", stdout);
    for (int  i = 1; i <= 5; i++) {
        int t;
        cin >> t;
        if (t == 0) {
            cout << i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3576
#include<iostream>
#include<stdio.h>
using namespace std;
using ll=long long;
#include<algorithm>
#include<set>
#include<vector>
#define rep(i,n) for(int i=0;i<(n);i++)
using P=pair<int,int>;

//auto

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



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

typedef long long ll;

using namespace std;

int main(){
    ll dp[100][21]={0};
    int n,in[100];
    
    scanf("%d",&n);
    
    for(int i=0;i<n;i++)
        scanf("%d",&in[i]);
    
    dp[0][in[0]]=1;
    
    for(int i=1;i<n-1;i++){
        for(int j=0;j<=20;j++){
            if(0<=in[i]+j && in[i]+j<=20)
                dp[i][in[i]+j]+=dp[i-1][j];
            if(0<=j-in[i] && j-in[i]<=20)
                dp[i][j-in[i]]+=dp[i-1][j];
        }
    }
    
    printf("%lld\n",dp[n-2][in[n-1]]);
    
    return 0;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
vector<vector<ll>> c(10, vector<ll>(10));
ll h, w, a, res;
int main()
{
    cin >> h >> w;
    for (ll i = 0; i < 10; i++)
    {
        for (ll j = 0; j < 10; j++)
        {
            cin >> c[i][j];
        }
    }
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            for(int k = 0; k < 10; k++){
                if(c[j][k] > c[j][i] + c[i][k])
                    c[j][k] = c[j][i] + c[i][k];
            }
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> a;
            if(a >= 0)
            res += c[a][1];
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	int n = sc.nextInt();
      	int p[] = new int[n];
      	int num;
      	int count=1;
      	for(int i = 0; i<n; ++i){
          p[i] = sc.nextInt();
        }
          num = p[0];
        for(int i = 1; i<p.length; ++i){
          if(p[i]< num){
            count +=1;
            num = p[i];
          }
        }
      System.out.println(count);

    }
}

Measured memory_bytes: 60676
#include<cstdio>
#include<iostream>
int m,n,k;
int jh[1000][1000]={},jw[1000][1000]={},oh[1000][1000]={},ow[1000][1000]={},ih[1000][1000]={},iw[1000][1000]={};
char field[1000][1000];

void solve_ac(int a,int b,int c,int d){
	//printf("ac:call %d,%d,%d,%d\n",a,b,c,d);
	int j=0,o=0,i=0;
	if(a==0){
		for(int lp=b;lp<=d;lp++){
			j+=jw[c][lp];
			o+=ow[c][lp];
			i+=iw[c][lp];
		}
	}else{
		for(int lp=b;lp<=d;lp++){
			j+=jw[c][lp]-jw[a-1][lp];
			o+=ow[c][lp]-ow[a-1][lp];
			i+=iw[c][lp]-iw[a-1][lp];
		}
	}
	printf("%d %d %d\n",j,o,i);
}
void solve_bd(int a,int b,int c,int d){
	//printf("bd:call %d,%d,%d,%d\n",a,b,c,d);
	int j=0,o=0,i=0;
	if(b==0){
		for(int lp=a;lp<=c;lp++){
			j+=jh[lp][d];
			o+=oh[lp][d];
			i+=ih[lp][d];
		}
	}else{
		for(int lp=a;lp<=c;lp++){
			j+=jh[lp][d]-jh[lp][b-1];
			o+=oh[lp][d]-oh[lp][b-1];
			i+=ih[lp][d]-ih[lp][b-1];
		}
	}
	printf("%d %d %d\n",j,o,i);
}
int main(void){
	int a,b,c,d;
	char temp;
	scanf("%d %d %d",&m,&n,&k);
	for(int lp_h=0;lp_h<m;lp_h++){
		for(int lp_w=0;lp_w<n;lp_w++){
			scanf("%c",&temp);
			if(temp=='\n'){
				lp_w--;
			}else{
				field[lp_h][lp_w]=temp;
			}
		}
	}
	for(int lp_h=0;lp_h<m;lp_h++){
		if(field[lp_h][0]=='J'){
			jh[lp_h][0]=1;
		}else if(field[lp_h][0]=='O'){
			oh[lp_h][0]=1;
		}else{
			
			ih[lp_h][0]=1;
		}
		for(int lp_w=1;lp_w<n;lp_w++){
			if(field[lp_h][lp_w]=='J'){
				jh[lp_h][lp_w]=1;
			}else if(field[lp_h][lp_w]=='O'){
				oh[lp_h][lp_w]=1;
			}else{
				ih[lp_h][lp_w]=1;
			}
			jh[lp_h][lp_w]+=jh[lp_h][lp_w-1];
			oh[lp_h][lp_w]+=oh[lp_h][lp_w-1];
			ih[lp_h][lp_w]+=ih[lp_h][lp_w-1];
		}
	}
	//printf("field make comp\n");
	/*for(int lp_h=0;lp_h<m;lp_h++){
		for(int lp_w=0;lp_w<n;lp_w++){
			printf("%d ",jh[lp_h][lp_w]);
		}
		printf("\n");
	}
	
	for(int lp_w=0;lp_w<n;lp_w++){
		if(field[0][lp_w]=='J'){
			jw[0][lp_w]=1;
		}else if(field[0][lp_w]=='O'){
			ow[0][lp_w]=1;
		}else{
			iw[0][lp_w]=1;
		}
		for(int lp_h=1;lp_h<m;lp_h++){
			if(field[lp_h][lp_w]=='J'){
				jw[lp_h][lp_w]=1;
			}else if(field[lp_h][lp_w]=='O'){
				ow[lp_h][lp_w]=1;
			}else{
				iw[lp_h][lp_w]=1;
			}
			jw[lp_h][lp_w]+=jw[lp_h-1][lp_w];
			ow[lp_h][lp_w]+=ow[lp_h-1][lp_w];
			iw[lp_h][lp_w]+=iw[lp_h-1][lp_w];
		}
		
	}
	/*for(int lp_h=0;lp_h<m;lp_h++){
		for(int lp_w=0;lp_w<n;lp_w++){
			printf("%d ",jw[lp_h][lp_w]);
		}
		printf("\n");
	}*/
	//printf("fielddp comp\n");
	for(int lp=0;lp<k;lp++){
		//printf("loopstart\n");
		scanf("%d %d %d %d",&a,&b,&c,&d);
		/*if(c-a>d-b){
			solve_ac(a-1,b-1,c-1,d-1);
		}else{
			solve_bd(a-1,b-1,c-1,d-1);
		}*/
		solve_bd(a-1,b-1,c-1,d-1);
	}
	
	return 0;
	
}

Measured memory_bytes: 15788
//
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define MOD 1000000007
#define PI 3.14159265
#define EPS 1e-9
#define Pi acos(-1.0)
typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;

/*CODE START HERE*/

int n, m;
string ans[102];

int main(){
    ios::sync_with_stdio(0);
    cin >> n >> m;
    
    forn(i,102){
        ans[i].resize(m+2);
    }

    forr(i,1,n+1){
        ans[i][0] = '#';
        ans[i][m+1] = '#';
        forr(j,1,m+1){
            cin >> ans[i][j];
        }
    }

    forn(j,m+2){
        ans[0][j] = '#';
        ans[n+1][j] = '#';
    }

    forn(i,n+2){
        cout << ans[i] << "\n";
    }



    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
const int MR=1e6+10;
typedef long long LL;

int main() {
	char a[4];
	scanf("%s",a);
	a[1]='R'+'B'-a[1];
	printf("%s\n",a);
    return 0;
}

Measured memory_bytes: 3764
#include <iostream>
#include <cmath>
#include <vector>
#include <numeric>

using lint = long long;

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

    std::vector<lint> as(n);
    for (auto& a : as) std::cin >> a;

    std::partial_sum(as.begin(), as.end(), as.begin());
    lint s = as.back();
    lint ans = s;
    for (auto a : as) {
        ans = std::min(ans, std::abs((s - a) - a));
    }

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


Measured memory_bytes: 1792
extern crate core;

use std::io::{self, Read};

#[macro_use]
mod parser {
    macro_rules! input {
    ($s:expr=>$($t:tt)*) => {
        let mut lines=$s.split("\n");
        $(
            line_parse!(lines,$t);
        )*
    };
    }

    macro_rules! line_parse {
    ($lines:expr,($($name:ident:$t:tt)*)) => {
        let mut line=$lines.next().unwrap().split_whitespace();
        $(value_def!(line,$name,$t);)*
    };

    //複数行
    ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
        values_def!($lines,$n,$name,$t);
    };
    }

    macro_rules! value_def {
    ($line:expr,$name:ident,$t:tt) => {
        let $name=value!($line,$t);
    };
    }

    macro_rules! values_def {
    ($lines:expr,$n:expr,$name:ident,$t:tt) => {
        let $name={
        let mut vec=Vec::new();
        for i in 0..$n{
            let mut next=$lines.next().unwrap().split_whitespace();
            vec.push(value!(next,$t));
        }
        vec
        };
    };
    }

    macro_rules! value {
    //配列
    ($line:expr,[$t:tt]) => {
        $line.map(|x|{
        let mut iter=::std::iter::once(x);
        value!(iter,$t)
        }).collect::<Vec<_>>()
    };
    //タプル
    ($line:expr,($($t:tt),*)) => {
        ($(value!($line,$t),)*)
    };
    //文字列
    ($line:expr,#) => {
        $line.next().unwrap()
    };
    //単一値
    ($line:expr,$t:ty) => {
        $line.next().unwrap().parse::<$t>().unwrap()
    };
    }
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn swap(i: usize, list: &mut Vec<i64>) {
    let l = list[i] - 1;
    let r = list[i + 1] + 1;
    list[i + 1] = l;
    list[i] = r;
}

fn solve(input: String) -> String {
    input!(input=>(n:usize)(list:[i64]));
    let mut list = list.into_iter()
        .map(|x| x - 1)
        .enumerate()
        .map(|(a, b)| b - a as i64)
        .collect::<Vec<_>>();
    let mut count = 0;
    for i in 0..n {
        if list[i] == 0 {
            if i == 0 {
                swap(i, &mut list);
            } else if i == n - 1 {
                swap(i - 1, &mut list);
            } else {
                if list[i + 1] == 0 {
                    swap(i, &mut list);
                } else if list[i - 1] == 1 {
                    swap(i, &mut list);
                } else {
                    swap(i - 1, &mut list);
                }
            }
            count += 1;
        }
    }
    count.to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "5\n1 4 3 5 2" => "2",
    test2: "2\n1 2" => "1",
    test3: "2\n2 1" => "0",
    test4: "9\n1 2 4 9 5 8 7 3 6" => "3",
}


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

int main() {
  int a, b, k; cin >> a >> b >> k;
  rep(i,b-a+1) {
    if (a+i < a+k || b-k < a+i) {
      cout << a+i << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3608
// I'm a f*cking looser
#include<bits/stdc++.h>
using namespace std;
#define int int64_t
#define fasino ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);

int dp[101][100001];
int we[101],val[101];

int memo_knapsack(int weight,int n){
    if(n < 0 || weight <=0) return 0;
    int& st = dp[n][weight];
    if(st!=-1) return st;
    st = numeric_limits<int>::min();
    if(we[n-1]<=weight)
        st=max(val[n-1]+memo_knapsack(weight-we[n-1],n-1),st);
    st = max(st,memo_knapsack(weight,n-1));
    return st;
} 

signed main()
{
    fasino
    int n,w;
    cin >> n >> w;
    for(int i=0;i<n;i++) cin>>we[i]>>val[i];
    memset(dp,-1,sizeof dp);
    int prof = memo_knapsack(w,n);
    cout<<prof<<'\n';
    return 0;
}


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

int main(){
    string s; cin >> s;
    int n = s.size();
    string ans(n,'x');
    cout << ans << endl;
}

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

int main(){
	map<int,int> mp;
	map<int,int>::iterator it;
	int n,a,sum=0;
	cin>>n;
	while(n--){
		cin>>a;
		if(mp.count(a)) mp[a]++;
		else mp[a]=1;
	}
	for(it=mp.begin();it!=mp.end();it++){
		pair<int,int> cur = *it;
		if(cur.first!=cur.second){
			if(cur.first>cur.second) sum+=cur.second;
			else sum+=cur.second-cur.first;
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 4736
s=int(input())
a=[s]

def has_duplicates(seq):
    return len(seq) != len(set(seq))

while True:
    if s%2==0:
        s=s/2
    else :
        s=3*s+1
    a.append(s)
    if has_duplicates(a):
        break;

print(len(a))

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,k = LI()
h = LI()
h.sort(reverse=1)
ans = sum(h[min(n,k):])
print(ans)

Measured memory_bytes: 80332