akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll            long long
#define nl            "\n"
#define PB            push_back
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    string s;
    cin>>s;
    for(int i=0;i<SZ(s);i++)
    {
        if(s[i]=='1')
        {
            s[i]='9';
        }
        else if(s[i]=='9')
        {
            s[i]='1';
        }
    }
    cout<<s<<nl;
    return 0;
}



Measured memory_bytes: 256
#!/usr/bin python3
# -*- coding: utf-8 -*-

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def find(self, x):          #親を出力
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def same(self, x, y):       #xとyが同じグループかどうか
        return self.find(x) == self.find(y)

    def size(self, x):          #グループの要素数
        return -self.parents[self.find(x)]

    def members(self, x):       #xと同じグループの要素
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):            #親の要素一覧
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):      #グループの個数
        return len(self.roots())

    def all_group_members(self):      #グループのメンバー一覧
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

################

def main():
    N, M = map(int, input().split())
    uf = UnionFind(N)
    rel = [list(map(int,input().split())) for i in range(M)]
    for i in rel:
        uf.union(i[0]-1, i[1]-1)

    print(uf.group_count())


if __name__ == '__main__':
    main()

Measured memory_bytes: 32208
#include <iostream>
typedef long long ll;
using namespace std;

int main()
{
    int n, s,ans,cnt = 0;
    ll sum = 0;
    cin >> n >> s;
    int a[100001];
    for(int i = 0; i < n; i++){
        cin >> a[i];
        if(sum < s){
            sum += a[i];
            ++cnt;
        }
    }

    if(sum < s){
        cout << "0" << endl;
        return 0;
    }
    ans = cnt;
    for(int i = 1;i < n;++i){
        sum -= a[i - 1];
        cnt--;
        while(i + cnt < n && sum < s){
            sum += a[i + cnt];
            cnt++;
        }
        if(sum >= s){
            ans = min(ans, cnt);
        }
    }
    cout << ans << endl;
}



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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define DBG(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define DBG(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define CIN(type, ...) \
  type __VA_ARGS__;    \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define COUT(...) write_to_cout(__VA_ARGS__);

#define ALL(x) (x).begin(), (x).end()
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

ll A[100000];

int main() {
  CIN(ll, H, N);
  REP(i, N) cin >> A[i];
  ll sum = 0;
  REP(i, N) sum += A[i];
  COUT(sum >= H ? "Yes" : "No");
}


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

int main() {
  int n;
  long long int a, b;
  cin >> n >> a >> b;
  vector<long long int> c(n);
  long long int cost = 0;
  for(int i=0;i<n;i++) cin >> c[i];
  for(int i=1;i<n;i++) {
    long long int distance = c[i] - c[i-1];
    cost += min(b, a * distance);
  }
  cout << cost << endl;
}

Measured memory_bytes: 1024
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
ts=time.time()
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
show_flg=False
#show_flg=True

ans=0
n,m=MI()
ed=[-1]*n
bg=[[] for _ in range(n)]
A=[0]*n
B=[0]*n
r=[]
for i in range(m):
    a,b=LI_()
    r+=[(a,b)]
    bg[a].append(b)
    ed[a]=b
    A[a]+=1
    B[b]+=1

show(r,A,B)
q=[]
for i in range(n):
    show(i,'q=',q,ans,end=' | ')
    if B[i]>0:
        ans+=1
        for j in q:
            B[j]-=1
        q=[]
    if A[i]>0:
        q+=bg[i]
    show(i,'q=',q,'ans=',ans,'A,B=',A,B)    
print(ans)

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

int H,N;
int A[100010];
int main(){
  cin >> H >> N;
  rep(i,N) cin >> A[i];
    
  rep(i,N){
    H -= A[i];
    if(H <= 0){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 640
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int  n = sc.nextInt();
    if((n/10)%111==0){
      System.out.println("Yes");
    }else if((n%1000)%111==0){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
      
  }
  

  
}


Measured memory_bytes: 23508
#include<iostream>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
using namespace std;

int main() {
  int a,b;

  cin >> a >> b;

  if (abs(a - b) % 2 == 0) {
    cout << min(a, b) + abs(a - b) / 2 << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
}


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

long long int solve(long long int n,map<long long int,long long int> &dp){
    if(n==0) return 1;
    if(n==1) return 2;
    if(dp.find(n)!=dp.end()) return dp[n];
    long long int res=0;
    res+=solve(n/2,dp);
    res+=solve(n/2-1,dp);
    res+=solve((n-1)/2,dp);
    return dp[n]=(res%(int(1e9)+7));
}
int main(){
    long long int n;
    cin>>n;
    map<long long int,long long int> dp;
    cout<<solve(n,dp)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>

using namespace std;

typedef long long ll;

int main(){

	int A,B,Q;
	cin >> A >> B >> Q;

	std::vector<ll> s(A+2);
	s[0] = -1e15;
	s[A+1] = 1e15;
	for (int i = 1; i < A+1; i++){
		cin >> s[i];
	}

	std::vector<ll> t(B+2);
	t[0] = -1e15;
	t[B+1] = 1e15;
	for (int i = 1; i < B+1; i++){
		cin >> t[i];
	}
	

	std::vector<ll> x(Q);
	for (int i = 0; i < Q; i++){
		cin >> x[i];
	}

	for (int i = 0; i < Q; i++){
		int sok = 0; int sng = A; int smid;
		while(abs(sok-sng)>1){
			smid = (sok+sng)/2;
			if(s[smid] <= x[i]) sok = smid;
			else sng = smid;
		}

		int tok = 0; int tng = B; int tmid;
		while(abs(tok - tng)>1){
			tmid = (tok+tng)/2;
			if(t[tmid] <= x[i]) tok = tmid;
			else tng = tmid;
		}
		
		ll res = 1e15;

		for (int sserch = sok; sserch < sok+2; sserch++){
			for (int tserch = tok; tserch < tok+2 ; tserch++){
				ll d1 = abs(s[sserch]-x[i])+abs(t[tserch]-s[sserch]);
				ll d2 = abs(t[tserch]-x[i])+abs(s[sserch]-t[tserch]);
				res = min(res,min(d1,d2));
			}
		}
	cout << res << endl;

	}
	return 0;
}

	

Measured memory_bytes: 3712
n, k = map(int, input().split())
li = []
for x in range(k*2):
    li.append(input().split())
li2 = []
i = 1
while i < k*2:
    for j in li[i]:
        li2.append(j)
    i += 2
li2 = set(li2)
print(n - len(li2))


Measured memory_bytes: 9544
#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and typedef Constants *******/
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define Dcout(a) cout << setprecision(20) << a << endl
#define MP make_pair
#define PB push_back
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
using ll = long long;
using PAIR = pair<int, int>;
using Graph = vector<vector<int>>;
const ll INF = (1LL << 60);
const double pi=acos(-1.0);
#define debug cout << "line : " << __LINE__ << " debug" << endl
/****** Template of some basic operations *****/
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/**************************************/
/******** User-defined Function *******/

/**************************************/
/********** Main()  function **********/
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n,m; cin >> n >> m;
    int ans = 0;
    vector<int> k(m);
    vector<vector<int>> s;
    rep(i,m){
        vector<int> a;
        cin >> k[i];
        rep(j,k[i]){
            int b; cin >> b;
            a.push_back(b-1);
        }
        s.push_back(a);
    }

    vector<int> p(m);
    rep(i,m) cin >> p[i];

    rep(bit,(1<<n)){
        bool flag = true;
        rep(i,m){
            int cnt = 0;
            rep(j,k[i]){
                if(bit & (1<<s[i][j])) cnt++;
            }
            if(cnt%2!=p[i]){
                flag = false;
                break;
            }
        }
        if(flag) ans++;
    }

    cout << ans << endl;

}
/********  Main() Ends Here *************/


Measured memory_bytes: 3660
import sys
input = sys.stdin.readline

inf = 10**9

n = int(input())

if(n==1):
    print(0)
    exit()

UD_x = [inf, -1*inf]
LR_y = [inf, -1*inf]
U_y = [inf, -1*inf]
D_y = [inf, -1*inf]
R_x = [inf, -1*inf]
L_x = [inf, -1*inf]

for i in range(n):
    tmp = input().split()
    x,y = map(int, tmp[:2])
    d = tmp[2]
    if(d == 'U'):
        UD_x[0] = min(UD_x[0], x)
        UD_x[1] = max(UD_x[1], x)
        U_y[0] = min(U_y[0], y)
        U_y[1] = max(U_y[1], y)
    elif(d == 'D'):
        UD_x[0] = min(UD_x[0], x)
        UD_x[1] = max(UD_x[1], x)
        D_y[0] = min(D_y[0], y)
        D_y[1] = max(D_y[1], y)
    elif(d == 'R'):
        LR_y[0] = min(LR_y[0], y)
        LR_y[1] = max(LR_y[1], y)
        R_x[0] = min(R_x[0], x)
        R_x[1] = max(R_x[1], x)
    elif(d == 'L'):
        LR_y[0] = min(LR_y[0], y)
        LR_y[1] = max(LR_y[1], y)
        L_x[0] = min(L_x[0], x)
        L_x[1] = max(L_x[1], x)

x_dif = max(UD_x[1], R_x[1], L_x[1]) - min(UD_x[0], R_x[0], L_x[0])
y_dif = max(LR_y[1], U_y[1], D_y[1]) - min(LR_y[0], U_y[0], D_y[0])
ans = x_dif * y_dif

check = []
if(D_y != [inf, -1*inf]):
    # D_y[0]
    for meet, speed in zip([LR_y[0], U_y[0]], [1,2] ):
        tmp = (D_y[0] - meet)/speed
        if(tmp > 0):
            check.append(tmp)
    # D_y[1]
    for meet, speed in zip([LR_y[1], U_y[1]], [1,2] ):
        tmp = (D_y[1] - meet)/speed
        if(tmp > 0):
            check.append(tmp)

if(D_y != [inf, -1*inf]):
    # D_y[0]
    for meet, speed in zip([LR_y[0], U_y[0]], [1,2] ):
        tmp = (D_y[0] - meet)/speed
        if(tmp > 0):
            check.append(tmp)
    # D_y[1]
    for meet, speed in zip([LR_y[1], U_y[1]], [1,2] ):
        tmp = (D_y[1] - meet)/speed
        if(tmp > 0):
            check.append(tmp)

if(U_y != [inf, -1*inf]):
    # U_y[0]
    for meet, speed in zip([LR_y[0], D_y[0]], [1,2] ):
        tmp = (meet - U_y[0])/speed
        if(tmp > 0):
            check.append(tmp)
    # U_y[1]
    for meet, speed in zip([LR_y[1], D_y[1]], [1,2] ):
        tmp = (meet - U_y[1])/speed
        if(tmp > 0):
            check.append(tmp)

if(L_x != [inf, -1*inf]):
    # L_x[0]
    for meet, speed in zip([UD_x[0], R_x[0]], [1,2] ):
        tmp = (L_x[0] - meet)/speed
        if(tmp > 0):
            check.append(tmp)
    # L_x[1]
    for meet, speed in zip([UD_x[1], R_x[1]], [1,2] ):
        tmp = (L_x[1] - meet)/speed
        if(tmp > 0):
            check.append(tmp)

if(R_x != [inf, -1*inf]):
    # R_x[0]
    for meet, speed in zip([UD_x[0], L_x[0]], [1,2] ):
        tmp = (meet - R_x[0])/speed
        if(tmp > 0):
            check.append(tmp)
    # R_x[1]
    for meet, speed in zip([UD_x[1], L_x[1]], [1,2] ):
        tmp = (meet - R_x[1])/speed
        if(tmp > 0):
            check.append(tmp)

for sec in check:
    x_dif = (max(UD_x[1], R_x[1]+sec, L_x[1]-sec)
            - min(UD_x[0], R_x[0]+sec, L_x[0]-sec))
    y_dif = (max(LR_y[1], U_y[1]+sec, D_y[1]-sec)
            - min(LR_y[0], U_y[0]+sec, D_y[0]-sec))
    ans = min(ans,x_dif * y_dif)

print(ans)

Measured memory_bytes: 43376
/*||>>>> Praveen Ojha <<<<>>>> 09 August 2019 <<<<>>>> 21:31:58 <<<<||*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
//Read Problems Carefully & Check for corner cases N=0,1 ?
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////

int32_t main(){__
    string s;
    cin>>s;
    int n=sz(s),cnt=0;
    vi r(n),l(n),ans(n);
    for(int i=n-1;i>=0;i--){
        if(s[i]=='R')
            cnt++;
        else
            cnt=0;
        r[i]=cnt;
    }
    r[0]=cnt;
    cnt=0;
    for(int i=0;i<n;i++){
        if(s[i]=='L')
            cnt++;
        else
            cnt=0;
        l[i]=cnt;
    }
    l[n-1]=cnt;
    // debug()<< imie(r) imie(l);
    for(int i=0;i<n;i++){
        if(r[i]){
        if(r[i]&1){
            ans[i+r[i]-1]++;
        }
        else{
            ans[i+r[i]]++;
        }
    }
    }
    // debug()<< imie(ans);
    for(int i=n-1;i>=0;i--){
        if(l[i]){
        if(l[i]&1){
            ans[i-l[i]+1]++;
        }
        else{
            ans[i-l[i]]++;
        }
        }
    }
    for(int i=0;i<n;i++)
        cout<<ans[i]<<" ";
    cout<<"\n";
return 0;
}

Measured memory_bytes: 3024
#include <iostream>
#include <sstream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef struct node {
  struct node *r;
  struct node *l;
  int key,priotity;
}Node;

Node* delete1(Node*,int);
Node* makeNode(int k,int p){
  Node* tmp=(Node* )malloc(sizeof(Node));
  tmp->key=k;
  tmp->priotity=p;
  tmp->l=tmp->r=NULL;
  return tmp;
}
Node* righRotate(Node* t){
  Node* s;
  s=t->l;
  t->l=s->r;
  s->r=t;
  return s;
}
node* leftRotate(Node* t){
  Node* s;
  s=t->r;
  t->r=s->l;
  s->l=t;
  return s;
}

Node* insert(Node *t,int key,int priotity){
  if(t==NULL){
    //cout<<key<<endl;
    return makeNode(key,priotity);
  }
  if(key==t->key){
    //cout<<"in ="<<endl;
    return t;
  }
  if(key<t->key){
    t->l= insert(t->l,key,priotity);
    //cout<<"in if"<<endl;
    if(t->priotity<t->l->priotity)
      t=righRotate(t);
  }
  else{
    t->r=insert(t->r,key,priotity);
    //cout<<"in else"<<endl;
    if(t->priotity<t->r->priotity)
      t=leftRotate(t);
  }
  return t;
}
void inorder(Node *node){
  if(node==NULL){
    return;
  }
  inorder(node->l);
  cout<<" "<<node->key;
  inorder(node->r);
}
void preorder(Node *node){
  if(node==NULL){
    return;
  }
    cout<<" "<<node->key;
    preorder(node->l);
    preorder(node->r);
}
Node* find(Node *t,int key){
  while(t!=NULL&&key!=t->key){
    if(t->key>key)t=t->l;
    else t=t->r;
  }
  return t;
}
Node* delete2(Node* t,int key){
  if(t->l==NULL&&t->r==NULL)return NULL;
  else if (t->l==NULL)t=leftRotate(t);
  else if(t->r==NULL)t=righRotate(t);
  else {
    if (t->l->priotity>t->r->priotity)
      t=righRotate(t);
    else
      t=leftRotate(t);
  }
  return delete1(t,key);
}
Node* delete1(Node* t,int key){
  if(t==NULL)return NULL;
  if(key<t->key)t->l=delete1(t->l,key);
  else if (key>t->key)t->r=delete1(t->r,key);
  else return delete2(t,key);
  return t;
}


int main(){
  int n,i,k,p;
  Node *tmp;
  Node* root=NULL;
  string str;
  cin>>n;
  for(i=0;i<n;i++){
    cin>>str;
    //cout<<"i="<<i<<endl;
    if(str=="insert"){
      cin>>k>>p;
      //if(i>0)cout<<"rootkeybefor:"<<root->key<<endl;
      root=insert(root,k,p);
      //cout<<"rootkeyafter:"<<root->key<<endl;
    }
    else if(str=="find"){
      cin>>k;
      tmp=find(root,k);
      if(tmp!=NULL)cout<<"yes"<<endl;
      else cout<<"no"<<endl;
    }
    else if(str=="delete"){
      cin>>k;
      root=delete1(root,k);
    }
    else{
      inorder(root);
      cout<<endl;
      preorder(root);
      cout<<endl;
    }
  }


  return 0;
}



Measured memory_bytes: 9404
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int dp[500][500];
string s[500];
int h, w, k;
void paint(int y, int x, int color)
{
    // 横に伸ばせるだけ伸ばす
    int x_min = 0;
    int y_min = 0;
    int x_max = w;
    int y_max = w;
    for (int j = x - 1; j >= 0; j--)
    {
        if (s[y][j] == '#')
        {
            x_min = max(x_min, j + 1);
            break;
        }
    }
    for (int j = x + 1; j < w; j++)
    {
        if (s[y][j] == '#')
        {
            x_max = min(x_max, j);
        }
    }
    for (int j = x_min; j < x_max; j++)
    {
        dp[y][j] = color;
    }
}
void copy(int i){
    if(i==0 || dp[i-1][0]==0){
        if(dp[i+1][0]==0){
            copy(i+1);
        }
        rep(j, w)
        {
            dp[i][j] =dp[i+1][j];
        }
    }
    else{
        rep(j, w)
        {
            dp[i][j] = dp[i - 1][j];
        }
    }
}
int main()
{
    cin >> h >> w >> k;
    rep(i, h)
    {
        cin >> s[i];
    }
    int cnt = 1;
    rep(i, h)
    {
        rep(j, w)
        {
            if (s[i][j] == '#')
            {
                paint(i, j, cnt);
                cnt++;
            }
        }
    }
    rep(i,h){
        if(dp[i][0]==0){
            copy(i);
        }
    }
    rep(i, h)
    {
        rep(j, w)
        {
            cout << dp[i][j] << ' ';
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1536
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N   = scanner.nextInt();
		int d[] = new int[N];
		int ans = 0;
		
		for (int i = 0; i < N; i++) {
			d[i] = scanner.nextInt();
		}
		scanner.close();
		boolean already;
		for (int i = 0; i < N; i++) {
			already = false;
			for (int j = 0; j < i; j++) {
				if (d[i] == d[j]) {
					already = true;
					break;
				}
			}
			if (!already) {
				ans++;
			}
		}
		System.out.println(ans);
	}

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP1(i, n) for (int i = 1; i < (n); i++)
#define CIN(A) int A; cin >> A;
#define CIN2(A, B) int A, B; cin >> A >> B;
#define CIN3(A, B, C) int A, B, C; cin >> A >> B >> C;
#define CINVEC(A, N) vector<int> A; REP(i, N) { int a; cin >> a; A.emplace_back(a); }
#define ANS(ans) cout << (ans) << endl
#define rsort(p, q) sort(p, q, greater<int>());

#define DEBUGV(V) REP(i, V.size()) cout << V.at(i) << " "; cout << endl 

int
main()
{
  CIN3(N, A, B);

  int ans = 0;
  REP1(i, N + 1) {
    int sum = i % 10 + (i / 10) % 10 + (i / 100) % 10 + (i / 1000) % 10 + (i / 10000) % 10;
    if (A <= sum && sum <= B) {
      ans += i;
    }
  }

  ANS(ans);

  return 0;
}


Measured memory_bytes: 256
/*
          Life before Death
          Strength before Weakness
          Journey before Destination
    */
    
    #include <bits/stdc++.h>
    using namespace std;
    
    typedef long long ll;
    #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    #define rep(i,a,n) for(ll i=a;i<n;i++)
    #define per(i,n,a) for (ll i=n;i>a;i--)
    #define te ll t; std::cin >> t; while(t--)
    #define SZ 100011
    //#define M_PI  3.141592653589793238462643383279502884L
    /*------Just DO IT--------------------------------------*/

    ll dp[SZ][4], a[SZ][4];

    ll solve(){
      ll n;
      cin>>n;
      rep(i,1,n+1) rep(j,1,4) cin>>a[i][j];
      rep(i,1,n+1){
        dp[i][1] = a[i][1] + max(dp[i-1][2],dp[i-1][3]);
        dp[i][2] = a[i][2] + max(dp[i-1][1],dp[i-1][3]);
        dp[i][3] = a[i][3] + max(dp[i-1][1],dp[i-1][2]); 
      }
      cout<<max({dp[n][1], dp[n][2], dp[n][3]})<<endl;
    } 
    
   int main() {
       fastio
       solve();
    }

Measured memory_bytes: 6528
#!python3

def resolve():
    s1 = input()
    s2 = input()

    n1, n2 = len(s1) + 1, len(s2) + 1
    dp = [[0]*(n2) for i in range(n1)]
    for i in range(n1): dp[i][0] = i
    for i in range(n2): dp[0][i] = i

    for i1 in range(1, n1):
        for i2 in range(1, n2):
            cost = 0 if s1[i1-1] == s2[i2-1] else 1
            dp[i1][i2] = min(
                dp[i1-1][i2]   + 1,
                dp[i1][i2-1]   + 1,
                dp[i1-1][i2-1] + cost)

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

if __name__ == "__main__":
    resolve()



Measured memory_bytes: 43076
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as C
import Data.List
import Control.Monad

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine


type UF = (Parent,Rank,Size)
type Parent = UM.IOVector Int
type Rank   = UM.IOVector Int
type Size   = UM.IOVector Int

makeset :: Int -> IO UF
makeset n = do
    par <- U.thaw (U.generate n id)
    rnk <- UM.replicate n 0
    siz <- UM.replicate n 1
    return (par,rnk,siz)

root :: UF -> Int -> IO Int
root uf@(par,rnk,_) n = do
    x <- UM.read par n
    if x == n then return x else do
        nr <- root uf x
        UM.write par n nr
        UM.write rnk n 1
        return nr

same :: UF -> Int -> Int -> IO Bool
same uf x y = do
    rx <- root uf x
    ry <- root uf y
    return (rx == ry)

size :: UF -> Int -> IO Int
size uf@(par,rnk,siz) x = do
    r <- root uf x
    UM.read siz r

unite :: UF -> Int -> Int -> IO ()
unite uf@(par,rnk,siz) x y = do
    b <- same uf x y
    when (not b) $ do
        tx <- root uf x
        ty <- root uf y        
        rx <- UM.read rnk tx
        ry <- UM.read rnk ty
        sx <- size uf tx
        sy <- size uf ty
        if rx < ry then UM.write par tx ty >> UM.modify siz (+sx) ty
        else UM.write par ty tx >> when (rx == ry) (UM.modify rnk succ tx) >> UM.modify siz (+sy) tx


main :: IO ()
main = do
    [n,m,k] <- r'

    uf <- makeset n
    cnt <- UM.replicate n 0

    replicateM_ m $ do
        [a,b] <- map pred <$> r'
        unite uf a b
        UM.modify cnt succ a
        UM.modify cnt succ b
    replicateM_ k $ do
        [c,d] <- map pred <$> r'
        b <- same uf c d
        when b $ do
            UM.modify cnt succ c
            UM.modify cnt succ d

    putStrLn =<< unwords <$> mapM (\i -> do
        s <- size uf i
        c <- UM.read cnt i
        return $ show (s-c-1)
        ) [0..n-1]

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

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

	int H, W;
	scanf("%d %d%*c", &H, &W);
	// printf("%d %d\n", H, W);

	vector<vector<int>> A(H, vector<int>(W));
	vector<vector<int>> B(H, vector<int>(W));

	char tmp;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			scanf("%c", &tmp);
			if (tmp == '.') {
				A[i][j] = 0;
			} else {
				A[i][j] = 1;
			}
			// printf("%d %d [%c]\n", i, j, A[i][j]);
		}
		scanf("%*c");
	}
	/*	for (int i = 0; i < H; i++) {
	        for (int j = 0; j < W; j++) {
	            printf("%d", A[i][j]);
	        }
	        printf("\n");
	    }*/
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (i == 0 && j == 0) {
				B[i][j] = A[i][j] ^ 0;
			} else if (i != 0 && j == 0) {
				B[i][j] = B[i - 1][j] + (A[i][j] ^ A[i - 1][j]);
			} else if (i == 0 && j != 0) {
				B[i][j] = B[i][j - 1] + (A[i][j] ^ A[i][j - 1]);
			} else {
				B[i][j] = min(B[i - 1][j] + (A[i][j] ^ A[i - 1][j]),
				              B[i][j - 1] + (A[i][j] ^ A[i][j - 1]));
				// printf("(%d %d) %d %d %d %d ->%d\n", i, j, B[i - 1][j],
				//        A[i][j] ^ A[i - 1][j], B[i][j - 1],
				//        A[i][j] ^ A[i][j - 1], B[i][j]);
			}
		}
	}
	printf("%d", (B[H - 1][W - 1] + 1) / 2);

	/*	for (int i = 0; i < H; i++) {
	        for (int j = 0; j < W; j++) {
	            printf("%d", A[i][j]);
	        }
	        printf("\n");
	    }
	    for (int i = 0; i < H; i++) {
	        for (int j = 0; j < W; j++) {
	            printf("%d", B[i][j]);
	        }
	        printf("\n");
	    }
	    */
	return 0;
}

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

