akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    private static Scanner sc;

    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {
            String S = sc.next();
        	System.out.println(S+(S.charAt(S.length()-1)=='s'?"es":"s"));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 25352
N, A, B = map(int,input().split())

x = 0
ans = 0
for i in range(N + 1):
    i = str(i)
    l = len(i)
    for j in range(l):
        x += int(i[j])
    if A <= x <= B:
        ans += int(i)
    x = 0
print(ans)

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

int main(){
  int A, B, K;
  cin >> A >> B >> K;
  
  if((B - A) / K < 2){
    for(int i=A; i<B+1; i++){
      cout << i << endl;
    }
  }
  else{
    for(int j=A; j<A+K; j++){
      cout << j << endl;
    }
    for(int k=B-K+1; k<B+1; k++){
      cout << k << endl;
    }
  }
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 29)
#define MOD 1000000007
//int dx[4] = {1,0,0,-1};
//int dy[4] = {0,1,-1,0};


int main(){

  string s;
  int k;
  set<string> se;
  cin >> s >> k;
  for(int i = 0;i < s.size();i++){
    for(int j = i;j < i+5;j++){
      se.insert(s.substr(i,j - i + 1));
    }
  }
  auto itr = se.begin();
  for(int i = 0;i < k-1;i++)itr++;
  cout << *itr  << endl;
  return 0;
}

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

public class Main {

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

	    int h1=gi();
	    int m1=gi();
	    int h2=gi();
	    int m2=gi();
	    int k=gi();

	    System.out.print((h2-h1)*60+(m2-m1)-k);
//	    if (s.startsWith("MUJIN")) {
//	    	System.out.print("Yes");
//	    }else {
//	    	System.out.print("No");
//	    }



	}

	public static long d(long n) {
		String a=String.valueOf(n);
		return (long)a.length();
	}

	// 文字列として入力を取得
	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: 35544
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long int LL;
typedef LL ll;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;
 
#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (int i=a;i<b;i++)
#define Ford(i,a,b) for (int i=a;i>=b;i--)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))
#define RET(x) { cout << x; exit(0); } 
const ll M=2e5+5,LG=19,SM=4000+5,inf=1e18+1;
ll mod=924844033;

ll h,w;
ll jad[M];

int main()
{
	ios::sync_with_stdio(0);
	cin >> h >> w;
	For(i,0,h)
	{
	    str s;
	    cin >> s;
	    For(j,0,w)
	    {
	        jad[i+j]+=s[j]=='#';
	    }
	} 
	For(i,0,h+w-1)
	{
	    //ER(jad[i]);
	    if (jad[i]!=1) RET("Impossible");
	}
	RET("Possible");
}    

Measured memory_bytes: 256
sx,sy,tx,ty = map(int,input().split())
dy , dx = ty-sy,tx-sx
ans = "U" * dy + "R" * dx
ans += "D" * dy + "L" * dx 
ans += "L" + "U" * (dy+1) + "R" * (dx+1) + "D"
ans += "R" + "D" * (dy+1) + "L" * (dx+1) + "U"
print(ans)

Measured memory_bytes: 3064
import numpy as np
N = int(input())
A = list(map(int, input().split()))
B = A.copy()
B.sort()
C=[]
for i in range(N):
  if B[i]<0:
    C.append(B[i])
  else:
    continue
count = len(C)
if count % 2 == 0:
  B = np.abs(B)
  ans = sum(B)
else:
  B = np.abs(B)
  X = sum(B)
  ans = X - 2*min(B)
print(ans)

Measured memory_bytes: 23304
import itertools

def calc_MP(take, num):
    return abs(sum(take) - num) + (len(take)-1) * 10

def main():
    n, a, b, c = [int(i) for i in input().split()]

    l = []
    for i in range(n):
        l.append(int(input()))

    ans = float("inf")
    for i0, i1, i2, i3, i4, i5, i6, i7 in itertools.product(range(4), range(4), range(4),range(4), range(4), range(4),range(4), range(4)):
        i_list = [i0, i1, i2, i3, i4, i5, i6, i7]
        MP = 0
        take_A = []
        take_B = []
        take_C = []

        for i in range(n):
            if i_list[i] == 1:
                take_A.append(l[i])
            elif i_list[i] == 2:
                take_B.append(l[i])
            elif i_list[i] == 3:
                take_C.append(l[i])

        if len(take_A) != 0 and len(take_B) != 0 and len(take_C) != 0:
            MP += calc_MP(take_A, a)
            MP += calc_MP(take_B, b)
            MP += calc_MP(take_C, c)
        else:
            MP = float("inf")
        ans = min(ans, MP)

    print(ans)

main()

Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys
from collections import defaultdict
# input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return map(int,input().split())
def LI(): return list(map(int,input().split()))


def main():
    N = INT()
    AB = [LI() for _ in range(N)]
    AB.sort(key=lambda x: -(x[0]+x[1]))

    answer = 0
    for i in range(N):
        if i%2 == 0:
            answer += AB[i][0]
        else:
            answer -= AB[i][1]
    
    print(answer)

    return


if __name__ == '__main__':
    main()


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

using namespace std;

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

    int ans = 0;
    for (int i = 0; i < str.size() / 2; i++) {
        if (str.at(i) != str.at(str.size() - 1 - i)) {
            ans++;
        }
    }

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

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main() {
	int x; cin >> x;
	string ans;
	if (x == 7) { ans = "YES"; }
	else if (x == 5) { ans = "YES"; }
	else if (x == 3) { ans = "YES"; }
	else { ans = "NO"; }
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let r = read::<i64>();
    let g = read::<i64>();
    println!("{}", 2 * g - r);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
import java.util.Scanner;
 
public class Main {
	public static void main (String args[]) {
		Scanner scan = new Scanner(System.in);

		Integer array[][] = new Integer[3][3];
		for(int i = 0;i < 3;i++) {
			for(int j = 0; j < 3; j++) {
				array[i][j] = scan.nextInt();
			}
		}
		int n = scan.nextInt();
		for(int k = 0; k < n; k++) {
			int num = scan.nextInt();
			for(int i = 0;i < 3; i++) {
				for(int j = 0; j < 3; j++) {		
					if(array[i][j].equals(num)) {
						array[i][j] = 0;
					}
				}
			}
		}
		
		for(int i = 0; i < 3; i++) {
			if(array[i][0] == 0 && array[i][1] == 0 && array[i][2] == 0) {
				System.out.println("Yes");
				return;
			}
			if(array[0][i] == 0 && array[1][i] == 0 && array[2][i] == 0) {
				System.out.println("Yes");
				return;
			}
		}
		// naname
		if(array[0][0] == 0 && array[1][1] == 0 && array[2][2] == 0) {
			System.out.println("Yes");
			return;
		}
		if(array[2][0] == 0 && array[1][1] == 0 && array[0][2] == 0) {
			System.out.println("Yes");
			return;
		}
		System.out.println("No");
	}
}

Measured memory_bytes: 21844
n = int(input())
a = list(map(int, input().split()))

flag = 1
i = 0
k = 0
while flag:
    flag = 0
    for j in range(n - 1, i, -1):
        if a[j] < a[j - 1]:
            t = a[j]
            a[j] = a[j - 1]
            a[j - 1] = t
            flag = 1
            k += 1
    i += 1
for i in range(0, n-1):
    print(a[i], end=" ")
print(a[n-1])
print(k)



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

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        String S = scan.next();
        int Q = scan.nextInt();
        StringPointer headP = null;
        StringPointer tailP = null;
        StringPointer now = new StringPointer(S);
        headP = now;
        tailP = now;

        boolean isReverse = false;
        for(int i = 0; i < Q; i++){
            int T = scan.nextInt();
            if(T == 1) {
                isReverse = !isReverse;
            } else if (T == 2) {
                int F = scan.nextInt();
                String C = scan.next();
                now = new StringPointer(C);
                if(F == 1) {
                    if(isReverse) {
                        tailP.next = now;
                        tailP = now;
                    } else {
                        now.next = headP;
                        headP = now;
                    }
                } else if(F == 2) {
                    if(isReverse) {
                        now.next = headP;
                        headP = now;
                    } else {
                        tailP.next = now;
                        tailP = now;
                    }
                }
            }
        }

        StringBuilder sb = new StringBuilder();

        now = headP;
        while(now != null) {
            sb.append(now.str);
            now = now.next;
        }

        if (isReverse)
            os.println(sb.reverse().toString());
        else
            os.println(sb.toString());

    }

    static class StringPointer {
        StringPointer next = null;
        String str = null;
        StringPointer(String str) {
            this.str = str;
        }
    }


}

