akhauriyash/Code-Regression huggingface dataset:
import sys,collections as cl,bisect as bs,math
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
  return list(map(int,input().split()))
def m(): #複数文字
  return map(int,input().split())
def onem(): #Nとかの取得
  return int(input())
def s(x): #圧縮
  a = []
  if len(x) == 0:
    return []
  aa = x[0]
  su = 1
  for i in range(len(x)-1):
    if aa != x[i+1]:
      a.append([aa,su])
      aa = x[i+1]
      su = 1
    else:
      su += 1
  a.append([aa,su])
  return a
def jo(x): #listをスペースごとに分ける
  return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
  return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def pow_k(x, n):
    ans = 1
    while n:
        if n % 2:
            ans *= x
        x *= x
        n >>= 1
    return ans
import fractions
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

"""
def nibu(x,n,r):
  ll = 0
  rr = r
  while True:
    mid = (ll+rr)//2

  if rr == mid:
    return ll
  if (ここに評価入れる):
    rr = mid
  else:
    ll = mid+1
"""

n = onem()
co = 0
for i in range(1,n+1):
  for j in range(1,n+1):
    for k in range(1,n+1):
      co += gcd_list([i,j,k])
print(co)



Measured memory_bytes: 73900
#coding:utf-8

EPS = 1e-3

class Point
	def initialize(args)
		@x,@y = args[0], args[1]
	end

	def x
		@x
	end
	def y
		@y
	end	
end


while !STDIN.eof? do
	str = gets.chomp.split(' ').map(&:to_f)
	#p str
	a = Point.new(str[0,2])
	b = Point.new(str[2,2])
	c = Point.new(str[4,2])
	p = Point.new(str[6,2])
	ab = Point.new([b.x-a.x,b.y-a.y])	
	bc = Point.new([c.x-b.x,c.y-b.y])	
	ca = Point.new([a.x-c.x,a.y-c.y])	
	ap = Point.new([p.x-a.x,p.y-a.y])	
	bp = Point.new([p.x-b.x,p.y-b.y])	
	cp = Point.new([p.x-c.x,p.y-c.y])	
	
	#外積を求める
	abap = ab.x*ap.y - ab.y*ap.x
	bcbp = bc.x*bp.y - bc.y*bp.x
	cacp = ca.x*cp.y - ca.y*cp.x
	
	if  abap==0 || bcbp==0 || cacp==0  then puts "NO"
	elsif abap*bcbp<0 || abap*cacp<0 || bcbp*cacp<0 then puts "NO"
	else puts "YES"
	end
	
end

Measured memory_bytes: 6164
N = list(map(int,input().split(" ")))
"""
for i in range(0,X+Y+1):
    for j in range(0,X+1):
        for k in range(0,Y+1):
            A2 = i/2
            B2 = i/2
            if A2+j == X and B2+k == Y:
                print(A*j+B*k+C*i)

"""
C = 0
ABC = N[0:3]
if ABC[2] != max(ABC) and abs(min(ABC) - ABC[2]) < abs(max(ABC) - ABC[2]):
    R = []
    AB = N[3]+N[4]+(abs(N[3]-N[4]))
    for i in range(AB+1):
        C=0
        A = i/2
        B = i/2
        C+=ABC[2]*i
        if A % 1 == 0.0 and B % 1 == 0.0:
            if N[3] > int(A) and (N[3]-A)*ABC[0] >= 0:
                C+=(N[3]-int(A))*ABC[0]
                A+=N[3] - int(A)
            if N[4] > int(B) and (N[4]-B)*ABC[1] >= 0:
                C+=(N[4]-int(B))*ABC[1]
                B+=N[4] - int(B)
            if A >= N[3] and B >= N[4]:
                R.append(C)
    print(int(min(R)))
else:
    print(ABC[0]*N[3]+ABC[1]*N[4])


Measured memory_bytes: 7040
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,s=0;
    cin>>n;
    int x[n];
    for(int i=0;i<n;i++)
    {
        cin>>x[i];
        s+=x[i];
    }
    sort(x,x+n);
    s-=x[n-1];
    if(x[n-1]<s)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


}


Measured memory_bytes: 256
#include<stdio.h>
 
int hantei(char x[], char y[]) {
  int xn = 0, yn = 0, flag = 0, i, j, max = 0;
  int c[1001][1001];
   
  while (flag == 0)
  {
    if (x[xn] != '\0')
    {
      xn++;
    }
    else
    {
      flag = 1;
    }
  }
   
  flag = 0;
   
  while (flag == 0)
  {
    if (y[yn] != '\0')
    {
      yn++;
    }
    else
    {
      flag = 1;
    }
  }
  for (i = 1; i < xn + 1; i++) c[i][0] = 0;
  for (j = 1; j < yn + 1; j++) c[0][j] = 0;
   
  for (i = 1; i < xn + 1; i++)
  {
    for (j = 1; j < yn + 1; j++)
    {
      if (x[i - 1] == y[j - 1])
      {
        c[i][j] = c[i - 1][j - 1] + 1;
      }
      else if (c[i - 1][j] >= c[i][j - 1])
      {
        c[i][j] = c[i - 1][j];
      }
      else
      {
        c[i][j] = c[i][j - 1];
      }
      if (max < c[i][j]) max = c[i][j];
    }
  }
   
  return max;
}
 
int main(void) {
  char x[1000], y[1000];
  int q, i;
   
  scanf("%d", &q);
   
  for (i = 0; i < q; i++)
  {
    scanf("%s", x);
    scanf("%s", y);
    printf("%d\n", hantei(x, y));
  }
   
  return 0;
}

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

using namespace std;


