akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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;
}

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

  vector<string> s(N);
  vector<int> t(N);
  rep(i, N) {
    cin >> s[i] >> t[i];
  }
  string X;
  cin >> X;

  int start;
  rep(i, N) {
    if (s[i] == X)
      start = i;
  }

  int ans = 0;
  repp(i, start + 1, N - 1) {
    ans += t[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
    int n,k,i,t,ans=0;
    double p;
    scanf("%d%d",&n,&k);
    int a[n];
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    for(i=0;i<n;i++)
    {
        p=abs(k-a[i]);
        t=a[i]>p?p:a[i];
        ans+=t;
    }
    printf("%d",2*ans);
    return 0;
}


Measured memory_bytes: 128
import math
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

def swap(a,b):
    return (b,a)

def gcd(a,b): #最大公約数
    if (a<b):
        a,b = swap(a,b)
    if (b==0):
        return a
    else:
        return gcd(b,a%b)

def lcm(a,b): #最小公倍数
    return a/gcd(a,b)*b

def divisors(a): # 約数列挙
    divisors = []
    for i in range(1,int(a**0.5)+1):
        if a%i==0:
            divisors.append(i)
            if i!=a//i:
                divisors.append(a//i)
    return divisors

def is_prime(a): #素数判定
    if a<2:
        return False
    elif a==2:
        return True
    elif a%2==0:
        return False
    sqrt_num = int(a**0.5)
    for i in range(3,sqrt_num+1,2):
        if a%i==0:
            return False
    return True

def prime_num(a): #素数列挙
    pn = [2]
    for i in range(3,int(a**0.5),2):
        prime = True
        for j in pn:
            if i%j==0:
                prime = False
                break
        if prime:
            pn.append(i)
    return pn

def prime_fact(a): #素因数分解
    sqrt = math.sqrt(a)
    res = []
    i = 2
    if is_prime(a):
        res.append(a)
    else:
        while a!=1:
            while a%i==0:
                res.append(i)
                a //= i
            i += 1
    return res

def main():
    a,b = map(int,input().split())
    if a%3==0 or b%3==0 or (a+b)%3==0:
        print('Possible')
    else:
        print("Impossible")
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 39276
#include <bits/stdc++.h>
#define MaxSize 100005
using namespace std;

int main()
{
    int a, b;
    scanf("%d %d",&a,&b);
    if(a==b)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
 
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
 
mint dp[61][2][2][2];
 
int main() {
  ll l, r;
  cin >> l >> r;
  dp[60][0][0][0] = 1;
  for (int i = 59; i >= 0; i--) {
    int lb = l>>i&1;
    int rb = r>>i&1;
    rep(j,2)rep(k,2)rep(s,2) { // mae no joutai
      mint pre = dp[i+1][j][k][s];
      rep(x,2)rep(y,2) { // senni
        if (x && !y) continue; // x = 1, y = 0
        int nj = j, nk = k, ns = s; // next no joutai
        // tsugi dou naru?
        if (!s && x != y) continue;
        if (x && y) ns = 1;
        // j: L <= X
        if (!j && !x && lb) continue;
        if (x && !lb) nj = 1;
        // k: Y <= R
        if (!k && y && !rb) continue;
        if (!y && rb) nk = 1;
        //
        dp[i][nj][nk][ns] += pre;
      }
    }
  }
  mint ans;
  rep(j,2)rep(k,2)rep(s,2) ans += dp[0][j][k][s];
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e5+5;
int n,m,k,p,sum;
int a[N],bin[N];

inline bool jay(int i)
{
	if (a[i]+m<a[p]) return false;
	int last=k-(n-i+1);
	if (last<p) return true;
	int hh=bin[i-1]-bin[p-1];
	hh=((i-1)-p+1)*(a[i]+m)-hh;
	if (hh>=(k-(n-i+1)-(p-1))*m) return true;
	else return false;
}	

//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
inline int read()
{
    int ret=0,ff=1; char ch=getchar();
    while(!isdigit(ch)){if(ch=='-') ff=-ff;ch=getchar();}
    while(isdigit(ch)){ret=(ret<<3)+(ret<<1)+ch-'0';ch=getchar();}
    return ret*ff;
}

signed main(){
	//freopen("sequence.in","r",stdin);
	//freopen("sequence.out","w",stdout); 
	n=read(); m=read(); k=read(); p=read();
	for (register int i=1; i<=n; ++i) a[i]=read();
	sort(a+1,a+n+1);
	reverse(a+1,a+n+1);
	for (register int i=1; i<=n; ++i) bin[i]=bin[i-1]+a[i];
	int now=p+1;
	while (a[now]==a[p] && now<=n) 
	{
		now++; 
	}
	sum=now-1;
	
	int i=now;
	while (i<=n)
	{
		if (jay(i)) sum++;
		else break;
		int j=i+1;
		while (j<=n && a[j]==a[i]) sum++,j++;
		i=j; 
	}
	printf("%lld\n",sum);
return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        static int turn;

        static void Main(string[] args)
        {
            //[summary]D - String Formation
            var S = new StringBuilder(Console.ReadLine());
            int Q = int.Parse(Console.ReadLine());
            
            int turn = 0;

            var forward = new StringBuilder("");
            var back = new StringBuilder("");

            for (int i = 0; i < Q; i++)
            {
                var q = Console.ReadLine().Split(' ');

                if (q[0] == "1")
                {
                    turn++;
                }
                else
                {
                    var F = q[1];
                    var C = q[2];

                    //if (IsForward(F))
                    //{
                    //    //先頭に挿入
                    //    forward.Insert(0, C);
                    //}
                    //else
                    //{
                    //    //末尾に追加
                    //    back.Append(C);
                    //}

                    if (F == "1" && turn % 2 == 0)
                    {
                        forward.Append(C);
                    }
                    else if (F == "2" && turn % 2 == 1)
                    {
                        forward.Append(C);
                    }
                    else
                    {
                        back.Append(C);
                    }
                }
            }

            string ans = "";

            if (turn % 2 == 0)
            {
                ans = Reverse(forward) + S.ToString() + back.ToString();
            }
            else
            {
                ans = Reverse(back) + Reverse(S) + forward.ToString();
            }

            Console.WriteLine(ans);
        }

        static bool IsForward(string F)
        {
            if (F == "1" && turn % 2 == 0)
            {
                return true;
            }
            else if (F == "2" && turn % 2 == 1)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        static string Reverse(StringBuilder sb)
        {
            return String.Join("", sb.ToString().Reverse());
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var arr = line.Split(' ');

            return arr.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 18864
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String w = sc.next();
        Map<String,Integer> map = new HashMap<>();
        for(int i = 0; i < w.length(); i++) {
            String key = w.substring(i, i + 1);
            if(map.containsKey(key)) {
                map.put(key, map.get(key) + 1);
            }else {
                map.put(key, 1);
            }
        }
        for(Entry<String, Integer> entry : map.entrySet()) {
            if(entry.getValue() % 2 != 0) {
               System.out.println("No");
               return;
            }
        }
        System.out.println("Yes");
    }
}

Measured memory_bytes: 35616
#include <stdio.h>
#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

void visit(int);

int n,G[MAX][MAX],color[MAX],d[MAX],f[MAX],time;

void dfs(void){
  int u;
  for(u=0;u<n;u++){
    color[u] = WHITE;
  }
  time = 0;

  for(u=0;u<n;u++){
    if(color[u]==WHITE){
      visit(u);
    }
  }

  for(u=0;u<n;u++){
    printf("%d %d %d\n",u+1,d[u],f[u]);
  }
}

void visit(int u){
  int v;

  color[u] = GRAY;
  d[u] = ++time;
  for(v=0;v<n;v++){
    if(G[u][v]==WHITE){
      continue;
    }
    if(color[v]==WHITE){
      visit(v);
    }
  }
  color[u] = BLACK;
  f[u] = ++time;
}

int main(){
  int u,v,k,i,j;

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

  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      G[u][v] = 1;
    }
  }

  dfs();

  return 0;
}



Measured memory_bytes: 2048
#include <stdio.h>

int search(int key, int S[], int n);

int main(){
  int n,q,key,i=0,count=0;
    int S[10000];
    
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&S[i]);
    }
    i = 0;
    scanf("%d",&q);
    for(i=0;i<q;i++){
      scanf("%d",&key);
      if(search(key, S, n)){
	count++;
      }
    }
    printf("%d\n",count);
    
    return 0;
}

int search(int key, int S[], int n){
  int i = 0;
  S[n] = key;
  while(S[i]!=key){
    i++;
    if(i==n){
      return 0;
    }
  }
  return 1;
}



Measured memory_bytes: 2100
n = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(1,n-1) :
    if (p[i-1] < p[i] < p[i+1]) or \
       (p[i-1] > p[i] > p[i+1]) :
        ans += 1

print(ans)


Measured memory_bytes: 2940
import math
from collections import deque
from collections import defaultdict
import itertools as it

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	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 size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		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()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq
def get_sieve_of_eratosthenes(n):
	#data = [2]
	data = [0,0,0]
	for i in range(3,n+1,2):
		data.append(i)
		data.append(0)
	for i in range(len(data)):
		interval = data[i]
		if interval!=0:
			for j in range(i+interval,n-1,interval):
				data[j] = 0
	#ans = [x for x in data if x!=0]
	ans = data[:]
	return ans

def solve(n,k,a):
	for j in range(k):
		b = [0]*n
		for i in range(n):
			l = max(0, i-a[i])
			r = min(n-1, i+a[i])
			b[l]+=1
			if r+1<n: b[r+1]-=1
		for i in range(1,n):
			b[i]+=b[i-1]
		if a==b:
			break
		a = b[:]

	for i in range(len(b)):
		print(b[i],end=" ")

def main():
	n,k = readInts()
	a = readInts()
	solve(n,k,a)

if __name__=='__main__':
	main()

Measured memory_bytes: 158472
#include <bits/stdc++.h>
#define FOR(i,a,b)  for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n)    FOR(i,0,n)
#define RER(i,n)    FOR(i,0,(n+1))
#define pb          push_back
#define mp(a,b)     make_pair((a),(b))
#define mset(m,v)   memset(m,v,sizeof(m))
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pair<ll, ll> > vpll;
typedef vector<string> vs;
typedef long double ld;
const double EPS    = 1e-10;
const int INF       = 1e+9;
const double PI     = acos(-1);


auto main() -> int
{
    int c5 = 0, c7 = 0;
    REP(i, 3) {
        int a;
        cin >> a;
        if ( a == 5 ) {
            ++c5;
        } else if ( a == 7 ) {
            ++c7;
        }
    }

    if ( c5 == 2 && c7 == 1 ) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }


    return 0;
}



