akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
        int n = sc.nextInt();
        int [] a = new int[n + 1];
        for (int i = 1; i <= n; i++) a[sc.nextInt()] = i;
        TreeSet<Integer> set = new TreeSet<>();
        long ans = 0;
        for (int i = 1; i <= n; i++) {
            int idx = a[i];
            int lo = 1; int hi = n;
            if (set.lower(idx) != null) lo = set.lower(idx) + 1;
            if (set.higher(idx) != null) hi = set.higher(idx) - 1;
            ans = (ans + ((long) idx - lo + 1) * ((long) hi - idx + 1) * i);
            set.add(idx);
        }
        out.println(ans);
        out.close();
    }


    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }


    }

}

Measured memory_bytes: 64264
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>
#define mod(x) ((x % MOD) + MOD) % MOD
#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

typedef pair<int,int> P;

const int INF = 1e18;
const int MOD = 1e9+7;
const int MAX_A = 1e9+1;


void add(vector<int>& bit, int i, int x) {
  while (i <= bit.size()) {
    bit[i] += x;
    i += i & -i;
  }
}

int sum(vector<int>& bit, int i) {
  int s = 0;
  while (i > 0) {
    s += bit[i];
    i -= i & -i;
  }
  return s;
}

int inversion(vector<int>& S)
{
  int N = S.size();
  vector<int> bit(2*(N+1));
  int s = 0;
  for (int i = 1; i <= N; i++) {
    s += sum(bit, S[i-1]+(N+1));
    add(bit, S[i-1]+(N+1), 1);
  }
  return s;
}

int count(vector<int> a, int x)
{
  int N = a.size();
  for(int i = 0; i < N; i++) {
    if (a[i] >= x) {
      a[i] = 1;
    } else {
      a[i] = -1;
    }
  }
  vector<int> S(N+1);
  S[0] = 0;
  for (int i = 1; i < N+1; i++) {
    S[i] = S[i-1] + a[i-1];
  }

  return inversion(S);
}

int binary(vector<int>& a, int N)
{
  int l = -1, r = MAX_A, m;
  while (r - l > 1) {
    m = (l + r) / 2;
    if (count(a, m) >= ((N*(N+1)/2)+1)/2) {
      l = m;
    } else {
      r = m;
    }
  }
  return l;
}


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

  cout << binary(a, N) << endl;

  return 0;
}


Measured memory_bytes: 4212
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
int main()
{
    int n, k;
    scanf("%d%d", &n, &k);
    vll h(n), dp(n + 2 * k, LLONG_MAX);
    dp[0] = 0;
    for (int i = 0; i < n; i++) scanf("%lld", &h[i]);
    for (int i = 0; i < n; i++){
        for (int j = 1; j <= k; j++){
            dp[i + j] = min(dp[i + j], dp[i] + abs(h[i + j] - h[i]));
        }
    }
    // for (int i = 0; i < n; ++i) cout << dp[i] << " ";
    // cout << endl;
    printf("%lld", dp[n - 1]);
    return 0;
}

Measured memory_bytes: 4840
void main() {
  problem();
}

void problem() {
  const N = scan!long;
  const M = scan!long;
  
  void solve() {

    const oddStart = M / 2;
    foreach(i, d; iota(2, M+1, 2).array){
      writefln("%s %s", oddStart - i, oddStart - i + d);     
    }
    
    const evenStart = N - (M % 2 == 0 ? M / 2 : M / 2 + 1);
    foreach(i, d; iota(1, M+1, 2).array){
      writefln("%s %s", evenStart - i, evenStart - i + d);     
    }
  }

  solve();
}

// ----------------------------------------------

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");

// -----------------------------------------------


Measured memory_bytes: 3432
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n, m;
    cin >> n >> m;
    vector<int> cnt(n, 0);
    vector<bool> wc(n, false);
    int i, ac = 0, pen = 0;
    for(i=0; i<m; i++){
        int x;
        string s;
        cin >> x >> s;
        x--;
        if(!wc[x]){
            if(s=="AC"){
                ac++;
                pen += cnt[x];
                wc[x] = true;
            }
            else cnt[x]++;
        }
    }
    cout << ac << " " << pen << endl;
    return 0;
}

Measured memory_bytes: 3700
n = int(input())