int main()
{
	int n;
	string s;
	string t;
	cin >> n >> s >> t;
	int res = 2 * n;
	int point = 0;
	bool flag = true;
	for(int i = 0 ; i < n ; i++)
	{
		for(int j = 0 ; j < n-i ; j++)
		{
			if(s[i+j] != t[j])
			{
				flag = false;
			}
			
		}
		if(flag)
		{
			point = i;
			break;
		}
		flag = true;
	}

	if(point == 0)
	{
		if(s[0]!=t[0])
		{
			cout << res;
		}
		else
		{
			cout << n;
		}
	}
	else
	{
		cout << res-(n-point);
	}
	return 0;
}
//s.earase(s.beigin()+makan)

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

class UnionFind {
    int n;
    vector<int> uni;
    int forest_size;
public:
    explicit UnionFind(int n) : n(n), uni(static_cast<u32>(n), -1), forest_size(n) {};

    int root(int a){
        if (uni[a] < 0) return a;
        else return (uni[a] = root(uni[a]));
    }

    bool unite(int a, int b) {
        a = root(a);
        b = root(b);
        if(a == b) return false;
        if(uni[a] > uni[b]) swap(a, b);
        uni[a] += uni[b];
        uni[b] = a;
        forest_size--;
        return true;
    }
    int size(){ return forest_size; }
    int size(int i){ return -uni[root(i)]; }
    bool same(int a, int b) { return root(a) == root(b); }
};

int main() {
    int n;
    cin >> n;
    vector<pair<int, int>> A(n), B(n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &A[i].first);
        A[i].second = i;
    }
    for (int i = 0; i < n; ++i) {
        scanf("%d", &B[i].first);
        B[i].second = i;
    }

    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    UnionFind uf(n);
    int ok = 0;
    for (int i = 0; i < n; ++i) {
        uf.unite(A[i].second, B[i].second);
        if(i && A[i].first <= B[i-1].first){
            ok = 1;
        }
        if(A[i].first > B[i].first){
            puts("No");
            return 0;
        }
    }
    puts(uf.size() == 1 && !ok ? "No" : "Yes");
    return 0;
}

Measured memory_bytes: 2176
#include <iostream>

using namespace std;

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


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

int main()
{
    int n,h,w;cin>>n>>h>>w;
    int ans = 0;
    for(int i = 0;i < n;i++){
        int a,b;cin>>a>>b;
        if(a >= h && b >= w) ans++;
    }
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>> n;
  int n1 = n%10;
  n/=10;
  int n2 = n%10;
  n/=10;
  int n3 = n%10;
  n/=10;
  int n4 = n%10;
  if(n1==n2&&n2==n3||n2==n3&&n3==n4){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }



}


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

#define int long long

signed main() {
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());
    if(s<t) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define ll long long 
# define skorost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 

using namespace std ;
 
ll z , o , ans ;

int N = 1e4 + 15820 ;

int main(){ skorost ;

	string s , t ;

	cin >> s >> t ;

	if( s.size() >= t .size()){

		cout << "No" << endl ;

		return 0 ;

	}

	int u =0 ;

	for( int i = 0 ; i < s.size() ; i ++ ){

		if( s[i] != t[i] ){

			u ++ ;

		}

	}

	if( u > 0 ){

		cout << "No" << endl; 

		return 0 ;

	}

	else{

		cout << "Yes"<< endl ;

	}

}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define ll long long int
#define fin for(i=0;i<n;i++)
#define vec vector<ll>
#define pb push_back
#define vecit vector<ll>::iterator
#define vecp vector<pair<ll,ll> >
#define vecpit vector<pair<ll,ll> >::iterator
#define mapp map<ll,ll>
#define mapr map<ll,pair<ll,ll> >
#define maprit map<ll,pair<ll,ll> >::iterator
#define mapit map<ll,ll>::iterator
#define mod1 1000000007
#define INF 10000000000
using namespace std;
/*ll od(ll i,ll j, vec v)
{
    if(i>j)
        return 0;
     if(i==j)
        return v[i];
    ll p=v[i];
    ll q=v[j];
    ll r=od(i+1,j-1,v);
    return (max(p,q)+min(min(p,q),r)-max(min(p,q),r));
}
ll ev(ll i,ll j,vec v)
{
    ll p,q;
    p=v[i]-od(i+1,j,v);
    q=v[j]-od(i,j-1,v);
    cout<<p<<q<<"\n";
    return max(p,q);
}*/
vector<vec >dp(3005,vec (3005,0));
ll od( vec v)
{
    ll i,j,k,l,n;
    n=v.size();
    for(i=n-1;i>=0;i--)
    {
        for(j=i;j<n;j++)
        {
            if(i==j)
                dp[i][j]=v[i];
            else
            dp[i][j]=max(v[i]-dp[i+1][j],v[j]-dp[i][j-1]);
        }
    }
    return dp[0][n-1];
}
int main()
{
    ll n;
    cin>>n;
    ll i,j,k,l;
    vec v;
    fin
     {
         cin>>j;
         v.pb(j);
     }

        k=od(v);
     cout<<k;
}


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

#define NL '\n'
#define C char
#define D double
#define F float
#define S string
#define sz(x) x.size()
#define INF LONG_LONG_MAX
#define PI (2.0*acos(0.0))
#define sfi(x) scanf("%d",&x)
#define sfi2(x,y) scanf("%d %d",&x,&y)
#define sfi3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sfl(x) scanf("%lld",&x)
#define sfl2(x,y) scanf("%lld %lld",&x,&y)
#define sfl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sfd(x) scanf("%lf",&x);
#define max3(a,b,c) max(a,max(b,c))
#define max4(a,b,c,d) max(max3(a,b,c),d)
#define min3(a,b,c) min(a,min(b,c))
#define min4(a,b,c,d) min(a,min3(b,c,d))
#define mem(ara,val) memset(ara,val,sizeof(ara))
#define READ freopen("input.txt","r",stdin)
#define WRITE freopen("output.txt","w",stdout)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;

/*LL gcd(LL a,LL b)
{
    if(b==0)
        return a;
    else
        return gcd(b,a%b);
}
LL lcm(LL a,LL b)
{
    return a/gcd(a,b)*b;
}*/