Measured memory_bytes: 167300
import collections
from collections import defaultdict
n= int(input())
a= list(map(int, input().split()))
d=defaultdict(int)
v=[0]*(pow(10,6)+1)
a.sort()
ans=0
for i in a:
    d[i]+=1

for i in a:
    if v[i]==0:
        if d[i]==1:
            ans+=1
        x = pow(10, 6) // i
        for j in range(1,x + 1):
            v[i*j]=1
print(ans)

Measured memory_bytes: 120908
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <map>
#include<numeric>
using namespace std;
#define rep(i,n) for(int i=0; i<(n);i++)
typedef long long ll;

// C
int main(){
    int x, n; cin >> x >> n;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    rep(i,n+1){
        if(!count(p.begin(), p.end(), x-i)){
            cout << x-i << endl;
            return 0;
        }
        if(!count(p.begin(), p.end(), x+i)){
            cout << x + i << endl;
            return 0;
        }
    }
    cout << x << endl;
	return 0;
}


Measured memory_bytes: 3188
d,n=gets.split.map(&:to_i)

case d
when 0
  if n < 100
    p n
  else
    p 101
  end
when 1
  if n < 100
    p 100 * n
  else
    p 10100
  end
when 2
  if n < 100
    p 10000 * n
  else
    p 1010000
  end