using namespace std;

int n,K;
typedef long long ll;
int px[51];
int py[51];
vector<ll>x;
vector<ll>y;
int main() {
  cin >> n >> K;

  for(int i = 0; i < n; i++) {
    cin >> px[i] >>py[i];
    x.push_back(px[i]);
    y.push_back(py[i]);
  }

  sort(x.begin(),x.end());
  sort(y.begin(),y.end());

  ll ans = (x[n-1] - x[0]) * (y[n-1] - y[0]);
 
  for(int i = 0; i < n; i++) {
    for(int j = i + 1; j < n; j++) {
      for(int k = 0; k < n; k++) {
	for(int l = k + 1; l < n; l++) {
	  int tmp = 0;
	  for(int m = 0; m < n; m++) {
	    if(x[i] <= px[m] && px[m] <= x[j] && y[k] <= py[m] && py[m] <= y[l]) tmp++;
	  }
	  
	  if(tmp >= K) ans = min(ans,(x[j] - x[i]) * (y[l] - y[k]));
	  
	  }
	  
      }
    }
  }
  cout << ans << endl;
}
			    

  


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

int main(){
    ll n,m,x;
    cin >> n >> m >> x;
    ll temp;
    ll book[n+10][m+10];
    ll  skill[m+10];
    ll ans = MOD;
    bool can = false;
    bool exist = false;
    bool allcan = false;
    for(ll i = 0; i < n ; i++){
        for(ll j = 0; j < m+1; j++){
            cin >> temp;
            book[i][j] = temp;
        }
    }
    
    for (ll bit = 0; bit < (1<<n); ++bit)
    {
      can = true;
        for(ll k = 0; k < m; k++){
            skill[k] = 0;
        }
        ll sum = 0; // 部分集合の和
        for (ll i = 0; i < n; ++i) {
            if (bit & (1<<i)) { // i が S に入っているなら足す
            sum += book[i][0];
            for(ll k = 1; k < m+1;k++){
                skill[k-1] += book[i][k];
            }
            }
        }
        for(ll k = 0; k < m; k++){
            if(skill[k] < x) can = false;
        }
        if(can){
            allcan = true;
            ans = min(ans,sum);
        }


    }
    if(allcan) cout << ans << endl;
    else cout << "-1" << endl;
    

}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long x,y,z,m,n;
	cin>>x>>y>>z;
	m=x/z;
	if(x%z!=0)
		m++;
	n=y/z;
	cout<<n-m+1<<endl;
	return 0;
}

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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin >> s;
    int n=s.size();

    int ans=0;
    int scnt=0;
    for(int i = 0; i < n; i++) {
        if(s[i]=='T' && scnt==0) continue;
        if(s[i]=='S') scnt++;
        else{
            scnt--;
            ans++;
        }
    }
    cout << n-ans*2 << "\n";

    return 0;
}

