akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
using namespace std;

long long xl[100005], xr[100005],vl[100005],vr[100005],c,ls[100005],rs[100005],cleft[100005],cright[100005],lmax[100005],rmax[100005];
int n;
int main() {
	cin >> n >> c;
	for (int i = 1; i <= n; i++) {
		cin >> xl[i] >> vl[i];
		xr[n + 1 - i] = c - xl[i];
		vr[n + 1 - i] = vl[i];
	}
	for (int i = 1; i <= n; i++) {
		ls[i] = ls[i - 1] + vl[i];
		rs[i] = rs[i - 1] + vr[i];
	}

	for (int i = 0; i <= n; i++) {
		cleft[i] = ls[i] - xl[i];
		cright[i] = rs[i] - xr[i];
	}
	//for (int i = 0; i <= n; i++) {
	//	cout << xr[i] << " ";
	//}
	//cout << endl;
	//for (int i = 0; i <= n; i++) {
	//	cout << cleft[i] << " ";
	//}
	//cout << endl;
	//for (int i = 0; i <= n; i++) {
	//	cout << cright[i] << " ";
	//}
	long long v = 0;
	//cout << " l max" << endl;
	for (int i = 0; i <= n; i++) {
		if (v < cleft[i]) {
			v = cleft[i];
		}
		lmax[i] = v;
	//	cout << v << " ";
	}
	//cout << endl;
	v = 0;
	for (int i = 0; i <= n; i++) {
		if (v < cright[i]) {
			v = cright[i];
		}
		rmax[i] = v;
	//	cout << v << " ";
	}
	//cout << endl << endl;
	long long ans = max(rmax[n], lmax[n]);
	for (int i = 1; i <= n; i++) {
		ans = max(ans, cleft[i] - xl[i] + rmax[n - i]);
	}
	for (int i = 1; i <= n; i++) {
		ans = max(ans, cright[i] - xr[i] + lmax[n - i]);
	}
	cout << ans << endl;

	return 0;
}

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

int n;
int c=0;

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    if(s=="A")c++;
    else{
      c--;
      if(c<0){
        cout<<"NO"<<endl;
        return 0;
      }
    }
  }
  cout<< (c==0?"YES":"NO") <<endl;
  return 0;
}

Measured memory_bytes: 3160
#include<iostream>
#include<iomanip>
#include<vector>
using namespace std;

#define inRange(x,a,b) (a <= x && x < b)
int dx[8] = {0,0,1,-1,1,1,-1,-1};
int dy[8] = {1,-1,0,0,1,-1,1,-1};

int col(char x){
    if(x == 'A' || x == 'D' || x == 'G')    return 0;
    if(x == 'B' || x == 'E' || x == 'H')    return 1;
    return 2;
}

int row(char x){
    if(x <= 'C')    return 0;
    if(x <= 'F')    return 1;
    return 2;
}

int main(){
    int n;
    char s, t, b;
    while(cin >> n, n){
        cin >> s >> t >> b;

        vector<vector<int>> mat(3, vector<int>(3, 0));
        vector<vector<double>> ans(3, vector<double>(3, 0.0)); 
        mat[row(b)][col(b)] = 1;
        ans[row(s)][col(s)] = 1.0;

        while(n-- > 0){
            vector<vector<double>> next(3, vector<double>(3, 0.0)); 
            for(int i = 0; i < 3; i++){
                for(int j = 0; j < 3; j++){
                    if(ans[i][j] == 0.0)  continue;
                    for(int k = 0; k < 4; k++){
                        int di = i+dx[k], dj = j+dy[k];
                        if(!inRange(di, 0, 3) || !inRange(dj, 0, 3) || mat[di][dj]==1){
                            next[i][j] += ans[i][j]/4.0;
                        }else{
                            next[di][dj] += ans[i][j]/4.0;
                        }
                    }
                }
            }
            ans = next;
        }

        cout << fixed << setprecision(10) << ans[row(t)][col(t)] << endl;
    }
    return 0;
}


Measured memory_bytes: 3136
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

vi f(int x) {
  return {x % 10, x / 10 % 10, x / 100 % 10, x / 1000};
}

int g(vi x) {
  return x[0] + x[1] * 10 + x[2] * 100 + x[3] * 1000;
}

int next(int x) {
  vi v = f(x);
  vi w = v;
  sort(all(v)), sort(rall(w));
  return g(v) - g(w);
}

void solve() {
  int n;
  while (cin >> n, n) {
    vi v = f(n);
    sort(all(v));
    if (v.front() == v.back()) {
      cout << "NA" << endl;
      continue;
    }
    int c = 0;
    for (; n != 6174; c++) {
      n = next(n);
    }
    cout << c << endl;
  }
}

Measured memory_bytes: 3124
/*********************
*  Author: xuziyuan  * 
*********************/

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,k,x,ans=0;

