akhauriyash/Code-Regression huggingface dataset:
S=input()
N=len(S)

s = S[::-1]
X=S[:int((N-1)/2)]
x = X[::-1]
Y=S[int((N+3)/2)-1:]
y = Y[::-1]

if S==s and X==x and Y==y:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
s = input()
t = input()
c = 0

for i in range(len(s) - len(t) + 1):
    c_1 = 0
    for j in range(len(t)):
        if s[i + j] == t[j]:
            c_1 += 1
    if c < c_1:
        c = c_1

print(len(t) - c)

Measured memory_bytes: 9060
operator fun Int.not() = if (this != 0) false else true
operator fun Int.plus(other: Boolean) = this + if (other) 1 else 0
data class Point(val x: Int, val y: Int) {
    constructor(xy: List<Int>): this(xy[0], xy[1])
}
fun main(args: Array<String>) {
    val N = nextInt()
    val XY = Array<Point>(N) { Point(listOfInt()) }
    val odd = (Math.abs(XY.first().x) + Math.abs(XY.first().y)) % 2
    if (XY.any { (Math.abs(it.x) + Math.abs(it.y)) % 2 != odd }) {
        println(-1)
        return
    }
    println(31 + !odd)
    if (!odd) print("1 ")
    for (i in 30 downTo 0) {
        print(1 shl i)
        print(if (i == 0) "\n" else " ")
    }
    for (xy in XY) {
        var (x, y) = xy
        if (!odd) {
            x -= 1
            print("R")
        }
        for (i in 30 downTo 0) {
            val t = 1 shl i
            if (Math.abs(x) < Math.abs(y)) {
                if (y > 0) {
                    y -= t
                    print("U")
                } else {
                    y += t
                    print("D")
                }
            } else {
                if (x > 0) {
                    x -= t
                    print("R")
                } else {
                    x += t
                    print("L")
                }
            }
        }
        println("")
    }
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }
fun listOfLong() = listOfString().map { java.lang.Long.parseLong(it) }


Measured memory_bytes: 41912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;
int H, W, D, A;
int Q, L, R;
int px[90001], py[90001]; // 整数iは(px[i],py[i])にいる
int dist[90001]; //

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin >> H >> W >> D;
    rep(i, H)
    {
        rep(j, W)
        {
            cin >> A;
            px[A] = i, py[A] = j;
        }
    }
    for (int i = D + 1; i <= H * W; ++i) {
        dist[i] = dist[i - D] + abs(px[i] - px[i - D]) + abs(py[i] - py[i - D]);
    }
    cin >> Q;
    rep(loop, Q)
    {
        cin >> L >> R;
        cout << dist[R] - dist[L] << endl;
    }

    return 0;
}

Measured memory_bytes: 2176
//
// Created on 2019-01-19.
//
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }

#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

#define PB push_back
#define INF 1e9
#define MOD 1e9+7
#define EPS 1e-9

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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


    string S, T;
    cin >> S >> T;

    if(S.length()<T.length()){
        cout<<"UNRESTORABLE"<<endl;
        return 0;
    }

    vs ans;
    REP(i, S.length()-T.length()+1){
        string tmp = S;
        bool is_condition_pass = true;
        REP(t, T.length()) tmp[i+t] = T[t];
        REP(s, S.length()) if (!(S[s] == '?' or tmp[s] == S[s])) is_condition_pass = false;

        if (is_condition_pass) ans.emplace_back(tmp);
    }

    if (ans.empty()) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }

    for (string& s : ans) REP(i,s.length()) {
        if (s[i] == '?') s[i] =  'a';
    }

    sort(ALL(ans));
    cout << ans[0] << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<stack>

const static int MAX = 100;
int G[MAX][MAX];
int nt[MAX];
int n;

int nextNode(int x){
    for(int i = nt[x]; i < n; i++){
	if(G[x][i] == 1){
	    nt[x] = i + 1;
	    return i;
	}
    }
    return -1;
}

int main(void){
    std::stack<int> st;
    int color[MAX], a[MAX], b[MAX];
    int u, k, v, time;

    time = 0;
    std::cin >> n;

    for(int i = 0; i < n; i++){
	color[i] = 0;
    }

    for(int i = 0; i < n; i++){
	std::cin >> u >> k;
	u--;
	for(int j = 0; j < k; j++){
	    std::cin >> v;
	    v--;
	    G[u][v] = 1;
	}
    }

    for(int i = 0; i < n; i++){
	if(color[i] == 0){
	    st.push(i);
	    color[i] = 1;
	    a[i] = ++time;
	}
	while(!st.empty()){
	    int cur = st.top();
	    int next = nextNode(cur);
	    if(color[next] == 0 && next != -1){
	        st.push(next);
	        color[next] = 1;
	        a[next] = ++time;
	    }
	    if(next == -1){
		st.pop();
		b[cur] = ++time;
	    }
	}
    }

    for(int i = 0; i < n; i++){
        std::cout << i+1 << " " << a[i] << " " << b[i] << std::endl;
    }


    return 0;

}



Measured memory_bytes: 3144
package main

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

var scanner = bufio.NewScanner(os.Stdin)

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

func nextInt() (int, error) {
	n, err := strconv.Atoi(nextString())
	return n, err
}

func main() {
	scanner.Split(bufio.ScanWords)

	stack := []int{}
	for {
		n, err := nextInt()
		if err != nil {
			break
		}

		if n == 0 { // pop
			fmt.Println(stack[len(stack)-1])
			stack = stack[0:(len(stack) - 1)]
		} else { // push
			stack = append(stack, n)
		}
	}
}