int main()
{
    int n;
    cin>>n;
    int arr[n];
    for(int i=0; i<n; i++)
        cin>>arr[i];
    sort(arr,arr+n);

    bool flag = false;
    for(int i=1; i<n; i++)
    {
        if(arr[i]==arr[i-1])
        {
            flag = true;
            break;
        }
    }

    if(!flag) cout<<"YES";
    else cout<<"NO";
}


Measured memory_bytes: 1152
program kadai
implicit none
real(8),parameter  ::  EPS=10e-8
integer  ::  n,m
integer,allocatable  ::  x(:,:)
real(8)  ::  ans
integer  ::  a
integer  ::  number
integer  ::  i,j,k

read(*,*) n,m
allocate(x(n,m))

do i=1,n
    read(*,*) x(i,:)
end do
number=0

do i=1,n-1
    do j=i+1,n
        ans=0
        do k=1,m
            ans=ans+(x(i,k)-x(j,k))**2
        end do
        a=sqrt(ans)
!write(*,*) ans,a,number
        if (abs(real(a*a,8)-ans)<EPS) then
            number=number+1
        end if
       ! write(*,*) ans,a,number
    end do
end do

write(*,*) number


stop

end program kadai


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
typedef long long ll;

using namespace std;

int main() {
    int n;
    cin >> n;
    
    vector<int> v(n);
    for(int i = 0; i < n; i++) {
        cin >> v[i];
    }
    
    int ans = 0;
    int cnt = 1;
    for(int i = 0; i < n; i++) {
        if(v[i] == cnt) {
            cnt++;
        }
        else {
            ans++;
        }
    }
    
    if(cnt == 1) {
        cout << -1 << endl;
    }
    else {
        cout << ans << endl;
    }
    return 0;
}



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


class Node{
  long long int counter;
  vector<Node*> children;
  public:
  Node(): counter(0), children({}){

  }
  void add_child(Node* child){
    this->children.push_back(child);
  }

  void count_up(int val){
    this->counter+=val;
  }

  long long int get_counter(){
    return this->counter;
  }

  void flow(int val){
    this->counter += val;
    for(auto& child : this->children){
      child->flow(this->counter);
    }
  }
};

