akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1LL << 60;

struct res{
    string name;
    int score;
    int num;
}res_res[101];

bool comp(res a,res b){
    if(a.name != b.name){
        return a.name < b.name;
    }
    else{
        return a.score>b.score;
    }
}

int main() {

    int N;
    cin >> N;

    rep(i,N){
        cin >> res_res[i].name >> res_res[i].score;
        res_res[i].num = i+1;
    }

    sort(res_res,res_res+N,comp);

    rep(i,N){
        cout << res_res[i].num << endl;
    }

    // vector<pair<std::string,int>> vec;

    // int N;
    // cin >> N;

    // rep(i,N){
    //     string tmps;
    //     int tmpp;
    //     cin >> tmps >> tmpp;

    //     pair<std::string,int> p = make_pair(tmps,tmpp);

    //     vec.emplace_back(p);
    // }

    // sort(vec.begin(),vec.end());

    // for (auto V : vec) {
    //     cout << V.first << " " << V.second << endl;
    // }

}

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

int main() {
    string s;
    cin >>s;
    rep(i, (int)s.size()){
        cout << 'x';
    }
    cout << endl;
}

Measured memory_bytes: 384
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[allow(unused_macros)]
macro_rules ! vec_md { ( $ init : expr ; $ ( $ dim : expr ) ;* ) => { vec_md ! ( $ ( $ dim ) ;* => $ init ) } ; ( $ head : expr ; $ ( $ tail : expr ) ;* => $ init : expr ) => { vec ! [ vec_md ! ( $ ( $ tail ) ;* => $ init ) ; $ head ] } ; ( $ head : expr => $ init : expr ) => { vec ! [ $ init ; $ head ] } ; }

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

    let mut dp = vec_md![None;n;n];
    for i in 0..n {
        dp[i][i] = Some(0u64);
    }
    let cum = Cum::new(&a);
    println!("{}", rec(&mut dp, &cum, 0, n-1));
}

fn rec(dp: &mut Vec<Vec<Option<u64>>>, c: &Cum, l: usize, r: usize) -> u64 {
    if let Some(src) = dp[l][r] {
        return src;
    }

    let mut ret = 1u64 << 60;
    for i in l..r {
        ret = std::cmp::min(
            ret,
            rec(dp,c,l,i) + rec(dp,c,i+1,r)
        );
    }
    ret += c.sum(l,r+1);
    dp[l][r] = Some(ret);
    ret
}

#[derive(Debug)]
#[allow(dead_code)]
struct Cum {
    s: Vec<u64>,
}
#[allow(dead_code)]
impl Cum {
    fn new(a: &Vec<u64>) -> Cum {
        let mut s = vec![0; a.len() + 1];
        for i in 0..a.len() {
            s[i + 1] = s[i] + a[i];
        }
        Cum { s: s }
    }
    #[doc = " [l,r)"]
    fn sum(&self, l: usize, r: usize) -> u64 {
        self.s[r] - self.s[l]
    }
}

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

using namespace std;

int main() {
    int n;
    scanf("%d", &n);
    int d1, d2, ct = 0;
    for (int i = 0; i < n; ++i) {
        scanf("%d%d", &d1, &d2);
        if (d1 == d2) {
            ++ct;
            if (ct == 3) {
                break;
            }
        } else {
            ct = 0;
        }
    }
    if (ct == 3) {
        puts("Yes");
    } else {
        puts("No");
    }
    return 0;
}

Measured memory_bytes: 3720
N, K = map(int, input().split())
Sunuke = [0]*N
for _ in range(K):
  d = int(input())
  A = list(map(int, input().split()))
  for a in A:
    Sunuke[a-1] += 1

ans = 0
for s in Sunuke:
  if s == 0:
     ans += 1
print(ans)


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

vector<string> split_naive(const string &s, char delim) {
	vector<string> elems;
	string item;
	for(char ch:s){
		if(ch==delim){
			if(!item.empty()) elems.push_back(item);
			item.clear();
		}
		else{
			item += ch;
		}
	}
	if(!item.empty()) elems.push_back(item);
	return elems;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	while(true){
		vector<vector<int>> T(8,vector<int>(8));
		int LX=10,RX=-1,TY=10,BY=-1;
		REP(i,8){
			string S;
			if(!(cin>>S)){
				return 0;
			}
			REP(j,8){
				T[i][j] = S[j]-'0';
				if(T[i][j]){
					LX = min(LX,j);
					RX = max(RX,j);
					TY = min(TY,i);
					BY = max(BY,i);
				}
			}
		}
		if(RX-LX==1 && BY-TY==1){
			out('A');
		}
		else if(RX-LX==0 && BY-TY==3){
			out('B');
		}
		else if(RX-LX==3 && BY-TY==0){
			out('C');
		}
		else if(RX-LX==1 && BY-TY==2){
			if(T[TY][LX]) out('F');
			else out('D');
		}
		else{
			if(T[TY][LX]) out('E');
			else out('G');
		}
	}
	
	return 0;
}


Measured memory_bytes: 3108
from sys import exit
import math
import collections
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