end

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

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

    int n, m;
    cin >> n >> m;
    vector<vector<int>> ab(n + 1);
    vector<int> f(n + 1);
    rep(i, 0, n + m - 1) {
        int a, b;
        cin >> a >> b;
        ab[a].push_back(b);
        f[b]++;
    }
    vector<int> dag;
    vector<int> par(n + 1);
    set<int> st;
    rep(i, 1, n + 1) if (f[i] == 0) st.insert(i);
    while (!st.empty()) {
        int a = *st.begin();
        st.erase(a);
        f[a]--;
        dag.push_back(a);
        for (auto b : ab[a]) {
            f[b]--;
            if (f[b] == 0) {
                par[b] = a;
                st.insert(b);
            }
        }
    }
    rep(i, 1, n + 1) cout << par[i] << endl;

    return 0;
}


Measured memory_bytes: 9592
#include<iostream>
using namespace std;
#define lli long long int
#include<vector>
#include<algorithm>
int main(){
  lli r,d,x,i;
  cin>>r>>d>>x;
  vector<int>v(11);
  v[0]=x;
  //cout<<x<<"\n";
  for(i=1;i<=10;i++){
    v[i]=(r*v[i-1])-d;
    cout<<v[i]<<"\n";
  }
  return 0;
}

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

using namespace std;

bool IsPalindrome(string s){
  int l = 0;
  int r = s.size()-1;
  while(l < r){
    if (s[l] != s[r]) return false;
    ++l;
    --r;
  }
  return true;
}