int main()
{
	cin>>n>>k;
	rep(i,n)
	{
		cin>>x;
		if(x>=k) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
 
int main(){
 
int a = 0,b = 0,c = 0,d = 0,e = 0;
 
std::cin >> a >> b >> c >> d >> e;
 
d = std::max({a,b,c});
 
e = std::min({a,b,c});
 
    if(a == d&&b == e){
        
     std::cout << d*10 + c + e << std::endl;
        
    }else if(a == d&&c == e){
        
     std::cout << d*10 + b + e << std::endl;
        
    }else if(b == d&&a == e){
        
     std::cout << d*10 + c + e << std::endl;
        
    }else if(b == d&&c == e){
        
     std::cout << d*10 + a + e << std::endl;
        
    }else if(c == d&&a == e){
        
     std::cout << d*10 + b + e << std::endl;
        
    }else{
     
        std::cout << d*10 + a + e << std::endl;
        
    }
    
    return 0;
}

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


int main(int argc, char const *argv[])
{
	
	 int r,d;
	 long int x;
	 int ans;

	 cin>>r>>d>>x;
	 
	 for(int i=0;i<10;i++)
	 {
	 	x=(r*x)-d;
	 	cout<<x<<endl;
	 }

	return 0;
}			

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(long i = 0; i < n; i++)
#define erep(i, n) for(long i = 1; i <= n; i++)
const long MOD = 1000000007;
#define all(a) a.begin(), a.end()
#define eall(a) a.begin()+1, a.end()
#define show(ans)  cout << ans << endl;


int main(){long N, K;
cin >> N >> K;
vector<long> vec(N+1);
erep(i, N){
    cin >> vec[i];
}
sort(eall(vec));
long tmp = 1e10;
erep(i, N-(K-1)){
    tmp = min(tmp, vec[i+(K-1)]-vec[i]);
}


show(tmp);




return 0;
}

Measured memory_bytes: 1024
#include <cmath>
#include <iostream>
#include <iomanip>

struct TPoint
{
    double x;
    double y;
};
struct TTriangle
{
    TPoint p1;
    TPoint p2;
    TPoint p3;
};
void SolveEquation(double a, double b, double c, double d, double e, double f, double* x, double* y)
{

    if(b){
        *x = (c * e - b * f) / (a * e - b * d);
        *y = (c - a * *x) / b;
    }else{
        *y = (f - d * c / a)/( e - d * b / a);
        *x = (c - b * *y) / a;
    }
}
/*
A(a, b) B(c, d) C(e, f)
(OA)^2 = (OB)^2
(OA)^2 = (OC)^2
x2-2ax+a2 + y2-2by+b2 = x2-2cx+c2 + y2-2dy+d2
(2c-2a)x + (2d-2b)y = c^2 + d^2 - a^2 - b^2;

x2-2ax+a2 + y2-2by+b2 = x2-2ex+e2 + y2-2fy+f2
(2e-2a)x + (2f-2b)y = e^2 + f^2 - a^2 - d^2
*/
TPoint GetCentral(const TTriangle& Tri)
{
    double a, b, c, d, e, f;
    a = 2 * (Tri.p2.x - Tri.p1.x);
    b = 2 * (Tri.p2.y - Tri.p1.y);
    c = std::pow(Tri.p2.x,2) + std::pow(Tri.p2.y,2) - std::pow(Tri.p1.x,2) - std::pow(Tri.p1.y,2);
    d = 2 * (Tri.p3.x - Tri.p1.x);
    e = 2 * (Tri.p3.y - Tri.p1.y);
    f = std::pow(Tri.p3.x,2) + std::pow(Tri.p3.y,2) - std::pow(Tri.p1.x,2) - std::pow(Tri.p1.y,2);
    TPoint P;
    SolveEquation(a, b, c, d, e, f, &P.x, &P.y);
    return P;
}
double GetLength(const TPoint& A, const TPoint& B)
{
    return std::sqrt(std::pow(A.x - B.x, 2) + std::pow(A.y - B.y, 2));
    // return std::sqrt((A.x - B.x)*(A.x - B.x) + (A.y - B.y)*(A.y - B.y));
}
double GetRadius(double a, double b, double c)
{
    return (a*b*c)/std::sqrt((a+b+c)*(-a+b+c)*(a-b+c)*(a+b-c));
}
double GetRadius(const TTriangle& Tri)
{
    double a = GetLength(Tri.p1, Tri.p2);
    double b = GetLength(Tri.p2, Tri.p3);
    double c = GetLength(Tri.p3, Tri.p1);
    return GetRadius(a, b, c);
}
int main()
{
    int n;
    std::cin >> n;
    for(int i = 0; i < n; ++i){
        // double a, b, c;
        // std::cin >> a >> b >> c;
        // std::cout << GetRadius(a, b, c) << std::endl;
        
        TTriangle tri;
        std::cin >> tri.p1.x >> tri.p1.y >> tri.p2.x >> tri.p2.y >> tri.p3.x >> tri.p3.y;
        TPoint C = GetCentral(tri);
        double r = GetRadius(tri);
        if(C.x == -0) C.x = 0;
        if(C.y == -0) C.y = 0;
        if(r   == -0) r   = 0;
        std::cout << std::fixed << std::setprecision(3);
        std::cout << C.x << " " << C.y << " " << r << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a[100005];
    bool vis[100005];
    cin>>n;
    long long ans=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]!=0)
        {
        	vis[i]=true;
		}
        ans+=a[i]/2;
        a[i]%=2;
    }
    for(int i=1;i<n;i++)
    {
        if(a[i]!=0 and a[i-1]!=0)
        {
            a[i]=0;
            a[i-1]=0;
            ans++;
        }
        else if(a[i]==0 and a[i-1]!=0)
        {
        	if(vis[i])
        	{
        		a[i]++;
				a[i-1]--;
			}
		}
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 768
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if(n == 0 && m == 0) break;

			t = new int[n+1][n+1];
			for(int i=0;i<m;i++){
				int from = sc.nextInt();
				int to = sc.nextInt();
				int cost = sc.nextInt();

				t[from][to] = t[to][from] = cost;
			}

			max = 0;
			maxS = "z";
			for(int i=1;i<=n;i++){
				used = new boolean[n+1][n+1];
				solve(i,0,""+(i==10?"x":i));
			}

			System.out.println(max);
			System.out.println(maxS.replaceAll("x","10"));
		}
	}

	private static int[][] t;
	private static boolean[][] used;
	private static int max;
	private static String maxS;

	private static void solve(int from,int cost,String s){
		for(int i=1;i<t.length;i++){
			if(!used[from][i] && t[from][i] != 0){
				used[from][i] = used[i][from] = true;
				solve(i,cost+t[from][i],s+" "+(i==10?"x":i));
				used[from][i] = used[i][from] = false;
			}
		}

		if(max <= cost){

			String rs = new StringBuilder(s).reverse().toString();

			if(max < cost){
				max = cost;
				if(s.compareTo(rs) < 0) maxS = s;
				else maxS = rs;
			}
			else{
				if(maxS.compareTo(s) > 0) maxS = s;
				if(maxS.compareTo(rs) > 0) maxS = rs;
			}
		}
	}
}

