akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vll vector<long long>
#define INF 1e18
 
ll modInverse(ll a, ll m);
ll gcd(ll a, ll b);
ll power(ll x, unsigned ll y, unsigned ll m);
ll logint(ll x,ll y);
 
 
ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b%a, a);
}
 
ll power(ll x, unsigned ll y, unsigned ll m)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2, m) % m;
    p = (p * p) % m;
 
    return (y%2 == 0)? p : (x * p) % m;
}
 
ll modInverse(ll a, ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;
 
    if (m == 1)
      return 0;
 
    while (a > 1)
    {
        // q is quotient
        ll q = a / m;
        ll t = m;
 
        // m is remainder now, process same as
        // Euclid's algo
        m = a % m, a = t;
        t = y;
 
        // Update y and x
        y = x - q * y;
        x = t;
    }
 
    // Make x positive
    if (x < 0)
       x += m0;
 
    return x;
}
 
void pairsort(ll a[],ll b[], ll n)
{
    pair<ll, ll> pairt[n];
 
    // Storing the respective array
    // elements in pairs.
    for (ll i = 0; i < n; i++)
    {
        pairt[i].first = a[i];
        pairt[i].second = b[i];
    }
 
    // Sorting the pair array.
    sort(pairt, pairt + n);
 
    // Modifying original arrays
    for (ll i = 0; i < n; i++)
    {
        a[i] = pairt[i].first;
        b[i] = pairt[i].second;
    }
}
 
ll logint(ll x,ll y)
{
    ll ans=0;
    ll a=1;
    for(ll i=0;i<x;i++)
    {
        if(x<=a)
        {
            return ans;
        }
        ans++;
        a*=y;
    }
    return -1;
}
/*
ll v[500001], size[500001];
vector<ll>ve(0);
ll fin(ll x){
    //using path compression optimization
    if(x == v[x]){
        return x;
    }
    return v[x] = fin(v[x]);
}
void uni(ll x, ll y){
    x = fin(x);
    y = fin(y);
    if(x == y){
        return ;
    }
    //Using Union by size method, to reduce long chains
    if(size[x] < size[y]){
	size[x]+= size[y];
    	v[y] = x;}
    else{
	size[y]+=size[x];
	v[x]=y;
	}
}
*/
int main()
{
   // ios::sync_with_stdio(0);
    //cin.tie(0);
    //cout.tie(0);
 
    /*
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    */
    ll a, k;
    cin>>a>>k;
    ll dp[a];
    memset(dp, 0, sizeof(dp));
    ll ar[a];
    REP(i, 0, a){
        cin>>ar[i];
    }
    dp[0] = 0;
    dp[1] = abs(ar[1]-ar[0]);
    REP(i, 2, a){
        ll ans=INF;
        for(ll j= i-1; j>=0 && j >= i-k; j--){
            ans = min(dp[j]+abs(ar[j]-ar[i]), ans);
        }
        dp[i] = ans;
    }
    cout<<dp[a-1];
}

Measured memory_bytes: 1792
n, x = list(map(int, input().split()))
# a = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(n)]
# k = int(input())
L = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
#ab = [list(map(int, input().split())) for i in range(n)]
# print(min(15*n, 100*(n//10+1), 100*(n//10)+15*(n % 10)))
d = 0
count = 1
for l in L:
    if d+l > x:
        break
    else:
        d = d+l
        count += 1

print(count)


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

int main() {
  

  // ここにプログラムを追記
  string a, s, c;
  cin >> a >> s >> c;
  char A, S, C;
  A = a.at(0);
  S = s.at(0);
  C = c.at(0);
  cout << A << S << C << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
const int Inf = 1e9 + 7;
int n, k, a;

int main() {
	cin >> n >> k;
	k--;
	int pos, ans;
	for(int i = 1; i <= n; i++) {
		cin >> a;
		if(a == 1) pos = i;
	}
	int minT = Inf;
	for(int i = 0; i <= k; i++) {
		ans = 1;
		int p1 = pos - i, p2 = pos + k - i;
		if((p1 - 1) % k) {
			if(p1 > 1) ans += (p1 - 1) / k + 1;
		}
		else {
			if(p1 > 1) ans += (p1 - 1) / k;
		}
		if((n - p2) % k) {
			if(p2 < n) ans += (n - p2) / k + 1;
		}
		else {
			if(p2 < n) ans += (n - p2) / k;
		}
		//cout << ans << endl;
		minT = min(ans, minT);
	}
	cout << minT << endl;
}

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

public class Main{
  public static OutputStream out=new BufferedOutputStream(System.out);
  static Scanner sc=new Scanner(System.in);
  static long mod=1000000007l;
  static int INF=1000000;

  //nl-->neew line; //l-->line;  //arp-->array print;  //arpnl-->array print new line
  public static void nl(Object o) throws IOException{out.write((o+"\n").getBytes()); }
  public static void l(Object o) throws IOException{out.write((o+"").getBytes());}
  public static void arp(int[] o) throws IOException{for(int i=0;i<o.length;i++) out.write((o[i]+" ").getBytes()); out.write(("\n").getBytes());}
  public static void arpnl(int[] o) throws IOException{for(int i=0;i<o.length;i++) out.write((o[i]+"\n").getBytes());}
  public static void scanl(long[] a,int n) {for(int i=0;i<n;i++) a[i]=sc.nextLong();}
  public static void scani(int[] a,int n) {for(int i=0;i<n;i++) a[i]=sc.nextInt();}
  public static void scan2D(int[][] a,int n,int m) {for(int i=0;i<n;i++) for(int j=0;j<m;j++) a[i][j]=sc.nextInt();}
  //
  static long cnt;
  static TreeSet<Integer> ans;
  static int n,m;
  static boolean[][] dp,vis;
  static HashMap<Pair,Boolean> arrl;
  static Stack<Integer> stk;
  static Queue<Integer> queue;
  static HashSet<Integer> mtrnode;
  static ArrayList<Integer> arrlans;


  public static void main(String[] args) throws IOException{
    long sttm=System.currentTimeMillis();
    long mod=1000000007l;

    int n=sc.nextInt();
    if(n>=30){
        nl("Yes");
    }
    else{
        nl("No");
    }

    out.flush();
  }

}

class Pair{
  int x,y;
  Pair(int x,int y){
    this.x=x;
    this.y=y;
  }
}


Measured memory_bytes: 38340
n = int(input())
s = input()
wcnt = [0] * n
ecnt = [0] * (n)
enum = 0
wnum = 0
for i in range(n):
    if s[i] == "W":
        wnum += 1
    wcnt[i] += wnum
    if s[-i - 1] == "E":
        enum += 1
    ecnt[-i - 1] += enum
ans = 10 ** 10
for i in range(n):
    temp = 0
    if i - 1 >= 0:
        temp += wcnt[i - 1]
    if i + 1 < n:
        temp += ecnt[i + 1]
    ans = min(ans, temp)
print(ans)


Measured memory_bytes: 32900
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

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

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

    int n, k;
    cin >> n >> k;

    vector<int> a(n);
    rep(i, n) cin >> a[i];

    vector<int> s(n+1);
    rep(i, n){
        s[i+1] = s[i] + a[i];
    }

    vector<int> t;
    rep(i, n){
        for(int j = i; j < n; j++){
            t.push_back(s[j+1] - s[i]);
        }
    }

    sort(ALL(t), greater<int>());
    int head = 0;
    int last = SZ(t) - 1;
    int ans = 0;
    for(int i = 40; i >= 0; i--){
        int cnt = 0;
        int tmpH, tmpL;
        int sum = ans ^ (1LL << i);
        for(int j = head; j <= last; j++){
            if((t[j] & sum) == sum){
                if(cnt == 0){
                    tmpH = j;
                }
                cnt++;
                if(cnt >= k){
                    tmpL = j;
                }
            }
        }
        if(cnt >= k){
            ans += (1LL << i);
            head = tmpH;
            last = tmpL;
        }
    }
    cout << ans << endl;

    /*
    rep(i, SZ(t)){
        cout << bitset<6>(t[i]) << endl;
    }
    */

    return 0;
}