int main(){
  string S;
  cin >> S;
  
  int N = S.size();
  string sub1 = S.substr(0, (N-1)/2);
  string sub2 = S.substr((N+3)/2-1, (N-1)/2);
  
  if (!IsPalindrome(S) || !IsPalindrome(sub1) || !IsPalindrome(sub2)){
    cout << "No";
    return 0;
  }
  
  cout << "Yes";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define all(x) (x.begin()),(x.end())
#define sz(x)  ((ll)x.size())
#define FAST_IO ios_base :: sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
using namespace std;
//#ifdef LOCAL
//#include "uj.h"
//#endif


int N;
int x,t;
void test_case(){
	cin >> N >> x >> t;
	int cnt = ceil((double)N/x)*t;
	cout << cnt;
}
	

	





int main(){
	FAST_IO;
	int tt;
	//cin>>tt;
	tt = 1;
	while(tt--){
		test_case();
	}
#ifndef ONLINE_JUDGE
 	cerr << "Running Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int r, g, b, N;
    cin >> r >> g >> b >> N;
    int ans = 0;
    REP(i, N/r + 1){
        REP(j, N/g + 1){
            int sum = i*r + j*g;
            int x = N - sum;
            if(x==0) ans++;
            else if(x % b == 0 && x > 0) ans++; 
        }
    }
    cout << ans << 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 REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int N, K; cin >> N >> K;
    if ((N+1)/2 < K) cout << "NO" << endl;
    else cout << "YES" << endl;
    return 0;
}

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

#pragma warning(disable:4996)
using namespace std;

vector<int>solve(const vector<vector<pair<int, int>>>&edges) {
	vector<int>memo(edges.size(),1e9);
	memo[0]=0;
	priority_queue<pair<int,int>>que;
	que.emplace(0,0);
	while (!que.empty()) {
		auto atop(que.top());
		que.pop();
		int now=atop.second;
		int now_cost=-atop.first;
		for (auto e : edges[now]) {
			int next=e.first;
			int next_cost=e.second+now_cost;
			if (memo[next] > next_cost) {
				memo[next]=next_cost;
				que.emplace(-next_cost,next);
			}
		}
	}
	return memo;
}
int main() {
	int N;cin>>N;
	vector<pair<int,int>>value_as,value_bs;
	for (int i = 0; i < N; ++i) {
		int a;cin>>a;
		value_as.push_back(make_pair(a,i));
	}
	for (int i = 0; i < N; ++i) {
		int b;cin>>b;
		value_bs.push_back(make_pair(b,i));
	}
	sort(value_as.begin(),value_as.end());
	sort(value_bs.begin(),value_bs.end());
	vector<vector<pair<int,int>>>edges(N);
	for (int i = 0; i < N - 1; ++i) {
		int l=value_as[i+1].second;
		int r=value_as[i].second;
		int cost=value_as[i+1].first-value_as[i].first;

		edges[l].push_back(make_pair(r,cost));
		edges[r].push_back(make_pair(l,cost));
	}
	for (int i = 0; i < N - 1; ++i) {
		int l = value_bs[i + 1].second;
		int r = value_bs[i].second;
		int cost = value_bs[i + 1].first - value_bs[i].first;

		edges[l].push_back(make_pair(r, cost));
		edges[r].push_back(make_pair(l, cost));
	}
	vector<int>answer=solve(edges);
	for(int i=0;i<N;++i)cout<<answer[i]<<endl;
	return 0;
}



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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

ll rec(int ix, int n, ll cur, ll sum, vector<int>& D)
{
  if (ix == n) { return cur + sum; }
  return rec(ix + 1, n, 10 * cur + D[ix], sum, D) +
    rec(ix + 1, n, D[ix], sum + cur, D);
}

int main()
{
  string s; cin >> s;
  int n = s.size();
  vector<int> D(n);
  for (int i = 0; i < n; ++i) {
    D[i] = s[i] - '0';
  }
  ll ans = rec(1, n, D[0], 0, D);
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
static int h[100010];
int 
main(){
	long int N,i;
	long int cnt=0;
	int K;
	scanf("%ld %d",&N,&K);

	for(i=0;i<N;i++){
		scanf("%d",&h[i]);
	}
	
	for(i=0;i<N;i++){
		if(h[i]>=K)cnt++;

	}
	printf("%ld\n",cnt);
 return 0;
}

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

using i64 = int_fast64_t;
using f64 = double;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    i64 n;
    cin >> n;
    i64 ans = 0;
    while (n) {
        if (n % 10 == 2) ans++;
        n /= 10;
    }

    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define PI acos(-1)
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

int modpow(int x, int n, int m) {
	x %= m;
	int res = 1;
	while(n > 0) {
		if(n & 1)
			res = res * x % m;
		x = x * x % m;
		n >>= 1;
	}
	return res;
}

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	srand(chrono::steady_clock::now().time_since_epoch().count());
	#ifndef ONLINE_JUDGE
		// freopen("input.txt", "r", stdin);
		// freopen("output.txt", "w", stdout);
	#endif

	int h, a;
	cin >> h >> a;
	int ans = (h + a - 1) / a;
	cout << ans;

	return 0;
}

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

int main() {
	int cnt[26] = {};
	char ch;

	while (cin >> ch) {
		ch = tolower(ch);
		if (isalpha(ch))
			cnt[ch - 'a']++;
	}

	for (int i = 0; i < 26; i++) {
		printf("%c : %d\n", 'a' + i, cnt[i]);
	}
	
	return 0;
}

Measured memory_bytes: 1124
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

int main(){
	long long n,ans=10000000000000;
	cin>>n;
	for(long long i=1;i<n;i++){
		if(i*i>n){
			break;
		}
		if(n%i==0){
			ans=min(ans,i+n/i-2);
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.stdio;

immutable uint MOD = 10^^9 + 7;
alias mint = ModInt!MOD;

void main() {
    auto s = readln.split.map!(to!int);
    auto n = s[0];
    auto k = s[1];
    auto A = readln.split.map!(to!int).array;

    auto cnt = new mint[](2002);
    foreach (a; A) cnt[a-1] += mint(1);
    foreach_reverse (i; 1..2002) cnt[i-1] += cnt[i];

    auto K = mint(k) * mint(k-1) / mint(2);
    auto ans = K * A.map!(a => cnt[a]).sum;

    foreach (i; 0..n) {
        foreach (j; i+1..n) {
            if (A[i] > A[j]) {
                ans += mint(k);
            }
        }
    }

    ans.writeln;
}

struct ModInt(uint mod) {
    import std.conv : to;

    uint n;

    this(int n) {
        this.n = (n % mod + mod) % mod;
    }

    this(long n) {
        this.n = (n % mod + mod) % mod;
    }

    private this(uint n) {
        this.n = n;
    }

    string toString() const {
        return to!string(this.n);
    }

    private uint normilize(uint n) const {
        return n < mod ? n : n - mod;
    }

    private ModInt pow(uint n, long x) const {
        long ret = 1;
        long a = n;
        while (x) {
            if (x & 1) ret = ret * a % mod;
            a = a * a % mod;
            x >>= 1;
        }
        return ModInt(to!ulong(ret));
    }

    ModInt opBinary(string op : "+")(ModInt rhs) const {
        return ModInt(normilize(n + rhs.n));
    }

    ModInt opBinary(string op : "-")(ModInt rhs) const {
        return ModInt(normilize(n + mod - rhs.n));
    }

    ModInt opBinary(string op : "*")(ModInt rhs) const {
        return ModInt(to!uint(to!long(n) * rhs.n % mod));
    }

    ModInt opBinary(string op : "/")(ModInt rhs) const {
        return this * pow(rhs.n, mod-2);
    }

    ModInt opBinary(string op : "^^")(ModInt rhs) const {
        return pow(this.n, rhs.n);
    }

    ModInt opBinary(string op, T)(T rhs) const {
        ModInt mod_rhs = ModInt(rhs);
        return opBinary!op(mod_rhs);
    }

    ModInt opOpAssign(string op)(ModInt rhs) {
        return mixin ("this=this"~op~"rhs");
    }
}


Measured memory_bytes: 380
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define lower(a,x) lower_bound(all(a), x) - a.begin();
#define COUNT(a,x)  upper_bound(all(a), x) - lower_bound(all(a), x);
#define MCOUNT(a,x,y) upper_bound(all(a), y) - lower_bound(all(a), x);
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end());
#define scan(x) scanf("%lld",&x);
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
typedef double D;
const ll inf = 5555555555555555555;
const ll mod = 1000000007;
const D pi = acos(-1);
const D eps = 1e-10;

ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool ok, flag;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111


int main(void) {
  cin >> n >> m;
  vll a(n);
  rep(i, n) {
	cin >> a[i];
	sum += a[i];
  }

  ma = -inf;
  ll x;
  rep(i, n - 1) {
	if (a[i] + a[i + 1] > ma) {
	  x = i + 1;
	  ma = a[i] + a[i + 1];
	}
  }

  if (ma < m) {
	cout << "Impossible" << endl;
	return 0;
  }

  cout << "Possible" << endl;
  FOR(i, 1, x) cout << i << endl;
  RFOR(i, x, n) cout << i << endl;


  return 0;
}

Measured memory_bytes: 1664
<?php
$C=str_split(fgets(STDIN));
$s='';
foreach($C as $c){
	$n=ord($c);
	if($n<65)$s.=$c;
	elseif($n<91)$s.=chr($n+32);
	elseif($n<97)$s.=$c;
	elseif($n<123)$s.=chr($n-32);
	else $s.=$c;
}
echo $s;

Measured memory_bytes: 15544
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }

    let mut a = a;

    let mut div_count = 0;

    loop {
        let mut divided = true;

        for i in 0..n {
            if a[i] % 2 == 0 {
                a[i] /= 2;
            } else {
                divided = false;
                break;
            }
        }
        if !divided {
            break;
        } else {
            div_count += 1;
        }
    }

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


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

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

  // 累積和を作る
  vector<int> sum(N + 1, 0);
  for (int i = 0; i < N; i++) {
    if (S.at(i) == 'A' && (i + 1) < N && S.at(i + 1) == 'C') {
      sum.at(i + 1) = sum.at(i) + 1;
    } else {
      sum.at(i + 1) = sum.at(i);
    }
  }

  // (left, right) = (3, 7) の場合
  // * right は 7 - 1 で 6文字目までに "AC" を満たす "A" が存在する件数を数える
  // なぜなら 7 文字目が "A" で 8 文字目が "C" の場合、7文字目の "A" は終端を
  // 超えてしまうため。
  // * 同様に left も 3 - 1 で 2文字目までに "AC" を満たす "A" が存在する件数を数える
  // * これらより、3〜6文字目の中で "AC" を満たす "A" の件数を数える
  //
  // (left, right) = (2, 3) の場合
  // * right は 3 - 1 で 2文字目までの "AC" を満たす "A" が存在する件数を数える
  // * left も 2 - 1 で 1文字目に "AC" を満たす "A" が存在する件数を数える
  // * これらより 2〜2文字目の中で "AC" を満たす "A" の件数を数える
  // * つまり、2文字目が "AC" を満たす "A" であるかどうかを数える
  for (int i = 0; i < Q; i++) {
    int left, right;
    cin >> left >> right;
    cout << (sum.at(right - 1) - sum.at(left - 1)) << endl;
  }

  return 0;
}


Measured memory_bytes: 3836
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,string> tp;
//typedef vector<tp> vt;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
class TreeDP{//c++11
	public:
	struct edge{
		int to,cost;
	};
	int n;
	vi dist;
	vector<vector<edge> >G;
	TreeDP(int size){
		n=size;
		dist=vi(n);
		G=vector<vector<edge> >(n);
	}
	void add_edge(int a,int b,int c){
		edge e={b,c},ee={a,c};
		G[a].pb(e);
		G[b].pb(ee);
	}
	void dfs1(int a,int par){
		for(edge &e:G[a]){
			if(e.to==par)continue;
			dfs1(e.to,a);
			dist[a]=max(dist[a],dist[e.to]+e.cost);
		}
	}
	int dfs2(int a,int d_par,int par){
		vp d_child;
		d_child.pb({0,-1});
		for(edge &e:G[a]){
			if(e.to==par)d_child.pb({d_par+e.cost,e.to});
			else d_child.pb({dist[e.to]+e.cost,e.to});
		}
		sort(d_child.rbegin(),d_child.rend());
		int ret=d_child[0].first+d_child[1].first;
		for(edge &e:G[a]){
			if(e.to==par)continue;
			ret=max(ret,dfs2(e.to,d_child[d_child[0].second==e.to].first,a));
		}
		return ret;
	}
	int dp(){
		dfs1(n/2,-1);
		return dfs2(n/2,0,-1);
	}
};
int main(){
	int n;
	cin>>n;
	TreeDP dp(n);
	rep(i,n-1){
		int a,b,c;
		cin>>a>>b>>c;
		dp.add_edge(a,b,c);
	}
	cout<<dp.dp()<<endl;
}

Measured memory_bytes: 15128
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl a,b,c,d;
    cin >> a >> b >> c;
    cout << min(b/a,c) << endl;
    return 0;
}