o = input()
e = input()
for i in range(len(e)):
    print(o[i] + e[i] ,end = "")
if len(o) != len(e):
    print(o[-1])
else:
    print()

Measured memory_bytes: 9336
#include<cstdio>
int n,m,nn,mm,i,j;
void put(int x){if (x>9) put(x/10);putchar(x%10+48);}
void write(int x){if (x<0) putchar('-'),x=-x;put(x);}
int main(){
	scanf("%d%d%d%d",&n,&m,&nn,&mm);
	if (n%nn==0&&m%mm==0){puts("No");return 0;}
	puts("Yes");
	int v=(1e9-1)/(nn*mm-1),k=-(nn*mm-1)*v-1;
	for (i=1;i<=n;i++,putchar('\n')) for (j=1;j<=m;j++)
		write(i%nn||j%mm?v:k),putchar(' ');
}

Measured memory_bytes: 2816
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;
namespace AtCoder
{
    class AC
    {
        const int MOD = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;
        const double EPS = 1e-8;
        static readonly int[] dx = { 0, 1, 0, -1 };
        static readonly int[] dy = { 1, 0, -1, 0 };

        static List<List<Edge>> G = new List<List<Edge>>();
        static bool[] seen;
        static long[] dis;
        
        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();

            var p = cin.SplitRead();

            int N = p[0];
            int M = p[1];
            if (M == 0) { Console.WriteLine("Yes");
                return;
            }


            for (var i = 0; i < N; i++) G.Add(new List<Edge>());
            seen = new bool[N];
            dis = new long[N];
            Initialize(ref seen, false);
            Initialize(ref dis, 0);

            for(var i = 0; i < M; i++)
            {
                var x = cin.SplitReadL();

                int L = (int)x[0] - 1;
                int R = (int)x[1] - 1;
                long D = x[2];

                G[L].Add(new Edge(R, D));
                G[R].Add(new Edge(L, -D));
            }


            
            for(var i = 0; i < N; i++)
            {
                if (!seen[i]) Dfs(i);
            }

            Console.WriteLine("Yes");
            
            

            //Console.Out.Flush();
        }
        struct Edge
        {
            //int _from;
            public int _to;
            public long _dist;

            public Edge(int R,long d)
            {
                _to = R;
                _dist = d;
            }
        }
        static public void Dfs(int node)
        {
            seen[node] = true;
            foreach(var e in G[node])
            {
                if (seen[e._to])
                {
                    if (dis[e._to] != dis[node] + e._dist)
                    {
                        Console.WriteLine("No");
                        Environment.Exit(0);
                    }
                    continue;
                }

                dis[e._to] = dis[node] + e._dist;
                Dfs(e._to);
            }

        }
            
    }
    

    public class Scanner
    {
        public int[] SplitRead()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReadL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }

    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
    }
}


Measured memory_bytes: 46172
#include<stdio.h>

char testcheck(int intermediate_test, int termend_exam, int retest){
    //1:attendance 2:absence
    int score = intermediate_test + termend_exam;
    if (intermediate_test == -1 || termend_exam == -1)
    {
        return 'F';
    }
    else if(score < 30){
        return 'F';
    }else if(score < 50){
        if(retest < 50){
            return 'D';
        }else{
            return 'C';
        }
    }else if(score < 65){
        return 'C';
    }else if(score < 80){
        return 'B';
    }else{
        return 'A';
    }
}

int main(void){
    int intermediate_test, termend_exam, retest;
    while(1){
        scanf("%d %d %d", &intermediate_test, &termend_exam, &retest);
        if (intermediate_test == -1 && termend_exam == -1){
            break;
        }
        printf("%c\n", testcheck(intermediate_test, termend_exam, retest));
    }
}


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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<int, int> P;
struct Edge{ll from, to, cost;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

ll N, M, K;
ll p[100100];
map<ll, ll> num;
ll q[100100];

void con(ll a, ll b){
  ll atmp=a, btmp=b;
  ll cnta=1, cntb=1;
  while(atmp!=p[atmp]){
    atmp = p[atmp];
    cnta++;
  }
  while(btmp!=p[btmp]){
    btmp = p[btmp];
    cntb++;
  }
  if(atmp==btmp)return;
  ll rt;
  if(cnta>cntb){
    rt=atmp;
  }else{
    rt=btmp;
  }
  num[rt]=num[atmp]+num[btmp];
  p[btmp]=rt;
  p[atmp]=rt;
  p[a]=rt;
  p[b]=rt;
  return;
}

ll root(ll a){
  ll atmp=a;
  while(p[atmp]!=atmp){
    atmp = p[atmp];
  }
  p[a]=atmp;
  return atmp;
}

bool iscon(ll a, ll b){
  ll atmp, btmp;
  while(atmp!=p[atmp]){
    atmp = p[atmp];
  }
  p[a]=atmp;
  while(btmp!=p[btmp]){
    btmp = p[btmp];
  }
  p[b]=btmp;
  return atmp==btmp;
} 
  
/**************************************
** A main function starts from here  **
***************************************/
int main(){
  cin >> N >> M >> K;
  rep(i, N){
    num[i]=1;
    p[i]=i;
  }
  
  llvec a(M, 0), b(M, 0);
  rep(i, M){
    cin >> a[i] >> b[i];
    a[i]--;b[i]--;
  }

  llvec c(K, 0), d(K, 0);
  rep(i, K){
    cin >> c[i] >> d[i];
    c[i]--;d[i]--;
  }

  rep(i, M){
    q[a[i]]++;q[b[i]]++;
    con(a[i],b[i]);
  }

  rep(i, K){
    if(root(c[i])==root(d[i])){
      q[c[i]]++; q[d[i]]++;
    }
  }
  
  rep(i, N){
    cout << num[root(i)] - q[i] - 1<< " ";
    //cout << num[root(i)] << " " << q[i] << " "<<num[root(i)]-q[i]-1 << endl;
  }
 
  return 0;
}


Measured memory_bytes: 11776
//#include "pch.h"
//#include "stdafx.h"
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <cstring>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define INF				2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define MIN(a, b)		((a) < (b) ? a : b)
#define MAX(a, b)		((a) > (b) ? a : b)
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)		/* 奇数 */
#define IsEven(x)		(!IsOdd((x)))					/* 偶数 */
#define ArrayLength(x)	(sizeof(x) / sizeof(x[0]))
#define DWORD_MAX		(0xFFFFFFFF)