def convert(num):
    if num <= 26:
        return chr(64 + num)
    elif num % 26 == 0:
        return convert(num // 26 - 1) + chr(90)
    else:
        return convert(num // 26) + chr(64 + num % 26)


print(str(convert(n)).lower())


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long

int main() {
  ll A, B, C, D;
  cin >> A >> B >> C >> D;

  int gcd = __gcd(C, D);
  ll lcm = C * D / gcd;

  ll a = A - 1;

  ll r = B - (ll)(B / C) - (ll)(B / D) + (ll)(B / lcm);
  ll l = a - (ll)(a / C) - (ll)(a / D) + (ll)(a / lcm);

  ll ans = r - l;
  cout << ans << endl;
};


Measured memory_bytes: 256
import numpy as np 
from sys import stdin, setrecursionlimit
 
setrecursionlimit(10 ** 9)

N,K = map(int,input().split())
A = list(map(int,input().split()))

t = 1
tpass = [1]
k = 0
j = 1
temp3 = [0]*N
for i in range(N):
    temp = A[t-1] 
    if i == K-1:
        print(temp)
        exit()
    if temp3[temp-1] != 0 :
        idx = tpass.index(temp)
        l = len(tpass)
        j = -1
        break
    else:
        
        t = temp
        temp3[t-1] = 1
        tpass.append(temp)
        k += 1

try:
    a = K - k
    loop = l - idx
    b = a % loop 
    temp2 = tpass[idx:]
    ans = temp2[b-1]
    print(ans)
except:
    pass

Measured memory_bytes: 51032
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
#define degreeToRadian(deg) (((deg)/360)*2*M_PI)
#define radianTodegree(rad) (((rad)/2/M_PI)*360)
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; }
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;
const int MOD = 1e9 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//cin.tie(0);ios::sync_with_stdio(false);
//cout << fixed << setprecision(15) << y << endl;
int main() {
  double a, b;
  cin >> a >> b;

  int ans = 1e6;
  for (int i = 1; i < 1300; i++) {
    //cout << i << ":" << (int)(0.08 * i) << " " << (int)(0.1 * i) << endl;
    if ((int)(0.08 * i) == a && (int)(0.1 * i) == b) {
      ans = min(ans, i);
    }
  }

  if (ans == 1e6) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3716
#include<stdio.h>

#define N 100000

int n, A[N];

int partition(int p, int r){
    int x=A[r];
    int i=p-1;
    for(int j=p; j<r; j++){
        if(A[j]<=x){
            i++;
            int temp;
            temp=A[i];
            A[i]=A[j];
            A[j]=temp;
        }
    }
    int temp;
    temp=A[i+1];
    A[i+1]=A[r];
    A[r]=temp;

    return i+1;

}

int main(void){
    scanf("%d", &n);

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

    int q=partition(0, n-1);

    for(int i=0; i<q; i++){
        printf("%d ",A[i]);
    }
    printf("[%d] ",A[q]);

    for(int i=q+1; i<n-1; i++){
        printf("%d ",A[i]);
    }
    printf("%d\n",A[n-1]);

    return 0;


}


Measured memory_bytes: 2184
//هوالحق
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> PII;
typedef long long ll;

template<typename T>
T In() {
   T x;
   cin >> x;
   return x;
}

int main() {
   ios::sync_with_stdio(false), cin.tie(nullptr);
   map<string, string> M;
   M["Sunny"] = "Cloudy";
   M["Cloudy"] = "Rainy";
   M["Rainy"] = "Sunny";
   cout << M[In<string>()];
   return cout << endl, 0;
}

Measured memory_bytes: 256
"use strict";
function Main(input) {
    let lines = input.split("\n");
    let N = lines[0] - 0;
    let sum = 0;
    for (let n = 1; n <= N; n++) {
        let xv = lines[n].split(/\s/);
        let x = xv[0] - 0;
        sum += (xv[1] == 'BTC') ? x * 380000.0 : x;
    }

    console.log(sum);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

using namespace std;

using ll = long long int;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	string x, y;

	cin >> x >> y;
	if (x < y) {
		cout << "<" << endl;
	} else if (x > y) {
		cout << ">" << endl;
	} else {
		cout << "=" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	
	if(b/a>=c)
	{
		cout<<c<<endl;
		return 0;
	}
	else{
		cout<<b/a<<endl;
		return 0;
	}
}

Measured memory_bytes: 256
/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

#include<bits/stdc++.h>
using namespace std;
#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;

typedef long long ll;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
#define pb     push_back
#define inf     2e18
#define low     -2e18
#define PI        acos(-1.0)
#define endl  "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)
const int sz = 1e5+9;

int main()
{
	
    ll i,n,t,k,j,x=0,y=0,m;
    cin>>n>>m>>k;
    if(n%m==0)
    	cout<<(n/m)*k<<endl;
    else cout<<((n/m)+1)*k<<endl;

    
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
using namespace std;
#define rep(i, n) for(int i=0;i<(n);i++)

int N, T;

int c[102], t[102];

int mc = 1003;

int main() {
  
  cin>>N>>T;
  rep(i, N)cin>>c[i]>>t[i];
  
  rep(i, N) {
    if(t[i]<=T) {
      if(c[i]<mc)mc = c[i];
    }
  }
  
  if(mc>1000)cout<<"TLE"<<endl;
  else cout<<mc<<endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		String str;
		int[] count = new int[26];
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while ((str = br.readLine()) != null) {
			str = str.toLowerCase();
			char[] cArray = str.toCharArray();
			for (char c : cArray) {
				if ((c - 'a') >= 0 && (c - 'a') <= 26 ) {
					count[c - 'a']++;
				}
			}
		}
		for (char c = 'a'; c <= 'z'; c++) {
			System.out.printf("%s : %d%n", c, count[c - 'a']);
		}
	}
}

Measured memory_bytes: 17144
from collections import deque

def solve(W, H, walls):
    edge = [[[] for i in range(W)] for j in range(H)]
    for i in range(H):
        for j in range(W-1):
            if (not walls[2*i][j]):
                edge[i][j].append((i, j+1))
                edge[i][j+1].append((i,j))
    for i in range(H-1):
        for j in range(W):
            if (not walls[2*i+1][j]):
                edge[i][j].append((i+1, j))
                edge[i+1][j].append((i,j))

    q = deque()
    q.append((0, 0))
    dist = [[-1]*W for i in range(H)]
    dist[0][0] = 1

    while q:
        y, x = q.popleft()
        for ny, nx in edge[y][x]:
            if (dist[ny][nx] == -1):
                dist[ny][nx] = dist[y][x] + 1
                q.append((ny, nx))


    return dist[H-1][W-1] if (dist[H-1][W-1] != -1) else 0

"""
def solve(W, H, walls):
    dire = [(1,0), (0,1), (-1,0), (0,-1)]
    field = [[1]*(2*W) for i in range(2*H)]
    for i in range(0,2*H,2):
        vertical_wall = walls[i]
        for j in range(W-1):
            if (vertical_wall[j]):
                field[i][j*2+1] = field[i+1][j*2+1] = 0

    for i in range(1,2*H-1,2):
        horizontal_wall = walls[i]
        for j in range(W):
            if (horizontal_wall[j]):
                field[i][j*2] = field[i][j*2+1] = 0

    q = deque()
    dist = [[-1]*(2*W) for i in range(2*H)]
    q.append((0,0))
    dist[0][0] = 0

    while q:
        y, x = q.popleft()
        for dy, dx in dire:
            if (y+dy<2*H) and (y+dy>=0) and (x+dx<2*W) and (x+dx>=0):
                if (field[y+dy][x+dx]) and (dist[y+dy][x+dx] == -1):
                    dist[y+dy][x+dx] = dist[y][x] + 1
                    q.append((y+dy, x+dx))
    res = dist[2*H-1][2*W-1]//2

    for i in field:
        for j in i:
            print("." if j else "#", end="")
        print()

    ans_dist = [[0]*W for i in range(H)]
    for i in range(H):
        for j in range(W):
            ans_dist[i][j] = max(dist[2*i][2*j], dist[2*i][2*j+1], dist[2*i+1][2*j], dist[2*i+1][2*j+1]) // 2
    for i in ans_dist:
        print(i)

    #for i in dist:
       # print(i)

    return res if (res != -1) else 0

"""
def main():
    ans = []
    while True:
        W, H = map(int, input().split())
        if (W==0) and (H==0):
            break
        walls = [list(map(int, input().split())) for i in range(2*H-1)]
        ans.append(solve(W, H, walls))
    
    for i in ans:
        print(i)

main()


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

ll GCD(ll a, ll b) {
    if(a < b) {
        swap(a, b);
    }
    if(a % b == 0) {
        return b;
    } else {
        return GCD(b, a % b);
    }
}

vector<pair<ll, int>> factorize(ll n) {
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; i++) {
        if(n % i != 0) {
            continue;
        }
        res.emplace_back(i, 0);
        while(n % i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if(n != 1) {
        res.emplace_back(n, 1);
    }
    return res;
}

int main() {
    ll A, B;
    cin >> A >> B;

    ll gcd = GCD(A, B);
    auto factors = factorize(gcd);

    cout << (factors.size() + 1) << endl;
    return 0;
}


Measured memory_bytes: 256
array = list(map(int, input().split()))
num = 3
def print_array():
    for i in range(num):
        if i != num-1:
            print(array[i], end=' ')
        else:
            print(array[i])
# insertion sort
for i in range(num):
    insert = array[i]
    j = 0
    while array[j] < insert:
        j+=1
    for k in range(i, j, -1):
        array[k] = array[k - 1]
    array[j] = insert
print_array()



Measured memory_bytes: 5600
#include <stdio.h>
int main(void)
{
    int N,hold;
    scanf("%d",&N);
    hold = N-N/10*10;
    switch(hold){
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
        printf("hon");
        break;
        case 0:
        case 1:
        case 6:
        case 8:
        printf("pon");
        break;
        case 3:
        printf("bon");
        break;
    }
    return 0;
}

Measured memory_bytes: 1692
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define mo 1000000007
#define mod2 1000000000
#define mod1 998244353
#define lol ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define F(i, n) for (ll (i) = 0; (i) < (n); (i)++)
#define pb push_back
#define pf push_front
#define mp make_pair
#define f first
#define ss second


ll func(ll n)
{
    if(n>=1800) return 1;
    if(n>=1600) return 2;
    if(n>=1400) return 3;
    if(n>=1200) return 4;
    if(n>=1000) return 5;
    if(n>=800) return 6;
    if(n>=600) return 7;
    if(n>=400) return 8;
    return 0;
}
int main()
{
    ll n;cin >> n;
    cout << func(n) << endl;
    // ll arr[n];
    // for(ll i=0;i<n;i++)
    // {
    //     cin >> arr[i];
    // }
}

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

const int MX = 200005;

int A[MX];

vector<pair<int, int>> st;
int lt[MX];
int a[MX];

int M;

void inc(int i, int t)
{
	while (true) {
		int j = (int)st.size() - 1;
		while (st[j].first > i) j--;
		if (lt[i] < st[j].second) {
			lt[i] = t;
			a[i] = 0;
		}
		
		//cout << st[j].first << " " << st[j].second << " " << i << endl;
		
		a[i]++;
		if (i > 0 && a[i] == M) {
			a[i] = 0;
			i--;
		}
		else {
			break;
		}
	}
}

int main()
{
	int n;
	ignore = scanf("%d", &n);
	
	for (int i = 1; i <= n; i++) {
		ignore = scanf("%d", A + i);
		if (A[i] > 200000) A[i] = 200000;
	}
	
	int L = 1, R = n - 1;
	int B = n;

	//int L = 2, R = 2; /////
	//int B = 0; //////
	
	while (L <= R) {
		M = (L + R) / 2;

		memset(lt, 0, sizeof lt);
		memset(a, 0, sizeof a);
		st.clear();
		
		bool ok = true;
		st.push_back({1, 0});
		for (int i = 1; i <= n; i++) {
			while (A[i] + 1 <= st.back().first) st.pop_back();
			st.push_back({A[i] + 1, i});
			
			if (i > 1 && A[i] <= A[i - 1]) {
				inc(A[i], i);
			}
			
			if (a[0] > 0) {
				ok = false;
				break;
			}
		}
		
		if (ok) {
			B = M;
			R = M - 1;
		}
		else {
			L = M + 1;
		}
	}
	
	printf("%d\n", B);
}


Measured memory_bytes: 4724
# i の味は l + i - 1 
n,l = gets.split.map(&:to_i)
ans = []
if l >= 0 
  (2..n).each do |i|
    ans << l + i - 1
  end
else 
  (1..n).each do |i|
    ans << l + i - 1
  end
end
sum = ans.inject(:+)

if ans.include?(0)
  p sum
elsif sum > 0
  p sum
else
  p sum - ans.max
end

Measured memory_bytes: 1916
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;

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


Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<iomanip>
using namespace std;
#define int long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF (long long)(1e18)
#define MOD (int)(1e9+7)
#define min(a,b) (a>b?b:a)
#define max(a,b) (a>b?a:b)
#define yn(f) (f?"Yes":"No")
#define YN(f) (f?"YES":"NO")


signed main(){
	cout<<fixed<<setprecision(7);
	int n, m;
	string str;
	
	cin>>str;
	
	cout<<(str[0]+str[1]+str[2]  - '0'- '0'- '0')<<endl;
	
	
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<functional>
#include<numeric>
#include<queue>
#include<stack>
#include<map>
#include<unordered_map>
#include<set>
#include<bitset>
#include<random>
#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 1LL << 61;
const ll mod = 1000000007LL;
//const ll mod = 998244353LL;

ll n = 0, m = 0, ans = 0, tmp = 0, ma = -inf, mi = inf;
string s;
ll dx[9] = { 0,1,0,-1,0,1,1,-1,-1 }, dy[9] = { 0,0,1,0,-1,1,-1,1,-1 };
#define endl '\n'
#pragma endregion
#define MAX 222222






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


  cin >> m >> n;
  FOR(i, 1, n + 1) {
    ll a, b;
    a = i / 10;
    b = i % 10;
    if (a < 2 || b < 2) continue;
    if (a*b <= m) ans++;
  }
  cout << ans << endl;





  return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
const int N=2e5+4;
int a[101];
vector<int> moves;
int32_t main()
{
	#ifndef ONLINE_JUDGE
		freopen("in","r",stdin);
		freopen("out","w",stdout);
	#endif
	int n,ans=0;
	cin>>n;
	int a[n][n];
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++){cin>>a[i][j];}

	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++)ans+=a[i][j];

	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			for(int k=0;k<n;k++)
			{
				if(a[i][j]+a[j][k]<a[i][k])
				{
					puts("-1");return 0;
				}
			}


	
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++)
		{	

			for(int k=0;k<n;k++)
			{
				if(i!=k and j!=k and a[i][k]+a[k][j]==a[i][j]){ans-=a[i][j];break;}
			}
		}

	cout<<ans;
	
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

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


int main()
{
    ll h,w;
    cin>>h>>w;
    if(h==1 || w==1) cout<<1<<endl;
    else cout<<(h*w+1)/2<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <cassert>
#include <complex>
 
using namespace std;
 
typedef long long ll;
 
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  int n;
  cin >> n;
  vector <int> a(n), b(n), c(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) cin >> b[i];
  for (int i = 0; i < n; ++i) cin >> c[i];
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());
  ll ans = 0;
  for (int x : b) {
    int c1 = lower_bound(a.begin(), a.end(), x) - a.begin();
    int c2 = c.end() - upper_bound(c.begin(), c.end(), x);
    ans += (ll)c1 * c2;
  }
  cout << ans << '\n';
}


Measured memory_bytes: 1408
// SeeAlso: 

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 100000

typedef int _loop_int;
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

int N, Q;
string S;
int l[MAX], r[MAX];

int t[MAX];

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

    t[0] = 0;
    for(int i = 1; i < N; i++) {
        if(S[i] == 'C') {
            if(S[i-1]=='A') {
                t[i] = t[i-1]+1;
            }else{
                t[i] = t[i-1];
            }
        }else{
            t[i] = t[i-1];
        }
    }

    REP(i, Q) {
        cin >> l[i] >> r[i]; 
    }

    REP(i, Q) {
        int ans = t[(r[i]-1)] - t[(l[i]-1)];    
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 2176
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<iomanip>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

#define fcout cout<<fixed<<setprecision(15)
#define repp(i,j,k) for(int i=j; i<k; ++i)
#define rep(i,j) repp(i,0,j)
#define rrep(i,j,k) for(int i=j; i>=k; --i)
#define all(x) (x).begin(), (x).end()
#define sort(x) sort(x.begin(), x.end())
#define lb(x,val) lower_bound(x.begin(), x.end(), val)
#define ub(x,val) upper_bound(x.begin(), x.end(), val)
#define pb(x) emplace_back(x);

typedef long long int lli;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef tuple<int, int, lli> tiil;

//const lli M=998244353ll;
const lli M=1000000007ll;
const double D=1.0;

int main(){
	fast_io
	int a,b,c; cin>>a>>b>>c;
	cout<<max(a*b, max(a+b,a-b));
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string toString(int n)
{
    string str;
    stringstream ss;
    ss << n;
    ss >> str;
    return str;
}
string toNegativeBase(int n, int negBase)
{
    if (n == 0)
        return "0";
 
    string converted = "";
    while (n != 0)
    {
        int remainder = n % negBase;
        n /= negBase;
        if (remainder < 0)
        {
            remainder += (-negBase);
            n += 1;
        }
        converted = toString(remainder) + converted;
    }
 
    return converted;
}
int main()
{	int n;
	cin>>n;
    int negBase = -2;
 
    cout << toNegativeBase(n, negBase)<<endl;
 
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace cc
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] strs = Console.ReadLine().Split(' ');

            long A = long.Parse(strs[0]);
            long B = long.Parse(strs[1]);

            long ans = 0;

            if (B - A <= 8)
            {
                for (long i = A; i <= B; i++)
                {
                    ans ^= i;
                }
            }
            else
            {
                while (A % 4 != 0)
                {
                    ans ^= A;
                    A++;
                }
                while (B % 4 != 3)
                {
                    ans ^= B;
                    B--;
                }
            }


            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
S=input()
if S[0]!='A':
  print('WA')
  exit()

if 'C' not in S[2:-1]:
  print('WA')
  exit()

s=list(S)
s.remove('A')
s.remove('C')

for x in s:
  if x not in 'abcdefghijklmnopqrstuvwxyz':
    print('WA')
    exit()

print('AC')

Measured memory_bytes: 8960
import sys
h,w,m=map(int,input().split())
bomb_h = [0]*h
bomb_w = [0]*w
place = list()
#O(m)
for _ in range(m):
  x,y=map(int,input().split())
  bomb_h[x-1]+=1
  bomb_w[y-1]+=1
  place.append([x-1,y-1])
x_cand = list()
x_max = 0
#O(H)
for x in range(h):
  if x_max < bomb_h[x]:
    x_cand = [x]
    x_max = bomb_h[x]
  elif x_max == bomb_h[x]:
    x_cand.append(x)
y_cand = list()
y_max = 0
#O(W)
for y in range(w):
  if y_max < bomb_w[y]:
    y_cand = [y]
    y_max = bomb_w[y]
  elif y_max == bomb_w[y]:
    y_cand.append(y)
ans = x_max+y_max
# ここまで10^6
cnt = 0
#O(M)
for p in place:
  if bomb_h[p[0]]== x_max and bomb_w[p[1]]==y_max:
    cnt += 1
if len(x_cand)*len(y_cand) > cnt:
  print(ans)
else:
  print(ans-1)

Measured memory_bytes: 82528
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> B(N-1);
  for (int i = 0; i < N-1; i++){
    cin >> B.at(i);
  }
  int ans = B.at(0) + B.at(N-2);
  for (int i = N-2; i > 0; i--){
    if(B.at(i) < B.at(i-1)){
      ans += B.at(i);
    } else if (B.at(i) >= B.at(i-1)){
      ans += B.at(i-1);
    }
  }
cout << ans << endl;
  return 0;
}


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

using namespace std;

#define ll long long
#define debug(n) cerr << #n << ':' << n << endl;

int main(){
  ll n,m;cin >> n >> m;
  vector<bool> brk(n,false);
  for(int i = 0; i < m; ++i){
    ll x; cin >> x;
    brk[x] = true;
  }

  vector<ll> cnt(n + 2, 0);
  cnt[n + 1] = 0;
  cnt[n] = 1;
  for(int i = n - 1; i >= 0; i--){
    if(brk[i])continue;
    cnt[i] = cnt[i + 1] + cnt[i + 2];
    cnt[i] %= 1000000007;
  }
  cout << cnt[0] << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define rep(i, init, n) for(int i = init; i <(int)(n); i++)

int main() {

    ll K, N;
    cin >> K >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];
    sort(A.begin(), A.end());
    ll tmp = A[0] + K - A[N-1];
    REP(i, N-1) tmp = max(tmp, A[i+1] - A[i]);
    cout << (K - tmp) << endl;
    return 0; 
}


Measured memory_bytes: 1792
# coding: utf-8
# Your code here!

import numpy as np

def canbe_solved(positions):
    odd_evens = [np.dot(p,np.ones(2,int)) %2 for p in positions]
    if len(set(odd_evens)) == 1:
        return True
    else:
        return False

def solutions(p,vals):
    u = np.dot(p, np.array([1,1]))
    v = np.dot(p, np.array([1,-1]))
    for val in vals:
        if u >=0:
            if v >= 0:
                print('R',end="")
                u -= val
                v -= val
            else:
                print('U',end="")
                u -= val
                v += val
        else:
            if v >= 0:
                print('D',end="")
                u += val
                v -= val
            else:
                print('L',end="")
                u += val
                v += val
    print()
    
    
def main():
    #input
    n = int(input().rstrip())
    positions = [np.asarray(list(map(int,input().rstrip().split()))) for _ in range(n)]
    vals = [1<<i for i in range(30,-1,-1)]
    if np.dot(positions[0], np.ones(2,int)) % 2 == 0:
        vals.append(1)

    if canbe_solved(positions):
        print(len(vals))
        for i,p in enumerate(vals):
            print(p,end="")
            if i == len(vals)-1:
                print('')
            else:
                print(' ', end="")

        for p in positions:
            solutions(p,vals)
    else:
        print('-1')
        
main()


Measured memory_bytes: 14636
#include<bits/stdc++.h>
using namespace std;
//約数の個数を求める関数
 long long int divisor(int num1){  
    vector<int> sum(num1+1);
	int num2 = num1;
    long long int ans=1;
	for(long long int i=2;i<=num1;i++){
        while(num2%i==0){
		sum[i]++;
		num2/=i;
        }
    }
	for(long long int i=2;i<=num1;i++)ans*=sum[i]+1;
	return ans;
}
//ここからサンプル
int main(){
    int N,K=0;
    cin >> N;
  if(N%2==0)N--;
  for(int i=N;i>0;i-=2){
    int L=divisor(i);
   if(8==L)K++;
  }
  cout << K << endl;
}


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

#define mp make_pair
#define pb push_back
#define p push

#define FOR(a, c) for(int a = 0;a<c;a++)
#define ll long long int

#define getI(a) scanf("%d",&a)
#define getII(a, b) scanf("%d%d",&a,&b)
#define getIII(a, b, c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a, b) scanf("%lld%lld",&a,&b)
#define getLLL(a, b, c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).rbegin(),(c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a, b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a, b) printf("%lld%lld",a,b);
#define pfd(a) printf("%lf",a);
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);

#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define SIZE  ( int)(1e9 + 7)
#define MAXN (ll) (1e5+5)

using namespace std;

typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector <vector<int>> vvi;
typedef vector<long long> vl;
typedef vector <pair<int, int>> vpi;
typedef vector <pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector <vi> graph;

int main(){
    IOS
    ll n;
    cin >>n;
    if(n==1){
        cout << 2 ;
        return 0;
    }
    bool ctr =1;
    while(1){
        ctr =1;
        for (ll i = 2; i *i <=n ; ++i) {
            if(n %i == 0){
                ctr = 0;
                break;
            }
        }
        if(ctr == 1){
            cout << n;
            return 0;
        }
        n++;
    }
    return 0;
}

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

int main() {
    int n,ans=0;
    cin>>n;
    if(n>=105){
        ans++;
    }
    if(n>=165){
        ans++;
    }
    if(n>=195){
        ans++;
    }
    if(n>=135){
        ans++;
    }
    if(n>=189){
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
B = list(map(int, input().split()))
A = [0] * N

for i in range(N):
    if i == 0:
        A[i] = B[0]
    elif i == N - 1:
        A[i] = B[i-1]
    else:
        A[i] = min(B[i-1], B[i])

print(sum(A))


Measured memory_bytes: 38384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            char[] input = br.readLine().toCharArray();
            List<Integer> charToIntList = new ArrayList<>();

            for (char c : input) {
                charToIntList.add((int) c);
            }

            sortNatualOrder(charToIntList);

            String result = "No";
            if (charToIntList.get(0) == charToIntList.get(1)
                && charToIntList.get(2) == charToIntList.get(3) 
                && charToIntList.get(1) != charToIntList.get(2)) {
                result = "Yes";
            }

            System.out.println(result);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }

    private static void sortNatualOrder(List<Integer> intList) {
        for (int i = 0; i < intList.size() - 1; i++) {
            for (int j = intList.size() - 1; j > i; j--) {
                if (intList.get(j - 1) > intList.get(j)) {
                    int tmp = intList.get(j - 1);
                    intList.set(j - 1, intList.get(j));
                    intList.set(j, tmp);
                }
            }
        }
    }
}

Measured memory_bytes: 21076
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from collections import defaultdict,Counter
from bisect import bisect_left,bisect_right
# from math import gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse_flag):
    data.sort(key=lambda x:x[col],reverse=reverse_flag)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

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

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def SI():
    return input()

def SMI():
    return input().split()

def SRI():
    return list(input().split())

def SCI(n):
    return [ input() for _ in range(n) ]

def SLI(n):
    return [ list(input().split()) for _ in range(n) ]

x,y,z,k = MI()
a = RI()
b = RI()
c = RI()

# a.sort(reverse=True)
# b.sort(reverse=True)
# c.sort(reverse=True)
# M = a[0] + b[0] + c[0]

M = max(a) + max(b) + max(c)

ls = []
for i in range(x):
    for j in range(y):
        ab = a[i] + b[j]
        ls.append(ab)

ls.sort(reverse=True)

ls = ls[:min(k,x*y)]

ls_ans = []
for i in range(min(k,x*y)):
    for j in range(z):
        ls_ans.append( ls[i] + c[j] )
ls_ans.sort(reverse=True)

for i in range(k):
    print(ls_ans[i])

Measured memory_bytes: 141184
inp = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n')
N = inp.shift() * 1
A = inp.shift().split(' ')
o = {}
cnt = 0
for(i=0;i<N;i++) {
    u = A[i] * 1
    if (o[u]) {
        if (o[u] == i+1) {
            cnt++
        }
    } else {
        o[i+1] = u
    }
}
console.log(cnt)

Measured memory_bytes: 26980
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		String s = in.nextLine();
		char[] c = s.toCharArray();
		Arrays.sort(c);
		if(c[0]==c[2]) System.out.println("No");
		else System.out.print("Yes");
	}
}