Measured memory_bytes: 1072
import math
A, B = list(map(int, input().split()))

amax = math.ceil((A + 1) * 12.5) - 1
amin = math.ceil(A * 12.5)
bmax = math.ceil((B + 1) * 10) - 1
bmin = math.ceil(B * 10)

if amin > bmax or bmin > amax:
    print(-1)
else:
    print(int(max(amin, bmin)))


Measured memory_bytes: 3064
n = int(input())
points = []
for _ in range(n):
    a, b = map(int, input().split())
    points.append((a, b, 'red'))
for _ in range(n):
    c, d = map(int, input().split())
    points.append((c, d, 'blue'))
points.sort()

used = set()
for i in range(len(points)):
    x1, y1, color1 = points[i]
    if color1 == 'red':
        continue
    
    y = -1
    k = -1
    for j in range(0, i):
        x2, y2, color2 = points[j]
        if color2 == 'red' and not j in used and y2 < y1 and abs(y2 - y1) < abs(y - y1):
            y = y2
            k = j
    
    if k != -1:
        used.add(k)

print(len(used))

Measured memory_bytes: 3064
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

// reference: http://ir5.hatenablog.com/entry/20171209/1512821837

struct Scanner<'a> {
    cin: StdinLock<'a>,
}
 
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }
 
    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }
 
    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }
}

use std::mem;
use std::cmp;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let S: String = sc.read();
    if S.len() == 2 {
        println!("{}", S);
    } else {
        println!("{}", S.chars().rev().collect::<String>());
    }
}

Measured memory_bytes: 2112
N, M = map(int, input().split(' '))
road = [list(map(int, input().split(' '))) for _ in range(M)]
road_num = [0] * N
for r in road:
    road_num[r[0] - 1] += 1
    road_num[r[1] - 1] += 1
for num in road_num:
    print(num)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
char a;
string s="CODEFESTIVAL2016";
int sum;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	for(int i=0;i<16;i++)
	{
		cin>>a;
		if(a!=s[i]) sum++;
	}
	cout<<sum<<endl;
	return 0;
}



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

int main() { 
  int a;
  int b;
  int c;
  cin >> a >> b >> c;
  if( a < c){
    if( c < b){
      cout<< "Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
  }
  else{
     if( c > b){
      cout<< "Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
  }

}



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

int main() {
  int n;cin>>n;vector<int>v(n-1);
  vector<int>vv(n+1,0);
  for(int i=0;i<n-1;i++){
    cin>>v.at(i);
    vv.at(v.at(i)-1)++;
  }
  for(int j=0;j<n;j++)cout<<vv.at(j)<<endl;
}


Measured memory_bytes: 4844
#include<iostream>
#include<map>
#include<queue>
using namespace std;
typedef pair<int,int> P;
#define fr first
#define sc second
#define rep(i,n) for(int i = 0 ; i < n ; ++i )

int n,m,p,q,r;int a;
deque<P> card;

int query(){
  int sum = 0,ans = 0;
  while(sum + card.front().sc - card.front().fr + 1 < p){
    sum += card.front().sc - card.front().fr + 1;
    card.pop_front();
  }
  if(sum + 1 != p) card.front().fr = card.front().fr + p - sum;
  sum = p;
  while(sum + card.front().sc - card.front().fr + 1 <= q){
    if(card.front().sc <= r){ //完全に含む
      ans += card.front().sc - card.front().fr + 1;
    }else if(card.front().fr <= r){ //微妙に含む
      ans += r - card.front().fr + 1;
    }
    sum += card.front().sc - card.front().fr + 1;
    card.pop_front();
  }
  if(!card.empty() && sum != q){
    card.push_front(P(card.front().fr,card.front().fr+q-sum-1));
    if(card.front().sc <= r){ //完全に含む
      ans += card.front().sc - card.front().fr + 1;
    }else if(card.front().fr <= r){ //微妙に含む
      ans += r - card.front().fr + 1; 
    }
  }
  return ans;
}

void deb(deque<P>& tmp){
  cout << endl;
  for(deque<P>::iterator it = tmp.begin();it!=tmp.end();it++){
    cout << (*it).fr << " " << (*it).sc << endl;
  }
}
deque<P> shuffle(int x,int y){
  deque<P> A,B,C;
  int sum = 0;
  while(sum + card.front().sc - card.front().fr + 1 <= x){
    A.push_back(card.front());
    sum += card.front().sc - card.front().fr + 1;
    card.pop_front();
  }

  if(sum != x){
    A.push_back(P(card.front().fr,card.front().fr + x - sum - 1));
    card.front().fr = card.front().fr + x - sum;
    sum = x;
  }
  while(sum + card.front().sc - card.front().fr + 1 <= y){
    B.push_back(card.front());
    sum += card.front().sc - card.front().fr + 1;
    card.pop_front();
  }

  if(sum != y){
    B.push_back(P(card.front().fr,card.front().fr + y - sum - 1));
    card.front().fr = card.front().fr + y - sum;
    sum = y;
  }
  while(!card.empty()){
    C.push_back(card.front());
    card.pop_front();
  }
  C.insert(C.end(),B.begin(),B.end());
  C.insert(C.end(),A.begin(),A.end());
  return C;
}

int main(){
  while(cin >> n , n){
    cin >> m >> p >> q >> r;
    p--;
    card.push_back(P(1,n));
    while(m--){
      int x,y;
      cin >> x >> y;
      card = shuffle(x,y);
    }
    cout << query() << endl;
    card.clear();
  }
}

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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;

const ll mod =1000000007;

#define rep(i,m,n) for(ll i=m;i<n;i++)
struct UnionFind {
    vector<int> par,si; 

    UnionFind(int N) : par(N), si(N,1) { 
        rep(i,0,N) par[i] = i;
    }

    int root(int x) { 
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        x = root(x); 
        y = root(y); 
        if (x == y) return; 
        si[y]+=si[x];
        par[x] = y; 
    }

    bool same(int x, int y) { 
      return root(x)== root(y);
    }
    int size(int x){
       return si[root(x)];
    }

};


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

 ll n;
  cin >> n;
  vector<pll> x(n),y(n);
  rep(i,0,n) {
    cin >> x[i].first >> y[i].first;
    x[i].second=i;
    y[i].second=i;
  }
  
  
  sort(x.begin(),x.end());
  sort(y.begin(),y.end());
  
  vector<tuple<ll,ll,ll>> t;
  rep(i,0,n-1) t.push_back(make_tuple(x[i+1].first-x[i].first,x[i].second,x[i+1].second));
  rep(i,0,n-1) t.push_back(make_tuple(y[i+1].first-y[i].first,y[i].second,y[i+1].second));
  
  sort(t.begin(),t.end());

  ll res=0;
  UnionFind u(n);
  rep(i,0,t.size()){
    if(!u.same(get<1>(t[i]),get<2>(t[i]))) {
      res+=get<0>(t[i]);
      u.unite(get<1>(t[i]),get<2>(t[i]));
    }
  }
  cout << res << endl;
}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int k = Integer.parseInt(sc.next());
        int[] h = new int[n];
        for(int i=0;i<n;i++)h[i] = Integer.parseInt(sc.next());
        Arrays.sort(h);
        int min = Integer.MAX_VALUE;
        for(int i=0;i+k-1<n;i++){
            min = Math.min(min,h[i+k-1]-h[i]);
        }
        System.out.println(min);
        sc.close();
    }
    
}

