akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define vector2(a,b,c) vector<vector<int>> a(b/*縦！w*/,vector<int>(c/*横！w*/))
#define INF 1e10
#define MOD 1e9+7
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 Graph = vector<vector<int>>;
int a,b;
char c[60][60];
int d[60][60];
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int bfs(){
  rep(i,a)rep(j,b)
    d[i][j]=INF;
  d[0][0]=0;
queue<P> q;
  q.push(P(0,0));
  while(q.size()){
  P p=q.front();
    q.pop();
    if(p.first==a-1&&p.second==b-1)
      break;
    rep(i,4){
    int nx=p.first+dx[i],ny=p.second+dy[i];
      if(0<=nx&&nx<a&&0<=ny&&ny<b&&c[nx][ny]=='.'&&d[nx][ny]==INF){
      q.push(P(nx,ny));
        d[nx][ny]=d[p.first][p.second]+1;
      }
    }
  }
  return d[a-1][b-1];
}
signed main(){
  cin>>a>>b;
  rep(i,a)rep(j,b)
    cin>>c[i][j];
  int e=0;
  rep(i,a)rep(j,b){
  if(c[i][j]=='#')
    e++;
  }
  int f=bfs();
  if(f==INF)
    cout<<-1<<endl;
  else
    cout<<a*b-e-f-1<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define co cout
#define ci cin
#define sf1(n) scanf("%lld",&n);
#define sf2(n,m) scanf("%lld %lld",&n,&m);
#define sf3(n,m,p) scanf("%lld %lld %lld",&n,&m,&p);
#define en cout<<endl;
#define pb push_back
#define coy cout<< "YES"<<endl;
#define con cout<< "NO"<<endl;
#define For(a,b) for(ll a=0;a<b;a++)
#define br break;
#define i64 long long
i64 M=10000000;
//ll b[805],ans[805];
map< ll,pair<ll,ll> >mp;

int main()
{
    ll t,n,g,k,m,mx=0,mn=1e9,res,c1,x,y,c2;
    ci>>n;
    mx=1;
    string st;
    ci>>st;
    for(ll i=1;i<st.size();i++)
    {
        if(st[i]!=st[i-1]) mx++;
    }
    co<<mx;
}



Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

using namespace std;

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

const double INF = 1e16;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

const ll MAX_N = 400 + 10;
ll dp[MAX_N][MAX_N];

void init() {
	for (ll i = 0; i < MAX_N; i++) {
		for (ll j = 0; j < MAX_N; j++) {
			dp[i][j] = INF;
		}
	}
}

int main() {
	init();
	ll i, j, k;

	ll N;
	cin >> N;
	vll A(N + 1);
	vll ACC(N + 1);
	ACC[0] = 0;
	ll foracc = 0;
	for (i = 1; i <= N; i++) {
		ll a;
		cin >> a;
		A[i] = a;
		foracc += a;
		ACC[i] = foracc;
	}

	for (i = 1; i <= N; i++) {
		dp[i][i] = 0;
	}
	
	for (i = 1; i < N; i++) {
		for (j = 1; j + i <= N; j++) {
			ll minc = INF;
			ll acc = ACC[j + i] - ACC[j - 1];
			for (k = j; k < j + i; k++) {
				ll tmpc = dp[j][k] + dp[k + 1][j + i] + acc;
				minc = min(minc, tmpc);
			}
			dp[j][j + i] = minc;
		}
	}
	cout << dp[1][N] << endl;

	return 0;
}


Measured memory_bytes: 1536
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;
public class Main {
	String s;
	int[] a;
	public void solve() {
		s = next();
		a = new int[26];
		for(int i = 0;i < s.length();i++){
			a[s.charAt(i) - 'A']++;
		}
		
		if(a['S'-'A'] > 0 && a['N'-'A'] == 0){
			out.println("No");
			return;
		}
		
		if(a['N'-'A'] > 0 && a['S'-'A'] == 0){
			out.println("No");
			return;
		}
		
		if(a['W'-'A'] > 0 && a['E'-'A'] == 0){
			out.println("No");
			return;
		}
		
		if(a['E'-'A'] > 0 && a['W'-'A'] == 0){
			out.println("No");
			return;
		}
		
		out.println("Yes");
	}
 
	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}
 
	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;
 
	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}
 
	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}
 
	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}
 
	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}
 
	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}
 
	public int nextInt() {
		return Integer.parseInt(next());
	}
 
	public long nextLong() {
		return Long.parseLong(next());
	}
 
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 8020
#include <bits/stdc++.h>
using namespace std;
#define _ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define MP make_pair
const int oo = 1e9;
int n,t[100000];
int main(){_
for(int i=0;i<3;i++){ cin >> t[i] ;}
sort(t,t+3);
int ans=0;
for(int i=1;i<3;i++){
    ans+=t[i]-t[i-1];
}
cout << ans;
}


Measured memory_bytes: 256
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long ll;
const int N=500;