Measured memory_bytes: 21716
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct node{
  int number;
  struct node *next,*prev;
};
typedef struct node * nodepointer;
nodepointer search(int k);
nodepointer insert(int x);
void delete(int x);
nodepointer deleteF();
nodepointer deleteL();
void list();
nodepointer head;
nodepointer tail;
int main()
{
  int n,m,k=0,i,sum=0,u,x=0,num,ema;
  char com[100];
  head=malloc(sizeof(struct node));
  tail=malloc(sizeof(struct node));
  head->next=tail;
  head->prev=NULL;
  tail->next=NULL;
  tail->prev=head;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    ema=scanf("%s",com);
    if(ema==EOF)break;
    if(strcmp("deleteFirst",com)==0){
      deleteF();
      continue;
    }else if(strcmp("deleteLast",com)==0){
      deleteL();
      continue;
    }
    scanf("%d",&num);
    if(strcmp("insert",com)==0){
      if(insert(num)==NULL);//printf("already exist\n");
    }else if(strcmp("delete",com)==0){
      delete(num);//printf("originally nothing\n");
    }
  }
  list();
  free(tail);
  free(head);
  return 0;
}
nodepointer search(int k){
  nodepointer n;
  for(n=head;n->next!=tail;n=n->next){
    if(n->next->number==k)return n->next;
  }
  return NULL;
}
nodepointer insert(int x){
  nodepointer new;
  new=malloc(sizeof(struct node));
  new->number=x;
  new->next=head->next;
  head->next->prev=new;
  head->next=new;
  new->prev=head;
  return new;
}
void delete(int x){
  nodepointer n,del;
  if((n=search(x))!=NULL){
    n->prev->next=n->next;
    n->next->prev=n->prev;
    free(n); 
  }
}
nodepointer deleteL(){
  nodepointer n,del;
  if(head->next!=tail){
    n=tail->prev->prev;
    del=n->next;
    n->next=tail;
    tail->prev=n;
    free(del);
    return n;
  }else{
    return NULL;
  }
}
nodepointer deleteF(){
  nodepointer n,del;
  n=head->next->next;
  del=n->prev;
  head->next=del->next;
  n->prev=head;
  free(del);
  return n;
}
void list(){
  nodepointer n;
  for(n=head->next;n!=tail;n=n->next){
    printf("%d",n->number);
    if(n->next!=tail)printf(" ");
  }
  printf("\n");
}