Measured memory_bytes: 12000
main = do
    [a, b, c, d] <- map readAsInt . words <$> getLine
    putStr $ solve a b c d

readAsInt :: String -> Int
readAsInt = read

solve :: Int -> Int -> Int -> Int -> String
solve a b c d =
    let
        takahashiMonster = Monster a b
        aokiMonthster = Monster c d
        (takahashiMonsterAfterBattle,
         aokiMonthsterAfterBattle) = battle takahashiMonster aokiMonthster FirstTurn
    in if isDead aokiMonthsterAfterBattle 
        then "Yes"
        else "No" 

data Monster = Monster {hp :: Int, atk :: Int}
data Turn = FirstTurn | SecondTurn deriving Eq

battle :: Monster -> Monster -> Turn -> (Monster, Monster)
battle first second turn
    | isDead first || isDead second = (first, second)
    | turn == FirstTurn  = battle first (attack first second) SecondTurn
    | turn == SecondTurn = battle (attack second first) second FirstTurn

isDead :: Monster -> Bool
isDead (Monster hp atk)
    | hp <= 0 = True
    | otherwise = False

attack :: Monster -> Monster -> Monster
attack attacker attacked = Monster {atk = atk attacked, hp = hp attacked - atk attacker}

Measured memory_bytes: 3916
local n = io.read("*n")
local edge = {}
local edgecnt = {}
local cost = {}
for i = 1, n do
  edge[i] = {}
  edgecnt[i] = 0
  cost[i] = 0
end
for i = 1, n - 1 do
  local a, b = io.read("*n", "*n")
  edgecnt[a] = edgecnt[a] + 1
  edgecnt[b] = edgecnt[b] + 1
  edge[a][b], edge[b][a] = true, true
end
local c = {}
for i = 1, n do
  c[i] = io.read("*n")
end
table.sort(c)
do
  local csum = 0
  for i = 1, n - 1 do
    csum = csum + c[i]
  end
  print(csum)
end
local tasks = {}
for i = 1, n do
  if edgecnt[i] == 1 then
    table.insert(tasks, i)
  end
end
for i = 1, n do
  local src = tasks[i]
  cost[src] = c[i]
  for dst, _u in pairs(edge[src]) do
    if 1 < edgecnt[dst] then
      edgecnt[dst] = edgecnt[dst] - 1
      if edgecnt[dst] == 1 then
        table.insert(tasks, dst)
      end
    end
  end
end
print(table.concat(cost, " "))


Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 4e3 + 5;

int n, num[3][MAXN];
char s[MAXN];
int main(){
    #ifdef Irene
    freopen("in.txt","r",stdin);
    #endif // Irene
    ios_base::sync_with_stdio(false);

    cin >> n >> s + 1;
    for(int i = 1; i <= n; i++){
        num[0][i] = num[0][i-1] + (s[i] == 'R');
        num[1][i] = num[1][i-1] + (s[i] == 'G');
        num[2][i] = num[2][i-1] + (s[i] == 'B');
    }
    ll ans = 0, len;
    for(int i = 1; i < n; i++){
        for(int j = i + 1; j <= n; j++){
            if(s[i] == s[j]) continue;
            len = j+j-i;
            if(s[i] == 'R' && s[j] == 'G')
                ans += num[2][n] - num[2][j] - (len <= n && s[len] == 'B');
            else if(s[i] == 'G' && s[j] == 'R')
                ans += num[2][n] - num[2][j] - (len <= n && s[len] == 'B');
            else if(s[i] == 'R' && s[j] == 'B')
                ans += num[1][n] - num[1][j] - (len <= n && s[len] == 'G');
            else if(s[i] == 'B' && s[j] == 'R')
                ans += num[1][n] - num[1][j] - (len <= n && s[len] == 'G');
            else if(s[i] == 'B' && s[j] == 'G')
                ans += num[0][n] - num[0][j] - (len <= n && s[len] == 'R');
            else if(s[i] == 'G' && s[j] == 'B')
                ans += num[0][n] - num[0][j] - (len <= n && s[len] == 'R');
        }
    }
    cout << ans;
}