typedef short SWORD;
typedef unsigned short WORD;
typedef long SDWORD;
typedef unsigned long DWORD;
typedef long long int QWORD;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
QWORD w[100];
QWORD v[100];
QWORD memo[100 + 1][100000 + 1];
int N, W;

/* 再起 */
QWORD solve(QWORD i, QWORD remainWeight)
{
	QWORD retVal;

	if (N <= i) {
		return 0;
	}

	if (0 < memo[i][remainWeight]) {
		return memo[i][remainWeight];
	}

	if (remainWeight < w[i]) {
		retVal = solve(i + 1, remainWeight);
	} else {
		retVal = MAX(solve(i + 1, remainWeight), solve(i + 1, remainWeight - w[i]) + v[i]);
	}

	memo[i][remainWeight] = retVal;
	return retVal;
}

/* メイン */
int main()
{
	cin >> N >> W;
	REP(x, N) cin >> w[x] >> v[x];
	REP(x, ArrayLength(memo)) REP(y, ArrayLength(memo[0])) memo[x][y] = -1;

	cout << solve(0, W);
	cout << endl;
	return 0;
}



Measured memory_bytes: 79232
program codechef;
  
  type coordonata=record
        
       y,x:integer;
     
         end;
  var n,c,i,j,m:byte;
     a,b:array[1..50] of coordonata; 
     min:integer;
begin
  read(n,m);
  for i:=1 to n do read(a[i].x,a[i].y);
  for i:=1 to m do read(b[i].x,b[i].y);
  
  for i:=1 to n do begin
  min:=abs(b[1].x-a[i].x)+abs(b[1].y-a[i].y);
     c:=1;
    for j:=2 to m do 
     if min> abs(b[j].x-a[i].x)+abs(b[j].y-a[i].y) then begin c:=j; min:=abs(b[j].x-a[i].x)+abs(b[j].y-a[i].y);
     end;
     writeln(c);
     end;
    end.

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

using namespace std;

int main()
{
    int n, v[22], c[22], cs1, cs2, sol=-1000000;
    cin >> n;
    for(int i=0;i<n;i++) cin >> v[i];
    for(int i=0;i<n;i++) cin >> c[i];
    for(int i=0;i<(1<<n);i++){
        cs1 = cs2 = 0;
        for(int j=0;j<n;j++){
            if(i&(1<<j)){
                cs1+=v[j];
                cs2+=c[j];
            }
        }
        sol = max(sol, cs1-cs2);
    }
    cout << sol;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    ll n;
    cin >> n;
    vector<ll> l(n);

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

    ll ans = 0;

    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            for (int k = j + 1; k < n; k++)
            {
                if (l[i] + l[j] > l[k] && l[i] + l[k] > l[j] && l[j] + l[k] > l[i] && l[i] != l[j] && l[j] != l[k] && l[k] != l[i])
                {
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;
}


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

using namespace std;
typedef long long ll;

const int N = 4010;
char s[N];
ll cnt[4][4][4];

int main() {
    int n;
    scanf("%d", &n);
    scanf("%s", s + 1);
    map<char, int> idx = {{'R', 0},
                          {'G', 1},
                          {'B', 2}};
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        int c = idx[s[i]];
        cnt[c][3][3]++;
        for (int j = 0; j < 3; j++) {
            if (j == c) continue;
            cnt[j][c][3] += cnt[j][3][3];
            cnt[3 - c - j][j][c] += cnt[3 - c - j][j][3];
        }
        for (int k = 1; i - 2 * k >= 1; k++)
            if (s[i - k] != s[i] && s[i - 2 * k] != s[i] && s[i - k] != s[i - 2 * k]) ans--;
    }
    for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) if (i != j) ans += cnt[3 - i - j][i][j];
    printf("%lld\n", ans);
}