Measured memory_bytes: 50068
#include<bits/stdc++.h>
using namespace std;
 
template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
        out << '(' << p.first << ',' << p.second << ')';
            return out;
}
 
template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
        in >> p.first >> p.second;
            return in;
}
 
template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
        for (T &x : v)
                    in >> x;
            return in;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<vector<T> > &v)
{
        for (const vector<T> &x : v)
                    out << x << '\n';
            return out;
}
 
template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
        for (const T &x : v)
                    out << x << ' ';
            return out;
}

template <class T>
ostream& operator << (ostream& out,const set<T> &s)
{
        for (const T &x : s)
                out << x << ' ';
            return out;
}
 
 
#define ll long long
#define lf long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef pair <ll,ll > ii;
typedef vector <ll> vi;
typedef vector <ii> vii;
typedef vector <bool> vb;
typedef vector <vector <ll> > vv;
typedef vector <vector <vector<ll> > > vvv;
typedef vector <string> vs;
typedef vector <lf> vf;
#define sz(x) (ll)(x).size()
#define tr1(x) cerr << #x << ": " << x << nl
#define tr2(x, y) cerr << #x << ": " << x << " | " << #y << ": " << y << nl
#define tr3(x,y,z) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<nl
#define tr4(x,y,z,w) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<" | "<<#w<<": "<<w<<nl
#define trv(a) cerr<<#a<<": ";for(ll zz=0;zz<sz(a);zz++) cerr<<a[zz]<<" ";cerr<<nl
#define trset(s) cerr<<#s<<": ";for(auto &i:s) cerr<<i<<" ";cerr<<nl
#define epsilon 0.00000001L
#define inf 9999999999999999ll// ~ 10^16
#define nl endl
#define all(x) x.begin(), x.end()
#define r_all(x) x.rbegin(), x.rend()
#define fast()  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod 1000000007ll
#define modulo 998244353ll
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

int main()
{
    fast();
    ll x;
    cin>>x;
    ll g=__gcd(x,360ll);
    ll n=(360/g);
    cout<<n<<nl;

}


Measured memory_bytes: 3560
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let (a, b, c) = parse_line!(usize, usize, usize);
    let dev = b / a;
    if dev < c {
        println!("{}", dev);
    } else {
        println!("{}", c);
    }
}

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

int main() {
	string A,B,C;
	
	cin >>A>>B>>C;
	
	if(A[A.size()-1]==B[0] && B[B.size()-1]==C[0]){
		cout << "YES" <<endl;
	}
else  {
	cout << "NO" <<endl;
	
}

	// your code goes here
	return 0;
}

Measured memory_bytes: 256
//In the Name of God
//Ya Ali

#include <bits/stdc++.h>

#define int long long

#define err(A) cout << #A << " = " << (A) << endl

using namespace std;

const int maxn = 404;

int n;

int a[maxn];

int p[maxn];

int dp[maxn][maxn];

int32_t main()
{
  memset(dp, 30, sizeof dp);
  
  ios::sync_with_stdio(0); cin.tie(0);

  cin >> n;

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

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

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

  for (int l = 2; l <= n; l ++)
    for (int i = 0, j = l; j <= n; i ++, j ++)
      for (int k = i; k < j; k ++)
	dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j] + p[j] - p[i]);

  cout << dp[0][n] << endl;
  
  return 0;
}