Measured memory_bytes: 3660
n=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

before=n+1
ans=0
for i in range(n):
  now=A[i]
  if now==before+1:
    ans+=B[now-1]+C[before-1]
  else:
    ans+=B[now-1]
  before=now
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
	int W, H, x, y, r;
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	if((x + r <= W) && (x - r >=0) && (y + r <= H) && (y - r >=0))
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}
} 


Measured memory_bytes: 2692
#include <bits/stdc++.h>
#include <limits>
#include <math.h>
#include <cmath>
#include <cctype>
#include <cstdio>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int> ;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vvll = vector<vector<long long >>;
#define PI  3.14159265358979323846264338327950288
#define rep(i, k, n) for(ll i = k; i < n; i++)



int main(){
  long double a, b, h, m;
  cin >> a >> b >> h >> m;
  
  long double c1, c2;
  c1 = (60.0000000000*h + m) * PI /360.0000000000;
  c2 = m * PI / 30.0000000000;
  
  long double x1, x2, y1, y2;
  x1 = a * cos(c1);
  x2 = b * cos(c2);
  y1 = a * sin(c1);
  y2 = b * sin(c2);
  
  long double dist;
  dist = pow(x1-x2, 2.0000000000000) + pow(y1-y2, 2.0000000000000000);
  dist = pow(dist,0.500000000000000000);
  
  cout << fixed << setprecision(15) << dist << endl;
  
}