Measured memory_bytes: 384
// #pragma GCC optimize(2)
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <sstream>
#include <cstring>
#include <set>
#include <cctype>
#include <bitset>
#define IO                       \
    ios::sync_with_stdio(false); \
    // cin.tie(0);                  \
    // cout.tie(0);
using namespace std;
int dis[8][2] = {0, 1, 1, 0, 0, -1, -1, 0, 1, -1, 1, 1, -1, 1, -1, -1};
typedef unsigned long long ULL;
typedef long long LL;
const int maxn = 1e5 + 10;
const int maxm = 1e6 + 10;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const LL mod = 1e9 + 7;
const double pi = acos(-1);

int main()
{
#ifdef ONLINE_JUDGE
#else
    freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#endif
    IO;
    int n;
    cin >> n;
    if (n == 1)
        cout << 0;
    else
    {
        LL sum = 1;
        for (int i = 0; i < n; i++)
        {
            sum = sum * 10 % mod;
        }
        LL ans = 0;
        LL t = 1;
        for (int i = 0; i < n; i++)
        {
            t = t * 9 % mod;
        }
        t = t * 2 % mod;
        ans = ans + t % mod;
        t = 1;
        for (int i = 0; i < n; i++)
        {
            t = t * 8 % mod;
        }
        ans = ans - t % mod;
        sum = (sum - ans + mod) % mod;
        cout << sum;
    }
    return 0;
}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define fastIO ios::sync_with_stdio(NULL); cin.tie(NULL);