Measured memory_bytes: 3704
#include<bits/stdc++.h>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <stdio.h>
#include <algorithm>
#include <map>
#include <queue>
#include <unordered_map>
#define ll long long
#define pii pair <int, int>
#define pll pair <long long, long long>
#define plxy pair <long long, pll>
#define INT_MAX 1e18
#define Keep_calm_You_are_still_learning ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
using namespace std;
const int mod=1e9+7;
const int N=2e5+5;
ll n,m,maxi,dp[N];
vector<vector<ll>>adj(N);
ll dfs(ll node)
{
    if(dp[node])
        return dp[node];
    for(ll i=0;i<adj[node].size();i++)
    {
        ll child=adj[node][i];
        dp[node]=max(dp[node],1+dfs(child));
    }
    return dp[node];
}
int main()
{
    Keep_calm_You_are_still_learning
    cin>>n>>m;
    for(ll i=0;i<m;i++)
    {
        ll u,v;
        cin>>u>>v;
        adj[u].push_back(v);
    }
    for(ll i=1;i<=n;i++)
    {
        dfs(i);
    }
    for(ll i=1;i<=n;i++)
    {
        maxi=max(maxi,dp[i]);
    }
    cout<<maxi;
    return 0;
}


Measured memory_bytes: 10240
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - 1 21
            var s = Console.ReadLine();

            s = s.Replace(" ", "");
            int num = int.Parse(s);
            int sqrt = (int)Math.Sqrt(num);

            if (sqrt * sqrt == num)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {

	static int[][] list = {
		{0,0,0},
		{0,0,255},
		{0,255,0},
		{0,255,255},
		{255,0,0},
		{255,0,255},
		{255,255,0},
		{255,255,255},
	};
	
	static String[] name = {"black","blue","lime","aqua","red","fuchsia","yellow","white"};
	
	static int trans(char jyu, char ichi){
		int sum = 0;
		if('a'<=jyu&&jyu<='f'){
			sum += jyu-'a'+10;
		}
		else{
			sum += jyu-'0';
		}
		sum*=16;
		if('a'<=ichi&&ichi<='f'){
			sum += ichi-'a'+10;
		}
		else{
			sum += ichi-'0';
		}
		return sum;
	}
	
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		while(true){
			char[] in = stdIn.next().toCharArray();
			if(in[0]=='0'){
				return;
			}
			int r = trans(in[1],in[2]);
			int g = trans(in[3],in[4]);
			int b = trans(in[5],in[6]);
			
			double min = Double.MAX_VALUE;
			int min_idx = -1;
			for(int k=0;k<8;k++){
				double tmp = Math.abs(Math.sqrt(Math.pow(r-list[k][0],2)+Math.pow(g-list[k][1],2)+Math.pow(b-list[k][2],2)));
				if(tmp<min){
					min = tmp;
					min_idx = k;
				}
			}
			System.out.println(name[min_idx]);
		}
	}
}

Measured memory_bytes: 12000
S = input()

ans = "AC"

if S[0] != "A":
    ans = "WA"

if S.count("C") != 1:
    ans = "WA"

if not ("C" in S[2:-1]):
    ans = "WA"

for i in range(len(S)):
    if S[i].isupper():
        if S[i] == "A" or S[i] == "C":
            pass
        else:
            ans = "WA"

print(ans)


Measured memory_bytes: 9032
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  n <- getl toInt
  unless (n == 0) $ do
    solve n <$> replicateM n (getl words) >>= print
    main

solve :: Int -> [[String]] -> Int
solve n xs = n - ((length . nubBy sameDice . map roll) xs)

roll :: [String] -> [String]
roll [c1,"Red",c3,c4,c5,c6] = ["Red",c6,c3,c4,c1,c5]
roll [c1,c2,"Red",c4,c5,c6] = ["Red",c2,c6,c1,c5,c4]
roll [c1,c2,c3,"Red",c5,c6] = ["Red",c2,c1,c6,c5,c3]
roll [c1,c2,c3,c4,"Red",c6] = ["Red",c1,c3,c4,c6,c2]
roll [c1,c2,c3,c4,c5,"Red"] = ["Red",c2,c4,c3,c5,c1]
roll x = x

sameDice :: [String] -> [String] -> Bool
sameDice xs [c1,c2,c3,c4,c5,c6] = xs `elem` ys
  where ys = [[c1,c4,c2,c5,c3,c6],[c1,c5,c4,c3,c2,c6],[c1,c3,c5,c2,c4,c6],[c1,c2,c3,c4,c5,c6]]

toInt :: String -> Int
toInt s = read s

