akhauriyash/Code-Regression huggingface dataset:
#
# 7d
#

def main():
    n, m, l = map(int, input().split())
    A = [[0 for i in range(m)] for j in range(n)]
    B = [[0 for i in range(l)] for j in range(m)]
    C = [[0 for i in range(l)] for j in range(n)]
    for i in range(n):
        A[i] = list(map(int, input().split()))
    for i in range(m):
        B[i] = list(map(int, input().split()))
    for i in range(n):
        for j in range(l):
            for k in range(m):
                C[i][j] += A[i][k] * B[k][j]
    for i in range(n):
        print(*C[i])


if __name__ == '__main__':
    main()



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

int main() {
  int N;
  cin >> N;
  int res=0;
  for (int a = 0; a <= 20; ++a)//4
  {
    for (int b = 0; b <=15; ++b)//7
    {
      int total = 4*a + 7*b;
      if (total == N) ++res;
    }
  }
  
  cout << ((res > 0)? "Yes":"No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    int n,k;
    cin >> n >> k;
    vector<int> h(n);
    
    for(int i = 0;i < n;i++){
          cin >> h[i];
    }
    
    sort(h.begin(),h.end());
    int ans = 1e9;
    for(int i = k - 1;i < n;i++){
          ans = min(ans,h[i] - h[i - k + 1]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3716
#include <algorithm>
#include <boost/optional.hpp>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))
#define PRECISION(x) std::fixed << std::setprecision(x)

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

constexpr int dx[] = {-1, 0, 1, 0};
constexpr int dy[] = {0, -1, 0, 1};

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

const int I_MAX = 26;

int calc_point(const int& D, const VI& c, const VI2D& s, const VI& t) {
	int point = 0;
	VI last(I_MAX + 1, 0);
	REP(i, D) {
		point += s[i][t[i]];
		last[t[i]] = i + 1;
		int down = 0;
		REP(j, I_MAX) { down += c[j] * ((i + 1) - last[j]); }
		point -= down;
	}

	return max(1000000 + point, 0);
}

VI initialize(const int D, const int type_num) {
	random_device seed_gen;
	mt19937 mt(seed_gen());
	VI t(D);
	REP(i, D) { t[i] = mt() % type_num; }
	return t;
}

void solve(const int& D, const VI& c, const VI2D& s) {
	chrono::system_clock::time_point start, end;
	start = chrono::system_clock::now();
	double elapsed =
		chrono::duration_cast<chrono::milliseconds>(end - start).count();

	VI t = initialize(D, I_MAX);
	int prev = calc_point(D, c, s, t);
	REP(i, D) {
		int q;
		int best_point = prev;
		int best_type = t[i];
		int old = t[i];

		// cout << endl;
		// REP(i, D) { cout << t[i] + 1 << " "; }
		// cout << endl;

		REP(j, I_MAX) {
			t[i] = j;
			int new_point = calc_point(D, c, s, t);
			if(new_point > best_point) {
				best_point = new_point;
				best_type = j;
			}
		}
		prev = best_point;
		t[i] = best_type;

		end = chrono::system_clock::now();
		double elapsed =
			chrono::duration_cast<chrono::milliseconds>(end - start).count();
		if(elapsed >= 1800.0) {
			break;
		}
	}

	REP(i, D) { cout << t[i] + 1 << endl; }
}

int main() {
	int D;
	cin >> D;
	VI c(I_MAX);
	REP(i, I_MAX) { cin >> c[i]; }
	VI2D s(D, VI(I_MAX));
	REP(i, D) {
		REP(j, I_MAX) { cin >> s[i][j]; }
	}
	solve(D, c, s);
	return 0;
}


Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
#define MAX 100000
const long long INF=1145141919,MOD=1e9+7;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const double EPS = 1e-9;    // 許容誤差。問題によって変える
//typedef complex<double> P;  // Point
//typedef vector<P> VP; //単純多角形
//#define X real()
//#define Y imag()
//#define LE(n,m) ((n) < (m) + EPS)
//#define GE(n,m) ((n) + EPS > (m))
//#define EQ(n,m) (abs((n)-(m)) < EPS)
//namespace std{
//    bool operator < (const P a, const P b){
//        return a.X != b.X ? a.X <b.X : a.Y < b.Y;
//    }
//}
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
//外積cross(a,b) = |a||b|sinθ
//double cross(const P& a, const P& b) {
 // return imag(conj(a)*b);
//}
//内積dot(a,b) = |a||b|cosθ
//double dot(const P& a, const P& b) {
  //return real(conj(a)*b);
//}
//Line
//struct L : public vector<P> {
  //L(const P &a, const P &b) {
    //push_back(a); push_back(b);
  //}
//};
//円
//struct C{
//  P p; double r;
//  C(const P &p, double r) : p(p), r(r) { }
//};
int main(){
    long long N,ans=0;
    cin>>N;
    for(int i=1;i<sqrt(N)+1;i++){
        if(N%i==0){
            long long x=N/i;
            if(x>i+1){
                ans+=x-1;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define N 200005
#define rank Rank
#define index Index
int main(){
    int n;
    scanf("%d",&n);
    pii p[105];
    for(int i = 0;i<n;i++){
        int x,y;
        scanf("%d %d",&x,&y);
        p[i]=mp(x,y);
    }
    map<pii,int> m;
    for(int i = 0;i<n;i++){
        for(int j =0;j<n;j++){
            if(i!=j)
            m[mp(p[i].x-p[j].x,p[i].y-p[j].y)]++;
        }
    }
    int ans=0;
    for(auto it:m)
        ans=max(it.y,ans);
    printf("%d\n",n-ans);
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
	int N;
	cin>>N;
	bool **box;
	box=new bool*[3];
	for(int i=0;i<3;++i){
		box[i]=new bool[N+1];
		for(int j=1;j<=N;++j){
			box[i][j]=false;
		}
		int n;
		cin>>n;
		for(int j=0;j<n;++j){
			int place;
			cin>>place;
			box[i][place]=true;
		}
	}
	int ans=0;
	for(int i=1;i<=N;++i){
		if(((!box[0][i])&&box[2][i])||(box[1][i]&&box[2][i])){
			++ans;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define F first
#define S second
#define bitcnt(v) __builtin_popcount(v)
#define all(v) v.begin(), v.end()

int mod = 1e9 + 7;

ll powMod(ll a, ll n){
	ll ans = 1LL;
	a %= mod;
	while(n > 0){
		if(n&1) ans = (ans * a) % mod;
		a = (a * a) % mod;
		n /= 2; 
	}
	return ans % mod;
}

void solution(){

	ll n; cin >> n;
	vector<vector<ll>> p;
	for(int i = 0 ; i < n; i++){
		ll x, y; cin >> x >> y;
		p.push_back({x,y});
	}
	sort(all(p));
	vector<ll> sum(n), diff(n);
	for(int i = 0; i < n; i++){
		sum[i] = p[i][0] + p[i][1];
		diff[i] = p[i][0] - p[i][1];
	}

	ll mnd = *min_element(all(diff));
	ll mns = *min_element(all(sum));

	ll ans = -1e18;

	for(auto x : sum)
		ans = max(ans, x - mns);

	for(auto x : diff)
		ans = max(ans, x - mnd);

	cout << ans << endl;





}	


int main(){ 
	fio;
	int t;
	t = 1;
	// cin >> t;
	for(int i = 1; i <= t; i++){
		// cout << "Case #" << i << ": ";
		solution();
	} 
	return 0;
}

Measured memory_bytes: 17388
#include<bits/stdc++.h>
    #define N 300005
    #define M 1000000007
    #define ll long long
    using namespace std;
    ll n,m,t,x,y,fac[N]= {1};
    ll arr[N];
    map<ll,ll> mp;
    vector<int> v[N];
    ll qpow(ll a,ll b)
    {
        ll ans=1;
        ll k=a;
        while(b)
        {
            if(b&1)ans=ans*k%M;
            k=k*k%M;
            b>>=1;
        }
        return ans;
    }
    ll C(ll n,ll m)
    {
        if(m>n)return 0;
        return fac[n]*qpow(fac[m],M-2)%M*qpow(fac[n-m],M-2)%M;
    }
    int main()
    {
        for(int i=1; i<N; i++)fac[i]=fac[i-1]*i%M;
        ll n;
        scanf("%lld",&n);
        int num;
        for(int i=1;i<=n+1;i++){
        	scanf("%lld",&arr[i]);
        	if(mp[arr[i]]) num=arr[i];
        	mp[arr[i]]=1;
        	v[arr[i]].push_back(i);
		} 
		cout<<n<<'\n';
        int id1=v[num][0];
        int id2=v[num][1];
        //cout<<num;
        int cha=id2-id1+1;
        for(ll i=2;i<=n+1;i++){
        	printf("%lld\n",(((C(n+1,i)-C(n+1-cha,i-1)+M)%M)%M));
		}
        return 0;
    }

Measured memory_bytes: 20864
Nmax = 1000000000000001
c = "abcdefghijklmnopqrstuvwxyz"

a = ""
N = int(input())
N = N-1
mm = 26
if N == 0:
  print("a")
  exit(0)
#
while N > 0:
  if N < mm:
    break
  N -= mm
  mm *= 26
#

while mm >= 26:
  mm = mm //26
  m = N // mm
  N = N % mm
  a = a + c[m]
#
print(a)


Measured memory_bytes: 9128
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int a[101][101];
int dy[]={1,-1};
int dx[]={-1,1};
void get(int n){
  if(n==1)return ;
  int y=0,x=0,d=0;
  int c=2;
  int f=1;
  while(1){
    if(y==n-1&&x==n-1)break;
    if(f&&y==0){
      if(x==n-1)a[++y][x]=c++;
      else a[y][++x]=c++;
      d=0;f=0;
    }
    else if(f&&x==0){
      if(y==n-1)a[y][++x]=c++;
      else a[++y][x]=c++;
      d=1;f=0;
    }
    else if(f&&x==n-1){
      a[++y][x]=c++;
      d=0;f=0;
    }
    else if(f&&y==n-1){
      a[y][++x]=c++;
      d=1;f=0;
    }
    else{
      f=1;
      y+=dy[d];
      x+=dx[d];
      a[y][x]=c++;
    }
  }
}
int main(){
  int p=1,n;
  a[0][0]=1;
  while(cin>>n,n){
    printf("Case %d:\n",p++);
    get(n);
    r(i,n){
      r(j,n)printf("%3d",a[i][j]);
      cout<<endl;
    }
  }
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << "\n"
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
const constexpr int MAX = 100;
const constexpr ll INF = 1LL<<32;
int n;
vv(ll, d, MAX, MAX, INF);
inline void floyd() {
	rep(k, 0, n) {
		rep(i, 0, n) {
			if(d[i][k] == INF) continue;
			rep(j, 0, n) {
				if(d[k][j] == INF) continue;
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
}
int main() {
	int e; cin >> n >> e;
	rep(i, 0, n) d[i][i] = 0LL;
	int u, v, c;
	rep(i, 0, e) {
		cin >> u >> v >> c;
		d[u][v] = c;
	}
	floyd();
	rep(i, 0, n) if(d[i][i] < 0) { P("NEGATIVE CYCLE"); return 0; }
	rep(i, 0, n) {
		rep(j, 0, n) {
			if(d[i][j] == INF) p("INF");
			else p(d[i][j]);
			p(j + 1 == n ? "\n" : " ");
		}
	}
	return 0;
}

Measured memory_bytes: 3300
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n,k = LI()
    a = LI()
    d = defaultdict(lambda:0)
    for i in a:
        d[i] += 1
    d = list(d.values())
    d.sort()
    ans = 0
    for i in range(len(d)-k):
        ans += d[i]
    print(ans)
    return

#B
def B():
    n,z,w = LI()
    a = LI()
    if n == 1:
        print(abs(a[0]-w))
        return
    ans = max(abs(a[-1]-w),abs(a[-2]-a[-1]))
    print(ans)
    return

#C
def C():
    n = I()
    s1 = S()
    s2 = S()
    dp = [[[0]*3 for j in range(3)] for i in range(n+1)]
    if s1[0] == s2[0]:
        dp[1] = [[1 if i == j else 0 for j in range(3)] for i in range(3)]
    else:
        dp[1] = [[0 if i == j else 1 for j in range(3)] for i in range(3)]
    for i in range(1,n):
        ni = i+1
        if s1[i] == s2[i]:
            for j in range(3):
                for k in range(3):
                    if k == j:continue
                    for l in range(3):
                        if l == j:continue
                        dp[ni][j][j] += dp[i][k][l]
        else:
            if i and s1[i] == s1[i-1]:
                for j in range(3):
                    for k in range(3):
                        dp[ni][j][k] = dp[i][j][k]
            else:
                for j in range(3):
                    for k in range(3):
                        if k == j:continue
                        for l in range(3):
                            if l == j:continue
                            for m in range(3):
                                if m == k:continue
                                dp[ni][j][k] += dp[i][l][m]
    ans = 0
    for i in range(3):
        for j in range(3):
            ans += dp[n][i][j]
    print(ans%mod)
    return

#D
def D():

    return

#E
def E():

    return

#Solve
if __name__ == "__main__":
    C()


Measured memory_bytes: 40560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  ll n, x, y;
  cin >> n;
  for (ll i = 0; i < n; i++) {
    ll t, a;
    cin >> t >> a;
    if (i == 0) {
      x = t;
      y = a;
      continue;
    }
    x += t - 1 - (x + t - 1) % t;
    y += a - 1 - (y + a - 1) % a;
    if (x/t >= y/a) y += (x/t - y/a)*a;
    else x += (y/a - x/t)*t;
  }
  cout << x + y << endl;
}

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

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((ll)(x).size())

const double PI  = acos(-1.0);
const double EPS = 1e-9;
const int INF = 1e9+10;
const ll mod = 998244353;
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; }
#define print(x) cerr << #x << " is " << x << endl;
//#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 


int main() {
    int M, N;
    ll K;
    int ans = 0;
    cin >> N >> M >> K;
    vector<ll> A(N), B(M);
    rep(i, N)cin >> A[i];
    rep(i, M)cin >> B[i];

    int i_max = -1;
    ll total = 0;
    for (int i = 0; i < M; i++){
        if (total + B[i] > K)break;
        total += B[i];
        i_max = i;
        ans++;
    }
    
    int keep = ans;
    for (int i = 0; i < N; i++){
        total += A[i];
        keep++;
        while(total > K && i_max >= 0){
            total -= B[i_max];
            i_max--;
            keep--;
        }
        if (total <= K)
        chmax(ans, keep);
    }
    cout << ans;
    
    return 0;
}


Measured memory_bytes: 6424
#include <iostream>
#include <algorithm>
//#include <tuple>
#include <cmath>
#include <string>
#include <vector>

#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
using namespace std;

int a, b;


int main() {

	cin >> a >> b;
	
	if (b%a == 0) cout << a + b << endl;
	else cout << b - a <<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int insertionSort(int A[], int n, int g);
int ShellSort(int A[], int n);
int main(){
  char line[100];
  int total;
  fgets(line, sizeof(line), stdin);
  sscanf(line, "%d", &total);
  int A[total];
  int i, j;
  int cnt;
  for(i=0; i<total; ++i){
	fgets(line, sizeof(line), stdin);
	sscanf(line, "%d", &A[i]);
  }
  cnt=ShellSort(A, total);

  printf("%d\n", cnt);
  for(i=0; i<total; ++i){
	printf("%d\n", A[i]);
  }
  return 0;
}
int insertionSort(int A[], int n, int g){
  int i, j;
  int cnt=0;
  int v;
  for(i=g; i<n; ++i){
	v=A[i];
	j=i-g;
	while((j>=0)&&(A[j]>v)){
	  A[j+g]=A[j];
	  ++cnt;
	  j=j-g;
	}
	A[j+g]=v;
  }
  return cnt;
}
int ShellSort(int A[], int n){
  int m, cnt=0;
  int i, j;
  i=1;
  m=1;
  while(i<=n){
	i=i*3+1;
	++m;
  }
  --m;
  int G[m];
  i=1;
  printf("%d\n", m);
  fflush(stdout);
  for(j=0; j<m; ++j){
	G[j]=i;
	i=i*3+1;
  }

  for(j=(m-1); j>=0; --j){
	cnt+=insertionSort(A, n, G[j]);
	printf("%d", G[j]);
	if(j>0)
	  printf(" ");
	else 
	  printf("\n");
  }

  return cnt;
}



Measured memory_bytes: 5680
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
using namespace std;

typedef long long ll;

int main()
{
    int N;
    cin >> N;
    string s;
    cin >> s;
    int l=0, r=0, l_needed=0, r_needed=0;
    for(int i=0; i<N; i++){
        if(s[i]=='(') l++;
        else r++;
        
        if(r>l){
            l_needed++;
            l++;
        }
    }
    r_needed=l-r;
    for(int i=0; i<N+r_needed+l_needed; i++){
        if(i<l_needed) cout << '(';
        else if(i<l_needed+N) cout << s[i-l_needed];
        else cout << ')';
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define fr                first
#define se                second
#define int               long long
#define pb                push_back
#define mp                make_pair
#define pii               pair<int,int>
#define vi                vector<int>
#define mi                map<int,int>
#define pqb               priority_queue<int>
#define set_bits(x)       __builtin_popcountll(x)
#define mod               1000000007
#define inf               1e18                        //Defining infinity the overflow of int
#define ps(x,y)           fixed<<setprecision(y)<<x   //fir defining the precision int the decimal upto y places.
#define zrosetbits(x)     __builtin_ctzll(x)         //it will give no of 0's before the first 1 from the right.
#define mk(a,n,type)     type *a=new type[n];
#define test(t)          int t; cin>>t; while(t--)
#define REP(i,a,b)       for(int i=a;i<b;i++)
 
 
void io()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin.tie(0);
 
 
}
 
 
int32_t main()
{
  io();
 
  
    int a;
    cin >> a;
    cout << a+(a*a)+(a*a*a)<< "\n";
 
 
 
  return 0;
}
 

Measured memory_bytes: 3636
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
	map <int,int> pre;
	map <int,string> res;
    int n,m; cin>>n>>m; 
    vector <pii> v(m),h(m);
    for (int i=0;i<m;i++){
    	cin>>v[i].ss>>v[i].ff;
    	h[i]=v[i];
    }
    sort(v.begin(), v.end());
    for (int i=0;i<m;i++){
    	string s=to_string(v[i].ss);
    	pre[v[i].ss]++;
    	string ss=to_string(pre[v[i].ss]);
    	while (sz(s)<6) s.insert(s.begin(),'0');
    	while (sz(ss)<6) ss.insert(ss.begin(),'0');
    	res[v[i].ff]=s+ss;
    }
    for (int i=0;i<m;i++){
    	cout << res[h[i].ff] << endl;
    }
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


Measured memory_bytes: 20372
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using bint = boost::multiprecision::cpp_int;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    rep(i,M) cin >> A[i];
    int ret = N;
    rep(i,M) ret -= A[i];
    if (ret < 0) ret = -1;
    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <sstream>
 
using namespace std;
 
int main(){
    int a, b;
    stringstream s;
    while(cin >> a >> b){
    s.str("");
    s << a + b;
    cout << s.str().size() << endl;
    }
    return 0;
}

Measured memory_bytes: 1220
N = int(input())
A = [None]*N
for i in range(N):
  A[i] = list(map(int,input().split()))
A.sort(key = lambda x:x[1])
B = [0]*len(A)
C = [0]*len(A)
for b in range(len(A)):
  B[b] = A[b][0]
for c in range(len(A)):
  C[c] = A[c][1]
jud = 'Yes'
Sum = 0
for j in range(N):
  Sum += B[j]
  if Sum > C[j]:
    jud = 'No'
    #print(C[j])
    #print(B[:j+1])
print(jud)


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

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
*/

using namespace std;

#if DEBUG && !ONLINE_JUDGE
    #include "debug.h"
#else
    #define debug(...)
#endif

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<vector<int> > vvi;
typedef vector<vector<ii> > vvii;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define ff first
#define ss second
#define trav(a, x) for(auto& a : x) 
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
const ll INF = 1e18;
const int mod =  1e9 + 7;
const int N = 1e6;
ll gcd(ll a,ll b){if (a==0) return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return a*(b/gcd(a,b));}
ll Abs(ll a){if(a>0)return a;return -a;}
ll Ceil(ll a,ll b){if(a%b==0)return a/b;else return a/b+1;}
double Abs(double a){if(a>0)return a;return -a;}

//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1

/*
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
*/

inline int pow_(ll x, ll y,ll p){
  int r = 1; while(y){if(y & 1) r = r * x % p; y >>= 1; x = x * x % p;} return r;
}
inline int inv_(int x){return pow_(x, mod - 2, mod);}
inline int add(int a, int b){a += b; if(a >= mod) a -= mod; return a;}
inline int mul(int a, int b){return a * 1LL * b % mod;}
inline int sub(int a, int b){a -= b; if(a < 0) a += mod; return a;}



int main()
{
	#ifdef LOCAL_TEST
    freopen("in.txt","r",stdin);
    //freopen("out.txt", "w", stdout);
    #else
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    #endif
    ll n,W;
    cin>>n>>W;
    ll w[105] = {0};
    ll v[105] = {0};

    for(int i=1;i<=n;i++)
    {
    	cin>>w[i]>>v[i];
    }

    ll dp[105][100005] = {0};

   	for(int i=1;i<=100000;i++)dp[0][i] = INF;

    for(int i=1;i<=n;i++)
    {
    	for(int j=1;j<=100000;j++)
    	{
    		if(j-v[i] >= 0)
    		{
    			dp[i][j] = min(dp[i-1][j-v[i]]+w[i],dp[i-1][j]);
    		}
    		else
    		{
    			dp[i][j] = dp[i-1][j];
    		}
    	}
    }

    ll max = -1;
    for(int i=1;i<=100000;i++)
    {
    	if(dp[n][i] <= W)
    	{
    		max = i;
    	}
    }

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

Measured memory_bytes: 82304
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <stack>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

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

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

//解説AC
//https://atcoder.jp/contests/abc122/submissions/4701924

int n;
int dp[111][4][4][4];

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

  cin >> n;
  dp[0][3][3][3] = 1;
  
  FOR(i, 1, n+1){
    REP(j, 4){
      REP(k, 4){
	REP(l, 4){
	  if(j == 0 && k == 2 && l == 1) continue;
	  if(j == 2 && k == 0 && l == 1) continue;
	  if(j == 0 && k == 1 && l == 2) continue;
	  REP(m, 4){
	    if(k == 0 && l == 2 && m == 1) continue;
	    if(k == 2 && l == 0 && m == 1) continue;	    
	    if(k == 0 && l == 1 && m == 2) continue;	    
	    if(j == 0 && k == 2 && m == 1) continue;	    
	    if(j == 0 && l == 2 && m == 1) continue;	    	    
	    dp[i][k][l][m] += dp[i-1][j][k][l];
	    dp[i][k][l][m] %= MOD;
	  }
	}
      }
    }
  }

  int ans = 0;
  REP(i, 4) REP(j, 4) REP(k, 4){
    if (i == 0 && j == 2 && k == 1)continue;
    if (i == 2 && j == 0 && k == 1)continue;
    if (i == 0 && j == 1 && k == 2)continue;
    ans += dp[n][i][j][k];
    ans %= MOD;    
  }
  cout << ans << endl;
  return 0;
}


  /*
  
  ll ans = mul(4, n);
  //cerr << ans << endl;
  //n=3のときのdif
  num[3] = 3;
  FOR(i,4,n+1){
    num[i] = num[i-1];
    num[i] += 3*mul(4, i-3)*(i-2);
    ll val = mul(4,i-4);
    if(num[i] < val){
      num[i] += (MOD-val);
    }
    else{
      num[i] -= val;
    }
    num[i] %= MOD;
    cerr << "i: " << i << " num: " << num[i] << endl;
  }
       
  cout << ((ans)%MOD + MOD - (num[n]%MOD))%MOD << endl;
  
  */


Measured memory_bytes: 256
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
import copy
# from fractions import gcd

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)

n = int(input())
A = list(map(int, input().split()))
s = 0
for i in range(1, n):
    if A[i-1] > A[i]:
        s += A[i - 1] - A[i]
        A[i] += A[i-1] - A[i]

print(s)


Measured memory_bytes: 94184
#include<bits/stdc++.h>
#define cy cout<< "Yes"<<endl;
#define cn cout<< "No"<<endl;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    fast;
    int a,b,c,d,e,i,j;
    cin >> a >> b;
    vector<int>vec;
    while(a--)
    {
        cin >> c;
        vec.push_back(c);
    }
    sort(vec.begin(),vec.end());
    long long sum=0;
    for(i=0;i<b;i++)
    {
        sum+=vec[i];
    }
    cout << sum << endl;





}






Measured memory_bytes: 3652
# coding: utf-8

n = int(input())
d = []
for i in range(n):
    _s, _p = input().split()
    d.append({'number': i, 'city': _s, 'point': int(_p)})
sortedd = sorted(d, key = lambda x: (x['city'], -x['point']))
for n in sortedd:
    print(n['number'] + 1)


Measured memory_bytes: 3060
like = input().split()
chara = ["A","B","C","D","E","F"]
inde = chara.index(like[0])
inde_1 = chara.index(like[1])

if inde > inde_1:
    print(">")
elif inde < inde_1:
    print("<")
else:
    print("=") 

Measured memory_bytes: 3060
#include <iostream>

using namespace std;
long long  i,nr,n,nr2,a;
int main()
{
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a;
        nr2=0;
        while(a%2==0)
        {
            a=a/2;
            nr2++;
        }
        if(nr2<nr or i==1)
        {
            nr=nr2;
        }
    }
    cout<<nr<<'\n';
    return 0;
}


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

int main(){
  int n;
  cin>>n;
  int a[3];
  vector<int>candidacy;
  set<int>ans;
  for (int i = 0; i < n; i++){
    cin>>a[i];
  }
  for (int i = 1; i*i <= a[0]; i++){
    if (a[0] % i == 0) {
      candidacy.push_back(i);
      candidacy.push_back(a[0] / i);
    }
  }
  for (int i = 0; i < n; i++){
    for (int j = 0; j < candidacy.size(); j++){
      if(a[i] % candidacy[j] != 0) {
	candidacy.erase(candidacy.begin()+j);
	j--;
      }
    }
  }
  for (int i = 0; i < candidacy.size(); i++){
    ans.insert(candidacy[i]);
  }
  for (int res: ans) {
    cout << res << endl;
  }
return 0;
}

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

int main() {
  string S;
  int N , i, count=0;
  cin >> N >> S;
  for(i=0; i<N-2; i++){
    if (S[i]=='A' && S[i+1]=='B' && S[i+2]=='C') {
      count++;
      i += 2;
    }
  }
  cout << count;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int N;
	scanf("%d",&N);
	int i;
	char S;
	int c=0;
	for(i=0;i<N;i++){
		scanf("%c",&S);
		if(S == 'Y'){
			c = 1;
			break;
		}
	}
	
	if(c == 0)	printf("Three");
	else			printf("Four");
	
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 210000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long C(int a,int b){
	if(a<b||b<0)return 0;
	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ
vector<int>g[110000];
int op[110000];
map<pair<int,int>,int>M;
int s[110000];
int t[110000];
int pr[110000];
int vis[110000];
vector<int>g2[110000];
void dfs(int a){
	vis[a]=1;
	for(int i=0;i<g[a].size();i++){
		if(!vis[g[a][i]]){
			pr[g[a][i]]=a;
			g2[a].push_back(g[a][i]);
			dfs(g[a][i]);
		}
	}
}
int dfs2(int a,int b){
	int cur=0;
	for(int i=0;i<g2[a].size();i++){
		cur+=dfs2(g2[a][i],a);
	}
	if(op[a]%2)cur++;
	if(cur%2&&b!=-1){
		int at=M[make_pair(a,b)];
		swap(s[at],t[at]);
	}
	return cur;
}
int main(){
	int a,b;scanf("%d%d",&a,&b);
	if(b%2){
		printf("-1\n");return 0;
	}
	for(int i=0;i<b;i++){
		int p,q;
		scanf("%d%d",&p,&q);p--;q--;
		g[p].push_back(q);
		g[q].push_back(p);
		M[make_pair(p,q)]=i;
		M[make_pair(q,p)]=i;
		s[i]=p;
		t[i]=q;
		op[p]++;
	}
	for(int i=0;i<a;i++)pr[i]=-1;
	dfs(0);
	dfs2(0,-1);

	for(int i=0;i<b;i++){
		printf("%d %d\n",s[i]+1,t[i]+1);
	}
}

Measured memory_bytes: 40832
import numpy as np
import sys
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N,T = inpl()
dp = np.zeros((6001),int)
ABs = [inpl() for _ in range(N)]
ABs.sort()

for A,B in ABs:
    dp[A:T+A] = np.maximum(dp[A:T+A], dp[:T]+B)
    # for i in reversed(range(A,T+A)):
    #     dp[i] = max(dp[i-A] + B, dp[i])


print(max(dp))


Measured memory_bytes: 23712
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const int MOD2=998244353;
const ll MAX=9187201950435737471;
const int N=100005;
const int INF=1e9+7;
const long double PI=acos(-1);



void solve(int T){
    string s;
    cin>>s;
    stack<char>st;
    for(int i=0;i<s.size();i++){
        if(s[i]=='0')st.push('0');
        else if(s[i]=='1')st.push(s[i]);
        else{
            if(!st.empty()){
                st.pop();
            }
        }
    }
    string ans="";
    while(!st.empty()){
        ans+=st.top();
        st.pop();
    }
    reverse(ans.begin(),ans.end());
    cout<<ans<<"\n";
}

int main() {
    fastio

    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
    }
	return 0;
}


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

int N;
int a[110];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> a[i];

    double avr = 0;
    for (int i = 0; i < N; i++) avr += (double)a[i];
    avr /= (double)N;

    int ans = 0;
    double min_abs = 1.0e9;
    for (int i = 0; i < N; i++) {
        if (abs(a[i] - avr) < min_abs) {
            min_abs = abs(a[i] - avr);
            ans = i;
        }
    }    

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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_MAX	2,147,483,647 = 2*1.0e9

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

  int count = 0;
  for(int x = 0; x <= K; x++){
    for(int y = 0; y <= K; y++){
      int z = S - x - y;
      if(z <= K && z >= 0) count +=1;
    }
  }

  cout << count << endl;

  return 0;
}



Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    L = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14,
         1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    k = int(input())

    print(L[k-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
using namespace std;
using ll = long long;
ll INF = 9999999999999999;

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

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

ll lcm(ll a, ll b){
    ll g = gcf(a, b);
    return a/g * b;
}
int main(void){
    int a; cin >> a;
    string s; cin >> s;
    if(a >= 3200) cout << s << endl;
    else if(a < 3200) cout << "red" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<Pll> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define SORT(x) sort(all(x))
#define RSORT(x) sort(all(x),greater<ll>())
#define vec_max(V) *max_element(all(V))
#define vec_min(V) *min_element(all(V))
#define vec_sum(V) accumulate(all(V), 0LL)
#define print(X) cout << (X) << "\n"
#define _ << " " <<
#define Yes print("Yes")
#define No print("No")
static const int INF = 1e+9+7;

int main(){
	ll N;
	cin >> N;
    
	if(N < 10) print(N);
	else if(N < 100) print(9);
	else if(N < 1000) print(9 + (N-99));
	else if(N < 10000) print(9 + 900);
	else if(N < 100000) print(9 + 900 + (N-9999));
	else print(9 + 900 + 90000);
	
 return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
#include <utility>
// #include <numeric>
using namespace std;



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<ll>> vvint;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define LLONG_MAX 9223372036854775807
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())


// typedef struct{
//   ll i;
//   ll j;
//   ll depth;
// } data;



int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0,};

// ll X,Y,Z,K;
// ll pmax = 30000000000;
// vint A,B,C;




// int binary_search(int key){
//  //isOKを満たす要素のうち最小のインデックスを返す。（要ソート）
//   int left = -1;
//   int right = N;
//
//   while(right - left > 1){
//     int mid = left + (right - left)/2;
//
//     if(isOK(mid, key)) right=mid;
//     else left=mid;
//   }
//
//   return right;
// }

// ll gcd(ll m, ll n){
//   if(m<n) swap(m,n);
//   if(n==0) return m;
//   return gcd(n, m%n);
// }



int main() {



  ll H,W,N;
  cin >> H >> W >> N;
  ll sr,sc;
  cin >> sr >> sc;
  string S,T;
  cin >> S >> T;

  ll ulim,dlim,llim,rlim;
  ulim = 1; dlim=H;llim=1;rlim=W;



  repr(i,N){
    // cout << S[i] << " " << T[i] << endl;
    // cout << ulim << " " << dlim << " " << llim << " " << rlim << endl;

    if(T[i]=='U') dlim=min(H, dlim+1);
    else if(T[i]=='D') ulim=max(1ll, ulim-1);
    else if(T[i]=='L') rlim=min(W, rlim+1);
    else if(T[i]='R') llim=max(1ll, llim-1);


    // cout << ulim << " " << dlim << " " << llim << " " << rlim << endl;

    if(S[i]=='U') ulim++;
    else if(S[i]=='D') dlim--;
    else if(S[i]=='L') llim++;
    else if(S[i]=='R') rlim--;

    // cout << ulim << " " << dlim << " " << llim << " " << rlim << endl;

    if(ulim>H||dlim<1||llim>W||rlim<1){ cout << "NO" << endl; return 0;}
    if(ulim>dlim||llim>rlim){ cout << "NO" << endl; return 0;}
  }

  if(ulim<=sr&&sr<=dlim&&llim<=sc&&sc<=rlim) cout << "YES" << endl;
  else cout << "NO" << endl;




}

















//


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

int n, a, b;
long long k;
const int MOD = 998244353;
int f[300010];

int add(int a, int b) {
	return ((long long) a + b) % MOD;
}

int mul(int a, int b) {
	return ((long long) a * b) % MOD;
}

int pot(int x, int y) {
	int out = 1, pr = x;
	while (y) {
		if (y & 1) out = mul(out, pr);
		pr = mul(pr, pr);
		y /= 2;
	}
	return out;
}

int main () {
	
	cin >> n >> a >> b >> k;
	long long int sol = 0;
	f[0] = 1;
	for (int i = 1; i <= n; i ++) {
		f[i] = mul(f[i-1], i);
	}
	
	for (int i = 0; i <= n; i ++) {
		long long int tren = k;
		tren -= i * a;
		if (tren < 0 || tren % b != 0) continue;
		tren /= b;
		if (tren > n) continue;
		long long int sad = mul(f[n], pot(mul(f[i], f[n-i]), MOD-2));
		sad = mul(sad, mul(f[n], pot(mul(f[tren],f[n-tren]), MOD-2)));
		
		sol += sad;
		sol %= MOD;
	}
	
	cout << sol;

	return 0;
}

Measured memory_bytes: 1408
n = int(input())
a = list(map(int,input().split()))

li = [0]*(n+1)

for i in a:
    li[i] += 1

li2 = [[0]*2 for _ in range(n+1)]

for i in range(n+1):
    for j in range(2):
        if j == 0:
            li2[i][j] = li[i] * (li[i] - 1) // 2
        else:
            li2[i][j] = max((li[i] - 1) * (li[i] - 2) // 2, 0)

sum1 = 0
for i in range(n+1):
    sum1 += li2[i][0]

sum2 = [0]*(n+1)

for i in range(n+1):
    sum2[i] = sum1 - li2[i][0] + li2[i][1]

for i in a:
    print(sum2[i])


Measured memory_bytes: 45596
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int N, D;
	cin >> N >> D;
	cout << (N) / (2 * D+1) + bool((N) % (2 * D+1)) << endl;
}

Measured memory_bytes: 256
h = [[[0 for _ in range(10)] for _ in range(3)] for _ in range(4)]

for _ in range(int(input())):
    b, f, r, v = map(int, input().split())
    h[b-1][f-1][r-1] += v

for b in range(4):
    for f in range(3):
        print(' ' + ' '.join(map(str,h[b][f])))
    if b<3:
        print('#'*20)


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

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ll = long long int;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using cdouble = complex<double>;

const double INFD = numeric_limits<double>::infinity();
const double PI = 3.14159265358979323846;
#define Loop(i, n) for(int i = 0; i < (int)(n); i++)
#define Loop1(i, n) for(int i = 1; i <= (int)(n); i++)
#define Loopr(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)(n); i >= 1; i--)
#define Foreach(buf, container) for(auto buf : container)
#define Loopdiag(i, j, h, w, sum) for(int i = ((sum) >= (h) ? (h) - 1 : (sum)), j = (sum) - i; i >= 0 && j < (w); i--, j++)
#define Loopdiagr(i, j, h, w, sum) for(int j = ((sum) >= (w) ? (w) - 1 : (sum)), i = (sum) - j; j >= 0 && i < (h); j--, i++)
#define Loopdiagsym(i, j, h, w, gap) for (int i = ((gap) >= 0 ? (gap) : 0), j = i - (gap); i < (h) && j < (w); i++, j++)
#define Loopdiagsymr(i, j, h, w, gap) for (int i = ((gap) > (h) - (w) - 1 ? (h) - 1 : (w) - 1 + (gap)), j = i - (gap); i >= 0 && j >= 0; i--, j--)
#define Loopitr(itr, container) for(auto itr = container.begin(); itr != container.end(); itr++)
#define printv(vector) Loop(ex_i, vector.size()) { cout << vector[ex_i] << " "; } cout << endl;
#define printmx(matrix) Loop(ex_i, matrix.size()) { Loop(ex_j, matrix[ex_i].size()) { cout << matrix[ex_i][ex_j] << " "; } cout << endl; }
#define quickio() ios::sync_with_stdio(false); cin.tie(0);
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
#define Comp(type_t) bool operator<(const type_t &another) const
#define fst first
#define snd second
bool nearlyeq(double x, double y) { return abs(x - y) < 1e-9; }
bool inrange(int x, int t) { return x >= 0 && x < t; }
bool inrange(vi xs, int t) { Foreach(x, xs) if (!(x >= 0 && x < t)) return false; return true; }
ll rndf(double x) { return (ll)(x + (x >= 0 ? 0.5 : -0.5)); }
ll floorsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (m * m <= x ? 0 : -1); }
ll ceilsqrt(ll x) { ll m = (ll)sqrt((double)x); return m + (x <= m * m ? 0 : 1); }
ll rnddiv(ll a, ll b) { return (a / b + (a % b * 2 >= b ? 1 : 0)); }
ll ceildiv(ll a, ll b) { return (a / b + (a % b == 0 ? 0 : 1)); }
ll gcd(ll m, ll n) { if (n == 0) return m; else return gcd(n, m % n); }
ll lcm(ll m, ll n) { return m * n / gcd(m, n); }

/*******************************************************/

int main() {
	ll n, m; cin >> n >> m;
	ll ans = (m * 1900 + (n - m) * 100) * (1LL << m);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d,e;
map <string, bool> m;
string s[109];
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a;
	for(b=1; b<=a; b++){
		cin>>s[b];
		if(m[s[b]]==1){
			cout<<"No";
			return 0;
		}
		m[s[b]]=1;
		if(b!=1){
			if(s[b][0]!=s[b-1][s[b-1].size()-1]){
				cout<<"No";
			return 0;
			}
		}
	}
	cout<<"Yes";
	return 0;
}

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

dp = [float('inf')] * n
dp[0] = 0
# 足場を一つづつ見ていく
for i in range(1, n):
    for j in range(max(0,i-k),i):
        # 今の足場へのコストと、他の足場から来た場合のコストを比較
        dp[i] = min(dp[i], dp[j] + abs(h[i]-h[j]))
print(dp[-1])

Measured memory_bytes: 55008
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;scanf("%d",&n);
    map<long long,int> a;
    for(int i=0;i<n;i++){
        long long l;scanf("%lld",&l);
        a[l]++;
    }
    set<long long> two,four;
    for(auto p:a){
        if(p.second>=4)four.insert(p.first);
        if(p.second>=2)two.insert(p.first);
    }
    long long ans=0;
    if(four.size()){
        auto itr=four.end();itr--;
        ans=(*itr)*(*itr);
    }
    if(two.size()>=2){
        auto itr=two.end();itr--;
        long long now=*itr;
        itr--;
        now*=(*itr);
        ans=max(ans,now);
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 6528