Measured memory_bytes: 3788
import numpy as np

H,W,K = list(map(int,input().split()))

arr = np.empty((H,W))

count = 0


for i in range(H):
    str_list = list(input())
    str_list_replaced1 = [s.replace("#","1") for s in str_list]
    str_list_replaced2 = [s.replace(".","0") for s in str_list_replaced1]
    arr[i:] = np.array(str_list_replaced2)


for i in range(2**H):
    for j in range(2**W):
        mask = np.zeros(shape=(H,W))
        mask_i_tmp = [int(k) for k in format(i,"06b")][-H:]
        mask_j_tmp = [int(k) for k in format(j,"06b")][-W:]

        mask_i = mask + np.expand_dims(np.array(mask_i_tmp),-1)
        mask_j = mask + np.expand_dims(np.array(mask_j_tmp),-1).T
        masked_arr = arr.astype(bool) & mask_i.astype(bool) & mask_j.astype(bool)

        
        if np.sum(masked_arr) == K:
            count += 1 

print(count)


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

using namespace std;

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

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

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

  int n, d, x;
  cin >> n >> d >> x;

  int sum = 0;
  rep(i, n) {
    int a;
    cin >> a;
    int cnt = 0;
    for (int i = 1; i <= d; i += a) ++cnt;
    sum += cnt;
  }

  cout << sum + x << "\n";

  return 0;
}


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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

using namespace std;
using P = pair<int, int>;

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; }

const int INF = 1e9;
const int INFLL = 1e18;
const int MOD = 1e9 + 7;

signed main(){
    int e;
    while( cin >> e, e ){
        int ans = INF;
        for( int y = 0; y * y <= e; y++ ){
            for( int z = 0; z * z * z <= e; z++ ){
                int x = e - y * y - z * z * z;
                if( x >= 0 ) chmin( ans, x + y + z );
            }
        }

        cout << ans << endl;
    }
}



Measured memory_bytes: 3076
N=int(input())
p=list(map(int,input().split()))

res = 0
flag=0
for i in range(N):
    if flag == 1:
        res += 1
        flag = 0
    else:
        if p[i] == i+1:
            flag = 1

if flag ==1:
    res += 1

print(res)

Measured memory_bytes: 14008
#include <stdio.h>
int main (){
	int n, A = 1;
	scanf("%d", &n);
	char s[n + 1];
	scanf("%s", s);
	if(n % 2 == 1){
		A = 0;
	}else{
		int temp = (n / 2) + 1;
		for(int i = 0 ; i < n / 2 ;i++){
			if(s[i] != s[i + (n / 2)]){
				A = 0;
				break;
			}
		}
	}
	if(A == 1){
		printf ("Yes");
	}else{
		printf ("No");
	}
	return 0;
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rbf(a, x) for (auto& a : x)
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define drep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define Maxe(x) *max_element(all(x))
#define Mine(x) *min_element(all(x))
#define Size(x) ((ll)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
#define Fi first
#define Se second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo
//mint,dijkstra,gyakugen

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll n,k;
        cin>>n>>k;
        vl p(n);
        rep(i,n)cin>>p[i];
        sort(all(p));
        ll res=0;
        rep(i,k)res+=p[i];
        cout<<res<<endl;
    }

Measured memory_bytes: 3648
s = sorted(set(input()))
for i in range(len(s)):
    if ord(s[i]) != ord("a")+i:
        ans = chr(ord(s[i])-1)
        break
    ans = chr(ord(s[-1]) + 1)
if len(s) == 26:
    ans = "None"
print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main() {
    long long N , K,option1,option2;
    cin  >> N >> K;
    option1 = N%K;
    option2 = abs(option1-K);
    if (option1<option2) cout << option1;
    else cout << option2 ;
}


Measured memory_bytes: 256
import numpy as np


def main(n, w, items):
    dp = np.zeros((n + 1, w + 1), dtype=int)
    for i in range(1, n + 1):
        weight, value = items[i - 1]
        dp[i][:weight] = dp[i - 1][:weight]
        dp[i][weight:] = np.maximum(dp[i - 1][weight:], dp[i - 1][:w - weight + 1] + value)
    return dp[n][w]


if __name__ == '__main__':
    N, W = map(int, input().split())
    I = []
    for _ in range(N):
        I.append(tuple(map(int, input().split())))
    print(main(N, W, I))


Measured memory_bytes: 92068
/*
*/

//#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd

#define eps 1e-8
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 600031;

long long x,y,ans,t;

int main(){
//	freopen("apache.in","r",stdin);
//	freopen("apache.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
//	cin.tie(0);

	ans=-1;

	cin>>x>>y;

	for (int t=1;t<=1000000;t++){
		long long here=1ll*x*t;
		if (here%y)
			ans=here;
	}
	cout<<ans<<endl;

//	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 764
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
#include<bitset>
#include<cstdlib>
// #include<deque>
// #include<multiset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

const int N = 1e5;
std::vector<std::vector<pair<int, int>>> g;
int n;
int used[N];
int col[N];

void dfs(int i, int c) {
  if(used[i]) return;
  used[i] = 1;
  col[i] = c;
  for(auto to : g[i]) {
    dfs(to.first, c ^ to.second);
  }
}

int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  cin >> n;
  g.resize(n);
  for(int i = 0; i < n - 1; i++) {
    int a, b, c; std::cin >> a >> b >> c;
    a--; b--;
    c &= 1;
    g[a].emplace_back(b, c);
    g[b].emplace_back(a, c);
  }
  dfs(0, 0);
  for(int i = 0; i < n; i++) cout << col[i] << "\n";
  cout << flush;
  return 0;
}