getl :: (String -> a) -> IO a
getl f = f <$> getLine

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll A, B;
    cin >> A >> B;
    repi(i, 1000) {
        ll a, b;
        a = i * 8 / 100;
        b = i * 10 / 100;
        if(A == a && B == b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


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

int main() {
	bool f=false;
	int a,b,w;
	string s;
	cin>>a>>b;
	s=to_string(a)+to_string(b);
	w=stoi(s);

	for(int i=0;i<10000;i++){
		if(w==i*i){
			f=true;
		}
	}
	if(f==true){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}



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

#define MOD 1000000007
 
int n;
long long ans;
char x[2][105];
 
int main() {
	scanf("%d%s%s", &n, x[0], x[1]);
	if (x[0][0] == x[1][0])
		ans = 3;
	else
		ans = 6;
	for (int i = 1; i < n; i++)
		if (x[0][i] != x[0][i - 1] && x[1][i] != x[1][i - 1]) {
			if (x[0][i] == x[1][i]) {
				if (x[0][i - 1] == x[1][i - 1])
					ans = ans * 2 % MOD;
			} else {
				if (x[0][i - 1] == x[1][i - 1])
					ans = ans * 2 % MOD;
				else
					ans = ans * 3 % MOD;
			}
		}
	printf("%lld\n", ans);
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	char s[3];
	scanf("%s",s);
	if(s[0]=='R'&&s[1]=='R'&&s[2]=='R'){
		printf("3\n");
	}
	else if(s[0]=='R'&&s[1]=='R'&&s[2]=='S'||s[0]=='S'&&s[1]=='R'&&s[2]=='R'){
		printf("2\n");
	}
	else if(s[0]=='S'&&s[1]=='S'&&s[2]=='S'){
		printf("0\n");
	}
	else{
		printf("1\n");
	}
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  while(n!=0) {
      vector<int> ten(n);
      double total=0;
      for (int i=0; i<n; i++) {
          cin >> ten.at(i);
          total+=ten.at(i);
      }
      double hekin=total/n;
      double bunsan=0;
      for (int i=0; i<n; i++) {
          bunsan+=(ten.at(i)-hekin)*(ten.at(i)-hekin);
      }
      bunsan/=n;
      cout << fixed << setprecision(7) << endl;
      cout << sqrt(bunsan) << endl;
      cin >> n;
  }
}


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

using namespace std;

typedef long long ll;
const int N = 300 + 7;
const ll INF = (ll) 1e18;
int n;
int k;
int a[N];
ll dp[N][N]; /// dp[last][cnt]

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

    cin >> n >> k;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    k = n - k;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= k; j++)
        {
            dp[i][j] = INF;
        }
    }
    for (int i = 1; i <= n; i++)
    {
        dp[i][1] = a[i];
    }
    ll ans = INF;
    for (int c = 1; c < k; c++)
    {
        for (int i = 1; i <= n; i++)
        {
            for (int j = i + 1; j <= n; j++)
            {
                dp[j][c + 1] = min(dp[j][c + 1], dp[i][c] + max(0, a[j] - a[i]));
            }
        }
    }
    for (int i = 1; i <= n; i++)
    {
        ans = min(ans, dp[i][k]);
    }
    cout << ans << "\n";
}


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

#define int long long
#define double long double

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define ALL(v) (v).begin(), (v).end()

#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

using pi = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vvb = vector<vb>;

const int INF = 1e16;
const int MOD = 1e9+7;

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

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

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int N; cin >> N;
    string S; cin >> S;
    vi v(N);
    REP(i, S.length())
    {
        if(S[i] == 'R') v[i] = 0;
        else if(S[i] == 'B') v[i] = 1;
        else v[i] = 2;
    }
    vvi sum(N+1, vi(3, 0));
    REP(i, S.length())
    {
        REP(j, 3)
        {
            sum[i+1][j] += sum[i][j] + (v[i] == j);
        }
    }

    int ans = 0;
    REP(j, N)
    {
        REP(i, j)
        {
            if(v[i] == v[j]) continue;
            ans += sum[N][3-v[i]-v[j]] - sum[j+1][3-v[i]-v[j]];
            if(2*j-i < N && v[2*j-i] == 3-v[i]-v[j]) ans--;
        }
    }
    cout << ans << endl;
}

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

using namespace std;
using llong = long long;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	int h,w;
	cin >> h >> w;

	string in;
	for(int i = 1; i <= h; i++){
		for(int j = 0; j < w; j++){
			cin >> in;
			if(in == "snuke")
				cout << (char)('A'+j) << i << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;
ll mod=1000000007;

ll fac[2000010];
 
ll modinv(ll a){
    ll b=mod,u=1,v=0;
    while(b){
        ll t=a/b;
        a-=t*b; swap(a,b);
        u-=t*v; swap(u,v);
        }
        u%=mod;
        if(u<0) u+=mod;
    return u;
}
 
void modfac(){
    fac[0]=1;
    for(ll i=1;i<2000010;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
}
 
ll modperm(ll n,ll k){
    if(n<0||k<0||n<k) return 0;
    else return (fac[n]*modinv(fac[n-k]))%mod;
}
 
ll modcomb(ll n,ll k){
    if(n<0||k<0||n<k) return 0;
    else return ((fac[n]*modinv(fac[k]))%mod*modinv(fac[n-k]))%mod;
}
 
ll modpow(ll a,ll b){
  ll ans=1;
  a%=mod;
  while(b){
    if(b&1) ans=ans*a%mod;
    a=a*a%mod;
    b>>=1;
  }
  return ans;
}

int main(){
  ll x,y;
  cin >> x >> y;
  if((x+y)%3||x>2*y||y>2*x){
    cout << 0 << endl;
    return 0;
  }
  modfac();
  ll all=(x+y)/3;
  cout << modcomb(all,x-all) << endl;
}

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

using namespace std;

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;

#define rep(i,a,b) for(int i =(a);i<(int)(b);i++)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()

typedef long long ll;

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

    int n; int W; 
    cin>>n>>W; 

    int weight[n], value[n];

    rep(i, 0, n){
        cin>>weight[i]>>value[i];
    }

    int sum = 0;

    for(auto x: value)  sum+= x;

    // DEBUG(sum);
    vector<ll> dp(sum+1, (ll)1e18);
    dp[0] = 0;

    rep(i, 0, n){
        for(int val = sum- value[i]; val >= 0; val--){
            dp[val+ value[i]] = min(dp[val+ value[i]], dp[val]+ weight[i]);
        }
    }


    ll ans = 0;

    // for(auto x: dp) cout<<" "<<x;
    // cout<<endl;

    rep(i, 0, sum+1){
        if(dp[i]<= W){
            ans = max(ans, (ll)i);
        }
    }
    cout<<ans<<endl;
    return 0 ;
}



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

int main(){
  double n;
  cin >> n;
  if( floor(floor(n/1.08)*1.08) == n ){
  	cout << floor(n/1.08) << endl;
  }else if( floor(ceil(n/1.08)*1.08) == n ){
    cout << ceil(n/1.08) << endl;
  }else{
    cout << ":(" << endl;
  }
  return 0;
}


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

int n;
int a[250005];
int id[505][505];
int dis[505][505],res[505][505];
bool lgl[505][505];
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			dis[i][j]=min(min(i-1,n-i),min(j-1,n-j));
		}
	}
	for(int i=1;i<=n*n;i++){
		int s;
		scanf("%d",&s);
		int x=(s-1)/n+1,y=(s-1)%n+1;
		res[x][y]=dis[x][y];
		lgl[x][y]=1;
		queue<pair<int,int>> q;
		q.emplace(x,y);
		while(q.size()){
			pair<int,int> T=q.front();
			q.pop();
			int x=T.first,y=T.second;
			int to=dis[x][y]+(!lgl[x][y]);
			for(int i=0;i<4;i++){
				int nx=x+dx[i],ny=y+dy[i];
				if(nx<1||nx>n||ny<1||ny>n){
					continue;
				}
				if(dis[nx][ny]>to){
					dis[nx][ny]=to;
					q.emplace(nx,ny);
				}
			}
		}
	}
	int sum=0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			sum+=res[i][j];
		}
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 6028
#include <iostream>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <vector>
#include <cmath>
#include <cstdint>
#include <string>