using namespace std;
const int N = 1E7+7;

bitset<N> visited;
int n,k,cnt;

int main()
{
    fastIO
    cin>>n>>k;
    
    for (int i = 1;i <= k;++i)
    {
        int t;
        cin>>t;
        
        for (int i = 1;i <= t;++i)
        {
            int tmp;
            cin>>tmp;
            visited[tmp] = true;
        }
    }
    
    for (int i = 1;i <= n;++i) 
        if (visited[i] == false) ++cnt;
    
    cout<<cnt;
}

Measured memory_bytes: 3652
def read():
    return raw_input().strip()
 
def read_ints():
    return map(int,read().split())
 
n,k = read_ints()
ans = 0
for x in range(1,n+1):
    if (2*x)%k == 0:
        m = (k-x) % k 
        ways = (n-m)/k + 1 
        if m == 0:
            ways -= 1 
        ans += ways*ways 
        
print ans

Measured memory_bytes: 8964
#include<bits/stdc++.h>
#include <iostream>
using namespace std;
const unsigned int M = 1000000007;
int main() {
    int n,m;
    cin>>n>>m;

    vector<vector<char>> matrix(n,vector<char>(m));

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cin>>matrix[i][j];
        }
    }

    int dp[n+1][m+1];
    memset(dp,0,sizeof(dp));

    dp[n-1][m-1]=1;
    for(int i=n-1;i>=0;i--)
    {
        for(int j=m-1;j>=0;j--)
        {
            if(i==n-1 && j==m-1)
            {
                continue;
            }
            if(matrix[i][j]=='#')
            {
                dp[i][j]=0;
            }
            else
            {
                dp[i][j]=(dp[i+1][j]%M+dp[i][j+1]%M)%M;
            }
        }
    }
    cout<<dp[0][0]<<endl;
    return 0;
}