Measured memory_bytes: 1536
#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
using namespace std;

int main(){
	char a,b,c,d,e,f;
	cin>>a>>b>>c>>d>>e>>f;
	if(a==f&&b==e&&c==d)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
from collections import UserList


def main():
    _ = input()
    A = Array(input().split(" ")).map(int)
    ans = A.with_index().sort(lambda x: x[1]).map(lambda x: x[0] + 1).join_to_str(" ")
    print(ans)


class Array(UserList):
    def __init__(self, iterable):
        self.data = iterable

    def map(self, f):
        return Array([f(x) for x in self.data])

    def join_to_str(self, sep):
        return sep.join(self.map(str))

    def filter(self, f):
        return Array([x for x in self.data if f(x)])

    def with_index(self):
        return Array([(i, x) for i, x in enumerate(self.data)])

    def sort(self, key):
        return Array(sorted(self.data, key=key))

    def sum(self):
        return sum(self.data)

    def min(self):
        return min(self.data)

    def max(self):
        return max(self.data)

    def fold_left(self, f, init):
        ret = init
        for x in self.data:
            ret = f(ret, x)
        return ret

    def _scan_left(self, f, init):
        ret = init
        for x in self.data:
            ret = f(ret, x)
            yield ret

    def scan_left(self, f, init):
        return Array(list(self._scan_left(f, init)))

    def lower_bound(self, x):
        """x以上になる最小のindex"""
        low = 0
        high = len(self)
        while low < high:
            mid = (low + high) // 2
            if self[mid] < x:
                low = mid + 1
            else:
                high = mid
        return low

    def upper_bound(self, x):
        """xより大きくなる最小のindex"""
        low = 0
        high = len(self)
        while low < high:
            mid = (low + high) // 2
            if self[mid] <= x:
                low = mid + 1
            else:
                high = mid
        return low

    def _distinct(self):
        dic = {}
        for x in self.data:
            if dic.get(x):
                continue
            dic[x] = True
            yield x

    def distinct(self):
        return Array(list(self._distinct()))


if __name__ == "__main__":
    main()


Measured memory_bytes: 24104
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

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

  set<string> st;
  rep(i, n) st.insert(s[i]);
  cout << st.size() << '\n';




  
  return 0;
}

Measured memory_bytes: 25108
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))
#define MOD 1000000007

typedef long long ll;
long long int dp[2][100005];
long long int tpow[100005];
string s;
long long int func(int st){
    if(st == s.length()) return 1;
    if(s[st]=='1'){
        return (tpow[s.length()-st-1] + 2*func(st+1)) % MOD;
    }else return func(st+1) % MOD;

}

int main(){
    tpow[0] = 1;
    for(int i=1;i<100005;i++) tpow[i] = (3 * tpow[i-1]) % MOD;
    rep(i,100005) dp[0][i] = 0;
    rep(i,100005) dp[1][i] = 0;
    cin >> s;
    dp[0][0] = 1;
    dp[1][0] = 1; 
    long long int ans = 0;
    cout << func(0) << endl;
    return 0;
}

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

int main(){
    using namespace std;
    size_t N, Y;
    cin >> N >> Y;
    auto y = (2 * N + 7 * Y) % 9;
    if(N < y)return 0 & puts("-1 -1 -1");
    N -= y;
    (Y -= 5000 * y) /= 1000;
    if(Y < N || 10 * N < Y)return 0 & puts("-1 -1 -1");
    cout << (Y - N) / 9 << " " << y << " " << (10 * N - Y) / 9 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int n;
  float sum = 0.0;
  int kei = 0;
  int a[n];
  scanf("%d",&n);
  for (int i = 0; i < n; i++){
	scanf("%d",&a[i]);
	sum += a[i];
  }
  sum /= n;
  if( (sum - (int)sum) >= 0.5) sum += 1;
  for (int i = 0; i < n; i++){
	kei += ((int)sum - a[i])*((int)sum - a[i]);
	}
  printf("%d",kei);
  return 0;
}
    

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

int main() {
  int A, 
      B,
 	  array[5],
      divisor,
      count = 0;
  
  cin >> A >> B;
  
  for (; A <= B; ) {
    //A += 1;
    divisor = A;
    
    for (int j = 4; j >= 0; j--) {
      array[j] = divisor % 10;
      divisor /= 10;
    }
    
    if (array[0] == array[4] && array[1] == array[3]) {
      count++;
    }
    
    A++;
  }
  
  cout << count << endl;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    cout << (n - 2) * 180 << endl;
    
    return 0;
}



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

using namespace std;

#define INF 1000000000
#define INFLL 0x3f3f3f3f3f3f3f3fLL 
#define EPS 10e-9
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define st first
#define nd second
#define sz(v) int(v.size())
#define all(X) (X).begin(), (X).end()
#define FOR(I, A, B) for(int I = A; I < B; I++)
#define RFOR(I, A, B) for(int I = A; I >= B; I--)

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<iii> viii;
typedef vector<ll> vll;
typedef vector<vll> vvl;

typedef vvl matrix;

matrix operator +(matrix a, matrix b){
	int n = sz(a);
	int m = sz(a[0]);
	matrix c;
	c.resize(n);
	FOR(i, 0, n){
		c[i].resize(m);
		FOR(j,0,m){
			c[i][j]=a[i][j]+b[i][j];
		}
	}
	return c;
}