Measured memory_bytes: 6260
N = int(input())
A = sorted([int(i) for i in input().split()])

if A[0] == 0:
    print(0)
    exit()
else:
    ans = 1
    for i in range(N):
        ans *= A[i]
        if ans > 10**18:
            print(-1)
            exit()
    print(ans)


Measured memory_bytes: 84820
#include <stdio.h>
int main(){
	int iN,iK;
	char cS[100];
	
	scanf("%d %d" , &iN,&iK);
	getchar();
	scanf("%[^\n]" , cS);
	cS[iK-1] += 32;
	printf("%s" , cS);
	
	return 0;
}

Measured memory_bytes: 1708
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int N; cin >> N;
  vector<int> x(N), y(N), b(N), p(N);
  for(int i=0; i<N; i++) {
    cin >> x[i] >> y[i] >> b[i] >> p[i];

    int ans = 1 << 29;
    for(int f=b[i]; f<=6; f++) {
      for(int g=p[i]; g<=6; g++) {
        int mon = f * x[i] + g * y[i];
        if(f >= 5 and g >= 2) {
          mon = mon / 5 * 4;
        }
        ans = min(ans, mon);
      }
    }
    cout << ans << endl;

    /*
    int mon = b[i] * x[i] + p[i] * y[i];
    if(b[i] >= 5 and p[i] >= 2) {
      mon = mon / 5 * 4;
    }
    cout
    */ 
  }
  return 0;
}



Measured memory_bytes: 3108
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

string str[4] = { "dream","dreamer","erase","eraser" };

int main() {
    string S;
    cin >> S;

    reverse(S.begin(), S.end());
    for (int i = 0; i < 4; i++) {
        reverse(str[i].begin(), str[i].end());
    }

    bool totalflag = true;
    for (int i = 0; i < S.size();) {
        bool partflag = false;
        for (int j = 0; j < 4; j++) {
            if (S.substr(i, str[j].size()) == str[j]) {
                partflag = true;
                i += str[j].size();
            }
        }
        if (!partflag) {
            totalflag = false;
            break;
        }
    }
    if (totalflag) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 512
import java.util.Scanner;
public class Main {
    public static int a,b;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        a=sc.nextInt();
        b=sc.nextInt();
        if(a>b) System.out.println("a > b");
        else if(a<b) System.out.println("a < b");
        else System.out.println("a == b");
        sc.close();
    }
}


Measured memory_bytes: 26204
#include <stdio.h>
#include <ctype.h>

int from_mcxi(const char* mcxi) {
	const char* nowp=mcxi;
	int num=1;
	int result=0;
	for(;*nowp;nowp++) {
		switch(*nowp) {
			case 'm':
				result+=1000*num;
				num=1;
				break;
			case 'c':
				result+=100*num;
				num=1;
				break;
			case 'x':
				result+=10*num;
				num=1;
				break;
			case 'i':
				result+=1*num;
				num=1;
				break;
			default:
				if(isdigit(*nowp))num=*nowp-'0';
		}
	}
	return result;
}

void to_mcxi(char* mcxi,int num) {
	if(num>=1000) {
		if(num>=2000)*(mcxi++)=(num/1000)+'0';
		*(mcxi++)='m';
		num%=1000;
	}
	if(num>=100) {
		if(num>=200)*(mcxi++)=(num/100)+'0';
		*(mcxi++)='c';
		num%=100;
	}
	if(num>=10) {
		if(num>=20)*(mcxi++)=(num/10)+'0';
		*(mcxi++)='x';
		num%=10;
	}
	if(num>=1) {
		if(num>=2)*(mcxi++)=(num/1)+'0';
		*(mcxi++)='i';
		num%=1;
	}
	*mcxi=0;
}