Measured memory_bytes: 256
n, m = map(int, raw_input().strip().split())

bulbs = []
for i in xrange(m):
    line = map(int, raw_input().strip().split())
    bulbs.append(line[1:])

p = map(int, raw_input().strip().split())

ans = 0
for i in xrange(1 << n):
    lit = 0
    for j in xrange(m):
        l = bulbs[j]
        on = 0
        for switch in l:
            switch -= 1
            if (i & (1 << switch)): on += 1
        if (on - p[j]) % 2 == 0:
            lit += 1
    if lit == m:
        ans += 1

print ans

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

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

constexpr ll MOD = 1e9+7;
constexpr int INF = 1<<30;
constexpr ll  LINF = 1LL<<60;

#define Sort(x) sort(x.begin(),x.end())
#define Reverse(x) reverse(x.begin(),x.end())
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ll<<(n))

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

// a = (a+b)%MOD;
void addmod(ll& a, ll b) {
  a = (a+b)%MOD;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// ========== end of template ==========
string S;
int N;
vi points;

int goRight(int x) {
  auto it = lower_bound(begin(points), end(points), x);
  auto p = *it;
  assert(p>=x);

  if ((p-x)%2==0) {
    return p;
  }
  return p+1;;
}

int goLeft(int x) {
  auto it = lower_bound(begin(points), end(points), x);
  it--;
  auto p = *it;
  assert(p<x);

  if ((x-p)%2==0) {
    return p;
  }
  return p+1;;
}

int main(int argc, char** argv) {
  cin >> S;
  N = S.size();

  vi ret(S.size());

  for (int i=0; i<N-1; i++) {
    if (S[i]=='R' && S[i+1]=='L') {
      points.push_back(i);
    }
  }

  for (int i=0; i<N; i++) {
    int z = 0;
    if (S[i]=='R') {
      z = goRight(i);
    } else {
      z = goLeft(i);
    }

    ret[z]++;
  }

  for (int i=0; i<N; i++) {
    cout << ret[i];
    if (i<N-1) {
      cout << " ";
    }
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 1232
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class A
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var ABC = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            Console.WriteLine(ABC.Distinct().Count());
        }
    }
}