Measured memory_bytes: 8416
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
  int A,B,X;
  cin >> A >> B >> X;
  if ((A != 0) && (B!=0)){
    cout << B/X - (A-1)/X << endl;
    return 0;
  }
  else if(A == 0 && (B != 0)){
    cout << B/X+1 << endl;
    return 0;
  }
    cout << 1 << endl;
}


Measured memory_bytes: 3596
#include <iostream>

using namespace std;

int main(void) {
    const int MAX_W = 100;
    const int MAX_H = 100;
    int W, H, N;
    cin>>W>>H>>N;
    int matrix[W][H];
    for (int i=0; i<H; ++i) {
        for (int j=0; j<W; ++j) {
            matrix[j][i] = 0;
        }
    }

    int x, y, a;
    for (int n=0; n<N; ++n) {
        cin>>x>>y>>a;
        switch (a) {
        case 1:
            for (int i=0; i<H; ++i) {
                for (int j=0; j<x; ++j) {
                    matrix[j][i] = 1;
                }
            }
            break;
        case 2:
            for (int i=0; i<H; ++i) {
                for (int j=x; j<W; ++j) {
                    matrix[j][i] = 1;
                }
            }
            break;
        case 3:
            for (int i=0; i<y; ++i) {
                for (int j=0; j<W; ++j) {
                    matrix[j][i] = 1;
                }
            }
            break;
        case 4:
            for (int i=y; i<H; ++i) {
                for (int j=0; j<W; ++j) {
                    matrix[j][i] = 1;
                }
            }
            break;
        }
    }

    int cnt = 0;
    
    for (int i=0; i<H; ++i) {
        for (int j=0; j<W; ++j) {
            if (matrix[j][i] == 0) {
                cnt += 1;
            }
        }
    }
    cout<<cnt<<endl;
    
    return 0;
}


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

typedef complex<int> P;

int main() {
    int n;
    P p[51][11];
    int m[51];

    while (cin >> n, n) {
        for (int i=0; i<=n; i++) {
            cin >> m[i];
            for (int j=0; j<m[i]; j++) {
                cin >> p[i][j].real() >> p[i][j].imag();
            }
        }

        for (int i=1; i<=n; i++) {
            if (m[0] != m[i]) { continue; }

            bool flag;
            int ox1, oy1, ox2, oy2;

            rep(k,4){
                rep(j,m[0])p[0][j] *= P(0, 1);

                flag = true;
                ox1 = p[0][0].real(); oy1 = p[0][0].imag();
                ox2 = p[i][0].real(); oy2 = p[i][0].imag();
                rep(j,m[0]){
                    if (p[0][j].real() - ox1 != p[i][j].real() - ox2) { flag = false; break; }
                    if (p[0][j].imag() - oy1 != p[i][j].imag() - oy2) { flag = false; break; }
                }
                if (flag) { cout << i << endl; break; }

                flag = true;
                ox1 = p[0][m[0]-1].real(); oy1 = p[0][m[0]-1].imag();
                ox2 = p[i][0].real(); oy2 = p[i][0].imag();
                rep(j,m[0]){
                    if (p[0][m[0]-1-j].real() - ox1 != p[i][j].real() - ox2) { flag = false; break; }
                    if (p[0][m[0]-1-j].imag() - oy1 != p[i][j].imag() - oy2) { flag = false; break; }
                }
                if (flag) { cout << i << endl; break; }
            }
        }
        cout << "+++++" << endl;
    }
}


Measured memory_bytes: 3064
import java.util.ArrayList;
import java.util.Scanner;

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

	int N;
	double x[];
	double y[];
	boolean used[];
	ArrayList<Double> ans = new ArrayList<Double>();

	public void run() {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		x = new double[N];
		y = new double[N];
		for(int i=0; i<N; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
		}
		used = new boolean[N];
		for(int i=0; i<N; i++) {
			for(int j=0; j<N; j++) {
				used[j]=false;
			}
			used[i]=true;
			dfs(i, 0, 0.0);
			used[i]=false;
		}
		double sum = 0.0;
		for(int i=0; i<ans.size(); i++) {
			sum += ans.get(i);
		}
		System.out.println(sum/ans.size());
		sc.close();
	}

	public void dfs(int i, int c, double sum) {

		if(c >= N-1) {
			ans.add(sum);
			return;
		}

		for(int j=0; j<N; j++) {
			if(!used[j]) {
				used[j] = true;
				dfs(j, c+1, sum+dist(i, j));
				used[j] = false;
			}
		}
	}

	public double dist(int i, int j) {
		return Math.sqrt(Math.pow(x[i]-x[j], 2)+Math.pow(y[i]-y[j], 2));
	}
}