int main(void) {
	int data_num,now_data;
	char q1[100],q2[100],ans[100];
	scanf("%d",&data_num);
	for(now_data=0;now_data<data_num;now_data++) {
		scanf("%s%s",q1,q2);
		to_mcxi(ans,from_mcxi(q1)+from_mcxi(q2));
		puts(ans);
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
#define int long long


signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    string s; cin >> s;
    int n = s.size();

    for(;;){
        s.pop_back();
        s.pop_back();
        n -= 2;
        bool hantei = true;
        for(int i = 0;i < n/2;i ++){
            if(s.at(i) != s.at(i+n/2)) hantei = false;
        }

        if(hantei == true) break;
    }

    cout << n << endl;
}


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

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

using namespace std;

int main(){
  int A,B;
  string S;
  cin >> A >> B;
  cin >> S;
  rep(i,A){
    if( '0' <= S[i] && S[i] <= '9') continue;
    else{
      cout << "No" << endl;
      return 0;
    }
  }
  if( S[A] != '-') {
    cout << "No" << endl;
    return 0;
  }
  FOR(i,A+1,B+A+1){
    if( '0' <= S[i] && S[i] <= '9') continue;
    else{
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  vector<int> b(n);
  for (int i = 0; i < n; i ++) {
    cin >> a.at(i) >> b.at(i);
  }
  vector<int> c(m);
  vector<int> d(m);
  for (int i = 0; i < m; i ++) {
    cin >> c.at(i) >> d.at(i);
  }

  for (int i = 0; i < n; i ++) {
    int ans = m, min = 400000000, tmp;
    for (int j = m - 1; j >= 0; j --) {
      tmp = abs(a.at(i) - c.at(j)) + abs(b.at(i) - d.at(j));
      if (tmp <= min) {
        min = tmp;
        ans = j + 1;
      }
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <queue>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;

int main(){
    int N; cin>>N;
    vector<long> array(N);
    vector<long> sorting(N);

    for(int i=0;i<N;i++){
        cin>>array.at(i);
        sorting.at(i)=array.at(i);
    }
    sort(sorting.begin(),sorting.end());
    for(int i=0;i<N;i++){
        if(array.at(i)>sorting.at(N/2-1))cout<<sorting.at(N/2-1)<<endl;
        else cout<<sorting.at(N/2)<<endl;
    }
}

Measured memory_bytes: 5376
from fractions import gcd


def lcm(a, b):
    return a * b // gcd(a, b)


n = int(input())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

l = 1
for e in a:
    l = lcm(l, e)

l %= mod

ans = 0
for e in a:
    ans += l * pow(e, mod - 2, mod)
    ans %= mod

print(ans)


Measured memory_bytes: 67672
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,m;
  cin>>n>>m;
  vector<int> a(n+1);
  vector<ll> sum(n+1,0);
  map<int,ll> cnt;
  cnt[0]++;
  FOR(i,1,n+1){
    cin>>a[i];
    sum[i]=sum[i-1]+a[i];
    cnt[sum[i]%m]++;
  }
  ll ans=0;
  for(auto itr:cnt){
    ans+=(itr.se)*(itr.se-1)/2;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    ll n;
    cin >> n;
    ll bin[(1<<n)][n], num[(1<<n)];
    for(int bit = 0; bit < (1<<n); bit++){
        num[bit] = 0;
        for(int i = 0; i < n; i++){
            if(bit & (1<<i)){
                num[bit]++;
                bin[bit][i] = 1;
            }
            else bin[bit][i] = 0;
        }
    }
    ll ans = 0;
    vector<ll> a(n);
    vector<vector<ll>> x(n, vector<ll>(n)), y(n, vector<ll>(n));
    rep(i, n){
        cin >> a.at(i);
        rep(j, a.at(i)){
            cin >> x[i][j] >> y[i][j];
            x[i][j]--;
        }
    }
    for(int bit = 0; bit < (1<<n); bit++){
        bool ok = true;
        rep(i, n){
            rep(j, a.at(i)){
                if(bin[bit][i] == 1)if(bin[bit][x[i][j]] != y[i][j])ok = false;
            }
        }
        if(ok)ans = max(ans, num[bit]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 4352
package main

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

func main() {
	sc := NewScanner()

	a := sc.NextInt()
	b := sc.NextInt()
	k := sc.NextInt()

	cnt := 0
	ans := 0
	for i := a; i >= 1; i-- {
		if a%i == 0 && b%i == 0 {
			cnt++
			if cnt == k {
				ans = i
				break
			}
		}
	}
	fmt.Printf("%v\n", ans)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

#define min(A, B) ((B) > (A) ? (A) : (B))

/*
int min(int a, int b)
{
    return (b > a ? a : b);
}
*/

int main(void)
{
    int i, j, k;
    int n;
    int div[10001];
    static int dp[2][5001][2];
    int lim;

    scanf("%d", &n);
    
    for (i = 1; i <= n - 1; i++){
        scanf("%d", div + i);
    }
    memset(dp, 1, sizeof(dp));
    dp[0][0][0] = dp[0][0][1] = 0;
    
    lim = n / 2;

    for (i = 0; i <= lim; i++){
        for (j = 0; j <= lim; j++){
            if (i){
                dp[i & 1][j][0] = dp[(i - 1) & 1][j][0];
                dp[i & 1][j][1] = dp[(i - 1) & 1][j][0] + div[i + j];
            }
            if (j){
                dp[i & 1][j][0] = min(dp[i & 1][j][0], dp[i & 1][j - 1][1] + div[i + j]);
                dp[i & 1][j][1] = min(dp[i & 1][j][1], dp[i & 1][j - 1][1]);
            }
        }
    }
     
    printf("%d\n", min(dp[0][lim][0], dp[0][lim][1]));
     
    return (0);
}

Measured memory_bytes: 484
import java.io.PrintWriter

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = nextList().map(String::toInt)
fun nextLongList() = nextList().map(String::toLong)
fun nextDoubleList() = nextList().map(String::toDouble)

val pw = PrintWriter(System.out)
fun print(s: Any = "") = pw.print(s)
fun println(s: Any = "") = pw.println(s)

fun main(args: Array<String>) {
    main()
    pw.flush()
}

fun main() {
    val (A, B) = nextIntList()
    println(A * B)
}

Measured memory_bytes: 36360
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

#define ll long long
#define ull unsigned long long
#define REP(i, n) for(int i=0; i<n; i++)

int main(){
    int N;
    cin >> N;
    //vector<int> t(N);
    //vector<int> x(N);
    //vector<int> y(N);
    int pos_x = 0;
    int pos_y = 0;
    int cur_t = 0;
    int x, y, t;
    REP(i,N){
        cin >> t >> x >> y;
        int diff_t = t - cur_t; 
        int diff_pos = abs(x - pos_x) + abs(y - pos_y);
        if(diff_t < diff_pos) goto fail;
        if((diff_t % 2) != (diff_pos % 2)) goto fail;
        pos_x = x;
        pos_y = y;
        cur_t = t;
    }

succcess:
    cout << "Yes" << endl;
    return 0;

fail:
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
while line = gets
    weight = line.to_f
    cls = "heavy"
    if weight <= 48.00
        cls = "light fly"
    elsif weight <= 51.00
        cls = "fly"
    elsif weight <= 54.00
        cls = "bantam"
    elsif weight <= 57.00
        cls = "feather"
    elsif weight <= 60.00
        cls = "light"
    elsif weight <= 64.00
        cls = "light welter"
    elsif weight <= 69.00
        cls = "welter"
    elsif weight <= 75.00
        cls = "light middle"
    elsif weight <= 81.00
        cls = "middle"
    elsif weight <= 91.00
        cls = "light heavy"
    end
    puts cls
end

Measured memory_bytes: 8664
// #include <atcoder/all>
// using namespace atcoder;
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
using namespace std;
using ll = long long;
template<typename T>
inline bool chmax(T& a, const T& b) {
    if (a < b){
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */
namespace detail {
    template<typename T, int N>
    auto make_vec(vector<int>& sizes, T const& x) {
        if constexpr (N == 1) {
            return vector(sizes[0], x);
        } else {
            int size = sizes[N-1];
            sizes.pop_back();
            return vector(size, make_vec<T, N-1>(sizes, x));
        }
    }
}
template<typename T, int N>
auto make_vec(int const(&sizes)[N], T const& x = T()) {
    vector<int> s(N);
    for (int i = 0; i < N; ++i) s[i] = sizes[N-i-1];
    return detail::make_vec<T, N>(s, x);
}
__attribute__((constructor))
void fast_io() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

struct unionfind {
    vector<int> d;
    unionfind(int n) : d(n, -1) {}
    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};

int main() {
    int n, m;
    cin >> n >> m;
    unionfind uf(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        uf.unite(a, b);
    }
    int now = 0;
    rep(i, n) if (uf.find(i) == i) now++;
    cout << now - 1 << '\n';
}

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

int main() {
    int n;
    cin>>n;
    int a[n],b[n],c[n-1];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int sum =0;
    for(int i=0;i<n;i++){
        cin>>b[i];
        sum +=b[i];
    }
    for(int i=0;i<n-1;i++){
        cin>>c[i];
    }
    
    for(int i=0;i<n-1;i++){
        if(a[i+1] == a[i]+1){
            sum += c[a[i]-1];
        }
    }
    
    cout << sum << endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int gcd(int a, int b)
{
    while (b > 0) {
        int t = a;
        a = b;
        b = t % b;
    }
    return a;
}
int main()
{
    int N, M;
    cin >> N >> M;
    string S, T;
    cin >> S >> T;
    int G = gcd(N, M);
    long long L = (long long)N * M / G;
    for (int i = 0; i < G; i++) {
        if (S[N/G*i] != T[M/G*i]) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << L << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>

using namespace std;

bool solve(const string& S)
{
	const int L = S.size();
	for (int i = 0; i + 1 < L; ++i) {
		if (S.substr(i, 2) == "AC") {
			return true;
		}
	}
	return false;
}

int main()
{
	string S;
	cin >> S;
	if (solve(S)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <utility>

using namespace std;

typedef pair<int,int> pii;
typedef long long ll;
#define mp make_pair
#define x first
#define y second

int main () {
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if((c-1)/b<=(a-1)/d) cout<<"Yes";
	else cout<<"No";



return 0;
}

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

int main() {
    char c;
    cin >> c;
    if(c=='A') cout << 'T' << endl;
    else if(c=='T') cout << 'A' << endl;
    else if(c=='C') cout << 'G' << endl;
    else if(c=='G') cout << 'C' << endl;
    return 0;
}


Measured memory_bytes: 256
/* JOI4.c */
#include <stdio.h>

 int main(void){
 int student[30] = {0} ;
 int x_i;
 int i;
 
 for(i=0; i<28; i++){
 scanf("%d", &x_i);
 student[--x_i]=1;
 }

 for(i=0; i<30;i++){
 if(student[i] == 0)
 printf("%d\n", i+1);
 }

 return 0;
 }

Measured memory_bytes: 596
import java.io.*;
import java.util.*;
import java.lang.Math;
import java.util.Arrays;

public class Main {
    public static void main(final String[] args) {

        Scanner sc = new Scanner(System.in);

        int n, x;
        MainRoop : while(true){
            n = sc.nextInt();
            x = sc.nextInt();
            int a[] = new int[n];
            for(int i = 0; i < n; i++)a[i] = i + 1;

            if(n == 0 && x == 0)break MainRoop;

            int ans = 0;
            for(int i = 0; i < n; i++){
                for(int j = i + 1; j < n; j++){
                    for(int k = j + 1; k < n; k++){
                        if(a[i] + a[j] + a[k] == x)ans++;
                    }   
                }
            }
            System.out.println(ans);
        }
    }
  
}


Measured memory_bytes: 27032
#include <bits/stdc++.h>
#include <chrono>
#include <math.h>
using namespace std;
#pragma GCC optimize("-O3")
#define endl "\n"
#define mp make_pair
#define st first
#define nd second
#define pii pair<int, int>
#define pb push_back
#define _upgrade ios_base::sync_with_stdio(0), cout.setf(ios::fixed), cout.precision(10), cin.tie(0), cout.tie(0);
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define FWD(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define fwd(i, a, b) for (int i = (a); i < (b); ++i)
#define all(c) (c).begin(), (c).end()
#define sz(X) (int)((X).size())
#define what(x) cerr << #x << " is " << x << endl;

int32_t main()
{
    _upgrade;
    string S;
    cin >> S;
    for (char c : S)
        cout << (c == '?' ? 'D' : c);
    cout << endl;
}

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

int main() {
  int X,N;
  cin >> X >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
  	cin >> vec.at(i);
  }
  
  //例外１
  if(N == 0){
  	cout << X << endl;
    return 0;
  }
  //例外２
  int check = 0;
  for( int i=0; i<N;i++){
    if(vec.at(i) == X) check =1;
  }
  if(check == 0){
    cout << X << endl;
    return 0;	
  }

  //メイン
  int ii = 1;
  int answer;
  for(int k=0; k<1000;k++){
  	//小さい方
    answer = X-ii;
    check = 0;
    for( int j=0; j<N;j++){
      if(vec.at(j) == answer) check =1;
    }
    if(check == 0){
    break;
    }  
    
    //大きい方
    answer = X+ii;
     check = 0;
    for( int j=0; j<N;j++){
      if(vec.at(j) == answer) check =1;
    }
    
    if(check == 0){
    	break;
    }  
    
  	ii++;
  }
  
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 3632
# -*- coding: utf-8 -*-
# モジュールのインポート
import math


def get_input() -> int:
    """
    標準入力の取得

    Returns:\n
        int: 標準入力
    """
    N = int(input())

    return N


def main(N: int) -> None:
    """
    求解処理

    Args:
        N (int): ページ数
    """
    result = math.ceil(N/2)

    # 結果出力
    print(result)


if __name__ == "__main__":
    N = get_input()
    main(N)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  vector<int> s(M);
  vector<char> c(M);
  for (int i = 0; i < M; i++){
    cin >> s[i] >> c[i];
    s[i]--;
  }
  int mp, Mp;
  if (N == 1){
    mp = 0;
    Mp = 9;
  } else if (N == 2){
    mp = 10;
    Mp = 99;
  } else {
    mp = 100;
    Mp = 999;
  }
  bool res = false;
  for (int i = mp; i <= Mp; i++){
    string S = to_string(i);
    bool ans = true;
    for (int j = 0; j < M; j++){
      if (S[s[j]] != c[j]){
        ans = false;
      }
    }
    if (ans){
      res = true;
      cout << i;
      break;
    }
  }
  if (!res){
    cout << -1;
  }
}

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

int main() {
	int W, H, N, ans = 0;
	cin >> W >> H >> N;
	vector<pair<int, int>> XY(N);
	for (pair<int, int>& i : XY) cin >> i.first >> i.second;
	for (int i = 1; i < N; ++i) {
		if (XY[i - 1].first < XY[i].first) {
			if (XY[i - 1].second < XY[i].second) ans += max(XY[i].first - XY[i - 1].first, XY[i].second - XY[i - 1].second);
			else ans += XY[i - 1].second + XY[i].first - XY[i - 1].first - XY[i].second;
		}
		else {
			if (XY[i - 1].second < XY[i].second) ans += XY[i - 1].first + XY[i].second - XY[i - 1].second - XY[i].first;
			else ans += max(XY[i - 1].first - XY[i].first, XY[i - 1].second - XY[i].second);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define prtd(var, i) cout << fixed << setprecision(i) << var << endl;
#define ll long long
using namespace std;


int main(){
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int tmp = 60*h2 + m2 - (60*h1 + m1);
    
        cout << tmp - k << endl;
    
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<map>
#include<set>
#include<algorithm>

using namespace std;

long long r[100005];
long long l[100005];

long long rmax[100005];
long long lmax[100005];

long long x[100005];
long long v[100005];

int main(){
  int n;
  long long c;
  cin>>n>>c;
  x[0] = 0;
  v[0] = 0;
  for(int i=1;i<=n;i++){
    cin>>x[i]>>v[i];
  }

  x[n+1] = c;
  v[n+1] = 0;

  long long tmp = 0;
  long long tmax = 0;
  for(int i=0;i<=n+1;i++){
    tmp += v[i];
    r[i] = tmp-x[i];
    tmax = max(r[i],tmax);
    rmax[i] = tmax;
  }

  //for(int i = 0;i<=n+1;i++){
  //  cout<<x[i]<<" "<<v[i]<<" "<<r[i]<<" "<<rmax[i]<<endl;
  //}cout<<endl;

  tmp = 0;
  tmax = 0;
  for(int i=n+1;i>=0;i--){
    tmp += v[i];
    l[i] = tmp-(c-x[i]);
    tmax = max(l[i],tmax);
    lmax[i] = tmax;
  }

  //for(int i = 0;i<=n+1;i++){
  //  cout<<x[i]<<" "<<v[i]<<" "<<l[i]<<" "<<lmax[i]<<endl;
  //}

  long long ans = 0;
  for(int i = 1;i<=n;i++){
    ans = max(ans,r[i]);
    ans = max(ans,l[i]);

    ans = max(ans, r[i]-x[i]+lmax[i+1]);
    //cout<<ans<<endl;
    ans = max(ans, l[i]-(c-x[i])+rmax[i-1]);
    //cout<<ans<<endl;
    //cout<<endl;
  }

  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 4992
#include <iostream>

using namespace std;

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

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

    int a[N], b[N];

    // a_i + b_iが等しくなるよう初期化
    for (int i = 0; i < N; ++i) {
        a[i] = i * 20000;
    }
    for (int i = 0; i < N; ++i) {
        b[N - i - 1] = i * 20000;
    }

    // pの先頭から加算 indexに注意
    for (int i = 0; i < N; ++i) {
        a[p[i] - 1] += i + 1;
        b[p[i] - 1] += i + 1;
    }

    // 出力
    for (int i = 0; i < N; ++i) {
        cout << a[i] << " ";
    }
    cout << endl;
    for (int i = 0; i < N; ++i) {
        cout << b[i] << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 896
/*input
6 727202214173249351
6 5 2 5 3 2


*/ 
#include <iostream>
#include <bits/stdc++.h>
#include <math.h> 
    
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define gc getchar_unlocked
#define fo(i,n) for(ll i=0;i<n;i++)
#define Fo(i,k,n) for(ll i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define int long long
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define ms(a,x) memset(a, x, sizeof(a));
#define endl "\n"
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
int mpow(int base, int exp); 
void ipgraph(int m);
//void dfs(int u, int par);
const int mod = 1000000007;
const int N = 1000000001;
const int MAX = 1e5+1;


vector<bool> visited(2*MAX,false);
int32_t main() {
    IOS;
	int n,k;cin>>n>>k;
	int arr[n+1];
	for(int i=1;i<=n;i++){
		cin>>arr[i];
	}
	vector<int> ans;
	set<int> s;
	int in = 1;
	// ans.push_back(1);
	// s.insert(in);
	int x  = k;
	// if(s.find(arr[in])!=s.end())
	// cout<<arr[in]<<endl;
	// while(x>0){
	// 	cout<<in<<" ";
	// 	in = arr[in];
	// 	x--;
	// }
	//cout<<endl;
	in = 1;
	while(s.find(in)==s.end()){
		//cout<<arr[in]<<" ";
		ans.push_back(in);
		s.insert(in);
		in = arr[in];
	}
	// for(auto &i:ans)cout<<i<<" ";
	//  	cout<<endl;
	//cout<<in<<endl;
	 in = find(ans.begin(),ans.end(),in)-ans.begin();
	int p = ans.size()-in;
	// if(in>1)
	//     p = (ans.size())-in;
	//cout<<p<<endl;
	//int r = k%p;
	if(k<in){
		cout<<ans[k]<<endl;
		return 0 ;
	}
	k-=in;
	//deb(k);
	int r = k%p;
	// cout<<r<<endl;
	// deb(in);
	cout<<ans[r+in]<<endl;
	return 0;
}






Measured memory_bytes: 15520
N=int(input())
E=[[] for i in range(N)]
for i in range(N-1):
  a,b,w=map(int,input().split())
  a,b,w=a-1,b-1,w%2
  E[a].append([b,w])
  E[b].append([a,w])
  
stack=[]
C=[None]*N
# 番号,色,親
stack.append([0,0,-1])
while stack:
  node=stack.pop()
  v=node[0]
  color=node[1]
  parent=node[2]
  C[v]=color
  children=E[v]
  for child in children:
    child_v=child[0]
    child_w=child[1]
    if child_v==parent:
      continue
    child_color=abs(child_w-color)
    stack.append([child_v,child_color,v])

for ans in C:
  print(ans)

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int dp[100001];
    for(int i = 0;i < 10;i ++){
        if(i==9) dp[i] = 1;
        else if(i < 6)dp[i] = i;
        else dp[i] = 1+dp[i-6];
    }
    for(int i = 10;i <= 100000;i ++){
        int si = i,m=1,n=1;
        while(si >= 6){
            si /= 6;
            m *= 6;
        }
        si = i;
        while(si >= 9){
            si /= 9;
            n *= 9;
        }
        dp[i] = min(dp[i-m]+1,dp[i-n]+1);
    }
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    string s; cin >> s;
    int k; cin >> k;
    vector<string> vec;
    for(int i = 0; i < s.size(); ++i){
        for(int j = 1; j <= k; ++j){
            string tmp = s.substr(i,j);
            vec.push_back(tmp);
        }
    }
    sort(ALL(vec));
    unique(ALL(vec));
    cout << vec[k-1] << endl;
    return 0;
}

Measured memory_bytes: 1660
H, W = map(int, input().split())
STAGE = [list(input()) for _ in range(H)]

dp = [[0] * W for _ in range(H)]
dp[0][0] = 1

MOD = 10 ** 9 + 7

for y in range(H):
	for x in range(W):
		if y + 1 < H and STAGE[y + 1][x] == ".":
			dp[y + 1][x] += dp[y][x] % MOD
		if x + 1 < W and STAGE[y][x + 1] == ".":
			dp[y][x + 1] += dp[y][x] % MOD

print(dp[-1][-1] % MOD)


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

template <int MOD>
struct Fp
{
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD)
    {
        if (val < 0)
            val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator-() const noexcept
    {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator+(const Fp &r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator-(const Fp &r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator*(const Fp &r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator/(const Fp &r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp &operator+=(const Fp &r) noexcept
    {
        val += r.val;
        if (val >= MOD)
            val -= MOD;
        return *this;
    }
    constexpr Fp &operator-=(const Fp &r) noexcept
    {
        val -= r.val;
        if (val < 0)
            val += MOD;
        return *this;
    }
    constexpr Fp &operator*=(const Fp &r) noexcept
    {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp &operator/=(const Fp &r) noexcept
    {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b)
        {
            long long t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0)
            val += MOD;
        return *this;
    }
    constexpr bool operator==(const Fp &r) const noexcept
    {
        return this->val == r.val;
    }
    constexpr bool operator!=(const Fp &r) const noexcept
    {
        return this->val != r.val;
    }
    friend constexpr ostream &operator<<(ostream &os, const Fp<MOD> &x) noexcept
    {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept
    {
        if (n == 0)
            return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1)
            t = t * a;
        return t;
    }
};

const int MOD = 2019;
using mint = Fp<MOD>;

int main(void)
{
    string s;
    cin >> s;
    reverse(s.begin(), s.end());

    mint tmp = 0, p = 1;

    vector<ll> dp(2020, 0);

    for (ll i = 0; i < s.size(); ++i)
    {
        mint c=s[i] - '0';
        tmp += c * p;
        dp.at(tmp.val)++;
        p *= 10;
    }

    ll ans = dp.at(0);

    rep(i, dp.size())
    {
        ans += dp.at(i) * (dp.at(i) - 1) / 2;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long int
#define veci vector<ll>

int main()
{
    fio;
    ll n,i;
    cin>>n;
    veci a(n),dp(n);
    for(i=0;i<n;i++)
    cin>>a[i];
    dp[0]=0;
    dp[1]=abs(a[0]-a[1]);
    for(i=2;i<n;i++)
    {
        dp[i]=min(dp[i-1]+abs(a[i-1]-a[i]),dp[i-2]+abs(a[i-2]-a[i]));
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int n,A[MAX],B[MAX],k;

void CountingSort();

int main(){

  int i, j;

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

  }
 

  CountingSort();
  for(i=1;i<n+1;i++){
    if(i>1)printf(" ");
    printf("%d",B[i]);
  }
printf("\n");

  return 0;
}

void CountingSort()
{
  int i,j,C[VMAX];
  
  for(i=0;i<=VMAX;i++){
    C[i]=0;
  }
    
  for(j=1;j<=n;j++){
    C[A[j]]++;
  }

  for(i=1;i<=VMAX;i++){
    C[i]=C[i]+C[i-1];
  }

  for(j=n;j>=1;j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
}



Measured memory_bytes: 17444
//競技プログラミング用のテンプレート
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <math.h>
#include <stack>
#include <limits>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repr(i, n) for(int i = n - 1; i >= 0; i--)

using namespace std;
//エイリアス
using ll = long long int;
using p = pair<int, int>;
using pl = pair<ll, ll>;
using v = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vl = vector<ll>;

//定数
const int intmax = numeric_limits<int>::max();
const ll llmax = numeric_limits<ll>::max();
const ll mod = 1e9 + 7;
const double pi = M_PI;

ll median(vl &target) {
  int size = target.size();
  if (size % 2 == 0) {
    size--;
    return target[size / 2] + target[(size / 2) + 1];
  } else {
    return target[size / 2];
  }
}

int main()
{
  int n;
  cin >> n;
  vl as(n, 0);
  vl bs(n, 0);
  rep(i, n) {
    ll a, b;
    cin >> a >> b;
    as[i] = a;
    bs[i] = b;
  }
  sort(as.begin(), as.end());
  sort(bs.begin(), bs.end());
  ll amedian = median(as);
  ll bmedian = median(bs) + 1;
  cout << bmedian - amedian << endl;
}


Measured memory_bytes: 6424
sx, sy, tx, ty = map(int, input().split())

p1 = 'U' * (ty - sy) + 'R' * (tx - sx)
p2 = 'U' + 'L' * (tx - sx + 1) + 'D' * (ty - sy + 1) + 'R'
p3 = p1[::-1]
p4 = p2[::-1]

print(p1 + p2 + p3 + p4)

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

int arr[201][201];

void warshall(int v){
    for(int k=1;k<=v;k++)
        for(int i=1;i<=v;i++)
            for(int j=1;j<=v;j++)
                    arr[i][j] = min(arr[i][j], arr[i][k]+arr[k][j]);
}

void init(int v){
    for(int i=1;i<=v;i++)
        for(int j=1;j<=v;j++)
            if(i!=j)
                arr[i][j] =  (1 << 29);
}

int main()
{
    int v,e,r,x,y,d,ans= (1 << 29);
    cin>>v>>e>>r;
    vector<int> R;
    for(int i=0;i<r;i++){
        cin>>x;
        R.push_back(x);
    }

    init(v);

    for(int i=0;i<e;i++){
        cin>>x>>y>>d;
        arr[x][y] = min(arr[x][y], d);
        arr[y][x] = min(arr[y][x], d);
    }

    warshall(v);

    /*for(int i=1;i<=v;i++)
    {
        for(int j=1;j<=v;j++)
            cout<<arr[i][j]<<" ";
        cout<<endl;
    }*/




    int temp = 0;
    sort(R.begin(),R.end());
    do{
        temp = 0;

        for(int i=0;i<r-1;i++)
        {
            temp += arr[R[i]][R[i+1]];
        }

        ans=min(ans,temp);
    }while(next_permutation(R.begin(),R.end()));

    cout<<ans<<endl;
}


Measured memory_bytes: 384
#include<stdio.h>
int main()
{
  int N;
  scanf("%d",&N);
  int A[N];
  int i;
  double ave=0;
  for(i=0;i<N;i++){
  	scanf("%d",&A[i]);
  }
  int P;
  int sum=0;
  int min=100000000;
  for(P=0;P<100;P++){
    for(i=0;i<N;i++){
      sum=sum+(A[i]-P)*(A[i]-P);
    }
    if(sum<min){
      min=sum;
    }
    sum=0;
  }
  printf("%d",min);
  return 0;
}
    


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int n,a[104],num[104],flag=0;
int main(){
    cin>>n;int maxx=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        maxx=max(maxx,a[i]);
        num[a[i]]++;
    }
    for(int i=maxx;i>maxx/2;i--){
        if(num[i]<2){
            flag=1;
            break;
        }num[i]-=2;
    }
    if((maxx&1)==0){
        if(num[maxx>>1]) num[maxx>>1]--;
        else flag=1;
    }
    if(flag) cout<<"Impossible";
    else{
        for(int i=1;i<=(maxx+1)/2;i++){
            if(num[i]){cout<<"Impossible";return 0;}
        }
        cout<<"Possible";
    }
}

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

using namespace std;

typedef long long LL;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const LL mod = 1e9+7;

int main(){
	int N; cin >> N;
	vector<int> A(N);
	int x = 0, y = 0;
	vector<vector<vector<int>>> name(1<<20,vector<vector<int>>(2,vector<int>(2,0)));
	vector<vector<LL>> dp(1<<20,vector<LL>(3,0));
	repp(i,0,N){
		cin >> A[i];
		x ^= A[i];
		if(x == 0){
			++y;
		} else {
			if(dp[x][2] < y){
				(dp[x][0] += dp[x][1]*(y-dp[x][2])) %= mod;
				dp[x][2] = y;
			}
			(dp[x][1] += dp[x][0]+1) %= mod;
		}
	}
	if(x == 0){
		LL ans = 1;
		repp(i,1,y) ans = ans*2%mod;
		repp(k,1,1<<20){
			(ans += dp[k][1]) %= mod;
		}
		cout << ans << endl;
	} else {
		cout << dp[x][0]+1 << endl;
	}
	return 0;
}


Measured memory_bytes: 215168
#include<stdio.h>

int main(){
    char s[101];
    scanf("%s", s);
    int c = 0;
    int l = 0;
    while(s[l] != '\0'){
        l++;
    }
    int k = l/2;
    for(int i=0; i<k; i++){
        if(s[i] != s[l-1-i]){
            c++;
        }
    }
    printf("%d", c);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int
#define Vec vector

Vec<ll> A;
Vec<ll> X;
Vec<Vec<ll>> S(2);
template<typename T> bool InRange(T t, T l, T r){ return l <= t && t < r; }


bool possible(int c, int idx, ll x, Vec<ll> &a){
	// 高橋君が右側c個取れる．青木君はidxから始まる
	// atatataaAatttT c == 4
	int N = a.size();
	if(c == 1) return true;
	if(N - c <= idx) return false;
	if(2 * c - 2 >= N) return false;
	
	// 高橋君が右側c-1個取り終わっていて，
	// 青木君がc-1個目としてA[N-c]を必ず取らなければいけない場合はfalse，
	// それ以外はtrue
	
	// 右にまだ余裕がある
	if(idx + (c - 2) < N - c) return true;
	
	// 右はN-c-1まで取っているとして，N-cを取るより左側をとる方が理にかなっている
	int nl = N - c - 1 - (c - 2);
	if(nl < 0) return false;
	if(abs(a[nl] - x) <= abs(a[N - c] - x)) return true;
	return false;
	
}

int main(){
	
	int N,Q;
	cin >> N >> Q;
	A.resize(N);
	X.resize(Q);
	for(int i=0;i<N;i++) scanf("%d",&A[i]);
	for(int i=0;i<Q;i++) scanf("%d",&X[i]);
	
;
	for(int i=0;i<2;i++) S[i].resize(N + 1);
	for(int i=0;i<N;i++){
		for(int j=0;j<2;j++){
			S[j][i + 1] = S[j][i] + (i % 2 == j ? A[i] : 0);
		}
	}
	
	Vec<ll> ans(Q);
	
	for(int i=0;i<Q;i++){
		ll x = X[i];
		
		auto itr = lower_bound(A.begin(), A.end(), x);
		int idx = itr - A.begin();
		if(idx >= N) idx = N - 1;
		if(idx > 0 && abs(x - A[idx - 1]) <= abs(A[idx] - x)) idx--;
		int l = 1, r = N;
		
		while(r - l > 1){
			// 高橋君が右側c個取れる
			// atatataaAatttT c == 4
			int c = (r + l) / 2;
			if(possible(c, idx, x, A)){
				l = c;
			} else {
				r = c;
			}
		}
		
		ll taka = (S[0][N] - S[0][N - l]) + (S[1][N] - S[1][N - l]);
		int rest = N - l - (l - 1);
		if(rest % 2 == 1){
			taka += S[1][rest];
		} else {
			taka += S[0][rest];
		}
		ans[i] = taka;
		
	}
	
	for(int i=0;i<Q;i++) printf("%lld\n",ans[i]);
	
	
    return 0;
}



Measured memory_bytes: 5632
A = [None]*3
for i in range(3):
    A[i] = list(map(int, input().split()))

bingocard = [[0]*4 for _ in range(4)]
N = int(input())
for _ in range(N):
    b = int(input())
    for row in range(3):
        for col in range(3):
            if b == A[row][col]:
                bingocard[row][col] = 1
                bingocard[row][3] += 1
                bingocard[3][col] += 1

flag = False
#横
for row in bingocard:
    if row[3] == 3:
        flag = True

#縦
for col in bingocard[3]:
    if col == 3:
        flag = True
    
#斜め
if bingocard[0][0] + bingocard[1][1] + bingocard[2][2] == 3:
    flag = True
if bingocard[2][0] + bingocard[1][1] + bingocard[0][2] == 3:
    flag = True

if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9204
let l = ["dream"; "dreamer"; "erase"; "eraser"]

let has_suffix s suffix =
  let lens = String.length s in
  let len_suf = String.length suffix in
  if lens < len_suf then false
  else String.sub s (lens - len_suf) len_suf = suffix

let trim_suffix s suffix =
  let lens = String.length s in
  let len_suf = String.length suffix in
  String.sub s 0 (lens - len_suf)

let rec f s =
  if s = "" then "YES"
  else
    match List.filter (has_suffix s) l with
    | [] -> "NO"
    | suf -> f (trim_suffix s (List.hd suf))

let () = f (read_line ()) |> print_endline

Measured memory_bytes: 8192