matrix operator *(matrix a, matrix b){
	int n = sz(a);
	int m = sz(b);
	int p = sz(b[0]);
	matrix c(n, vll(p));
	vll col(m);
	FOR(j,0,p){
		FOR(k,0,m){
			col[k] = b[k][j];
		}
		FOR(i,0,n){
			ll s =0;
			FOR(k,0,m){
				s+=a[i][k]*col[k];
				s%=MOD;
			}
			c[i][j]=s;
		}
	}	
	return c;
}

matrix id(int tam){
	matrix c(tam, vll(tam, 0));
	FOR(i,0,tam){
		c[i][i] = 1;
	}
	return c;
}

matrix matrixExp(matrix a, ll n){
	if(n == 0) return id(sz(a));
	matrix c = matrixExp(a, n/2);
	c = c*c;
	if(n%2) c = c*a;
	return c;
}


int main(){
	ll n, k;
	cin >> n >> k;
	matrix c(n, vll(n));
	FOR(i,0,n){
		FOR(j,0,n){
			ll aux;
			scanf("%lld", &aux);
			c[i][j] = aux;
		}
	}
	c = matrixExp(c, k);
	ll ans = 0;
	FOR(i,0,n){
		FOR(j,0,n){
			ans+=c[i][j];
			ans%=MOD;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
    long long n,b;
    cin>>n;
    vector<long long> a(n,0);
    f(i,0,n-1){
        cin>>b;
        a[b-1]++;
    }
    f(i,0,n){
        cout<<a[i]<<endl;
    }
    return 0;
}

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

int main() {
  ll gcd(ll a, ll b);
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N, X; cin >> N >> X;
  set<ll> S;
  for (ll i = 0; i < N; i++) {
    ll x; cin >> x;
    S.insert(abs(x-X));
  }
  ll ans = *S.begin();
  for (auto it = S.begin(); it != S.end(); ++it)
    ans = gcd(ans, *it);
  cout << ans << endl;
}

ll gcd(ll a, ll b) {
  ll n = min(a,b); ll x = max(a,b);
  if (n == 0)
    return x;
  else
    return gcd(n, x%n);
}


Measured memory_bytes: 4864
import java.util.Scanner;

public class Main {

	static Scanner scanner;

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

	    String n=gs();
	    //int h=gi();
	    //int w=gi();
int c=0;
	    for (int i=0; i<n.length();i++) {
	    	if(n.charAt(i)=='2') {
	    		c++;
	    	}
	    }

	    System.out.print(c);
//	    if (n%10==3) {
//	    	System.out.print("bon");
//	    }else if(n%10==0 || n%10==1 || n%10==6 || n%10==8){
//	    	System.out.print("pon");
//	    } else {
//	    	System.out.print("hon");
//	    }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35592
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <type_traits>
#include <map>

using namespace std;

int a, b, c;
int pizza_a_need, pizza_b_need;

int main(int argc, const char * argv[]) {
  cin >> a >> b >> c >> pizza_a_need >> pizza_b_need;
  int n = max(pizza_a_need, pizza_b_need);
  long long ans = 999999999999999999;
  for(int i = 0; i <= n; i++){
    int pa = i;
    int pb = i;
    long long price = max(0,(pizza_a_need - pa)*a) + max(0,(pizza_b_need - pb)*b) + i*2*c;
    ans = min(ans, price);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <cmath>
using namespace std;
#define vsort(vec) sort(vec.begin(), vec.end())
#define vreverse(vec) reverse(vec.begin(), vec.end())
using ll =long long;
const ll INF =1001001001;

//最大公約数
ll gcd(ll a, ll b){
   if (a%b==0){
       return(b);
   }else{
       return(gcd(b,a%b));
   }
}
//最小公倍数
ll lcm(ll a, ll b){
   return a*b/gcd(a,b);
}


int main(void){
cout<<fixed<<setprecision(10);
//cin.tie(0); ios::sync_with_stdio(false);


  ll N;
  string S;
  cin>>N>>S;
  int counter=0;
  int M=0;
  
  
  
  for(int i=0;i<S.size();i++){
    if(S[i]=='I'){counter++;}
      if(S[i]=='D'){counter--;}
    M=max(M,counter);
  }
  
  cout<<M<<endl;
  
  
}



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

int main()
{
  string str;
  cin>>str;
  
  if(str[0]=='7'||str[1]=='7'||str[2]=='7')
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 3128
import sys
import itertools


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n = int(readline())
    a = tuple(map(int, readline().split()))
    b = tuple(map(int, readline().split()))
    nl = sorted(a)
    an = -1
    bn = -1
    for i, v in enumerate(itertools.permutations(nl, n)):
        if v == a:
            an = i
        if v == b:
            bn = i
    print(abs(an - bn))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 39152
#left child right siberings representation
#left : index of the most left children
#right : index of the nearest right siberings


class node:
    def __init__(self,parent, left, right):
        self.parent=parent
        self.left=left
        self.right=right


class tree:
    #give some list to define the tree structure
    def __init__(self, list):
        #root initialization
        self.root=None
        self.T=[]
        self.insert(list)

    #parse data to tree structure
    def insert(self,list):
        nnodes=len(list)
        for i in range(nnodes):
            self.T.append(node(None, None, None))
        for i in range(nnodes):
            #n=node index
            n=int(list[i][0])
            nch=list[i][1]
            for j in range(nch):
                chnode=list[i][2+j]
                #set the parent in the each child node
                self.T[chnode].parent=n
                if (j==0):
                    #most left children
                    self.T[n].left=chnode

                #define the nearest right siberings in the child node
                if (j < nch-1):
                    self.T[chnode].right=list[i][j+3]

    def getDepth(self, index):
        d=0
        u=index
        while self.T[u].parent !=None:
            u=self.T[u].parent
            d=d+1

        return d

    def getChildrens(self, index):
        ch=[]
        c=self.T[index].left
        ic=c
        while ic!=None:
            ch.append(ic)
            ic=self.T[ic].right

        return ch

    def printNode(self, index):
        print("parent="+str(self.T[index].parent)+",depth="+str(self.getDepth(index)) +\
              ",right="+str(self.T[index].right)+ ",left="+str(self.T[index].left))
        print(self.getChildrens(index))
        return

    def stringForAOJ(self,index):
        #node index
        strs=""
        strs=strs+"node "+str(index)+":"

        #parent
        if self.T[index].parent==None:
            strs=strs+" parent = -1,"
        else:
            strs = strs + " parent = "+str(self.T[index].parent)+","

        #depth
        strs=strs+" depth = "+str(self.getDepth(index))+","

        #type
        if self.T[index].parent==None:
            strs=strs+" root,"
        elif self.T[index].left==None:
            strs = strs + " leaf,"
        else:
            strs = strs + " internal node,"

        #childrens
        strs=strs+" ["
        ch=self.getChildrens(index)
        for i in range(len(ch)):
            strs=strs+str(ch[i])
            if (i < len(ch)-1):
                strs=strs+", "

        strs=strs+"]"

        return strs





n=int(input())
dlist=[]
for i in range(n):
    dlist.append(list(map(int,(input().split()))))

#print(dlist)
t=tree(dlist)

for i in range(n):
    print(t.stringForAOJ(i))





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

    while(tap<b){
      tap += a-1;
      ans++;
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 21844
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;


// Merges two subarrays of arr[]. 
// First subarray is arr[l..m] 
// Second subarray is arr[m+1..r] 
void merge(int arr[], int l, int m, int r) 
{ 
    int i, j, k; 
    int n1 = m - l + 1; 
    int n2 =  r - m; 
  
    /* create temp arrays */
    int L[n1], R[n2]; 
  
    /* Copy data to temp arrays L[] and R[] */
    for (i = 0; i < n1; i++) 
        L[i] = arr[l + i]; 
    for (j = 0; j < n2; j++) 
        R[j] = arr[m + 1+ j]; 
  
    /* Merge the temp arrays back into arr[l..r]*/
    i = 0; // Initial index of first subarray 
    j = 0; // Initial index of second subarray 
    k = l; // Initial index of merged subarray 
    while (i < n1 && j < n2) 
    { 
        if (L[i] <= R[j]) 
        { 
            arr[k] = L[i]; 
            i++; 
        } 
        else
        { 
            arr[k] = R[j]; 
            j++; 
        } 
        k++; 
    } 
  
    /* Copy the remaining elements of L[], if there 
       are any */
    while (i < n1) 
    { 
        arr[k] = L[i]; 
        i++; 
        k++; 
    } 
  
    /* Copy the remaining elements of R[], if there 
       are any */
    while (j < n2) 
    { 
        arr[k] = R[j]; 
        j++; 
        k++; 
    } 
} 

void mergeSort(int arr[], int l, int r) 
{ 
    if (l < r) 
    { 
        int m = l+(r-l)/2; 
  
        mergeSort(arr, l, m); 
        mergeSort(arr, m+1, r); 
  
        merge(arr, l, m, r); 
    } 
} 
 
int main() {
    int n,k;
    cin>>n>>k;
    int a[n];
    long long ans =0;
    for(int i = 0; i<n; i++){
        cin>>a[i];
    }
    mergeSort(a,0,sizeof(a)/sizeof(a[0])-1);

    for (int i =0; i<n-k; i++){
        ans += a[i];
    }
  cout<<ans;
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define KIND 26
int main()
{
    int N;
    cin >> N;
    char S[N+3];
    cin >> S;
    int prev[KIND] = {0}, next[KIND] = {0};
    for(int i = 0; i < N; ++i) next[S[i] - 'a']++;
    int common = 0;
    for(int cur = 0; cur < N; ++cur) {
        int res = 0;
        char tmp = S[cur];
        ++prev[tmp - 'a']; --next[tmp - 'a'];
        for(int i = 0; i < KIND; ++i) 
            if(prev[i] > 0 && next[i] > 0) ++res;
        if(res > common) common = res;
    }
    cout << common << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;

public class Program
{
    public static void Main() {
        Reader reader = new Reader(Console.In);
        int x = reader.RInt();
        int y = reader.Int();

        var g1 = new List<int> { 1, 3, 5, 7, 8, 10, 12 };
        var g2 = new List<int> { 4, 6, 9, 11 };

        if(g1.Any(a => a == x) && g1.Any(a => a == y)) {
            Console.WriteLine("Yes");
        }else if(g2.Any(a => a == x) && g2.Any(a => a == y)) {
            Console.WriteLine("Yes");
        }else {
            Console.WriteLine("No");
        }
    }
}

public class Reader
{
    private readonly TextReader reader;
    private readonly char separator = ' ';
    private string[] A = new string[0];
    private int i;

    public Reader(TextReader r) { reader = r; }

    public string String() { return Set(); }
    public int Int() { return int.Parse(Set()); }
    public long Long() { return long.Parse(Set()); }

    public string RString() { return RSet(); }
    public int RInt() { return int.Parse(RSet()); }
    public long RLong() { return long.Parse(RSet()); }


    public int[] IntArray() { return A.Select(x => int.Parse(x)).ToArray(); }

    private void Read() {
        string line = reader.ReadLine();

        A = line.Split(separator);
        i = 0;
    }

    private string Set() { return A[i++]; }
    private string RSet() { Read(); return A[i++]; }
}

Measured memory_bytes: 13268
#include <iostream>
#include <queue>
#include <set>
#include <cassert>
#include <map>
#include <sstream>
using namespace std;

int main(){
	long long A,B,C;
	cin >> A >> B >> C;
	long long ans = 1e18;

	ans = min((B%2)*A*C,min((A%2)*B*C,(C%2)*A*B));
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define N 8
#define FREE -1
#define NOT_FREE 1

using namespace std;

int row[N], col[N], dpos[2 * N - 1], dneg[2 * N - 1];

void print () {
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (row[i] == j)
        cout << "Q";
      else
        cout << ".";
    }
    cout << endl;
  }
}

void recursive (int i) {
  // printf("i = %d, row[%d] = %d\n", i, i, row[i]);
  if (i == N) {
    print();
    return;
  }

  if (row[i] != FREE) {
    // cout << "next" << endl;
    recursive(i + 1);
    return;
  }

  for (int j = 0; j < N; j++) {
    if (
      col[j] == NOT_FREE ||
      dpos[i + j] == NOT_FREE ||
      dneg[i - j + (N - 1)] == NOT_FREE
    ) continue;
    row[i] = j;
    col[j] = dpos[i + j] = dneg[i - j + (N - 1)] = NOT_FREE;
    recursive(i + 1);
    // 回溯
    row[i] = col[j] = dpos[i + j] = dneg[i - j + (N - 1)] = FREE;
  }
}

int main () {
  int k, _i, _j;

  cin >> k;

  for (int i = 0; i < N; i++)
    row[i] = col[i] = FREE;
  for (int i = 0; i < 2 * N - 1; i++)
    dpos[i] = dneg[i] = FREE;

  for (int i = 0; i < k; i++) {
    cin >> _i >> _j;
    row[_i] = _j;
    col[_j] = dpos[_i + _j] = dneg[_i - _j + (N - 1)] = NOT_FREE;
  }

  recursive(0);

  return 0;
}


Measured memory_bytes: 3116
## coding: UTF-8
N = int(input())
s = input().split()
l1 = [int(p) for p in s]
s2 = input().split()
l2 = [int(p) for p in s2]

#print(N)
#print(l1)
#print(l2)
#print(sum(l1[2:]))

def Cumulative_sum(l):
    output_list = []
    for i in range(len(l)):
        output_list.append(sum(l[:i+1]))
    return output_list

#print(Cumulative_sum(l1))
#print(Cumulative_sum(l2))
#print(Cumulative_sum(l2)[len(l2)-1])


def calc_sum(cut_off):
    if(cut_off != 0):
        add = Cumulative_sum(l1)[cut_off] + Cumulative_sum(l2)[len(l2)-1] - Cumulative_sum(l2)[cut_off - 1]
    else:
        add = Cumulative_sum(l1)[cut_off] + Cumulative_sum(l2)[len(l2)-1]
    return add

#print(calc_sum(0))
#print(calc_sum(1))
#print(calc_sum(2))

answer = 0
for i in range(N):
    if(answer <= calc_sum(i)):
        answer = calc_sum(i)
        #print(answer)
print(answer)

'''
answer = 0

mode = 1 #上の段

def countup(mode, index):
    if(mode == 1):
        add = l1[index]
    if(mode == 2):
        add = l2[index]
    return add


answer += countup(mode, 0)
for i in range(1,N):
    #print(sum(l1[i:]))
    #print(sum(l2[i-1:]))
    if( mode == 1 and sum(l1[i:]) < sum(l2[i-1:]) ):
        mode = 2 #下の段に移動
        answer += countup(mode, i-1)
    #print('mode:{}, index:{}'.format(mode, i))
    answer += countup(mode, i)
if(N == 1):
    answer += l2[0]
print(answer)
'''






Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
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; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

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

int bingo[3][3];
bool flag[3][3];
int cnt[2][105];
int h, w;
int choco[1010][1010];
int s[11][11];

int main() {
	int n;
	cin >> n;
	vector<int>a(n);
	vector<bool>color(8);
	int res = 0, ans = 0;
	bool flag = false;
	rep(i, n) {
		cin >> a[i];
		if (a[i] < 3200) {
			int rank = a[i] / 400;
			color[rank] = true;
			flag = true;
		}
		else {
			res++;
		}
	}
	rep(i, 8) {
		if (color[i])ans++;
	}
	if (flag) {
		cout << ans << " " << ans + res << endl;
	}
	else {
		cout << 1 << " " << res << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define _GLIBCXX_DEBUG

using _loop_ll = long long;
#define REP(i,n) for(_loop_ll (i)=0; (i)<(_loop_ll)(n); (i)++)
#define FOR(i,a,b) for(_loop_ll (i)=(_loop_ll)(a); (i)<(_loop_ll)(b); (i)++)
#define FORR(i,a,b) for(_loop_ll (i)=(_loop_ll)(b)-1; (i)>=(_loop_ll)(a); (i)--)
 
#define ALL(v) (v).begin(),(v).end()
 
#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;

constexpr long long int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll n, m;
    cin >> n >> m;
    
    if(n <= m){
        REP(i, m) cout << n;
        cout << endl;
    }
    else{
        REP(i, n) cout << m;
        cout << endl;
    }

    

    return 0;
};


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

typedef long long int ll;
typedef double d;

#define tt int t; cin>>t; while(t--)
#define lo(i, a, b) for(int i=a; i<b; i++)
#define rlo(i, a) for(int i=a; i>=0; i--)

#define be(a) a.begin(),a.end()
#define sz(x) x.size()

#define sp " "
#define nl cout<<'\n';
#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

int main()
{
    su;
    string c,d;
    cin>>c>>d;
    reverse(be(d));
    if(c==d)
      cout<<"YES";
    else
      cout<<"NO";
    nl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
using namespace std;
/***********************************************/
/* Dear online judge:
 * I've read the problem, and tried to solve it.
 * Even if you don't accept my solution, you should respect my effort.
 * I hope my code compiles and gets accepted.
 *  ___  __     _______    _______      
 * |\  \|\  \  |\  ___ \  |\  ___ \     
 * \ \  \/  /|_\ \   __/| \ \   __/|    
 *  \ \   ___  \\ \  \_|/__\ \  \_|/__  
 *   \ \  \\ \  \\ \  \_|\ \\ \  \_|\ \ 
 *    \ \__\\ \__\\ \_______\\ \_______\
 *     \|__| \|__| \|_______| \|_______|
 */
const long double mod = 1000000007;

long long sum(long long X) {
	long long res = 0;
	while(X) res += X%10, X/=10;
	return res;
}

long long nxt(long long X) {
	long long mn = X;
	long long p = 1;
	long long other = 0;
	long long cur = X;
	while(cur) {
		other += p * 9;
		cur /= 10;
		p *= 10;
		if(mn * sum(cur * p + other) > (cur * p + other) * sum(mn)) mn = cur * p + other;
	}
	return mn;
}

int main(int argc, char** argv) {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int K;
	cin>>K;
	long long cur = 1;
	while(--K) {
		cout<<cur<<'\n';
		cur = nxt(cur+1);
	}
	cout<<cur<<'\n';
	return 0;
}


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

int main() {
    int n; cin>>n;
    
    int h[n+1]; 
    h[0]=0;
    for(int i=1; i<=n; i++) cin>>h[i];

    int cost[n+1] = {0};
    cost[1] = 0;
    cost[2] = abs(h[1] - h[2]);

     for(int i=1; i<n-1; i++) {
         if( cost[i+1] > cost[i] + abs(h[i+1] - h[i]) ) {
             cost[i+1] = cost[i] + abs(h[i+1] - h[i]);
         }

         cost[i+2] = cost[i] + abs( h[i]-h[i+2] );
     }

    if( cost[n] > cost[n-1] + abs(h[n] - h[n-1]) ) {
        cost[n] = cost[n-1] + abs(h[n] - h[n-1]);
    }
    
    cout<<cost[n]<<'\n';
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<map>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
#define sort(s) sort(s.begin(),s.end())
#define r(s) reverse(s.begin(),s.end())
#define please return
constexpr auto AC = 0;
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	vector<char> s(a);
	rep(i, a)cin >> s[i];
	s[b - 1] += 32;
	rep(i, a)cout << s[i];
	cout << endl;

	

		please AC;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

int dxy[5] = {0, 1, 0, -1, 0};
// cmd

using Weight = int;
using Flow = int;
struct Edge {
    int s, d; Weight w; Flow c;
    Edge() {};
    Edge(int s, int d, Weight w = 1) : s(s), d(d), w(w), c(w) {};
};
bool operator<(const Edge &e1, const Edge &e2) { return e1.w < e2.w; }
bool operator>(const Edge &e1, const Edge &e2) { return e2 < e1; }
inline ostream &operator<<(ostream &os, const Edge &e) { return (os << '(' << e.s << ", " << e.d << ", " << e.w << ')'); }

using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

void addArc(Graph &g, int s, int d, Weight w = 1) {
    g[s].emplace_back(s, d, w);
}
void addEdge(Graph &g, int a, int b, Weight w = 1) {
    addArc(g, a, b, w);
    addArc(g, b, a, w);
}

pii solve(vector<string> &data, vvi &used, int i, int j)
{
    pii ret = {0, 0};
    if (data[i][j] == '#') {
        ret.sec++;
    } else {
        ret.fir++;
    }
    rep(k, 4) {
        int nx = i + dxy[k], ny = j + dxy[k+1];
        if (in(nx, 0, data.size()) && in(ny, 0, data[0].size()) && 
                !used[nx][ny] && data[i][j] != data[nx][ny]) {
            used[nx][ny] = 1;
            pii tmp = solve(data, used, nx, ny);
            ret.fir += tmp.fir; ret.sec += tmp.sec;
        }
    }
    return ret;
}

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

    int2(h, w);
    vector<string> data(h);
    rep(i, h) {
        cin >> data[i];
    }

    vvi used(h, vi(w, 0));

    int ans = 0;
    rep(i, h) {
        rep(j, w) {
            if (!used[i][j]) {
                used[i][j] = 1;
                pii tmp = solve(data, used, i, j);
                //cout << tmp.fir << " " << tmp.sec << endl;
                ans += tmp.fir * tmp.sec;
            }
        }
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 21760