Measured memory_bytes: 4176
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		int K = sc.nextInt();

		System.out.println((K / 2) * (K - K / 2));
	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <string>

int main(){
	int n; // the number of datasets
	std::cin >> n;
	std::cin.ignore();

	for(int i = 0; i < n; ++i){
		std::string text;
		std::getline(std::cin, text); // input
		
		int text_size = text.size();
		int moji = text.find("Hoshino");
		while(moji != std::string::npos){
			text.replace(moji, 7, "Hoshina");
			moji = text.find("Hoshino", moji);
		}
		
		std::cout << text << std::endl; //output
	}

	return 0;
}

Measured memory_bytes: 1212
#define _USE_MATH_DEFINES
#include <cmath>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main() {
	int n, m;
	cin>> n >> m;
	for (int i = 0; i < m; i++) {
		int hoge;
		cin >> hoge;
		n -= hoge;
	}
	if (n < 0)n = -1;
	cout << n;
}



Measured memory_bytes: 3624
#include<stdio.h>

int n;
int a[20];

int solve(int i, int m)
{
	int res;
	
	if(m == 0){
		return 1;
	}else if(i >= n){
		return 0;
	}
	
	res = solve(i + 1, m) || solve(i + 1, m - a[i]);
	
	return res;
}

int main()
{
	int q, i;
	int j = 0;
	int m[200];
	
	scanf("%d", &n);
	
	for(i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	
	scanf("%d", &q);
	
	for(i = 0; i < q; i++){
		scanf("%d", &m[i]);
	}
	
	for(i = 0; i < q; i++){
		if(solve(j, m[i]) == 1){
			printf("yes\n");
		}else{
			printf("no\n");
		}
	}
	
	return 0;
}
	


Measured memory_bytes: 1968
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;

int dp[105][4][2] = {0};

int main() {
    string S;
    int K;
    cin >> S >> K;
    int N = S.size();
    dp[0][0][1] = 1;
    rep(i, N) rep(k, 4) rep(m, 2) {
        int nd = S[i] - '0';

        rep(d, 10) {
            int nk = (d == 0) ? k : k + 1;
            if(nk>3) continue;
            int nm = m;
            if(m==1){
              if(d > nd) continue;
              if(d < nd) nm = 0;
            }
            dp[i + 1][nk][nm] += dp[i][k][m];
        }
    }
    cout << dp[N][K][0] + dp[N][K][1] << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<string>
#include<iostream>
using namespace std;
typedef long long ll;
const int maxn = 2e5+7;
int main(){
    string s;
	string temp="keyence";
    cin>>s;
    if(s.substr(s.length()-7)==temp)
        return 0*printf("YES\n");
    for(int i=0;i<s.length()-7;i++)
        if(s.substr(i,i+7)==temp)
            return 0*printf("YES\n");
    for(int i=1;i<=6;i++){
        string t=s.substr(0,i)+s.substr(s.length()-7+i);
        if(t==temp)
            return 0*printf("YES\n");
    }
    printf("NO");
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
int main()
{
	int a, b, c;
	std::cin >> a >> b >> c;
	int cnt = 0;
	for(int i = a; i <= b; i++)
	{
		if(c % i == 0)
		{
			cnt++;
		}
	}
	std::cout << cnt << std::endl;
	return 0;
}


Measured memory_bytes: 3100
N=gets.to_i
D=*$< #文字列の配列
(N-1).times do
#p D
t=0
D.map{|l|c,s,f=l.split.map &:to_i
#print("(c,s,f)=(#{c.class},#{s.class},#{f.class})")
if s>=t
  t=s+c
elsif t%f==0
  t+=c
else
  t+=c+f-(t%f)
end
}
p t
D.shift
end
print("0")

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

//________
typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
typedef vector<Pii> Vp;
#define pb push_back
#define fi first
#define se second
#define mkp make_pair
#define All(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i,f,n) for(int i=(f); i<=(n); ++i)
#define show(x) cerr << #x << ':' << x << endl
#define outl(x) cout << x << '\n';

#define INF (1 << 29)

#define FAST cin.tie(0), ios::sync_with_stdio(false)
inline int chmax(int &a, int b){return b>a ? a=b,1 : 0;}
inline int chmin(int &a, int b){return b<a ? a=b,1 : 0;}
//________

main(){
	string n;
	FAST;
	cin >> n;
	int cnt =0;
	if(n[1] == n[2]){
		if(n[0] == n[1] || n[3] == n[1]){
			outl("Yes");
			return 0;
		}
	}
	outl("No");
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
typedef int64_t Weight;
Weight INF = 1000000000000000000ll;
struct Edge{
  int src, dest; Weight weight;
  bool operator < (const Edge &rhs) const {return weight > rhs.weight;}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

void add_edge(Graph &g, int src, int dest, Weight weight) {
  g[src].push_back((Edge){src, dest, weight});
  g[dest].push_back((Edge){dest, src, weight});
}

bool dfs(const Graph &g, vector<int>& vis, int i=0, bool is_black=true) {
  if (is_black) {
    vis[i] = 0;
  } else {
    vis[i] = 1;
  }
  for (auto &e : g[i]) {
    if (vis[e.dest] == -1) {
      if (!dfs(g, vis, e.dest, !is_black)) return false;
    } else if (vis[e.dest] == vis[i]) return false;
  }
  return true;
}

std::pair<bool, int64_t> dfs2(const Graph &g, vector<bool> &vis, vector<int64_t>& w, int i=0) {
  vis[i] = true;
  for (auto &e : g[i]) {
    if(!vis[e.dest]) {
      w[e.dest] = e.weight - w[i];
      bool valid;
      int64_t diff;
      std::tie(valid, diff) = dfs2(g, vis, w, e.dest);
      if (!valid) return std::make_pair(valid, diff);
    } else if (w[e.dest] + w[i] != e.weight) {
      return std::make_pair(false, e.weight - (w[e.dest] + w[i]));
    }
  }
  return std::make_pair(true, 0);
}

int main() {
  int64_t n,m;
  cin>>n>>m;
  Graph g(n);
  REP(i,m) {
    int u,v,s;
    cin>>u>>v>>s;
    --u;--v;
    add_edge(g, u, v, s);
  }
  vector<int> vis(n, -1);
  bool is_b = dfs(g, vis);
  vector<bool> vis2(n, false);
  vector<int64_t> w(n);
  auto p = dfs2(g, vis2, w);
  if (is_b) {
    if (p.first) {
      int64_t mn0 = INF;
      int64_t mn1 = INF;
      REP(i,n) {
        if (vis[i] == 0) {
          mn0 = min(mn0, w[i]);
        } else {
          mn1 = min(mn1, w[i]);
        }
      }
      cout << max((int64_t)0, mn0 + mn1 - 1) << endl;
    } else {
      cout << 0 << endl;
    }
  } else {
    if (p.first) {
      bool valid = true;
      REP(i,n) if (w[i] <= 0) valid = false;
      if (valid) {
        cout << 1 << endl;
      } else {
        cout << 0 << endl;
      }
    } if ((p.second % 2) == 0) {
      vis2.assign(n, false);
      w[0] += p.second / 2;
      auto q = dfs2(g, vis2, w);
      if (q.first) {
        bool valid = true;
        REP(i,n) if (w[i] <= 0) valid = false;
        if (valid) {
          cout << 1 << endl;
        } else {
          cout << 0 << endl;
        }
        return 0;
      }
      vis2.assign(n, false);
      w[0] -= p.second;
      auto r = dfs2(g, vis2, w);
      if (r.first) {
        bool valid = true;
        REP(i,n) if (w[i] <= 0) valid = false;
        if (valid) {
          cout << 1 << endl;
        } else {
          cout << 0 << endl;
        }
        return 0;
      }
      cout << 0 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 16768
#include <cstdio>
#include <vector>
#include <iostream>
using namespace std;
int in(){ int a; scanf("%d",&a); return a; }
int main(){
	int n,S;
	while(n=in(),S=in(),(n||S)){
		int w[102]={},a[102]={};
		int ans = 0;
		for(int i = 0 ; i < n ; i++){int b; w[b=in()]++; a[b]++; }
		for(int i = 99 ; i >= 0 ; i--) w[i] += w[i+1];
		for(int i = 0 ; i <= 100 ; i++) if(2*i>S) ans+=a[i]*(a[i]-1)/2;
		for(int i = 1 ; i <= 100 ; i++) ans+=a[i]*w[max(i+1,S-i+1)];
		printf("%d%c",ans,10);
	}
}

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

int main(){
  int n;  string s;
  cin >> n >> s;
  int mx=0;
  for(int i=0;i<n-1;i++){
    int cnt=0;
    string f = s.substr(0,i+1);
    string b = s.substr(i+1,n-1-i);
    vector<char> c;
    rep(j,f.size()){
	  if( count(b.begin(),b.end(),f.at(j)) > 0  && count(c.begin(),c.end(),f.at(j)) == 0){
        cnt++;
        c.push_back(f.at(j));
      }
    }
    mx = max(mx,cnt);
  }
  cout << mx << endl;
  return 0;
}


Measured memory_bytes: 256
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll fastexp(ll x,ll a){
    ll res = 1;
    while(a>0){
        if(a&1){
            res = (res*x)%mod;
        }
        a=a>>1;
        x=(x*x)%mod;
    }
    return res;
}
ll inverse(ll n){
    return fastexp(n,mod-2);
}
template <typename T>
void add(T &a, T b){
	a += b;
	if(a >= mod)a -= mod;
}
template <typename T>
void sub(T &a, T b){
	a -= b;
	if(a < 0)a += mod;
}
template <typename T>
void mul(T &a, T b){
	a *= b;
	if(a > mod)a %= mod;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	// #ifndef ONLINE_JUDGE
 //    	freopen("input.txt", "r", stdin);
 //    	freopen("output.txt", "w", stdout);
	// #endif
	int k;
	cin>>k;
	// if(k <= 9){
	// 	cout<<k;
	// 	return 0;
	// }	
	k--;
	queue<ll> q;
	rep(i,9){
		q.push(i+1);
	}
	rep(i,k){
		ll x = q.front();
		q.pop();
		if(x%10 != 0){
			q.push(10*x + x%10 - 1);	
		}
		q.push(10*x + x%10);
		if(x % 10 != 9){
			q.push(10*x + x%10 + 1);
		}
	}
	ll x = q.front();
	cout<<x;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
      long long t=0,n,c,d,f,g,h,i,j,k,l,a1,a2,a3,b1,b2,b3;
     cin>>n;long long a[n];
     cin>>a[0];
     for(i=1;i<n;i++)
     {
         cin>>a[i];
         if(a[i]<a[i-1])
         {
             t+=(a[i-1]-a[i]);
             a[i]=a[i-1];
         }}
         cout<<t<<endl;

      return 0;
}


Measured memory_bytes: 5160
extern crate core;

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

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

fn run(input: String) -> String {
    input
        .split_whitespace()
        .skip(1)
        .map(|x| x.parse::<u64>().unwrap())
        .fold(None, |a, b| {
            Some(match a {
                None => b,
                Some(a) => lcm(a, b),
            })
        })
        .unwrap()
        .to_string()
}

fn gcd(a: u64, b: u64) -> u64 {
    let r = a % b;
    if r == 0 {
        b
    } else {
        gcd(b, r)
    }
}

fn lcm(a: u64, b: u64) -> u64 {
    a / gcd(a, b) * b
}

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

tests! {
    test1: "2
2
3" => "6",
    test2: "5
2
5
10
1000000000000000000
1000000000000000000" => "1000000000000000000",
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
signed main(){
    int a,b;cin >> a >> b;
    bool ok = true;
    if(a > 8 || b > 8)ok = false;
    if(ok)puts("Yay!");
    else puts(":(");
    


    return 0;
}

Measured memory_bytes: 256
def get_input():
    while True:
        try:
            yield ''.join(input())
        except EOFError:
            break

N = list(get_input())
for l in range(len(N)):
    a = float(N[l])
    s = a
    for i in range(2,11):
        if i % 2 == 0:
            a *= 2.0
            s += a
        else:
            a /= 3.0
            s += a
    print(s)



Measured memory_bytes: 5576
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const S = arg[1].split("");
    
    let left  = [];
    let right = [];
    
    for(let i in S) {
        if(S[i] === "(") {
            left.push(1);
        }
        
        if(S[i] === ")") {
            if(left.length) {
                left.pop();
            } else {
                right.push(1);
            }
        }
    }
    
    for(let i in right) {
        S.unshift("(")
    }
    
    for(let i in left) {
        S.push(")")
    }

    console.log(S.join(""));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
import java.util.*;

public class Main {

	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int z = sc.nextInt();
		int w = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = sc.nextInt();
		}
		if (n == 1) {
			System.out.println(Math.abs(arr[n - 1] - w));
		} else {
			System.out.println(Math.max(Math.abs(arr[n - 1] - w), Math.abs(arr[n - 1] - arr[n - 2])));
		}
	}
}


Measured memory_bytes: 27220
h,w = map(int,input().split())
m = [input() for _ in range(h)]
vx=[0,1,1,1,0,-1,-1,-1]
vy=[1,1,0,-1,-1,-1,0,1]
ans=[['#']*w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if m[i][j]=='#':
            ans[i][j]='#'
            continue
        count=0
        for k in range(8):
            ny=vy[k]+i
            nx=vx[k]+j
            if 0<=ny and ny<h and 0<=nx and nx<w:
                if m[ny][nx]=='#':
                    count+=1
        ans[i][j]=str(count)
for i in ans:
    print(''.join(i))


Measured memory_bytes: 9164
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<array>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


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


#define ARRAY_MAX 100005
const int INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

int dx4[4] = { 1,0,0,-1 };
int dy4[4] = { 0,1,-1,0 };
int dx2[2] = { 1,0 };
int dy2[2] = { 0,1 };

/******************************************************************************************/
typedef tuple<int,int,int> tpl;


//ユークリッド互除法
template<typename T>
T gcd(T x, T y) {

	if (y == 0) {
		return x;
	}
	else {
		return gcd(y, x % y);
	}
}


int main() {

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

    int n;
    cin >> n;
    cout << (n+1)/2 << endl;

	return 0;
}






Measured memory_bytes: 256