using namespace std;

int main() {
  while (true) {
    int n;
    int x;
    cin >> n >> x;
    if (!n && !x) {
      break;
    }
  
    int count = 0;
  
    for (int i = 1; i <= n; ++i) {
      for (int j = i + 1; j <= n; ++j) {
        int k = x - i - j;
        if (j < k && k <= n) {
          ++count;
        }
      }
    }
  
    cout << count << endl;
  }

}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

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

    vector<int> x(n),y(n);
    rep(i,n) scanf(" %d %d", &x[i], &y[i]);

    vector<int> sorted_x(x), sorted_y(y);
    sort(all(sorted_x));
    sort(all(sorted_y));

    vector<int> cx,cy;

    if(n%2==0)
    {
        cx.pb(sorted_x[n/2-1]);
        cy.pb(sorted_y[n/2-1]);
    }
    cx.pb(sorted_x[n/2]);
    cy.pb(sorted_y[n/2]);

    ll ans = LLONG_MAX;
    int ax,ay;
    for(const auto &X:cx)for(const auto &Y:cy)
    {
        ll s = 0;
        ll D = 0;
        rep(i,n)
        {
            ll d = abs(X-x[i])+abs(Y-y[i]);
            D = max(D,d);
            s += d*2;
        }
        s -= D;

        if(ans>s)
        {
            ans = s;
            ax = X;
            ay = Y;
        }
    }

    printf("%lld\n%d %d\n", ans,ax,ay);
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    int h[100000];
    for(int i=0;i<N;i++) cin >> h[i];
    int dp[100000];
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    for(int i=0;i<N;i++){
        dp[i+2] = min(dp[i]+abs(h[i+2]-h[i]),dp[i+1]+abs(h[i+2]-h[i+1]));
    }
    cout << dp[N-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    vector<int>v1;
    vector<int>v2;
    int a,b;
    bool sign1=0,sign2=0;
    while(m--){
        scanf("%d%d",&a,&b);
        if(a==1) {v1.push_back(b);sign1=1;}
        if(b==n) {v2.push_back(a);sign2=1;}
    }
    if(!sign1||!sign2) printf("IMPOSSIBLE");
    else{
        sort(v1.begin(),v1.end());
        sort(v2.begin(),v2.end());
        bool flag=0;
        int l1=v1.size(),l2=v2.size();
        int sum=0;
        for(int i=0;i<l1;i++){
            if(v1[i]==n){flag=1;break;}
            int m=lower_bound(v2.begin()+sum,v2.end(),v1[i])-v2.begin();
            if(m<l2){
                if(v2[m]==v1[i]) {flag=1;break;}
                else {sum=m;}
            }
            else {flag=0;break;}
            if(flag) break;
        }
        if(flag) printf("POSSIBLE");
        else printf("IMPOSSIBLE");


    }

    return 0;
}


Measured memory_bytes: 1276
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define VVi vector<vector<ll>>
#define Vd vector<double>
#define Vb vector<bool>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<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;}

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=0,z=0;
  string s="",t="";
  //

  // ここから
  IN3(a,b,n);
  Vi X(n);
  Vi Y(n);
  Vi A(n);
  REP(i,n){
    IN3(X[i],Y[i],A[i]);
  }
  vector<vector<char>> area(b, vector<char>(a));
  REP(i,b){
    REP(j,a){
      area[i][j] = 'w';
    }
  }
  REP(i,n){
    if(A[i]==1){
      REP(j,b){
        REP(k,X[i]){
          area[j][k] = 'b';
        }
      }
    } else if(A[i]==2){
      REP(j,b){
        FOR(k,X[i],a){
          area[j][k] = 'b';
        }
      }
    } else if(A[i]==3){
      REP(j,Y[i]){
        REP(k,a){
          area[j][k] = 'b';
        }
      }
    } else {
      FOR(j,Y[i],b){
        REP(k,a){
          area[j][k] = 'b';
        }
      }
    }
  }
  REP(i,b){
    REP(j,a){
      if(area[i][j]=='w') z++;
    }
  }
  OUT(z);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define P pair<int,int>