Measured memory_bytes: 28288
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  if(abs(a-c)<=d){
    cout << "Yes";
  }else{
   	if(abs(a-b)<=d && abs(b-c)<=d){
      cout << "Yes"; 
    }else{
      cout << "No";
    }
  }
  return 0;
}

Measured memory_bytes: 256
A, B, C, D = gets.split(' ').map(&:to_i)
left = 0
right = 0
lcm = C.lcm(D)

# A < B
left  = (A - 1) - (((A - 1) / C) + ((A - 1) / D) - ((A - 1) / lcm))
right = B - ((B / C) + (B / D) - (B / lcm))

puts right - left

Measured memory_bytes: 1788
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://beta.atcoder.jp/contests/abc103/tasks/abc103_d

int main() {
    int N, M; cin >> N >> M;
    vector<P> p;
    REP(i, M) {
        int a, b; cin >> a >> b;
        p.push_back({b, a});
    }

    sort(p.begin(), p.end());

    int now = 0;
    int ans = 0;
    for (P t : p) {
        if (t.second >= now) {
            ans++;
            now = t.first;
        }
    }

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <array>
#include <vector>
#include <functional>
#include <unordered_map>
#include <map>
#include <numeric>
#include <limits>
#include <utility>
#include <queue>
#include <random>
using namespace std;

int main() {
	int n, x = 0, m = 0;
	string s;
	cin >> n;
	cin >> s;
	for (int i = 0; i < n;i++) {
		if(s[i] == 'I') x++;
		else x--;
		m = max(m,x);
	}

	cout << m << endl;
	return 0;
}

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

#define rand() ((rand()<<15)+rand())

using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;

template<typename Key, typename Value>
using hash_map = cc_hash_table<Key, Value>;
template<typename T, typename Cmp = less<T>>
using oset = tree<T, null_type, Cmp, rb_tree_tag, tree_order_statistics_node_update>;
*/
typedef long long lint;
typedef complex<double> point;

const int INF = 0x3f3f3f3f;
const lint INFL = 0x3f3f3f3f3f3f3f3fLL;
const double E = 1e-9, pi = 2 * acos(0);

template<typename T, typename U> void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> void amax(T &x, U y) { if (x < y) x = y; }

bool solve(int testNumber) {
	int n, k;
	if (!(cin >> n >> k)) {
		return false;
	}
	lint ans = 0;
	for (int b = k + 1; b <= n; b++) {
		int x = n / b, y = n % b;
		ans += x * (b - k) + max(y - k + 1, 0) - !k;
		//cout << b << ' ' << x * (b - k) << ' ' << max(y - k, 0) << endl;
	}
	cout << ans << endl;
	return true;
}

void init(const char *in = nullptr, const char *out = nullptr) {
	if (in) freopen(in, "r", stdin);
	if (out) freopen(out, "w", stdout);
	srand(unsigned((long long)new char));
}

int main() {
	ios_base :: sync_with_stdio(false);
	cin.tie(nullptr);
	init();
	for (int i=1; solve(i); i++);
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <list>
#define INF 10000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define DUMP(a) for(long long dump=0; dump<(ll)a.size(); dump++) { cout<<a[dump]; if(dump!=(ll)a.size()-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;
using namespace std;

int main(){
	int n;
	cin >> n;
	ll a[n];
	REP(i, n) cin >> a[i];
	if(a[n-1] != 2) cout << -1 << endl;
	else{
		int flag = 1;
		ll min = 2, max = 2;
		for(int i = n-1; i >= 1; i--){
			max += a[i];
			max = a[i-1] * (max / a[i-1] - 1 * (max % a[i-1] == 0));
			min = a[i-1] * (min / a[i-1] + 1 * (min % a[i-1] != 0));
			if(min > max) flag = 0;
		}
			max = a[0] - 1 + max;
		if(flag == 0) cout << -1 << endl;
		else cout << min << " " << max << endl;
	}
	return 0;
}


Measured memory_bytes: 1024
//g++ -Wshadow -Wall -O2 -Wno-unused-result -Wno-psabi
#include "bits/stdc++.h"
#define f first
#define s second
#define inf 1e18
#define ll long long
#define mod 1000000007
#define pb emplace_back
#define vll vector<long long int>
#define ull unsigned long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) ((long long int)(x).size())
#define mll map<long long int, long long int>
#define pll pair<long long int, long long int>
using namespace std;

string s;

void input(){
	cin >> s;
}

void solve(){
	if(s.back() == 's') cout << s << "es";
	else cout << s << "s";
	
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(20);
	ll t = 1;
	//cin >> t;
	while(t--){
		input();
		solve();
        cout<<endl;
	}
	cin.get();
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

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

	int N,M;
	cin >> N >> M;
	int c[31] = {};
	for(int i=0; i<N; i++){
		int K;
		cin >> K;
		for(int j=0; j<K; j++){
			int A;
			cin >> A;
			c[A]++;
		}
	}

	int ans = 0;
	for(int i=0; i<M; i++){
		if(c[i+1] == N) ans++;
	}
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
#define ff first
#define ss second
#define pb push_back
#define N 505


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin >> n;
	int h[n];
	for (int i = 0; i < n; ++i)
	{
		cin >> h[i];
	}

	int ans = 1, f = 0;
	for(int i = 1; i < n; ++i)
	{
		f = 1;
		for(int j = 0; j < i; ++j)
			if(h[i] < h[j])
				f = 0;
		if(f)
			ans++;
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
N, A, B = map(int, input().split())
 
# 完全に含まれる操作の回数はfloor(N/(A+B))
ans = (N // (A+B)) * A
res = N % (A+B)
# 不完全な操作は高々1回
# A>resなら、青色はres個で、res>=Aなら、青色はA個
ans += min(res, A)
 
print(ans)

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

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define INF (1 << 29)

using namespace std;

struct Tuple{
	int a, b, c, d;
};

vector<Tuple> T;
int n, m, q, ans = -INF; 

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

	for(int i = 0; i < q; i++){
		Tuple t;
		cin >> t.a >> t.b >> t.c >> t.d;
		T.pb(t);
	}
	
	vector<int> A(n + m - 1, 1);
	for(int i = 0; i < m - 1; i++) A[i] = 0;

	do{
		int zc = 0, sum = 0;
		vector<int> x;
		for(int i = 0; i < n + m; i++){
			if(A[i] == 0) zc++;
			else x.pb(zc + 1);
		}
/*		for(int i = 0; i < n; i++){
			cout << x[i] << " ";
		}
		cout << endl;*/
		for(int i = 0; i < q; i++){
			if(x[T[i].b - 1] - x[T[i].a - 1] == T[i].c) sum += T[i].d;
		}
		ans = max(ans, sum);
	}while(next_permutation(A.begin(), A.end()));

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

Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1000000007;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX*/                      int gcd(ll a,ll b){return b?gcd(b,a%b):a;}
/*"lcm"   MIN*/                      int lcm(ll a,ll b){return a*b/gcd(a,b);}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}

int main(){
    string s,t;
    cin >> s >> t;
    vector<int>ss(100,-1),gg(100,-1);
    for(int i=0;i<s.size();i++){
        int a = s.at(i)-'a',b=t.at(i)-'a';
        if(ss.at(a)!=-1||gg.at(b)!=-1){
            if(ss.at(a)!=b||gg.at(b)!=a){
                cout<<"No"<<endl;
                return 0;
            }
        }
        else {ss.at(a)=b;gg.at(b)=a;}
    }
    cout << "Yes"<<endl;
}



Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;

template <class T> using Vec = vector<T>;

/* 定数 */
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;

#define ALL(v) v.begin(), v.end()

#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

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

void Main() {
    u64 A, B;
    cin >> A >> B;
    for (int i = 1; i < 1010; i++) {
        if (floor(i * 0.08) == A && floor(i * 0.10) == B) {
            cout << i << endl;
            return;
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 256
arr = list(input())
tmp1 = arr[0]
tmp2 = arr[1]
 
i = 2
flg = True
if (tmp1 != tmp2):
    while i < len(arr):
        tmp3 = arr[i]
        if (tmp3 == tmp2):
            print(str(i) + " " + str(i + 1))
            flg = False
            break
        if (tmp3 == tmp1):
            print(str(i - 1) + " " + str(i + 1))
            flg = False
            break
 
        tmp1 = arr[i - 1]
        tmp2 = arr[i]
        i = i + 1
else:
    print("1 2")
    flg = False
 
if (flg):
    print("-1 -1")

Measured memory_bytes: 3956
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main(void){
    int a, b;
    cin >> a >> b;
    if(a > b){
        for(int i=0; i<a; i++){
            cout << b;
        }
        cout << endl;
    }else{
        for(int i=0; i<b; i++){
            cout << a;
        }
        cout << endl;
    }
    return 0;
}

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


using namespace std;

using ll   = long long;
using ii   = pair   < int , int >;
using i3   = pair   < int , ii  >;
using li   = pair   < ll  , int >;
using lii  = pair   < ll  , ii  >;
using pll  = pair   < ll  , ll  >;
using vi   = vector < int       >;
using vl   = vector < ll        >;
using vii  = vector < ii        >;
using vli  = vector < li        >;
using vpll = vector < pll       >;
using vi3  = vector < i3        >;
using vlii = vector < lii       >;


const int N = 2e5 + 5;
const ll INF = 1e17 + 7;
const double eps = 1e-9 , PI = acos(-1);



int n;
ll  m;
ll a[N];

void solve(int testCase){

    scanf("%d %lld" , &n , &m);
    ll lcm = 0;
    for(int i = 0 ; i < n ; i ++){
            scanf("%lld" , &a[i]);
            a[i] /= 2;

            if(i == 0)lcm = a[i];
            else {
                    lcm = lcm * a[i] / __gcd(lcm , a[i]);
            }

            if(lcm > m){
                    printf("0\n");
                    return;
            }
    }

    if(n == 1){
            printf("%lld\n" , (m / a[0] + 1ll) / 2);
            return;
    }

    for(int i = 0 ; i < n ; i ++){
            if((lcm / a[i]) %2 == 0){
                    printf("0\n"); return;
            }
    }


    printf("%lld\n" , (m / lcm + 1) / 2);
}

main(){

    int t = 1;
    // scanf("%d" , &t);

    for(int testCase = 1 ; testCase <= t ; testCase ++){
            solve(testCase);
    }

    return 0;
}


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

#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to));
#define sort(a) sort(a.begin(), a.end())

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

int main() {
  int x;
  cin >> x;
  if (x == 3 || x == 5 || x == 7) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<math.h>
#include<map>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>
// 追加１
#include <fstream>



using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 2019;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()



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

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

    reple(i, A, B)
    {
        if (i % K == 0)
        {
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<stdio.h>

#define nax 100009

int rec(int n,int k,int a[],int dp[],int pos){
	if(dp[pos]!=-1) return dp[pos];
	for(int i = 0 ; i < n;i++){
		if(pos-a[i]>=0){
			if(rec(n,k,a,dp,pos-a[i])==0){
				return dp[pos]=1;
			}
		}
	}
	return dp[pos] = 0;
}

int main(){
	int n,k,a[102];
	int dp[nax];

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

	//dp -> 1:Gano,0:Pierdo
	for(int i = 0 ; i <nax;i++){
		dp[i] = -1;
	}
	
	if(rec(n,k,a,dp,k)){
		//Gano
		printf("First");
	}else{
		printf("Second");
	}

	return 0;
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

constexpr ll INF = 1e18;

ll mul(ll x, ll y) {
  if ((double)x * y >= 1e18) return INF;
  return x * y;
}

void chmin(ll &x, ll y) {
  if (y >= INF) y = INF;
  x = min(x, y);
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int N; ll T; cin >> N >> T;
  vector<ll> A(N), B(N); rep(i, N) cin >> A[i] >> B[i];
  vector<ll> zero;
  vector<int> many;
  rep(i, N) {
    if (A[i] == 0) {
      zero.push_back(B[i]);
    } else {
      many.push_back(i);
    }
  }
  sort(range(many), [&](int i, int j) {
    return A[i] * (B[j] + 1) > A[j] * (B[i] + 1);
  });
  vector<ll> dp(50, INF);
  dp[0] = 0;
  for (int i : many) {
    repr(j, 50) if (dp[j] != INF) {
      chmin(dp[j + 1], mul(A[i], dp[j] + 1) + B[i] + dp[j] + 1);
    }
  }
  sort(range(zero));
  if (zero.size() > 0) {
    zero[0]++;
  }
  for (int i = 1; i < zero.size(); i++) {
    zero[i] += zero[i - 1] + 1;
    zero[i] = min(zero[i], INF);
  }
  ll ans = 0;
  rep(i, 50) if (dp[i] <= T) {
    // dp[i] + zero[j] <= T
    // zero[j] <= T - dp[i]
    ll c = upper_bound(range(zero), T - dp[i]) - zero.begin();
    ans = max(ans, i + c);
  }
  cout << ans << endl;
}

Measured memory_bytes: 5620
package main

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

type Scanner struct {

    reader *bufio.Reader
    buffer []string
    pointer int
}

func NewScanner() *Scanner {
    return &Scanner{
        reader: bufio.NewReaderSize(os.Stdin,4096),
        pointer: 0,
    }
}

func (self *Scanner) NextLine () string {
    var buffer []byte
    for {
        line,isPrefix,_ := self.reader.ReadLine()
        buffer = append(buffer, line...)
        if !isPrefix {
            break
        }
    }
    return string(buffer)
}

func (self *Scanner) Next () string {
    if self.pointer >= len(self.buffer) {
        line := self.NextLine()
        self.buffer = strings.Fields(line)
        self.pointer = 0
    }
    self.pointer++
    return self.buffer[self.pointer-1]
}

func (self *Scanner) NextInt () int {
    s := self.Next()
    i,_ := strconv.ParseInt(s,10,32)
    return int(i)
}

func (self *Scanner) NextLong () int64{
    s := self.Next()
    l,_ := strconv.ParseInt(s,10,64)
    return int64(l)
}

func (self *Scanner) NextFloat () float32 {
    s := self.Next()
    f,_ := strconv.ParseFloat(s,32)
    return float32(f)
}

func (self *Scanner) NextDouble () float64 {
    s := self.Next()
    d,_ := strconv.ParseFloat(s,64)
    return float64(d)
}

func Calc (array []int,mod int) int {
	length := len(array)

	ret := 0
	for i := 0; i < length; i++ {
		ret = (ret * 4 + array[i]) % mod
	}

	return ret
}

func min (a,b int) int { if a < b { return a } else { return b } }

func main () {
	cin := NewScanner()

	N := cin.NextInt();
    A := make([]int, N);
    for i := 0;i < N; i++ {
        A[i] = cin.NextInt();
    }

    ans := 1000000000;
	for i := 0; i < N; i++ {
        cnt := 0;
        for (A[i] & 1) == 0 && A[i] > 0 {
            A[i] /= 2;
            cnt++;
        }

        ans = min(ans,cnt);
	}

	fmt.Println(ans);
}

Measured memory_bytes: 640
S = input()

gu = ['R', 'U', 'D']
ki = ['L', 'U', 'D']
flag = True
for i, s in enumerate(S):
    if i%2==0:
        if s in gu:
            pass
        else:
            flag = False
            break
    else:
        if s in ki:
            pass
        else:
            flag = False
            break

if flag:
    print('Yes')
else:
    print("No")


Measured memory_bytes: 9052
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<set>
#include<map>
using namespace std;
 
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)
 
typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;
 
constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int gcd(int a, int b) {
    if (b==0) return a;
    return gcd(b, a%b);
}
 
int main() {
    int N,X; cin>>N>>X;
    int x[N+1]; REP(i,N) cin>>x[i];
    x[N] = X;
    sort(x,x+N+1);
    vector<int> v;
    REP(i,N) {
        v.push_back(x[N-i]-x[N-1-i]);
    }
    REP(i,v.size()) cerr<<v[i]<<endl;
    int tmp = v[0];
    REP(i,N-1) {
        tmp = gcd(v[i+1],tmp);
    }
    cout<<tmp<<endl;
}


Measured memory_bytes: 1276
using System;
namespace ConsoleApplication1{
    class Program{
        static void Main(string[] args){
            int[] prime = new int[100000];
            int ptr = 0;
            prime[ptr++] = 2;
            prime[ptr++] = 3;
            for (int i = 5; i <= 999999; i++) {
                Boolean flag = true;
                for (int j = 0; prime[j] <= Math.Sqrt(i); j++) {
                    if (i % prime[j] == 0) {
                        flag = false;
                        break;
                    }
                }
                if (flag) {
                    prime[ptr++] = i;
                }
            }
            String str;
            while ((str=Console.ReadLine())!=null) {
                int n = int.Parse(str);
                int count = 0;
                for (int i = 0; i<ptr;i++ ) {
                    if (prime[i] > n) {
                        break;
                    } else {
                        count++;
                    }
                }
                Console.WriteLine(count);
            }
        }
    }
}

Measured memory_bytes: 6004
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int h=scan.nextInt();
		int w=scan.nextInt();
		char map[][]=new char[h][w];
		for(int i=0;i<h;i++) {
			String str= scan.next();
			for(int j=0;j<w;j++) {
				map[i][j]=str.charAt(j);
			}
		}
		scan.close();
		for(int i=0;i<h;i++) {
			for(int j=0;j<w;j++) {
				if(map[i][j]=='#'){
					System.out.print('#');
				}else {
					int cnt=0;
					for(int k=-1;k<=1;k++) {
						for(int l=-1;l<=1;l++) {
							if(k==0&& k!=l ||k==-1&&i!=0 || k==1&&i!=h-1) {
								if(l==0&& k!=l || l==-1&&j!=0 || l==1&&j!=w-1) {
									if(map[i+k][j+l]=='#')cnt++;
								}
							}
						}
					}
					System.out.print(cnt);
				}
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 23636
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://arc076.contest.atcoder.jp/tasks/arc076_c>
 問題文============================================================
 すぬけ君は、パズルゲームで遊んでいます。
 このパズルゲームでは、R×C の長方形の盤面に、1 から N までの整数が 2 つずつ書かれています。
 整数 i が書かれている座標は、(xi,1,yi,1) と (xi,2,yi,2) です。
 
 すぬけ君の目的は、1 から N までのすべての整数に対し、同じ整数の書かれている座標同士を曲線で結ぶことです。
 このとき、曲線が長方形の外に出たり、互いに交わったりしてはいけません。
 
 このようなことが可能かどうか判定してください。
 =================================================================
 解説=============================================================
 ================================================================
 */

ll R,C,N;
ll p2d(ll x,ll y){
    if(x!=0 && x!= R && y!= 0 && y!= C) return -1;
    ll res = -1;
    if(x==0) res = y;
    else if(y==C) res = C+x;
    else if(x==R) res = C+R+(C-y);
    else if(y==0) res = C+R+C+(R-x);
    return res;
}
string solve(){
    cin >> R >> C >> N;
    vector<pll> ps;
    for(int i = 0; i < N;i++){
        ll x1,y1,x2,y2; cin >> x1 >> y1 >> x2 >> y2;
        ll d1 = p2d(x1,y1); if(d1 < 0) continue;
        ll d2 = p2d(x2,y2); if(d2 < 0) continue;
        if(d1 > d2) swap(d1,d2);
        ps.push_back({d1,d2});
    }
    sort(ps.begin(),ps.end());
    stack<ll> s;
    s.push(LINF);
    for(auto& p:ps){
        ll d1,d2; tie(d1,d2) = p;
        while(d1 >= s.top()) s.pop();
        if(d2 >= s.top()) return "NO";
        s.push(d2);
    }
    return "YES";
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 2420
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> VI;
typedef vector<long long int> VLLI;
typedef vector<pair<int, int> > VPI;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll, ll> PLL;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

int main() {
    int n, num;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> num;
        if (num%2 == 0) {
            if (num%3 != 0 and num%5 != 0) {
                cout << "DENIED" << "\n";
                return 0;
            }
        }
    }
    cout << "APPROVED" << "\n";
}



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

#define INF INT_MAX
#define UINF UINT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<pii> a;
    REP(i,n){
        int aa;
        cin >> aa;
        a.push_back(make_pair(aa,i));
    }

    sort(all(a));

    REP(i,n){
        cout << a[i].second + 1;
        if(i != n-1)cout << " "; 
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 1780
# python3

def whether_predict(s):
	w_list=["Sunny", "Cloudy", "Rainy"]
	num=w_list.index(s)
	predict_index= (num+1)%3
	return w_list[predict_index]

if __name__ == '__main__':
    input = input()
    print(whether_predict(input))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    long long arr[n+1];
    arr[0]=0;
    for(int i=1;i<=n;i++)
    cin>>arr[i];
    arr[0]=arr[1];
    long long dp[n+1];
    dp[0]=0;
    dp[1]=0;
    for(int i=2;i<=n;i++)
    dp[i]=min(dp[i-1]+abs(arr[i-1]-arr[i]),dp[i-2]+abs(arr[i-2]-arr[i]));
    cout<<dp[n];
}

Measured memory_bytes: 1792
def vec(s,t):
    return [t[0]-s[0], t[1]-s[1]]

def area(a,b):
    return a[0]*b[1] - a[1]*b[0]

while True:
    try:
        l = [float(x) for x in input().split()]

        a = [l[0],l[1]]
        b = [l[2],l[3]]
        c = [l[4],l[5]]
        p = [l[6],l[7]]

        x = area(vec(p,a),vec(p,b))
        y = area(vec(p,b),vec(p,c))
        z = area(vec(p,c),vec(p,a))

        if (x<0 and y<0 and z<0) or (x>0 and y>0 and z>0):
            print('YES')
        else:
            print('NO')
    except:
        break


Measured memory_bytes: 5592
data_setlist = []
while True:
    a, OP, b = map(str, input().split())
    if OP == "?":
        break
    data_setlist.append((a, OP, b))

for each_data in data_setlist:
    if each_data[1] == '+':
        print(int(each_data[0]) + int(each_data[2]))
    if each_data[1] == '-':
        print(int(each_data[0]) - int(each_data[2]))
    if each_data[1] == '*':
        print(int(each_data[0]) * int(each_data[2]))
    if each_data[1] == '/':
        if int(each_data[2]):
            print(int(int(each_data[0])/int(each_data[2])))



Measured memory_bytes: 5604