Measured memory_bytes: 32972
/***"In the name of Allah(swt), the most gracious, most merciful. Allah(swt) blesses with knowledge whom he wants."***/
/*** "ALHAMDULILLAH for Everything..." ***/
#include<bits/stdc++.h>
using namespace std;
#define  fastt       ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define  ll         long long
#define  debug      printf("Come here!")
#define  inf        1000000000000000000
#define  pb         push_back
#define  mp         make_pair
#define  sz(a)      a.size()
#define  mem(a,b)   memset(a,b,sizeof(a))
#define  clr(x)     x.clear()
#define  ff         first
#define  ss         second
#define  case(x)    cout << "Case " << x <<": "

#define  md         1000000007
#define  pi         acos(-1.0)
#define  cos(a)     cos(a*pi/180)
#define  sin(a)     sin(a*pi/180)
#define  tan(a)     tan(a*pi/180)
#define  cosi(a)    acos(a)/(pi/180)
#define  sini(a)    asin(a)/(pi/180)
#define  tani(a)    atan(a)/(pi/180)

#define  vl         vector <ll>
#define  vs         vector <string>
#define  vc         vector <char>
#define  vpll       vector < pair <ll, ll> >
#define  vpsl       vector < pair <string, ll> >
#define  vpls       vector < pair <ll, string> >
#define  pql        priority_queue<ll>
#define  minpql     priority_queue<ll,vector<ll>,greater<ll> >