int n;
int Icst[N+3][N+3];
ll Ef[N+3][N+3],Ecac[N+3],Ecuc[N+3];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			if(i!=j)
				scanf("%d",&Icst[i][j]);
	n++;
	memset(Ef,0x3f,sizeof Ef);
	const ll INF=Ef[0][0];
	ll Vans=INF;
	Ef[0][0]=0;
	for(int i=1;i<=n-1;i++){
		for(int j=0;j<i;j++){
			Ecac[j]=0;
			for(int k=i+1;k<n;k++) Ecac[j]+=Icst[k][j];
			if(j) Ecac[j]+=Ecac[j-1];
		}
		for(int j=i-1;j>=0;j--){
			Ecuc[j]=0;
			for(int k=j+1;k<=i;k++) Ecuc[j]+=Icst[j+1][k];
			if(j+1<i-1) Ecuc[j]+=Ecuc[j+1];
		}
		for(int j=0;j<i;j++){
			for(int k=0;k<=j;k++)
				Ef[i][j]=min(Ef[i][j],Ef[j][k]+Ecac[j]-Ecac[k]+Ecuc[j]);
			if(i==n-1) Vans=min(Vans,Ef[i][j]);
		}
	}
	printf("%lld\n",Vans);
	return 0;
}

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

int main() {
	int n, k;
	cin >> n >> k;
	if (n % 2 == 0) {
		if (k > n/2)
			cout << "NO" << endl;
		else
			cout << "YES" << endl;
	}
	else {
		if (k > n/2 + 1)
			cout << "NO" << endl;
		else
			cout << "YES" << endl;
	}
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<vector<int>> point(n, vector<int>(3));
  vector<vector<int>> point_list(3);
  int i, j, k;
  for (i = 0; i < n; i++) {
    for (j = 0; j < 3; j++) {
      cin >> point[i][j];
      point_list[j].push_back(point[i][j]);
    }
  }
  for (i = 0; i < 3; i++) {
    sort(point_list[i].begin(), point_list[i].end());
  }
  vector<int> result(n, 0);
  for (i = 0; i < n; i++) {
    for (j = 0; j < 3; j++) {
      for (k = 0; k < point_list[j].size(); k++) {
        if (point[i][j] == point_list[j][k]) {
          if (k == point_list[j].size() - 1) {
            result[i] += point[i][j];
          } else {
            if (point[i][j] != point_list[j][k + 1]) {
              result[i] += point[i][j];
            }
          }
          break;
        }
      }
    }
  }
  for (i = 0; i < n; i++) {
    cout << result[i] << endl;
  }
  return 0;
}



Measured memory_bytes: 3120
package main

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

func main() {
	A := nextInt()
	B := nextInt()

	if (B+A)%2 == 0 {
		fmt.Println((B + A) / 2)
	} else {
		fmt.Println("IMPOSSIBLE")
	}
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)

	return i
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

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

    vector<vector<ll>> cnt(n+1, vector<ll>(60, 0));
    for(int i=0;i<n;++i) {
        for(int j=0;j<60;++j) {
            if(a[i] & (1LL << j)) {
                cnt[i+1][j] = cnt[i][j] + 1;
            } else {
                cnt[i+1][j] = cnt[i][j];
            }
        }
    }

    ll ans = 0LL;
    for(int j=0;j<60;++j) {
        ll s = (1LL << j) % MOD;
        for(int i=0;i<n;++i) {
            if(a[i] & (1LL << j)) {
                // cerr << (n-1-i) <<  " "  << (cnt[n][j] - cnt[i+1][j]) << endl;
                ans += (s * ((n-1-i) - (cnt[n][j] - cnt[i+1][j]))) % MOD;
            } else {
                // cerr << (cnt[n][j] - cnt[i+1][j]) << endl;
                ans += (s * (cnt[n][j] - cnt[i+1][j])) % MOD;
            }
            ans %= MOD;
        }
        // cerr << ans << endl;
    }

    cout << ans << endl;
}


Measured memory_bytes: 156928
#include <vector>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <cassert>
#include <stack> 

#define INFLL 2000000000000000000
#define INF 2000000000
#define MOD 1000000007
#define BASE 77747
#define PI acos(-1.0)
#define MAXLEN 29

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

using namespace std;

int n;
int arr[100000];
int tmp[100001];
int f[100001];

void add(int index, int val) {
	while (index < n + 1) {
		f[index] += val;
		index = (index | (index + 1));
	}
}
int get(int index) {
	int sum = 0;
	while (index >= 0) {
		sum += f[index];
		index = (index & (index + 1)) - 1;
	}
	return sum;
}

ll getCnt() {
	for (int i = 0; i < n + 1; i++) f[i] = 0;
	ll ans = 0;
	for (int i = 1; i < n + 1; i++) tmp[i] = tmp[i - 1] + tmp[i];
	int mini = INF;
	for (int i = 0; i < n + 1; i++) mini = min(mini, tmp[i]);
	for (int i = 0; i < n + 1; i++) tmp[i] -= mini;
	for (int i = n; i >= 0; i--) {
		ans += get(tmp[i] - 1);
		add(tmp[i], 1);
	}
	return n * 1LL * (n + 1) / 2 - ans;
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &arr[i]);
	int l = 1, r = 1000000001;
	ll ind = n * 1LL * (n + 1) / 2;
	ind = (ind + 1) / 2;
	while (l < r - 1) {
		int mid = (l + r) / 2;
		tmp[0] = 0;
		for (int i = 0; i < n; i++) 
			if (arr[i] >= mid) tmp[i + 1] = 1;
			else tmp[i + 1] = -1;
		if (getCnt() < ind) r = mid;
		else l = mid;
	}
	printf("%d\n", l);
	return 0;
}


Measured memory_bytes: 1536
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yosiiii
 */


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