Measured memory_bytes: 25832
#include <stdio.h>
#include <string.h>
int main(int argc, const char * argv[]) {

    char p[120], s[120], ss[250];
    scanf("%s %s", s, p);
    strcpy(ss, s);
    strcat(ss, s);
    if (strstr(ss, p)) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	string s, t;
	cin >> s >> t;

	sort(s.begin(), s.end());
	sort(t.rbegin(), t.rend());

	if (s < t) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}

	return 0;

}

Measured memory_bytes: 256
n, k = map(int, input().split())
hs = list(map(int, input().split()))

inf = 10**20
dp = [inf] * n
dp[0] = 0

for i in range(1, n):
    for j in range(i - 1, max(0, i - k) - 1, -1):
        dp[i] = min(dp[j] + abs(hs[i] - hs[j]), dp[i])

print(dp[-1])

Measured memory_bytes: 53472
#include <iostream>

const int MAX = 100000;
const int SENTINEL = 1000000001;

typedef struct
{
    char c;
    int value;
} Card;

void swap(Card &x, Card &y)
{
    Card temp = x;
    x = y;
    y = temp;
}

int partition(Card *array, int p, int r)
{
    int i = p, x = array[r].value;
    for (int j = p; j < r; j++)
    {
        if (array[j].value <= x)
        {
            swap(array[i++], array[j]);
        }
    }
    swap(array[i], array[r]);
    return i;
}

void quickSort(Card *array, int p, int r)
{
    if (r < p + 1)
        return;
    int m = partition(array, p, r-1);
    quickSort(array, p, m);
    quickSort(array, m+1, r);
}

void merge(Card *array, int left, int mid, int right)
{
    int n1 = mid - left, n2 = right - mid, l = 0, r = 0;
    Card L[n1 + 1], R[n2 + 1];
    L[n1].value = R[n2].value = SENTINEL;
    for (int i = left; i < mid; i++)
        L[i - left] = array[i];
    for (int i = mid; i < right; i++)
        R[i - mid] = array[i];
    for (int i = left; i < right; i++)
    {
        if (L[l].value > R[r].value)
            array[i] = R[r++];
        else
            array[i] = L[l++];
    }
}

void mergeSort(Card *array, int left, int right)
{
    if (left + 2 > right)
        return;
    int mid = (left + right) / 2;
    mergeSort(array, left, mid);
    mergeSort(array, mid, right);
    merge(array, left, mid, right);
}

int main()
{
    int n;
    bool stable = true;
    Card array1[MAX], array2[MAX];
    std::cin >> n;
    for (int i = 0; i < n; i++)
    {
        std::cin >> array1[i].c >> array1[i].value;
        array2[i].c = array1[i].c;
        array2[i].value = array1[i].value;
    }
    quickSort(array1, 0, n);
    mergeSort(array2, 0, n);
    for (int i = 0; i < n; i++)
    {
        if (array1[i].c != array2[i].c)
        {
            stable = false;
            break;
        }
    }
    if (stable)
        std::cout << "Stable" << std::endl;
    else
        std::cout << "Not stable" << std::endl;
    for (int i = 0; i < n; i++)
    {
        std::cout << array1[i].c << " " << array1[i].value << std::endl;
    }
    /*
    std::cout << std::endl;
    for (int i = 0; i < n; i++)
    {
        std::cout << array2[i].c << " " << array2[i].value << std::endl;
    }
    */
}



Measured memory_bytes: 5460
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

int main(){
  string s = in<string>();
  if([&](){
       foreach(i,s)if(i=='7')return true;
       return false;
     }()){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	
	ScanInt(scanner)
	M := ScanInt(scanner)
	X := ScanInt(scanner)
	
	l := 0
	r := 0
	for i := 0; i < M; i++ {
	    A := ScanInt(scanner)
	    if A < X {
	        l++
	    } else if A > X {
	        r++
	    }
	}
	fmt.Println(Min(l, r))
}

func ScanInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func ScanFloat64(scanner *bufio.Scanner) float64 {
	scanner.Scan()
	f, e := strconv.ParseFloat(scanner.Text(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func ScanText(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func Max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Abs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}
 

Measured memory_bytes: 640