#define  setbits(x)     __builtin_popcountll(x)
#define  zerobits(x)    __builtin_ctzll(x)

#define toll(a) atoll(a.c_str())
string tostr(ll a) {stringstream rr;rr<<a;return rr.str();}
ll pow(ll c,ll d){return d==0?:c*pow(c,d-1);}
ll gcd(ll a,ll b) {return b==0? a:gcd(b,a%b);}
ll lcm(ll a,ll b) {return ((a*b)/gcd(a,b));}

/* mpp.max_load_factor(0.25); mpp.reserve(1024); */
/* cout << fixed << setprecision(12);*/

int main()
{

    ll n, m, k, i, j, x, y, p=0, h, f=0;
    string s;
    cin>>s;
    k = s.size();
    ll a[k+1];
    mem(a, -1);
    vl v;
    if(s[0]=='<'){
        a[0]=0;
        v.pb(0);
    }
    if(s[k-1]=='>'){
        a[k]=0;
        v.pb(k);
    }
    for(i=0; i<s.size()-1; i++){
        if(s[i]=='>' && s[i+1]=='<'){
            a[i+1]=0;
            v.pb(i+1);
        }
    }
    sort(v.begin(), v.end());
    if(v[0]!=0){
        x=v[0];
        y=1;
        for(i=x-1; i>=0; i--){
            a[i]=y;
            y++;
        }
    }
    if(v[v.size()-1]!=0){
        x=v[v.size()-1];
        y=1;
        for(i=x+1; i<=k; i++){
            a[i]=y;
            y++;
        }
    }
    for(j=0; j<v.size()-1; j++){
        x=v[j+1];
        y=1;
        for(i=x-1; i>0 && s[i]=='>' && s[i-1]=='>'; i--){
            a[i]=y;
            y++;
        }

        x=v[j];
        y=1;
        for(i=x+1; i<k && s[i]=='<' && s[i-1]=='<'; i++){
            a[i]=y;
            y++;
        }

    }
    for(i=0; i<=k; i++){

        if(a[i]==-1 && i>0 && i<k){
            a[i]=max(a[i-1], a[i+1])+1;
        }
        else if(a[i]==-1 && i>0){
            a[i]=a[i-1]+1;
        }
        else if(a[i]==-1 && i<k){
            a[i]=a[i+1]+1;
        }
        p+=a[i];

    }
    cout<<p<<endl;

    return 0;
}



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