#define All(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
typedef long long ll;
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const ll LINF = 1e18;
int main() {
	string a, b, c;
	cin >> a >> b >> c;
	string ans = "";
	ans += a[0];
	ans += b[1];
	ans += c[2];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <sstream>

using namespace std;


int main(int argc, const char * argv[]) {
    string ss; cin >> ss;
    
    int prev = ss[0] - '0';
    int start0_cnt = (prev == 0) ? 0 : 1;
    int start1_cnt = (prev == 0) ? 1 : 0;
    int prev_start0 = 0;
    int prev_start1 = 1;
    for (int i = 1; i < ss.size(); i++) {
        int tmp = ss[i] - '0';
        if (prev_start0 == tmp) {
            prev_start0 = (prev_start0 + 1) % 2;
            start0_cnt++;
        } else {
            prev_start0 = tmp;
        }
        if (prev_start1 == tmp) {
            prev_start1 = (prev_start1 + 1) % 2;
            start1_cnt++;
        } else {
            prev_start1 = tmp;
        }
    }
    
    cout << min(start0_cnt, start1_cnt) << endl;
    
    return 0;
}


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

using namespace std;

int main(){
  string candidates[16] = {"AKIHABARA", "AKIHABAR", "AKIHABRA", "AKIHABR",
                           "AKIHBARA", "AKIHBAR", "AKIHBRA", "AKIHBR",
                           "KIHABARA", "KIHABAR", "KIHABRA", "KIHABR",
                           "KIHBARA", "KIHBAR", "KIHBRA", "KIHBR"};
  string S;
  cin >> S;
  bool there_is = false;
  for(int i=0; i<16; i++){
    if(S == candidates[i]){
      there_is = true;
      break;
    }
  }
  if(there_is){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.*;

public class Main {
	
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int a = sc.nextInt();
			int b = sc.nextInt();
			System.out.println((a-1) * (b-1));
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}

}


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

int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];

    int count = 0;

    for (int i = 0; i < n - 2; i++)
    {
        if ((p[i] < p[i + 1] && p[i + 2] > p[i + 1]) || (p[i + 2] < p[i + 1] && p[i] > p[i + 1]))
            ++count;
    }
    cout << count << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll K; cin >> K;
  queue<ll> q; repr(i,1,10) q.push(i);

  ll count = 0;
  vector<ll> result;
  rep(i,K) {
    ll qt = q.front(); q.pop();
    result.push_back(qt);
    if (qt%10!=0) q.push(qt*10+qt%10-1);
    q.push(qt*10+qt%10);
    if (qt%10!=9) q.push(qt*10+qt%10+1);
  }

  cout << result[K-1] << endl;
  return 0;
}

Measured memory_bytes: 2548
# -*-coding:utf-8

def main():

    while True:
        deck = input()
        if(deck == '-'):
            break

        shuffleTime = int(input())

        for i in range(shuffleTime):
            rollNumber = int(input())
            deck = deck[rollNumber:] + deck[:rollNumber]

        print(''.join(deck))


if __name__ == '__main__':
    main()

Measured memory_bytes: 7776
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
using namespace std;
//using namespace boost::multiprecision;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

typedef pair<long long, long long> P;
map<P, long long> mp;
long long func(long long s, long long x){
  long long res = 0;
  if(s < 0LL || x < 0LL){
    return 0LL;
  }
  if(s == 0LL){
    return 1LL;
  }
  if(mp[P(s,x)] < 0LL){
    res = 0LL - mp[P(s,x)];
    return res;
  }
  res += func(s/2LL, x/2LL);
  res = mod(res);
  if(s-1LL >= 0LL && x-1LL >= 0LL){
    res += func((s-1LL)/2LL, (x-1LL)/2LL);
    res = mod(res);
  }
  if(s-2LL >= 0LL){
    res += func((s-2LL)/2LL, x/2LL);
    res = mod(res);
  }
  mp[P(s,x)] = 0LL - res;
  return res;
}
int main(){
  
  long long n;
  cin>>n;
  long long ans = func(n,n);
  cout<<ans<<endl;
  return 0;
}


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

int main() {
	int n,i,j,k;
	cin >>n>>k;
	int a[n+1],dp[n+1];
	for(i=1;i<=n;i++)
	cin >>a[i];
	dp[1]=0;
	dp[2]=abs(a[2]-a[1]);
	for(i=3;i<=n;i++)
	{
	    int mn=1e09;
	    for(j=i-1;j>=max(1,i-k);j--)
	    {
	        mn=min(mn,abs(a[j]-a[i])+dp[j]);
	    }
	    dp[i]=mn;
	}
	cout<<dp[n];
}