class CSlimes {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n;
        string s;
        in >> n >> s;
        int ans=0;
        rep(i,n-1){
            if(s[i]!=s[i+1]){
                ans++;
            }
        }
        out << ans+1 << endl;
	}
};


int main() {
	CSlimes solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 512
#include<stdio.h>
int main(void){
    int a,b,c,swap;
    scanf ("%d %d %d",&a,&b,&c);
    if (a > b)
    {
      swap = a;
      a = b;
      b = swap;
    }
    if (b > c)
    {
        swap = b;
        b = c;
        c = swap;
    }
    if (a > c)
    {
        swap = a;
        a = c;
        c = swap;
    }
    printf ("%d",(b*a)/2);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long int MOD = 1000000007;
const long long  INF = 1LL << 60;

int main(void){
    string S, T; cin >> S >> T;
    
    int ans = 0;
    for (int i = 0;  i < S.size(); i++){
        if (S[i] != T[i]) ans++;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 3852
[<EntryPoint>]
let main argv =
    let input = stdin.ReadLine().Split(' ') |> Array.map int
    let n = input.[0]
    let c = input.[2]
    let arrB = stdin.ReadLine().Split(' ') |> Array.map int

    let mutable count = 0
    for i in [0..n-1] do
        let tmpCount =
            stdin.ReadLine().Split(' ') |> Array.map int
            |> Array.map2 (*) arrB
            |> fun a -> if (Array.sum a) + c > 0 then 1 else 0
        count <- count + tmpCount
    count |> printfn "%d"
    0


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

using namespace std;

//container util
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int N;
const int MAX = 100001;
int A[MAX] = {0};
int B[MAX] = {0};
int C[MAX] = {0};

int main(void){


	cin >> N;
	REP(i,N) cin >> A[i];
	REP(i,N) cin >> B[i];
	REP(i,N) cin >> C[i];

	sort(A,A+N);
	sort(B,B+N);
	sort(C,C+N);

	long long int ans = 0;
	REP(i,N){
		long long a = lower_bound(A, A+N, B[i]) - A;
		long long c = N - (upper_bound(C, C+N, B[i]) - C);
		ans += a*c;
	}

	cout << ans << endl;


	return 0;

}


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

int selectionSort(int A[],int N){
    int sw=0;
    int minj;
    for(int i=0;i<N-1;i++){
        minj=i;
        for(int j=i;j<N;j++){
            if(A[j]<A[minj])minj=j;
        }
        swap(A[i],A[minj]);
        if(i!=minj)sw++;
    }
    return sw;
}
int main(){
    int N,sw;
    int A[100];
    cin>>N;
    for(int i=0;i<N;i++)cin>>A[i];
    sw=selectionSort(A,N);
    for(int i=0;i<N;i++){
        if(i)cout<<" ";
        cout<<A[i];
    }
    cout<<endl;
    cout<<sw<<endl;
    
    return 0;
}


Measured memory_bytes: 3084
import sys
from collections import defaultdict, deque
import bisect
from heapq import *
from math import factorial
sys.setrecursionlimit(200000)
input = sys.stdin.readline

A, B, = map(int, input().split())
# N = int(input())
# L = [int(v) for v in input().split()]
# L = [[int(v) for v in input().split()] for _ in range(N)]
# L = [int(input()) for _ in range(N)]
# L = [list(input().strip())  for _ in range(N)]
# S = input().strip()

def gcd(x, y):
    if x < y:
        x, y = y, x
    if x % y == 0:
        return y
    return gcd(y, x % y)

print(A * B // gcd(A, B))

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

int main()
{
    int K;
    cin >> K;
    if (K % 7 == 0)
    {
        K /= 7;
    }
    K *= 9;
    ll test = 1;
    for (int i = 1; i <= K; i++)
    {
        // cout<<test<<endl;
        test = test * 10 % K;
        if (test == 1)
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


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

int mod_num = 998244353;

int main(){
    int N;
    std::cin >> N;
    std::vector< int > cnt(N, 0);
    int max = 0;
    int tmp;
    std::cin >> tmp;
    if(tmp != 0){
        std::cout << 0 << std::endl;
        return 0;
    }
    cnt[0]++;
    for(int i=1; i<N; i++){
        int tmp;
        std::cin >> tmp;
        cnt[tmp]++;
        if(max < tmp){ max = tmp; }
    }
    if(cnt[0] != 1){
        std::cout << 0 << std::endl;
        return 0;
    }
    long long ans = 1;
    for(int i=0; i<max; i++){
        for(int j=0; j<cnt[i+1]; j++){
            ans = (ans * cnt[i]) % mod_num;
        }
    }
    
    std::cout << ans << std::endl;
    
    return 0;
    
}



Measured memory_bytes: 640
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn f(s: &Vec<usize>, a: usize) -> usize {
    let mut acc = 0;

    let mut buf = 0;
    let mut i = 0;
    while i < s.len() {
        buf = buf * 10 + s[i];
        if (a >> i) & 1 == 1 {
            acc += buf;
            buf = 0;
        }
        i += 1;
    }
    acc += buf;
    return acc;
}

fn main() {
    input! {
      s: String,
    }
    let mut nums = Vec::new();
    for c in s.chars() {
        nums.push(c as usize - 0x30);
    }

    let l = nums.len();

    let ans = (0..(1 << (l - 1))).fold(0, |acc, i| acc + f(&nums, i));

    println!("{}", ans);
}


Measured memory_bytes: 4352
N, M = map(int, input().split())
gate = [ list(map(int, input().split())) for i in range(M) ]

max_L = max([ i[0] for i in gate])
min_R = min([ i[1] for i in gate])
ans = 0
if max_L > min_R:
	ans = 0
else:
	ans = min_R - max_L + 1
print(ans)

Measured memory_bytes: 28264
n = int(input())
alpha = [chr(ord('a') + i) for i in range(26)]
count = 1
m = n
while True:
    m -= 26 ** count
    if m > 0:
        count += 1
    else:
        m += 26 ** count
        break
keta = count
dec = m - 1

def Base_10_to_n(X, n):
    if (int(X/n)):
        a = alpha[X%n]

        return Base_10_to_n(int(X/n), n)+a
    else:
        a = alpha[X%n]
        return a
############################
 
 
#####関数をつかってみる．#####
######今回は二進数に変換######
x10 = dec
x2 = Base_10_to_n(x10, 26)
if len(x2) < count:
    x2 = 'a'*(count - len(x2)) + x2
print( x2 )#"100011"が表示される．


Measured memory_bytes: 9216
#include <stdio.h>
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long ll;

int main() {
  int N;
  cin>>N;
  int t = N / 100;
  int ans = t * 111;
  if (N > ans) ans += 111;
  cout<<ans<<endl;
  return 0;
}

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

#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

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

    string s;
    cin >> s;

    int64_t m = s.size();

    vector a(1, 0L);
    int64_t t = 0;
    for (auto c : s) {
        if (c == '0') {
            a.push_back(t);
        } else {
            ++t;
        }
    }
    a.push_back(t);

    int64_t k;
    cin >> k;
    k = min(k, a.back());

    int64_t n = a.size();

    constexpr auto M = 998244353L;

    vector dp(vector(k + 1, vector(a.back() + 1, 0L)));
    int64_t mk = 0;
    dp[0][0] = 1;
    for (auto i : irange(0L, n - 1)) {
        for (auto j : irange(mk, -1L, -1L)) {
            for (auto c : irange(0L, a.back() - a[i + 1] + 1)) {
                for (auto b : irange(c + 1, c + a[i + 1] - a[i] + 1)) {
                    auto w = j + b - c;
                    if (w > k) {
                        break;
                    }
                    mk = max(mk, w);
                    dp[w][c] += dp[j][b];
                    if (dp[w][c] >= M) {
                        dp[w][c] -= M;
                    }
                }
            }

            for (auto c : irange(1L, a.back() - a[i + 1] + 1)) {
                dp[j][c] += dp[j][c - 1];
                if (dp[j][c] >= M) {
                    dp[j][c] -= M;
                }
            }
        }
    }

    int64_t ans = 0;
    for (auto i : irange(0L, k + 1)) {
        ans += dp[i][0];
        if (ans >= M) {
            ans -= M;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3844
#include<bits/stdc++.h>
int i,j,p,n,q,a[9]={5,7,5,7,7,-1};char s[50];
main(){for(;scanf("%d\n",&n),n;){for(i=0;i<n;s[i++]=strlen(gets(s+i)));
for(i=j=0;j<6;i++)for(p=i,j=q=0;q>=0;)for(q=a[j++];q>0;q-=s[p++]);
printf("%d\n",i);
}}

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

typedef long long ll;
vector<ll> a;

int solve(string s) {
    int k = s.size();
    if (k == 11) return 0;
    a.push_back(stoll(s));
    int last = s[k - 1] - '0';
    if (last == 0) solve(s + to_string(last)), solve(s + to_string(last + 1));
    else if (last == 9) solve(s + to_string(last)), solve(s + to_string(last - 1));
    else solve(s + to_string(last)), solve(s + to_string(last + 1)), solve(s + to_string(last - 1));
}

int main() {
    int k; cin >> k;
    for (int i = 1; i <= 9; i++) {
        solve(to_string(i));
    }
    sort(a.begin(),a.end());
    cout << a[k-1] << "\n";
}

Measured memory_bytes: 2424
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main()
{
	int a,b,c,p,F;
	scanf("%d %d %d",&a,&b,&c);
	
	p = (a + b + c)/ 2;
	F =sqrt(p * (p -a) * (p-b) * (p-c));
	
	printf("%d\n",F);
		
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)

const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long A, long long B, std::string S){
    ll iAB = 0, iB = 0;
    rep(i, N){
        if(S[i]=='c'){
            cout << NO << endl;
        }
        if(S[i]=='a'){
            if(iAB < A+B){
                cout << YES << endl;
                iAB ++;
            }
            else
                cout << NO << endl;
        }
        if(S[i] == 'b'){
            if(iAB < A+B && iB < B){
                cout << YES << endl;
                iAB ++;
                iB++;
            }
            else
                cout << NO << endl;
        }
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    std::string S;
    std::cin >> S;
    solve(N, A, B, S);
    return 0;
}


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

int main() {
  int R, G, B, N;
  cin >> R >> G >> B >> N;

  int ans = 0;
  rep(i, N / R + 1) {
    rep(j, (N - i * R) / G + 1) {
      if ((N - i * R - j * G) % B == 0) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    int n,ans=0,tmp=0;
    cin>>n;
    Vi a(n);
    REP(i,0,n) cin>>a[i];
    REP(i,0,n-1){
        if(a[i]>=a[i+1]) tmp++;
        else tmp=0;
        chmax(ans,tmp);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll n;
	cin>>n;
	int a[10001]={0};
	for(int i=1;i*i<=10000;i++){
	  for(int j=1;j*j<=10000;j++){
	  	for(int k=1;k*k<=10000;k++){
	  		ll x=i*i+j*j+k*k+i*j+j*k+k*i;
	  		if(x<=10000){
	  			a[x]++;
	  		}
	  	}
	  }
	}
	for(int i=1;i<=n;i++){
		cout<<a[i]<<endl;
	}
}

Measured memory_bytes: 3632
from itertools import accumulate
N, K = map(int, input().split())
A = list(map(int, input().split()))

i = 0
for _ in range(min(K, 50)):
    B = [0] * (N + 1)
    for i, a in enumerate(A):
        j = max(0, i - a)
        B[j] += 1
        j = min(N, i + a + 1)
        B[j] -= 1
    B.pop()
    A = list(accumulate(B))

print(*A)

Measured memory_bytes: 184336
n=int(input())
s=input()
x=[]
y=list(s)
k=0
for i in range(n):
    x.append(s[i])
    del y[0]
    xn=list(set(x))
    yn=list(set(y))
    t=0
    for a in xn:
        for b in yn:
            if a==b:
                t+=1
                k=max(k,t)
print(k)

Measured memory_bytes: 3060
N = int(input())
dic = {}
for i in range(0,N):
  inp = input()
  if inp not in dic:
    dic[inp] = 1
  else:
    dic[inp] +=1

m = max(dic.values())

keys = [k for k,v in dic.items() if v == m]

keys.sort()

for i in range(0,len(keys)):
  print(keys[i])

Measured memory_bytes: 32096
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s,w;
	cin >> s >> w;
	if(s[0]==w[2] && s[1]==w[1] && s[2]==w[0]){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline  #危険！基本オフにしろ！

def BELLMANFORD(point,d,n):
    cost       = [-float("inf")for node in range(n+1)]
    cost[point]= 0
    for i in range(n-1):                                  #経路の長さは最大n-1であるため
        for now,lis in d.items():
            for nex,c in lis:
                if cost[nex]<cost[now]+c:
                    cost[nex]=cost[now]+c

    negative=[0]*n                                        #負閉路の長さは最大nであるため
    
    for i in range(n):                  #閉路判定
        for now,lis in d.items():
            for nex,c in lis:
                if negative[now-1]==1:
                    negative[nex-1]=1
                if cost[nex]<cost[now]+c:
                    cost[nex]=cost[now]+c
                    negative[now-1]=1
 
    return cost,negative


def main():
    n,m=map(int,input().split())
    
    d={}
    for s in range(m):
        a,b,c=map(int,input().split())
        if a in d:
            d[a].append((b,c))
        else:
            d[a]=[(b,c)]
    
    x,y=(BELLMANFORD(1,d,n))
    
    if y[n-1]>0:
        print("inf")
    else:
        print(x[n])


if __name__ == '__main__':
    main()


Measured memory_bytes: 45660
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100000;

int n;
ll a[MAXN];
ll asum[MAXN+1];

bool ok[MAXN];


void run() {
	scanf("%d",&n); REP(i,n) scanf("%lld",&a[i]); sort(a,a+n);
	asum[0]=0; REP(i,n) asum[i+1]=asum[i]+a[i];
	memset(ok,false,sizeof(ok)); ok[n-1]=true;
	for(int i=n-2,j=n-1;i>=0;--i) {
		while(2*asum[i+1]<a[j]) --j; ok[i]=ok[j];
	}
	int ret=0; REP(i,n) if(ok[i]) ++ret; printf("%d\n",ret);
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 1920
N = int(input())
A = [int(x) for x in input().split()]

high = 1000
kabu = 1000 // A[0]
amar = 1000 - kabu * A[0]

for i in range(1, N):
    res = amar + kabu * A[i]
    if res > high:
        high = res
    if A[i] < max(A[i:]):
        kabu = high // A[i]
        amar = high - kabu * A[i]
    
print(high)

Measured memory_bytes: 9096
#include <cmath>
#include <iostream>
#include <vector>

using namespace std;

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

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

    vector<vector<long long>> dp(n, vector<long long>(2));
    dp[0][0] = a[0];
    dp[0][1] = -a[0];
    for (int i = 1; i < n; i++) {
        dp[i][0] = max(dp[i - 1][0] + a[i], dp[i - 1][1] - a[i]);
        dp[i][1] = max(dp[i - 1][0] - a[i], dp[i - 1][1] + a[i]);
    }

    cout << dp[n - 1][0] << endl;
}


Measured memory_bytes: 6144
function main()
  V=zeros(Int,3010,3010)
  dp=zeros(Int,3010,3010,4)
  R,C,K=parse.(Int,split(readline()))
  for i=1:K
    r,c,v=parse.(Int,split(readline()))
    V[r,c]=v
  end
  for i=1:R
    for j=1:C
      for k=1:3
        dp[i+1,j+1,k+1]=max(max(dp[i,j+1,4],dp[i+1,j,k])+V[i,j],max(dp[i+1,j,k+1],dp[i,j+1,k+1]))
      end
    end
  end
  println(dp[R+1,C+1,4])
end
main()

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

using namespace std;

typedef long long ll;

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

int main() {
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  ll cd = C * D / gcd(C, D);
  ll a = (A - 1) - ((A - 1) / C + (A - 1) / D - (A - 1) / cd);
  ll b = B - (B / C + B / D - B / cd);
  cout << b - a << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <functional>
#include <queue>

//AtCoderC++.cpp

using namespace std;

void Show(vector<vector<int>> Ns) {
	for (int i = 0; i < Ns.size(); i++) {
		for (int j = 0; j < Ns[i].size(); j++) {
			if (j == Ns[i].size() - 1) {
				cout << Ns[i][j] << endl;
			} else {
				cout << Ns[i][j] << ",";
			}
		}
	}
}

void Show(vector<int> N) {
	for (int i = 0; i < N.size(); i++) {
		cout << N[i];
		if (i != N.size() - 1) {
			cout << " ";
		} else {
			cout << endl;
		}
	}
}


int main() {
	int N;
	double T, A;
	cin >> N >> T >> A;
	double Temp = 100000000;
	int No = 0;
	int Height;
	for (int i = 0; i < N; i++) {
		cin >> Height;
		if (Temp > abs(A - (T - Height * 0.006))) {
			No = i + 1;
			Temp = abs(A - (T - Height * 0.006));
		}
	}
	cout << No << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  int n;
  cin >> n;
  int k = n/2;
  cout << k*(n-k) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
#include<map>
#include<iomanip>
using namespace std;

int main(void){
 int d,n;
 vector<int> D;
 
 cin>>n;
 for(int i=0; i<n; i++){
  cin>>d;
  D.push_back(d);
 }
 sort(D.begin(),D.end());
 
 cout<<D[n/2]-D[n/2-1]<<endl;

 return 0;
}



Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a[111111];
  cin>>n;
  for(int i=0;i<n;i++) cin>>a[i];
  sort(a,a+n);
  long long int ans=0;
  for(int i=n-2;i>=0;i--){
    if(a[i+1]==a[i]){
      if(ans==0) ans+=a[i];
      else{
	ans*=a[i];
	break;
      }
      i--;
    }
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int a[111][111];
int dp[111][111];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,m; cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		string s; cin>>s;
		for(int j=0;j<m;j++)
		{
			if(s[j]=='#') a[i][j]=1;
			else a[i][j]=0;
		}
	}
	dp[0][0]=a[0][0];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(i+j>0) dp[i][j]=int(1e9);
			if(i>0)
			{
				int c = a[i][j];
				if(c>0&&a[i-1][j]>0) c=0;
				dp[i][j]=min(dp[i][j],dp[i-1][j]+c);
			}
			if(j>0)
			{
				int c = a[i][j];
				if(c>0&&a[i][j-1]>0) c=0;
				dp[i][j]=min(dp[i][j],dp[i][j-1]+c);
			}
		}
	}
	cout<<dp[n-1][m-1]<<'\n';
}


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

using namespace std;

void solve();

int main() {
#ifdef OFFLINE
	freopen("input.txt", "r", stdin);
#endif
	ios::sync_with_stdio(false);
	solve();
	return 0;
}

#define forn(i, n) for (int i=0; i<n; ++i)

const int N = 2001;
int n, k;
vector<int> g[N];

int dfs(int u, int par, int h) {
	if (h==0) return 1;
	int ret = 1;
	for (int v: g[u])
		if (v != par)
			ret += dfs(v, u, h-1);
	return ret;
}

void solve() {
	cin >> n >> k;
	forn(_, n-1) {
		int u, v; cin >> u >> v; --u, --v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	int vmax = 0;
	if (k & 1) {
		forn(u, n)
			for (int v: g[u]) if (u < v)  {
				int vcur = 0;
				vcur += dfs(u, v, k/2);
				vcur += dfs(v, u, k/2);
				vmax = max(vmax, vcur);
			}
	} else {
		forn(u, n) {
			int vcur = dfs(u, -1, k/2);
			vmax = max(vmax, vcur);
		}
	}
	cout << n - vmax << endl;
}

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

int main() {
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	if(H%h<1 && W%w<1) cout << "No" << endl;
	else{
	    cout << "Yes" << endl;
	    int T=((H/h)*(W/w))/(W*(H%h)+H*(W%w)-(H%h)*(W%w))+1;
	    for(int i=1; i<=H; ++i){
	        for(int j=1; j<=W; ++j){
	            if(i%h<1 && j%w<1) cout << -T*(h*w-1)-1;
	            else cout << T;
	            if(j<W) cout << ' ';
	            else cout << endl;
	        }
	    }
	}
	return 0;
}


Measured memory_bytes: 1280
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

func exec(stdin *Stdin, stdout *Stdout) {
	n := stdin.ReadInt()
	d := stdin.ReadInt()
	a := stdin.ReadInt()

	monsters := []Monster{}
	for i := 0; i < n; i++ {
		x := stdin.ReadInt()
		h := stdin.ReadInt()
		monsters = append(monsters, Monster{X: x, H: h})
	}
	sort.Sort(Monsters(monsters))

	q := NewDeque()
	c := 0
	ans := 0
	for _, monster := range monsters {
		for !q.IsEmpty() {
			rng := q.PeekFirst().(*Range)
			if rng.Left <= monster.X && monster.X <= rng.Right {
				break
			}

			c -= rng.Count
			q.PopFirst()
		}

		if c*a < monster.H {
			var count int
			if (monster.H-c*a)%a == 0 {
				count = (monster.H - c*a) / a
			} else {
				count = (monster.H-c*a)/a + 1
			}

			c += count
			ans += count
			rng := &Range{
				Left:  monster.X,
				Right: monster.X + 2*d,
				Count: count,
			}
			q.AppendLast(rng)
		}
	}

	stdout.Println(ans)
}

type Monster struct {
	X int
	H int
}

type Monsters []Monster

func (ms Monsters) Len() int           { return len(ms) }
func (ms Monsters) Less(i, j int) bool { return ms[i].X < ms[j].X }
func (ms Monsters) Swap(i, j int)      { ms[i], ms[j] = ms[j], ms[i] }

type Range struct {
	Left  int
	Right int
	Count int
}

func main() {
	stdout := NewStdout()
	defer stdout.Flush()
	exec(NewStdin(bufio.ScanWords), stdout)
}

type Stdin struct {
	stdin *bufio.Scanner
}

func NewStdin(split bufio.SplitFunc) *Stdin {
	s := Stdin{bufio.NewScanner(os.Stdin)}
	s.stdin.Split(split)
	s.stdin.Buffer(make([]byte, bufio.MaxScanTokenSize), int(math.MaxInt32))
	return &s
}

func (s *Stdin) Read() string {
	s.stdin.Scan()
	return s.stdin.Text()
}

func (s *Stdin) ReadInt() int {
	n, _ := strconv.Atoi(s.Read())
	return n
}

func (s *Stdin) ReadFloat64() float64 {
	n, _ := strconv.ParseFloat(s.Read(), 64)
	return n
}

type Stdout struct {
	stdout *bufio.Writer
}

func NewStdout() *Stdout {
	return &Stdout{bufio.NewWriter(os.Stdout)}
}

func (s *Stdout) Flush() {
	s.stdout.Flush()
}

func (s *Stdout) Println(a ...interface{}) {
	fmt.Fprintln(s.stdout, a...)
}

type Deque struct {
	deque []interface{}
}

func NewDeque() *Deque {
	return &Deque{deque: []interface{}{}}
}

func (d *Deque) AppendFirst(v interface{}) {
	e := make([]interface{}, len(d.deque)+1)
	copy(e[1:], d.deque)
	d.deque = e
}

func (d *Deque) AppendLast(v interface{}) {
	d.deque = append(d.deque, v)
}

func (d *Deque) PopLast() interface{} {
	n := len(d.deque)
	v := d.deque[n-1]
	d.deque = d.deque[0 : n-1]
	return v
}

func (d *Deque) PopFirst() interface{} {
	v := d.deque[0]
	d.deque = d.deque[1:]
	return v
}

func (d *Deque) PeekFirst() interface{} {
	return d.deque[0]
}

func (d *Deque) PeekLast() interface{} {
	return d.deque[len(d.deque)-1]
}

func (d *Deque) IsEmpty() bool {
	return len(d.deque) == 0
}


Measured memory_bytes: 14976
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
typedef long long i64;
int main(){
    int a;
    cin >> a;
    cout << 48-a << endl;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>

using namespace std;

typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int x[110000];
long long int DP[20][110000];

int main(){
	int N, Q;
	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> x[i];
	}
	long long int L;
	cin >> L;
	int pos = 0;
	for(int i = 0; i < N; i++){
		while(pos < N - 1 && x[pos + 1] - x[i] <= L){
			pos += 1;
		}
		DP[0][i] = pos;
	}
	for(int i = 1; i < 20; i++){
		for(int j = 0; j < N; j++){
			DP[i][j] = DP[i - 1][DP[i - 1][j]];
		}
	}
	cin >> Q;
	for(int loop = 0; loop < Q; loop++){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		if(a > b){
			swap(a, b);
		}
		long long int ans = 0, pos = a;
		for(int i = 19; i >= 0; i--){
			if(DP[i][pos] < b){
				ans += (1 << i);
				pos = DP[i][pos];
			}
		}
		cout << ans + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 18560
import java.util.*;
import java.util.function.*;
 
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    sc.close();

    StringBuilder buf;
    buf = new StringBuilder();
    for (int i = 0; i < b; i++) buf.append(String.valueOf(a));
    String ab = buf.toString();

    buf = new StringBuilder();
    for (int i = 0; i < a; i++) buf.append(String.valueOf(b));
    String ba = buf.toString();
    
    String ans = ab.compareTo(ba) < 0 ? ab : ba;
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
#include<iostream>
using namespace std;
int increase_debt(int debt,int n) {
	if(n==0) return debt;
	debt += debt*0.05;
	if(debt % 1000 != 0)
		debt += 1000 - debt % 1000;
	increase_debt(debt,n-1);
}
int main() {
	int n;
	cin >> n;
	cout << increase_debt(100000,n) << endl;
	return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(void)
{
  short a, b, c, n;
  char i;

  scanf("%hd", &n);

  for (i = 0; i < n; i++) {
    scanf("%hd%hd%hd", &a, &b, &c);
    if (a*a+b*b == c*c || a*a+c*c == b*b || b*b+c*c == a*a)
      printf("YES\n");
    else
      printf("NO\n");
  }

  return 0;
}

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

int main() {
  int N,K;
  cin>>N>>K;
  vector<int> x(N);
  rep(i,N) {
    cin>>x[i];
  }
  //右端をxr,  左端をxlとする。xl=xr+K-1
  //この場合のD=min(|xr|+|xr-xl|,|xl|+|xl-xr|)すなわちmin(|xr|,|xl|)+|xr-xl|
  int D=pow(10,9);
  rep(i,N){
    if(i+K-1<=N-1){
      D=min(D, min(abs(x[i]),abs(x[i+K-1]))+abs(x[i]-x[i+K-1]));
    }
  }
  cout<<D<<endl;
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repk(i,k, n) for (int i = k; i < (int)(n); ++i)
#define MAX 500010
typedef long long int ll;

using namespace std;

int ans;

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

	cout << N*N << endl;

	return 0;
}

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

int main() {
    
   long long int a,b,c,k;
   cin>>a>>b>>c>>k;
   long long int ans=0;
   ans=min(a,k);
   k-=min(a,k);
   k-=min(b,k);
   ans-=min(c,k);
   cout<<ans;
}


Measured memory_bytes: 3636
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

class UnionFind:
    def __init__(self, n):
        self.parent = [i for i in range(n)]
        self.num = [1 for i in range(n)]

    def root(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.root(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x != y:
            self.parent[x] = y
            self.num[y] += self.num[x]

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

    def count(self, x):
        return self.num[self.root(x)]

N, M = map(int, input().split())
un = UnionFind(N)
for i in range(M):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    un.unite(a, b)
ans = 0
for i in range(N):
    ans = max(ans, un.count(i))
print(ans)


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

// #define multitest 1
#ifdef WIN32
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
#define pc(...) PC(#__VA_ARGS__, __VA_ARGS__);
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
	out << '[' << p.first << ", " << p.second << ']';
	return out;
}
template <typename Arg>
void PC(const char *name, Arg &&arg)
{
	std::cerr << name << " { ";
	for (const auto &v : arg)
		cerr << v << ' ';
	cerr << " }\n";
}
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#define pc(...)
#endif

using ll = long long;
#define f first
#define s second
#define pb push_back
const long long mod = 1000000007;
auto TimeStart = chrono::steady_clock::now();

const int nax = 2e5 + 10;

void solve()
{
	int a;
	string s;
	cin >> a >> s;
	if (a < 3200)
		cout << "red";
	else
		cout << s;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
#ifdef multitest
	cin >> t;
#endif
	while (t--)
		solve();
#ifdef WIN32
	cerr << "\n\nTime elapsed: " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " seconds.\n";
#endif
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  vector<long> A(N), B(N);
  rep (i, N) cin >> A[i];
  rep (i, N) cin >> B[i];

  long marginA = 0;
  long marginB = 0;

  rep (i, N) {
    if (A[i] < B[i]) marginA += (B[i] - A[i]) / 2;
    else marginB += A[i] - B[i];
  }

  if (marginA >= marginB) cout << "Yes" << endl;
  else cout << "No" << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 384
package main

import (
  "fmt"
)

func main() {
  var n int
  num := make([]int, 10)
  
  for i := 0; i < 4; i++ {
    fmt.Scanf("%d", &n)
    num[n]++
  }
  
  ans := "YES"
  if num[1] != 1 {
    ans = "NO"
  }
  if num[9] != 1 {
    ans = "NO"
  }
  if num[7] != 1 {
    ans = "NO"
  }
  if num[4] != 1 {
    ans = "NO"
  }
  fmt.Printf("%s\n", ans)
}

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

int main() {
	int a, b, c, k;
	bool ans;
	cin >> a >> b >> c >> k;
	for (int i = 0; i < k; i++) {
		if (a < b && b < c) {
			ans = true;
			break;
		}
		else if (a < b && b >= c) {
			c *= 2;
		}
		else if (a >= b && b < c) {
			b *= 2;
		}
		else if (a >= b && b >= c) {
			b *= 2;
		}
	}
	if (a < b && b < c) {
		ans = true;
	}
	else {
		ans = false;
	}
	if (ans == true) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3628
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //
const long infty = 1_000_000_000_000_000_100;
void solve(){
	int n = read.to!int;
	
	long[] as;
	foreach(i; 0 .. n) as ~= read.to!long;
	
	long calc(long x, long y, int l, int r){
		if(l + 1 == r) return 0;
		long res = infty;
		foreach(i; l + 1 .. r){
			long temp = calc(x, x + y, l, i) + (x + y) * as[i] + calc(x + y, y, i, r);
			res = min(res, temp);
		}
		return res;
	}
	
	long ans = as[0] + calc(1, 1, 0, n - 1) + as[n - 1];
	ans.writeln;
}



Measured memory_bytes: 256
n, k = gets.chomp.split(' ').map{ |e| e.to_i }
h = gets.chomp.split(' ').map{ |e| e.to_i }

dp = [0]

(n - 1).times{|ii|
  i = ii + 1
  min = dp[i - 1] + (h[i - 1] - h[i]).abs
  kt = (i - 1) < (k - 1) ? i - 1 : k - 1
  kt.times{|jj|
    j = jj + 1
    cand = dp[i - j - 1] + (h[i - j - 1] - h[i]).abs
    min = cand if cand < min
  }
  dp.push(min)
}
puts dp.last


Measured memory_bytes: 10784