const string alphas = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
const int length = alphas.size();

char cipher(char c, int x) {
  return alphas[(alphas.find(c, 0) + length + x) % length];
}

int main() {
  int n;
  while (cin >> n && n) {
    vector<int> keys(n);
    for (int i = 0; i < n; i++) {
      cin >> keys[i];
    }
    string s;
    cin >> s;
    for (int i = 0, len = s.size(); i < len; i++) {
      cout << cipher(s[i], -keys[i % n]);
    }
    cout << endl;
  }
}

Measured memory_bytes: 1212
#[test]
fn test_solve() {
    assert_eq!(solve("2 3 3\n2 2\nRRL\nLUD\n"), "YES\n");
    assert_eq!(solve("4 3 5\n2 2\nUDRRR\nLLDUD\n"), "NO\n");
    assert_eq!(solve("5 6 11\n2 1\nRLDRRUDDLRL\nURRDRLLDLRD\n"), "NO\n");
}

fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let h: usize = sc.read();
    let w: usize = sc.read();
    let n: usize = sc.read();
    let r: usize = sc.read();
    let c: usize = sc.read();
    let s = sc.chars();
    let t = sc.chars();

    let mut lrud = (1, w, 1, h);
    for i in (0..n).rev() {
        match t[i] {
            'L' => {
                if lrud.1 < w {
                    lrud.1 += 1
                }
            }
            'R' => {
                if lrud.0 > 1 {
                    lrud.0 -= 1
                }
            }
            'U' => {
                if lrud.3 < h {
                    lrud.3 += 1
                }
            }
            'D' => {
                if lrud.2 > 1 {
                    lrud.2 -= 1
                }
            }
            _ => unreachable!(),
        }
        match s[i] {
            'L' => lrud.0 += 1,
            'R' => lrud.1 -= 1,
            'U' => lrud.2 += 1,
            'D' => lrud.3 -= 1,
            _ => unreachable!(),
        }
        if lrud.0 > lrud.1 || lrud.2 > lrud.3 {
            return "NO\n".to_string();
        }
    }
    if lrud.0 <= c && c <= lrud.1 && lrud.2 <= r && r <= lrud.3 {
        "YES\n"
    } else {
        "NO\n"
    }
    .to_string()
}

fn main() {
    let mut buf = String::new();
    use std::io;
    use std::io::{Read, Write};
    io::stdin().read_to_string(&mut buf).unwrap();
    io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}

struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.get().chars().collect()
    }
}


Measured memory_bytes: 6396