Measured memory_bytes: 1024
#include <cstdio>
#define ll long long
const int p = 1e9+7;
int n, X, Y, Z;
int f[42][1<<17];
int main() {
	scanf("%d%d%d%d", &n, &X, &Y, &Z);
	f[0][0] = 1;
	int Haiku = (1<<(Z-1)) | (1<<(Y+Z-1)) | (1<<(X+Y+Z-1));
	int mask = (1<<(X+Y+Z))-1, ans = 1;
	for(int i = 1; i <= n; i ++ ) ans = ans*10ll%p;
	for(int i = 0; i < n; i ++ ) for(int S = 0; S <= mask; S ++ ) if(f[i][S]) {
		for(int j = 1; j <= 10; j ++ ) {
			int to = ((S<<j) | (1<<(j-1))) & mask;
			if((to&Haiku) != Haiku) f[i+1][to] = (f[i+1][to]+f[i][S])%p;
		}
	}
	for(int i = 0; i <= mask; i ++ ) ans = (ans-f[n][i]+p)%p;
	printf("%d\n", ans);
}


Measured memory_bytes: 19328
N=int(input())
S=list()
ac=0
wa=0
tle=0
re=0
for i in range(N):
  S.append(input())
for c in S:
  if c == "AC":
    ac+=1
  elif c=="WA":
    wa+=1
  elif c=="TLE":
    tle+=1
  elif c=="RE":
    re+=1
print("AC x ",ac)
print("WA x ",wa)
print("TLE x ",tle)
print("RE x ",re)

Measured memory_bytes: 16316
#include <iostream>
#include <cstdio>
#include <vector>
#include <deque>
#include <algorithm>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
 
int a[10000];
int ans[100][100];
int main(){
    int H,W;
    cin >> H >> W;
    int N;
    cin >> N;
    int inp;
    REP(i,N){
        cin >> inp;
        a[i] = inp;
    }

    bool rev = false;
    int index = 0;
    for(int h = 0; h < H; h++){
        for(int w = 0; w < W; w++){
           if(a[index]-- > 0){
               if(!rev) ans[h][w] = index + 1;
               else ans[h][W-1-w] = index + 1;
           }else{
               if(!rev) ans[h][w] = ++index + 1;
               else ans[h][W-1-w] = ++index + 1;
               a[index]--;
           } 
        }
        if(rev) rev = false;
        else rev = true;
    }

    for(int h = 0; h < H; h++){
        for(int w = 0; w < W; w++){
            printf("%d ", ans[h][w]);
        }
        printf("\n");
    }

    return 0;
}


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

int main() {
  long long x, k, d;
  scanf("%lld %lld %lld", &x, &k, &d);

  long long ans, s = abs(x) / d;
  if (s < k) {
    if (s % 2 == k % 2)
      ans = abs(abs(x) - s * d);
    else
      ans = abs(abs(x) - (s + 1) * d);
  }
  else {
    ans = abs(abs(x) - k * d);
  }

  printf("%lld\n", ans);

  return 0;
}

Measured memory_bytes: 3784
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int[] a = new int[n + 1];
    int[] b = new int[n + 1];
    for (int i = 0; i < n + 1; i++) {
      a[i] = Integer.parseInt(sc.next());
    }
    for (int i = 0; i < n; i++) {
      b[i] = Integer.parseInt(sc.next());
    }
    b[n] = 0;
    long count = 0;
    int remainB = 0;
    for (int i = 0; i < n + 1; i++) {
      int remainA = Math.max(a[i] - remainB, 0);
      count += Math.min(a[i], remainB);
      remainB = Math.max(b[i] - remainA, 0);
      count += Math.min(remainA, b[i]);
    }
    pw.println(count);
  }
}


Measured memory_bytes: 50984
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define int ll

int n,W;
int w[1000000],v[1000000];
int dp[110][100010];

signed main(){
  cin>>n>>W;

  rep(i,n){
    cin>>w[i]>>v[i];
  }

  FOR(i,1,n+1){
    rep(j,W+1){
      dp[i][j]=dp[i-1][j];
      if(j-w[i-1]<0) continue;
      dp[i][j] = max(dp[i][j],dp[i-1][j-w[i-1]]+v[i-1]);  
    }
  }



  cout<<dp[n][W]<<endl;
}

Measured memory_bytes: 83456
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	string ans = "Yes";
	int n;
	cin >> n;
	int prev = 0;

	rep(i,n) {
		int h;
		cin >> h;

		if (h < prev) {
			ans = "No";
			break;
		}
		if (prev <= h-1) {
			h--;
		}
		prev = h;
	}

	cout << ans << endl;




	return 0;
}

Measured memory_bytes: 256
"""
author : halo2halo
date : 31, Jan, 2020
"""

import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

K, S = map(int, readline().split())
ans = 0
for x in range(K + 1):
    for y in range(K + 1):
        if 0 <= S - x - y <= K:
            ans += 1
print(ans)


Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reg(i,a,b) for(int i=(a);i<=(b);i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=(b);i>=(a);i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX

char s[505];

bool expr(int& p){
	bool res = true;
	if(s[p]!='m')return false;
	p++;
	
	if(s[p]!='e'){
		res &= expr(p);
	}
	if(s[p]=='e')p++;
	else return false;
	
	if(s[p]!='w'){
		res &= expr(p);
	}
	if(s[p]=='w')p++;
	else return false;
	
	return res;
}

int main(void){
	scanf("%s",s);
	int p = 0;
	if((!expr(p)) || p!=strlen(s))printf("Rabbit\n");
	else printf("Cat\n");
	return 0;
}

Measured memory_bytes: 948