Measured memory_bytes: 7808
# 2019/04/13
# AtCoder Beginner Contest 124 - D

# Input
n, k = map(int,input().split())
s = input()
bgnl = list()
endr = list()

bgnl.append(0)
endr.append(0)

seqflg = False

# Search for begin 1
for i in range(n):
    if s[i] == "0":
        if seqflg == True and i > 0:
            endr.append(i-1)
            seqflg = False
    elif s[i] == "1" and seqflg == False:
        bgnl.append(i)
        seqflg = True

if s[n-1] == "1":
    endr.append(n-1)

bgnl.append(n-1)
endr.append(n-1)

max = 0
if len(bgnl) >= k:
    for j in range(0, len(bgnl)-k):
        pcnt = endr[j+k] - bgnl[j] + 1
#        if j == 0 or j+k == n:
#            pcnt -= 1
#        print(pcnt, endr[j+k], bgnl[j])
        if max < pcnt:
            max = pcnt
    ans = max

else:
    ans = n
    
#print(bgnl)
#print(endr)

# Output
print(ans)

Measured memory_bytes: 7172
#include <bits/stdc++.h>
using namespace std;
 //Compiler version g++ 6.3.0
int main()
{
    int N, M;
    string s;
    map<string, int> m;
    
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> s;
        m[s]++;
    }
    cin >> M;
    for (int i = 0; i < M; i++) {
        cin >> s;
        m[s]--;
    }
    
    int ans = 0;
    for (auto i = m.begin(); i != m.end(); i++) {
        ans = max(i->second, ans);
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        long N = cin.nextLong();
        long min = -1;
        for (int i = 0; i < 5; i++)
        {
            long tmp = cin.nextLong();
            if (min == -1 || tmp < min)
            {
                min = tmp;
            }
        }

        if (N % min == 0)
        {
            Console.WriteLine(5 + N / min - 1);
        }
        else
        {
            Console.WriteLine(5 + N / min);
        }
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }

    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}

Measured memory_bytes: 13140
using System;
using System.Collections.Generic;
using System.Text;

namespace CSharpTest
{
    class D_Floor
    {
        static void Main(string[] args)
        {
            string[] ABN = Console.ReadLine().Split();
            Int64 A = Int64.Parse(ABN[0]);
            Int64 B = Int64.Parse(ABN[1]);
            Int64 N = Int64.Parse(ABN[2]);
            if(N < B)
            {
                double Core = (double)N / (double)B;
                double Fraction = Core - Math.Floor(Core);
                Console.WriteLine(Math.Floor(Fraction * A));
            }
            else
            {
                double Core = (double)(B - 1) / (double)B;
                double Fraction = Core - Math.Floor(Core);
                Console.WriteLine(Math.Floor(Fraction * A));
            }
        }
    }
}


Measured memory_bytes: 27600
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
  int a[100000] = {0}, ai, sum[100000] = {0};
  int N;

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

  for(int i = 0;i < 100000-2;i++){
    sum[i] = a[i] + a[i+1] + a[i+2];
  }

  sort(sum, sum+100000, std::greater<int>());

  cout << sum[0] << endl;

  return 0;
}


Measured memory_bytes: 1024
s = raw_input().strip()
k = input()

n = len(s)

ans = 0

if n == 1:
    print k / 2
    exit()

if n == 2:
    if s[0] != s[1]:
        print 0
    else:
        print k

    exit()