int main(){
  int N, Q;
  cin >> N >> Q;
  vector<Node> nodes(N);

  for(int ii=0; ii<N-1; ii++){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    nodes[a].add_child(&nodes[b]);
  }

  for(int ii=0; ii<Q; ii++){
    int p, x;
    cin >> p >> x;
    p--;
    nodes[p].count_up(x);
  }

  nodes[0].flow(0);

  for(int ii=0; ii<N; ii++){
    if(ii!=0) cout << " ";
    cout << nodes[ii].get_counter();
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 20096
def func():
    N, K = map(int, input().split())
    S = input()

    happy = 0

    for i in range(N-1):
        if S[i] == S[i + 1]:
            happy += 1

    happy += K * 2
    happy = min(happy, N-1)

    print(happy)

if __name__ == '__main__':
    func()


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

int main(void){

  char s[4];
  scanf("%s", s);
  if (strlen(s) == 2) {
    printf("%s\n", s);
  } else {
    printf("%c%c%c\n", s[2], s[1], s[0]);
  }

  return 0;
}

Measured memory_bytes: 128
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define ll long long
#define lson rt << 1
#define rson rt << 1 | 1
#define N 300010
#define M 1010

using namespace std;
int n, k, a[N], dp[N];
struct node {
	int sum;
}tree[N << 2];

int read() {
	int s = 0, f = 0; char ch = getchar();
	while (!isdigit(ch)) f |= (ch == '-'), ch = getchar();
	while (isdigit(ch)) s = s * 10 + (ch ^ 48), ch = getchar();
	return f ? -s : s;
}

void push_up(int rt) {
	tree[rt].sum = max(tree[lson].sum, tree[rson].sum);
}

void build(int rt, int l, int r) {
	tree[rt].sum = 0;
	if (l == r) return;
	int mid = (l + r) >> 1;
	build(lson, l, mid), build(rson, mid + 1, r);
	push_up(rt);
}

void change(int rt, int c, int l, int r, int pos) {
	if (l == r) {
		tree[rt].sum = c;
		return;
	}
	int mid = (l + r) >> 1;
	if (pos <= mid) change(lson, c, l, mid, pos);
	else change(rson, c, mid + 1, r, pos);
	push_up(rt);
}

int query(int rt, int l, int r, int L, int R) {
	if (L <= l && r <= R) return tree[rt].sum;
	int mid = (l + r) >> 1, ans = 0;
	if (L <= mid) ans = max(ans, query(lson, l, mid, L, R));
	if (R > mid) ans = max(ans, query(rson, mid + 1, r, L, R));
	return ans;
}

int main() {
	n = read(), k = read();
	int m = 0;
	for (int i = 1; i <= n; i++) a[i] = read(), m = max(a[i] + 1, m);
	build(1, 1, m);
	for (int i = 1; i <= n; i++) {
		dp[i] = query(1, 1, m, max(a[i] - k, 1), min(a[i] + k, m)) + 1;
		change(1, dp[i], 1, m, a[i]);
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) ans = max(ans, dp[i]);
	cout << ans << "\n";
}

Measured memory_bytes: 10072
//Tonight's the night and it is going to happen again and again.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define T ll t; cin>>t; while(t--)
#define mod 1000000007
#define f(n) for(ll i = 0;i<n;i++)
#define endl "\n"
ll gcd(ll a,ll b){if(b==0){return a;}return gcd(b,a%b);}
int main()
{
   ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   ll n;cin>>n;ll dp[n+1][n+1];memset(dp,0,sizeof(dp));ll sum=0;
   ll a[n];f(n){cin>>a[i];sum+=a[i];}
   for(ll i=n-1;i>=0;i--)
   {
     for(ll j=i;j<n;j++)
     {
     	if(i==j){dp[i][j]=a[i];}
     	else{
      dp[i][j]=max(a[i]-dp[i+1][j],a[j]-dp[i][j-1]);}//segmwnt can be represented by
      //2 states.
     }
   } 
   cout<<dp[0][n-1]; 
}


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

int main(){
	int k, s;
	cin >> k >> s;
	
	long long ans = 0;
	for(int i = 0; i <= k; i++){
		for(int j = 0; j <= k; j++){
			if(s >= i + j && s - i - j <= k){
				ans++;
			}
		}
	}
	
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int main()
{
    vector<vector<int>> a(3,vector<int> (3)),data(3,vector<int> (3));
    rep(i,3) rep(k,3) cin>>a[i][k];
    int n,ans=0;
    cin>>n;
    rep(j,n)
    {
        int b;
        cin>>b;
        rep(i,3) rep(k,3)
        {
            if(a[i][k]==b)
            {
                data[i][k]=1;
                break;
            }
        }
    }
    if(data[0][0]==1&&data[0][1]==1&&data[0][2]==1) ans++;
    if(data[1][0]==1&&data[1][1]==1&&data[1][2]==1) ans++;
    if(data[2][0]==1&&data[2][1]==1&&data[2][2]==1) ans++;
    if(data[0][0]==1&&data[1][0]==1&&data[2][0]==1) ans++;
    if(data[0][1]==1&&data[1][1]==1&&data[2][1]==1) ans++;
    if(data[0][2]==1&&data[1][2]==1&&data[2][2]==1) ans++;
    if(data[0][0]==1&&data[1][1]==1&&data[2][2]==1) ans++;
    if(data[0][2]==1&&data[1][1]==1&&data[2][0]==1) ans++;
    if(ans>0)cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3612
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n ;
    cin >>  n ;
  
    vector<int> a(n) ;
    for(int i=0;i<n;i++){
      cin >> a.at(i)  ;
    }
 
  int count ;
  count = 0 ;
  
  for(int i=0;i<n;i++){
    while(a.at(i)%2==0){
        a.at(i) /= 2 ; 
        count ++ ;
  }
     }
  
  cout << count << endl ;
    return 0;
}



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

//int N,v[21],c[21];
int N;

int main() {
  cin >> N;
  // for(int i=0;i<N;i++) cin >> v[i];
  // for(int i=0;i<N;i++) cin >> c[i];
  vector<int> v_list(N);
  vector<int> c_list(N);
  // v_list.resize(N);
  // c_list.resize(N);
  for(int i=0;i<N;i++) { cin >> v_list[i]; }
  // cout << "v_list.size()=" << v_list.size() << "\n";
  for(int i=0;i<N;i++) { cin >> c_list[i]; }
  // cout << "c_list.size()=" << c_list.size() << "\n";

  int ans = 0;
  for (int i=0; i< (1 << N); ++i) {
    int tmp = 0;
    for (int j=0; j<N ; ++j) {
      if (i & (1<<j)) {
        // cout << "j=" << j << ",";
        tmp = tmp + v_list[j] - c_list[j];
      }
    }
    if (tmp > ans) ans = tmp;
    // cout << bitset<5>(i) << "," << tmp << "\n";
  }
  cout << ans << "\n" ;


#if 0
  cout << N << "\n";
  //for(int i=0;i<N;i++) cout << v[i] << " " ;
  for (auto t_v : v_list) cout << t_v << " " ;
  cout << "\n";
  //for(int i=0;i<N;i++) cout << c[i] << " " ;
  for (auto t_c : c_list) cout << t_c << " " ;
  cout << "\n";
#endif
  return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
h = list(map(int, input().split()))
hc = h.copy()

t = [0]*m
for j in range(m):
    t[j] = tuple(map(int, input().split()))

count = 0

for i in range(m):
    if h[t[i][0]-1] > h[t[i][1]-1]:
        hc[t[i][1]-1] = 0
    elif h[t[i][0]-1] < h[t[i][1]-1]:
        hc[t[i][0]-1] = 0
    else:
        hc[t[i][0]-1] = 0
        hc[t[i][1]-1] = 0

for i in range(n):
    if hc[i] == 0:
        continue
    else:
        count += 1

print(count)


Measured memory_bytes: 87860
#include <bits/stdc++.h>
using namespace std;
int get(int x){
    int ans = 0 ;
    while(x!=0){
        ans += x%10 ;
        x/=10;
    }
    return ans ;
}
int main(){
    int n , a , b ;
    cin >> n >> a >> b ;
    long long ans = 0 ;
    for(int i=1;i<=n;i++){
        int x = get(i);
        if ( x >= a && x <= b ){
            ans += i ;
        }
    }
    cout << ans << endl;


    return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX 2005
#define ll long long
#define upperlimit 1000100
#define INF 1e18
#define eps 1e-8
#define endl '\n'
#define pcc pair<char,char>
#define pii pair<ll,ll>
#define pll pair<ll,ll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define MOD 1000000007
#define slld(t) scanf("%lld",&t)
#define sd(t) scanf("%d",&t)
#define pd(t) printf("%d\n",t)
#define plld(t) printf("%lld\n",t)
#define mp(a,b) make_pair(a,b)
#define FF first
#define SS second
#define pb(x) push_back(x)
#define vi vector<int>
#define clr(a) memset(a,0,sizeof(a))
#define debug(a) printf("check%d\n",a)
#define csl ios::sync_with_stdio(false);cin.tie(0);
#define INT_SIZE 32
using namespace std;

ll gcd(ll n1,ll n2){
	if(n1%n2==0)return n2;
	return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent)
{
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%MOD;
		base=(base*base)%MOD;
		exponent/=2;
	}
	return ans;
}
int arr[MAX],n;
int ans[MAX][MAX];
int msis[MAX][MAX],msis2[MAX][MAX];
int pre[MAX];
int len[MAX][MAX];
void maxSumIS(int x)
{
    int i, j, max = 0;

    for ( i = x; i < n; i++ )
        msis[x][i] = arr[i];
    for ( i = x+1; i < n; i++ )
        for ( j = x; j < i; j++ )
            if ( arr[i] > arr[j] && msis[x][i] < msis[x][j] + arr[i])
                msis[x][i] = msis[x][j] + arr[i];

    for ( i = x; i < n; i++ )
    {
    	ans[x][i]=ans[x][i-1];
        if ( ans[x][i] < msis[x][i] )
            ans[x][i] = msis[x][i];
    }
}
int main()
{
	ll x;
	cin>>x;
	ll ans=x/11;
	ans*=2LL;
	ll rem=x%11;
	if(rem!=0&&rem<=6)
        ans++;
    else if(rem!=0)
        ans+=2;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
def median(array):
    tmp = sorted(array)
    if len(array) % 2:
        return tmp[len(array)//2]
    else:
        return (tmp[len(array)//2] + tmp[len(array)//2 - 1]) / 2


[n], *x = [[*map(int, t.split())] for t in open(0)]
a, b = zip(*x)
if n % 2 == 0:
    print(int(2*(median(b) - median(a)) + 1))
else:
    print(median(b) - median(a) + 1)


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

int main()
{
	int number;
	int score, sum, max, min;
	
	while(true)
	{
		cin >> number;
		if(!number) return 0;
		sum = 0, max = 0, min = 1000;
		for(int i = 0; i < number; ++i)
		{
			cin >> score;
			sum += score;
			if(score > max) max = score;
			if(score < min) min = score;
		}
		cout << (sum - max - min) / (number - 2) << endl;
	}
}

Measured memory_bytes: 0
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
int T[1000], A[1000];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N) cin >> T[i] >> A[i];
  long long a = T[0], b = A[0];
  for (int i=1; i<N; i++) {
    long long x = max((a+T[i]-1)/T[i], (b+A[i]-1)/A[i]);
    a = x*T[i], b = x*A[i];
  }
  cout << a+b << "\n";
  return 0;
}


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

int solve(int n,vector<ll> &x,vector<ll> &y){
    int cnt0 = 0,p,q,cnt;
    for(int i = 0;i < n;i ++){
        for(int j = i+1;j < n;j ++){
            p = x[i]-x[j];
            q = y[i]-y[j];
            cnt = 0;
            for(int k = 0;k < n;k ++){
                for(int l = 0;l < n;l ++){
                    if(x[k]-x[l]==p && y[k]-y[l]==q) cnt ++;
                }
            }
            cnt0 = max(cnt0,cnt);
        }
    }
    return n-cnt0;
}

int main(){
    int n;
    cin >> n;
    vector<ll> x(n),y(n);
    for(int i = 0;i < n;i ++){
        cin >> x[i] >> y[i];
    }
    cout << solve(n,x,y) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
typedef long long ll;
int main(){
	string s;
	cin >> s;
	int l = s.size();
	map<char,int> m;
	m['S']=m['N']=m['W']=m['E']=0;
	rep(i,l){
		m[s[i]]=1;
	}

	if ((m['S']^m['N'])||(m['W']^m['E'])){
		cout << "No" << endl;
	}
	else cout << "Yes" << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
    return (a/GCD(a,b))*b;   //先にGCDで割ることで、overflow防止
}

bool IsPrime(long long num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main() {
    ll A,B;
    cin >> A >> B;
    ll G = GCD(A,B);
    vector<ll> vec; //公約数のリスト
    for (ll i = 1;i*i<=G;i++) {
        if (G%i==0) {
            vec.push_back(i);
            vec.push_back(G/i);
        }
    }
    ll cnt = 0;
    for (ll i = 0;i<vec.size();i++) {
        if (IsPrime(vec.at(i))) {
            cnt++;
        }
    }
    cnt++;
    cout << cnt << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
#define ff first
#define ss second
#define ll long long
#define pq priority_queue
#define mii map<int,int>
 
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef set<int> si;
typedef vector<vi> vii;
typedef vector<ii> vpi;
typedef vector<ll> vll;
int oo = (1e9) + 7;
 
string s;
int d;
int tb[10005][105][2];
vi num;
 
int dp(int i, int n, int f) {
    if(i == (int)s.size() and n == 0) return 1;
    if(i == (int)s.size()) return 0;
    if(tb[i][n][f] != -1) return tb[i][n][f];
 
    int limit = f == 0 ? num[i] : 9;
    // Se o número formado já é menor que a entrada, podemos colocar qualquer dígito.
 
    int ans = 0;
    for(int dgt = 0; dgt <= limit; dgt++)
    {
        if(f == 0 and dgt < limit) ans = ans%oo + dp(i+1, (n%d+dgt%d)%d, 1)%oo;
        else if(f == 0 and dgt == limit) ans = ans%oo + dp(i+1, (n%d+dgt%d)%d, 0)%oo;
        if(f == 1) ans = ans%oo + dp(i+1, (n%d+dgt%d)%d, f)%oo;  
    }
    tb[i][n][f] = ans % oo;
    return ans % oo;
}
 
int main() {
    cin >> s >> d;
 
   
    for(size_t i = 0; i < s.size(); i++)
    {
        num.push_back(s[i] - '0');
    }
   
    memset(tb, -1, sizeof tb);
    printf("%d\n", (dp(0, 0, 0)+oo-1) % oo);
 
    return 0;
}


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

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    int ans;
    
    if (x < y) {
        cout << 0 << endl;
        return 0;
    }
    
    x -= z;
    ans = x / (y + z);
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;
int main(){
    int n,l,sum,abs_min;

    cin>>n>>l;
    abs_min=abs(n)+abs(l);
    sum=0;
    for(int i=0; i<n; i++){
        //cout<<"l+i : "<<l+i<<endl;
        sum+=l+i;
        if(abs(abs_min)>abs(l+i)){
            abs_min=l+i;
            //cout<<"abs_min : "<<abs_min<<endl;
        }
    }
    //cout<<abs_min<<endl;
    cout<<sum-abs_min<<endl;

    return 0;
}

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

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define int long long

using namespace std;

using P = pair<int, int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

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

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const long long MOD=1e9+7;

signed main(){
	int n;
	cin>>n;
	string s[110000];
	int t[100];
	rep(i,n)cin>>s[i]>>t[i];
	string x;
	cin>>x;
	int m;
	rep(i,n)if(s[i]==x)m=i;
	int ans=0;
	rep(i,m+1,n)ans+=t[i];
	cout<<ans<<endl;
}

Measured memory_bytes: 1152
//**KEEP IT SHORT AND SIMPLE**

#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FILES freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define REP(i,a,b) for (int i = a; i < b; i++)
#define NL '\n'
#define F first
#define S second
#define dot(a, b) (conj(a) * (b)).real()
#define cross(a, b) (conj(a)* (b)).imag()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef bool bl;
typedef vector < vector<long long> > vvl;
typedef vector <long long> vll;
typedef pair <long long, long long> pll;
typedef map <long long, long long> mll;
typedef map <long long, bool> mlb;
typedef priority_queue<long long, vector<long long>, greater<long long> > minPq;
typedef tuple<ll, ll, ll> line;
typedef complex<double> point;
const double pi = 2 * acos(0.0);
const int OO = 0x3f3f3f3f;
int main()
{
    IO
    ll n, k;
    cin >> n >> k;
    ll h[n], ans[n];
    REP(i, 0, n)    cin >> h[i];
    ans[0] = 0;
    REP(i, 1, n)
    {
        ll Min = 1e18;
        REP(j, max(i - k, ll(0)), i)
            Min = min(Min, abs(h[j] - h[i]) + ans[j]);
        ans[i] = Min;
    }
    cout << ans[n - 1];
    return 0;
}


Measured memory_bytes: 1792
n, m = gets.split.map(&:to_i)
multiple_array = n.times.map {gets.split.map(&:to_i)}.sort_by! { |a, b| a }
ans = 0

multiple_array.each do |a, b|
  buy = 0
  if m >= b
    ans += a * b
    m -= b
  else
    ans += a * m
    m = 0
  end
  break if m == 0
end

puts ans

Measured memory_bytes: 12664
fn main() {
    let (n, m): (usize, usize) = (read::<usize>(), read::<usize>());
    let mut arr = vec![vec![]; n];
    let mut yarr = vec![];
    let mut parr = vec![];
    for _ in 0..m {
        let (p, y) = (read::<usize>(), read::<usize>());
        yarr.push(y);
        parr.push(p);
        arr[p - 1].push(y);
    }
    for i in 0..n {
        arr[i].sort();
    }
    for i in 0..m {
        print!("{:06}", parr[i]);
        println!(
            "{:06}",
            arr[parr[i] - 1]
                .binary_search(&yarr[i])
                .expect("something wrongs")
                + 1
        );
    }
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


Measured memory_bytes: 15868
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (int i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define F first
#define S second
#define I insert
#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define debug1(a) cout<<" "<<#a<<" : "<<a<<"\n"
#define debug2(a,b) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define debug3(a,b,c) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define debug4(a,b,c,d) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"
#define INF (int)10000000000000000
#define PI (double)3.14159265358979
// #define M 421412341324321
#define MOD 1000000007

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int n, m;
	cin>>n>>m;
	if (n==m)
		cout<<"Yes";
	else 
		cout<<"No";


	



	return 0;
}

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

using namespace std;

typedef long long ll;

const ll mod = 1e9 + 7;

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

    int n;
    string s;

    cin >> n >> s;

    vector<vector<ll>> dp(n + 1, vector<ll>(n + 1));

    dp[0][1] = 1;

    for(int i = 1; i < n; i++)
    {
        vector<ll> cumul(n + 1);

        for(int j = 1; j <= i + 1; j++)
            cumul[j] = (cumul[j - 1] + dp[i - 1][j]) % mod;

        for(int j = 1; j <= i + 1; j++)
            dp[i][j] = s[i - 1] == '<' ? cumul[j - 1] : (cumul[i + 1] - cumul[j - 1] + mod) % mod;
    }

    ll ans = 0;

    for(int i = 1; i <= n; i++)
        ans = (ans + dp[n - 1][i]) % mod;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 70784
// 105

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

int main() {
    int odds[6] = {3, 5, 7, 9, 11, 13};
    int n;
    cin >> n;
    int count = 0;
    for (int i = 0; i < 4; i++) {
        for (int j = i + 1; j < 5; j++) {
            for (int k = j + 1; k < 6; k++) {
                if (odds[i] * odds[j] * odds[k] <= n) {
                    count++;
                }
            }
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
import std.algorithm;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.meta;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;

alias Event = Tuple!(long, "t", long, "id", string, "type", long, "value");
alias Cand = Tuple!(long, "value", long, "id");

auto solve(long N, long Q, long[] S, long[] T, long[] X, long[] D) {
    auto events = make!(RedBlackTree!Event);
    foreach (s, t, x, n; zip(S, T, X, iota(N))) {
        events.insert(Event(s - x, n, "add", x));
        events.insert(Event(t - x, n, "dispose", x));
    }

    auto cands = make!(RedBlackTree!Cand);
    auto disposed = make!(RedBlackTree!long);
    foreach (d; D) {
        while (!events.empty && events.front.t <= d) {
            auto e = events.front;
            events.removeFront;

            if (e.type == "add")
                cands.insert(Cand(e.value, e.id));
            else
                disposed.insert(e.id);
        }

        while (!cands.empty && cands.front.id in disposed)
            cands.removeFront;

        if (cands.empty)
            writeln(-1);
        else
            writeln(cands.front.value);
    }
}

void main() {
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    long Q;
    Q = input.front.to!long;
    input.popFront;

    long[] S = new long[](cast(size_t) (N));
    long[] T = new long[](cast(size_t) (N));
    long[] X = new long[](cast(size_t) (N));
    foreach (i; 0 .. cast(size_t) (N)) {
        S[i] = input.front.to!long;
        input.popFront;
        T[i] = input.front.to!long;
        input.popFront;
        X[i] = input.front.to!long;
        input.popFront;
    }

    long[] D = new long[](cast(size_t) (Q));
    foreach (i; 0 .. cast(size_t) (Q)) {
        D[i] = input.front.to!long;
        input.popFront;
    }

    static if (is(ReturnType!solve == void))
        solve(N, Q, S, T, X, D);
    else
        solve(N, Q, S, T, X, D).writeln;
}


Measured memory_bytes: 88060
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>
#include <cstring>

using namespace std;

typedef pair<int, int> P;
#define mp make_pair
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort((v).begin(), (v).end());					//小さい順
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());		//大きい順
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define F first
#define S second
#define pb1 push_back
#define mod 1000000007LL
#define INF 1234567890

const int maxn = 2e5 + 10;


//initialization here
//

//
//initialization finish


// your function is here
//



//
// your function finished



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

	// your code is here
	//
	
	int n, l; cin >> n >> l;

	string s[101];
	rep(i, n)
	{
		cin >> s[i];
	}

	sort(s, s + n);

	rep(i, n) cout << s[i];
	cout << endl;
	//
	// your code finished

	return 0;
}

Measured memory_bytes: 256
//Bismillahir Rahmanir Rahim//
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,c,a;
    cin>>n;
    c=0;
    for(int i=1;i<=n;i++){
        cin>>a;
        if(a%2==1&&i%2==1) c++;
    }
    cout<<c<<endl;
}

Measured memory_bytes: 3568
use std::io;

fn main() {
    let mut input_text = String::new();
    io::stdin()
        .read_line(&mut input_text)
        .expect("Failed to read");

    let v: Vec<usize> = input_text
        .trim()
        .split(' ')
        .map(|v| v.parse().unwrap())
        .collect();

    let (h, w): (usize, usize) = (v[0], v[1]);

    let mut mmap = vec!['.'; h*w];
    let mut imap = vec![0 ; h*w];

    let dy: [i32; 9] = [-1, -1, -1, 0, 0, 0, 1, 1, 1];
    let dx: [i32; 9] = [-1, 0, 1, -1, 0, 1, -1, 0, 1];

    for n in 0..h {
        input_text = "".to_string();
        io::stdin()
            .read_line(&mut input_text)
            .expect("Failed to read");

        for (m, c) in input_text.trim().chars().enumerate() {
            mmap[n * w + m] = c;
            if c == '#' {
                for p in 0..9 {
                    let ni = n as i32 + dy[p] as i32;
                    let mj = m as i32 + dx[p] as i32;
                    if ni < 0 || ni >= h as i32 { continue; }
                    if mj < 0 || mj >= w as i32 { continue; }

                    let i = (ni as usize * w + mj as usize) as usize;
                    imap[i] += 1; 
                }
            }
        }
    }

    for n in 0..h {
        for m in 0..w {
            let i = (n * w + m) as usize;
            if mmap[i] == '#' {
                print!("#");
            } else {
                print!("{}", imap[i]);
            }
        }
        println!("");
    }

}


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

#define F first
#define S second
#define pb push_back
#define mp make_pair

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

ll lcm(ll a, ll b){
	return (a/gcd(a, b))*b;
}

ll dp[100005],n;
vector <ll> v;

ll solve(ll k)
{
	if(dp[k] != -1)
		return dp[k];
	else if(k < v[0])
		return dp[k] = 0;
	else if(find(v.begin(),v.end(),k) != v.end())
		return dp[k] = 1;

	dp[k] = 0;
	for(ll i = 0;i<n;i++)
	{
		if(k >= v[i])
			dp[k] = dp[k] || !solve(k-v[i]);
		else
			break;
	}

	return dp[k];
}

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

	ll k,i,j;


	cin >> n >> k;

	for(i=0;i<n;i++)
	{
		ll x;
		cin >> x;

		v.pb(x);
	}

	memset(dp,-1,sizeof(dp));

	dp[0] = 0;

	ll x = solve(k);

	if(x)
		cout << "First" << endl;
	else
		cout << "Second" << endl;

}

Measured memory_bytes: 7480
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
int const M=2e5+10,inf=1e9+10,mod=1e9+7,M2=1e6+10,M3=3e3+10;
int a[M],b[M],ps[M];
main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)cin>>b[i];
	for(int i=n;i>=1;i--)ps[i]=ps[i+1]+b[i];
	int ans=-inf;
	int now=0;
	for(int i=1;i<=n;i++)
	{
		now+=a[i];
		ans=max(ans,now+ps[i]);
	}
	cout<<ans;
}

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

int main(){
    long int a,b,c,d,e,f,g,h,j,k,ii;
    ii = 0;
    cin >> a >> b;
    vector<int> ie(b);
    c = b - 1;
    for(int i;i < b;i++){
        cin >> ie.at(i); 
    }
    vector<int> ieai(b);
    for(int m = 0; m < c;m = m + 1){
        ii = m + 1;
        ieai.at(m) = ie.at(m) - ie.at(ii); 
    }
    ieai.at(c) = -1*(a - ie.at(c) + ie.at(0));
    sort(ieai.begin(),ieai.end());
    d = ieai.at(0);
    cout << a + d  <<endl;


}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int mi = 1000;
        int ma = 0;
        for (int i = 0; i < n; i++) {
            int an = sc.nextInt();
            mi = Math.min(mi, an);
            ma = Math.max(ma, an);
        }

        System.out.println(ma - mi);
    }

}

Measured memory_bytes: 21076
#include <stdio.h>
#include <math.h>

int main() {
    int n, k, q, ans = 1;
    scanf("%d %d", &n, &k);
    q = n / k;
    while (n >= k) {
        q = n / k;
        n = q;
        ans++;
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 128
/*2019/10/02 */
/*template*/
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
#define MIN 999999999
#define MAX -999999999
typedef long long int ll;
typedef unsigned long long int ull;
void llswap(ll *x,ll *y){ll tmp;tmp=*x;*x=*y;*y=tmp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int rmax(int x,int y){return x>y?x:y;}
int rmin(int x,int y){return x>y?y:x;}
ll llrmax(ll x,ll y){return x>y?x:y;}
ll llrmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){if(*(int*)a < *(int*)b)return -1;else if(*(int*)a == *(int*)b)return 0;else return 1;}
int desc(const void *a,const void *b){if(*(int*)a < *(int*)b)return 1;else if(*(int*)a == *(int*)b)return 0;else return -1;}
int llasc(const void *a,const void *b){if(*(ll*)a < *(ll*)b)return -1;else if(*(ll*)a == *(ll*)b)return 0;else return 1;}
int lldesc(const void *a,const void *b){if(*(ll*)a < *(ll*)b)return 1;else if(*(ll*)a == *(ll*)b)return 0;else return -1;}
int gcd(int x,int y){if(y==0)return x;return gcd(y,x%y);}
 
/*
int asc_t(const void *a,const void *b){if((pair_t*)a->d < (pair_t*)b->d)return -1;else if((pair_t*)a->d == (pair_t*)b->d)return 0;else return 1;}
int desc_t(const void *a,const void *b){if((pair_t*)a->d < (pair_t*)b->d)return 1;else if((pair_t*)a->d == (pair_t*)b->d)return 0;else return -1;}
*/

int main(){
    int n;
    char str[100][100];
    int cnt[100][26]={{}};
    int cnt_min[26]={};

    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%s",str[i]);
    }
    for(int i=0;i<26;i++){
        cnt_min[i]=MIN;
    }
    for(int i=0;i<n;i++){
        for(int j=0;str[i][j]!='\0';j++){
            cnt[i][str[i][j]-'a']++;
        }
    }
    int max=0;
    for(int i=0;i<26;i++){
        for(int j=0;j<n;j++){
            if(cnt_min[i]>cnt[j][i]){
                cnt_min[i]=cnt[j][i];
            }
        }
    }
    for(int i=0;i<26;i++){
        for(int j=0;j<cnt_min[i];j++){
            printf("%c",i+'a');
        }
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 128
import sys


class Queue:
    def __init__(self):
        self.Q = []

    def isEmpty(self):
        return len(self.Q) == 0

    def enqueue(self, x):
        self.Q.append(x)
        # return self.Q

    def dequeue(self):
        if self.isEmpty():
            sys.exit("Empty")
        else:
            return self.Q.pop(0)



n, power = map(int, raw_input().split(" "))
process_list = [map(str, raw_input().split(" ")) for i in range(n)]
process_list = [(p[0], int(p[1])) for p in process_list]

q = Queue()
for p in process_list:
    q.enqueue(p)
elapsed_time = 0
while not q.isEmpty():
    process = q.dequeue()
    if process[1] > power:
        elapsed_time += power
        q.enqueue((process[0], process[1] - power))
    else:
        elapsed_time += process[1]
        print(str(process[0]) + " " + str(elapsed_time))



Measured memory_bytes: 17644
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <limits.h>
const long long INF = LLONG_MAX / 2;
#define FOR(i, r, n) for(int i=(r); i<(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ll long long int
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
	vector.erase(vector.begin() + index);
}

using namespace std;
ll ans = 0, sum = 0, n, k, t;
string s;

vector<ll> v;
map<char, ll> m;

int main() {
	cin >> s;
	REP(i, s.size()) {
		m[s[i]]++;
	}
	for (auto itr = m.begin(); itr != m.end(); ++itr) {
		if (itr->second % 2) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define REP(i,j,k)     for(int i = j ; i < k ; ++i)
#define RREP(i,j,k)    for(int i = j ; i >=k ; --i)
#define A    first
#define B    second
#define mp   make_pair
#define pb   emplace_back
#define PII pair<int , int>
#define MEM(i,j)   memset(i , j , sizeof i)
#define ALL(i)     i.begin() , i.end()
#define DBGG(i,j)     cout << i << " " << j << endl
#define DB4(i,j,k,l)  cout << i << " " << j << " " << k << " " << l << endl
#define IOS cin.tie(0) , cout.sync_with_stdio(0)
#define endl "\n"
///------------------------------------------------------------
#define MAX 300900
#define INF 0x3f3f3f3f

int n , a , b;

int32_t main(){
	IOS;
	cin >> n >> a >> b;
	if(a + b > n + 1) return cout << -1 << endl , 0;
	if(a == 1 || b == 1){
		if(a + b != n + 1) return cout << -1 << endl , 0;
		else {
			if(a == 1){
				RREP(i , n , 1) cout << i << " " ; cout << endl;
				return 0;
			}
			if(b == 1){
				REP(i , 1 , n + 1) cout << i << " " ; cout << endl;
				return 0;
			}
		}
	}
	else {
		// cout << "here" << endl;
		int siz = n % a == 0 ? n / a : n / a + 1;
		if(siz > b) return cout << -1 << endl , 0;
		vector<int> sol;
		sol.pb(b);
		int las = a - 1 , use = b;
		RREP(i , las , 2){
			if(n - use + 1 - siz >= i)
				 sol.pb(use + siz) , use += siz;
			else sol.pb(use + 1) , use ++;
		}
		sol.pb(n);
		int pos = 1;
		// for(auto to : sol) cout << to << " " ; cout << endl;
		for(auto to : sol){
			RREP(i , to , pos) cout << i << " " ;
			pos = to + 1;
		}
		cout << endl;
	}
    return 0;
}


Measured memory_bytes: 3060