# case 1: s[0] = s[n - 1]
if s[0] == s[n - 1]:
    prev = n - 1

    suff = 0
    ridx = 0
    for i in xrange(n - 1, -1, -1):
        if s[i] == s[prev]: suff += 1
        else: break

        prev = i
        ridx = i

    if suff == n:
        print (n * k) // 2
        exit()

    pref = 0
    prev = 0
    lidx = 0
    for i in xrange(n):
        if s[i] == s[prev]: pref += 1
        else: break

        prev = i
        lidx = i

    left = pref
    mid = pref + suff
    right = suff

    ans = (left // 2) + (mid // 2) * (k - 1) + (right // 2)

    prev = lidx + 1
    sz = 0
    for i in xrange(lidx + 1, ridx):
        if s[i] == s[prev]: sz += 1
        else:
            ans += ((sz // 2) * k)
            sz = 1

        prev = i

    if (sz > 1):
        ans += ((sz // 2) * k)
        sz = 0

    print ans
    exit()
else:
    ans = 0
    sz = 0
    prev = 0
    for i in xrange(n):
        if s[i] == s[prev]:
            sz += 1
        else:
            ans += (sz // 2)
            sz = 1
            
        prev = i

    ans += (sz // 2)
    sz = 0

    ans *= k

    print ans
    exit()

Measured memory_bytes: 28524
#include<bits/stdc++.h>
using namespace std;
#define lli long long int  

int main()
{
	lli x,n,t;
	cin>>x>>n>>t;
	lli z;
	z=x/n;
	if(x%n!=0)
	z++;
	cout<<z*t;
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int n,m;
  cin >> n >> m;
  vector<long long int> ans(n+1);
  if (m==0){
    ans[0] = 1;
    ans[1]=1;
    for (int i=2; i<=n;i++){
      ans[i] = ans[i-1] + ans[i-2];
      ans[i] = ans[i] % 1000000007;
    }
    cout << ans[n]%1000000007 << endl;
    return 0;
  }
  vector<int> a(m);
  for (int i=0; i<m; i++){
    cin >> a[i];
  }
  int atenji=0;
  ans[0] = 1;
  if (1==a[atenji]){
    ans[1]=0;
    atenji++;
    atenji = atenji > m-1 ? atenji - 1 : atenji;
  }
  else ans[1]=1;
  for (int i=2; i<=n;i++){
    if(i==a[atenji]){
      atenji++;
      atenji = atenji > m-1 ? atenji - 1 : atenji;
      ans[i] = 0;
      continue;
    }
    else {
      ans[i] = ans[i-1] + ans[i-2];
    }
    ans[i] = ans[i] % 1000000007;
  }
  cout << ans[n]%1000000007 << endl;
}

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

int main(){
  int n, m, num, mini, index = 0;
  int a[51], b[51], c[51], d[51];
  cin >> n >> m;
  for(int i = 0; i < n; i++){
    cin >> a[i] >> b[i];
  }
  for(int i = 0; i < m; i++){
    cin >> c[i] >> d[i];
  }

  for(int i = 0; i < n; i++){
    mini = 999999999;
    for(int j = 0; j < m; j++){
      num = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      if(mini > num){
        mini = num;
        index = j;
      }
    }
    cout << index + 1 << endl;
  }
}


Measured memory_bytes: 256
H,W = map(int,input().split())

A = [list(input()) for _ in range(H)]

memo = {}
for a in A:
    for ai in a:
        if ai in memo:
            memo[ai] += 1
        else:
            memo[ai] = 1
            
mod0 = []
mod1_3 = []
mod2 = []
for key, value in memo.items():
    if value % 4 == 0:
        mod0.append(key)
    elif value % 4 == 2:
        mod2.append(key)
    else:
        mod1_3.append(key)

if W % 2 == 0 and H % 2 == 0:
    if len(mod1_3) > 0 or len(mod2) > 0:
        print("No")
    else:
        print("Yes")

elif W % 2 == 0 or H % 2 == 0:
    if H % 2 == 0:
        W, H = H, W
 
    if W // 2 < len(mod2):
        print("No")
    elif len(mod1_3) > 0:
        print("No")
    else:
        print("Yes")

else:
    if len(mod1_3) == 1 and len(mod2) <= H // 2 + W // 2:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 65392
q = int(input())
lr = [list(map(int,input().split())) for _ in range(q)]

def sieve(n):
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False

    for i in range(2, n+1):
        if is_prime[i-1]:
            j = 2 * i
            while j <= n:
                is_prime[j-1] = False
                j += i
    table = [i for i in range(1, n+1) if is_prime[i-1]]
    return is_prime, table

like = []
sieve1 = sieve(10**5)[1]
is_prime = sieve(10**5)[0]

for i in sieve1[1:]:
    if is_prime[(i+1) // 2-1]:
        like.append(i)

li = [0] * (10**5 + 10)

for i in like:
    li[i] = 1

for i in range(len(li) - 1):
    li[i+1] += li[i]

for l,r in lr:
    print(li[r] - li[l-1])


Measured memory_bytes: 32376
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		String s = sc.next();
		String[] S = s.split("");
		String tmp =s.substring(k-1, k).toLowerCase() ;
		S[k-1] = tmp;
		for(int i = 0; i < n; i++) {
			System.out.print(S[i]);
		}
		System.out.println();
		sc.close();
	}
}


Measured memory_bytes: 21204
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <list>

using namespace std;

static const int MAX = 10000;
static const int WHITE = 0;
static const int BLACK  =2;

vector<int> G[MAX];                     //隣接リスト G[i]にはi番目の頂点から向かう頂点が格納されている
int colors[MAX] = {WHITE};              //色
int inDegrees[MAX] = {0};               //入次数
list<int> orders;                        //頂点の順番格納

void bfs(int v);

//トポロジカルソート
void topologicalSort(int vNumber){

    //色と入次数の初期化
    for(int i=0;i<vNumber;i++){
        colors[i] = WHITE;
        inDegrees[i] = 0;
    }

    //inDegreeをそれぞれ格納
    for(int i=0;i<vNumber;i++){
        for(int j=0;j<G[i].size();j++){
            int v = G[i][j];
            inDegrees[v]++;
        }
    }


    //各頂点から行う
    for(int i=0;i<vNumber;i++){

        //すでに順番が決まっていない
        //かつ、入次数がゼロの場合
        if(colors[i] != BLACK  &&  inDegrees[i]  == 0){
            bfs(i);
        }
    }

}

//幅優先探索
void bfs(int v){

    //順番確定
    colors[v] = BLACK;

    //頂点vを含む集合の更新
    queue<int> Q;
    Q.push(v);

    while(!Q.empty()){
        int u = Q.front(); Q.pop();
        orders.push_back(u);


        for(int i=0;i<G[u].size();i++){
            //辺の削除
            int to = G[u][i];
            inDegrees[to]--;

            //uからの向かう頂点が浮いていた場合
            if(inDegrees[to] == 0 && colors[to] !=BLACK){
                colors[to] = BLACK;
                Q.push(to);
            }
        }
    }

}

void print(){
    for(auto it=orders.begin(); it!= orders.end();it++){
        printf("%d\n",*it);
    }
}

int main() {

    int V; scanf("%d", &V);
    int E; scanf("%d", &E);

    int s, t;
    for(int i=0;i<E;i++){
        scanf("%d %d", &s, &t);
        G[s].push_back(t);
    }

    topologicalSort(V);

    print();

    return 0;
}


Measured memory_bytes: 4220
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long

signed main(){
    string S,T;
    cin>>S>>T;
    sort(S.begin(),S.end());
    sort(T.rbegin(),T.rend());
    if(S<T) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
//#pragma GCC optimize("no-stack-protector,fast-math")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<ll, ll> pll;
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define debugp(x) cerr<<#x<<"= {"<<(x.first)<<", "<<(x.second)<<"}"<<endl;
#define debug2(x, y) cerr<<"{"<<#x<<", "<<#y<<"} = {"<<(x)<<", "<<(y)<<"}"<<endl;
#define debugv(v) cerr<<#v<<" : ";for (auto x:v) cerr<<x<<' ';cerr<<endl;
#define all(x) x.begin(), x.end()
#define pb push_back
#define kill(x) return cout<<x<<'\n', 0;

const ld eps=1e-7;
const int inf=1000000010;
const ll INF=10000000000000010LL;
const int mod = 998244353;
const int MAXN = 1000010, LOG=20;

ll n, m, k, u, v, x, y, t, a, b, ans;
ll A[MAXN];
ll dp[MAXN];
//short mob[MAXN];

ll powmod(ll a, ll b){
	if (!b) return 1;
	if (b&1) return a*powmod(a*a%mod, b>>1)%mod;
	return powmod(a*a%mod, b>>1);
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	//mob[1]=1;
	//for (int i=1; i<MAXN; i++) for (int j=i+i; j<MAXN; j+=i) mob[j]-=mob[i];
	cin>>n;
	while (n--) cin>>x, ans-=x, A[x]+=x;
	for (int i=1; i<MAXN; i++){
		for (int j=i+i; j<MAXN; j+=i) A[i]+=A[j];
		A[i]%=mod;
	}
	
	for (int i=MAXN-1; i; i--){
		dp[i]=A[i]*A[i]%mod;
		for (int j=i+i; j<MAXN; j+=i) dp[i]-=dp[j];
		dp[i]%=mod;
		ans+=dp[i]*powmod(i, mod-2)%mod;
	}
	
	ans%=mod;
	//debug(ans)
	ans=ans*powmod(2, mod-2)%mod;
	if (ans<0) ans+=mod;
	cout<<ans<<'\n';
	
	return 0;
}


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

int N, T, ans, minv = mod, maxg = 0;

int main()
{
    cin >> N >> T;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        if (A[i] <= minv) //min
            minv = A[i];
        if (maxg < A[i] - minv) //sale
        {
            maxg = A[i] - minv;
            ans = 1;
        }
        else if (maxg == A[i] - minv)
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
using System;

namespace ABC082B
{
    class Program
    {
        static void Main(string[] args)
        {
            var a1 = Console.ReadLine().ToCharArray();
            var  b1 = Console.ReadLine().ToCharArray();
            Array.Sort(a1); Array.Sort(b1); Array.Reverse(b1);
            string  a2 = new string(a1); string  b2 = new string(b1); 
            if(string.Compare(a2,b2) < 0){
                Console.WriteLine("Yes");
            } else{
                Console.WriteLine("No");
            }
//                Console.WriteLine("{0} {1}", a2, b2);
//                Console.WriteLine("{0} {1}", a2.ToString(), b2.ToString());
        }
    }
}


Measured memory_bytes: 13536
#include <iostream>
#include <string>
#include <vector>
using namespace std;
void solve(){
     int H, W;
    cin >> H >> W;
    vector<string> S(H);
    for(int i = 0; i < H; ++i){
        cin >> S[i];
    }
    int *pzero = new int(0);
    vector<vector<int*>> sj(H, vector<int*>(W, pzero));
    for(int i = 0; i < H; ++i){
        int j = 0;
        while(j < W){
            if(S[i][j] == '.'){
            int *psum = new int(0);
                while(j < W && S[i][j] == '.'){
                    sj[i][j] = psum;
                    (*psum)++;
                    j++;
                }
            }
            j++;
        }
    }
    vector<vector<int*>> si(H, vector<int*>(W, pzero));
    for(int j = 0; j < W; ++j){
        int i = 0;
        while(i < H){
            if(S[i][j] == '.'){
            int *psum = new int(0);
                while(i < H && S[i][j] == '.'){
                    si[i][j] = psum;
                    (*psum)++;
                    i++;
                }
            }
            i++;
        }
    }
    int max = 0;
    for(int i = 0; i < H; ++i){
        for(int j = 0; j < W; ++j){
            int t = *si[i][j] + *sj[i][j] - 1;
            if(max < t) max = t;
        }
    }
    cout << max;
}
int main(){
    solve();
    return 0;
}

Measured memory_bytes: 123648
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;

const int N = (int) 1e6 + 6, mod = (int) 0;
int n, h, see[N], par[N], deg[N], has0[N], has1[N], mark[N];
vector<int> adj[N];
int find(int x) { return x == par[x] ? x : par[x] = find(par[x]); }
void unite(int u, int v) {
	u = find(u);
	v = find(v);
	par[u] = v;
}
void add_edge(int x, int y) {
	deg[x]--;
	deg[y]++;
	mark[x] = mark[y] = 1;
	unite(x, y);
	adj[x].push_back(y);
}
void dfs(int v) {
	if (see[v]++) return;
	for (int u : adj[v])
		dfs(u);
}

int main() {
	for (int v = 0; v < N; ++v) par[v] = v;
	cin >> n >> h;
	for (int j = 0; j < n; ++j) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		int x, y;
		if (c == 0) {
			x = a;
		} else {
			x = h + 1 + c;	
		}
		if (d == 0) {
			y = h + 1 + b;
		} else {
			y = d;
		}
//		cout << x << ' ' << y << endl;
		add_edge(x, y);
	}
	int m = h + 1 + h + 1;
	for (int x = 0; x < m; ++x) {
		if (deg[x] < 0) {
			dfs(x);
		}
	}
	for (int x = 0; x < m; ++x)
		if (mark[x] && !see[x]) {
			cout << "NO\n";
			return 0;
		}
/*	for (int x = 0; x < m; ++x) {
		for (int y = 0; y < m; ++y) {
			if (deg[x] && deg[y] && find(x) != find(y)) {
				cout << "NO\n";
				return 0;
			}
		}
	} */
	int odd0 = 0;
	int odd1 = 0;
	for (int x = 0; x <= h; ++x) {
	//	odd0 += (deg[x] == -1);
		if (deg[x] > 0) {
			cout << "NO\n";
			return 0;
		}
	}
	for (int x = h + 1; x < m; ++x)  {
	//	odd1 += (deg[x] == 1);
		if (deg[x] < 0) {
			cout << "NO\n";
			return 0;
		}
	}
	if (odd0 != odd1) {
		cout << "NO\n";
		return 0;
	}
	cout << "YES\n";
	
}






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

int main() {
    int64_t K, N; cin >> K >> N;
    vector<int64_t> A(N), B(N);
    rep(i, N){
        cin >> A.at(i);
    }
    rep(i, N - 1){
        B.at(i) = A.at(i + 1) - A.at(i);
    }
    B.at(N - 1) = K - A.at(N - 1) + A.at(0);
    
    cout << K - *max_element(B.begin(), B.end()) << endl;
}


Measured memory_bytes: 3456
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    int n;
    cin >> n;
    vector<string> S;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        S.push_back(s);
    }

    auto cmp = [&](const string& l, const string& r) {
        if (l.length() == r.length()) {
            return l < r;
        }
        return l.length() < r.length();
    };
    sort(S.begin(), S.end(), cmp);

    const long long P = 1e9 + 7;
    const long long Q = 941083981;
    set<pair<int,int>> M;
    vector<int> cnts(26, 0);
    long long res = 0;

    set<string> M2;
    for (auto& s : S) {
        for (auto c : s) {
            ++cnts[c - 'a'];
        }
        for (char ch = 'a'; ch <= 'z'; ++ch) {
            if (cnts[ch - 'a'] > 0) {
                string t;
                t += ch;
                if (M2.count(t) > 0) {
                    ++res;
                }
            }
        }
        int n = s.length();
        // string t;
        long long H1 = 0, H2 = 0;
        for (int i = n - 1; i >= 0; --i) {
            // t += s[i];
            --cnts[s[i] - 'a'];
            H1 = ((H1 * 347) + s[i]) % P;
            H2 = ((H2 * 259) + s[i]) % Q;

            for (char ch = 'a'; ch <= 'z'; ++ch) {
                if (cnts[ch - 'a'] > 0) {
                    // t += ch;
                    auto H11 = ((H1 * 347) + ch) % P;
                    auto H22 = ((H2 * 259) + ch) % Q;
                    if (M.count(make_pair(H11, H22)) > 0) {
                        ++res;
                    }
                    // t.pop_back();
                }
            }
        }

        M.insert(make_pair(H1, H2));
        M2.insert(s);
    }
    
    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 34436