akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

void BugCheck(const vector<int>&);
bool BugCheckInner(const vector<int>&);

int main(){
  int i, n, h;
  vector<int> data;

  while(1){
    cin >> n;
    if(n == 0) break;

    for(i=0; i<=n; ++i){
      cin >> h;
      data.push_back(h);
    }

    BugCheck(data);
    data.clear();
  }
  return 0;
}

void BugCheck(const vector<int>& data1){
  int i, j;
  vector<int> data2;
  for(i=0; i<data1.size(); ++i){
    for(j=0; j<data1.size(); ++j){
      if(i != j) data2.push_back(data1[j]);
    }

    if(BugCheckInner(data2)){
      cout << data1[i] << endl;
      return;
    }
    data2.clear();
  }
}

bool BugCheckInner(const vector<int>& data){
  int i, a;
  for(i=1, a=data[1]-data[0]; i<data.size(); ++i){
    if(data[i]-data[i-1] != a) return false;
  }
  return true;
}

Measured memory_bytes: 1220
import math
import itertools
n = int(input())
ma = [list(map(int,input().split())) for _ in range(n)]
#print(ma) 
#[[0, 0], [1, 0], [0, 1]]

li = [i for i in range(n)]
kumiawase = list(itertools.permutations(li))
#[(0, 1, 2), (0, 2, 1), (1, 0, 2), (1, 2, 0), (2, 0, 1), (2, 1, 0)]
fin_li = []
kumi_kazu = 0
for k in kumiawase:
    #print(k)
    for i,kk in enumerate(list(k)):
        if i == 0:
            continue
        start = ma[k[i]]
        goal = ma[k[i-1]]
        x = (start[0]-goal[0])**2
        y = (start[1]-goal[1])**2
        fin_li.append(math.sqrt(x+y))
    kumi_kazu += 1
#print(kumiawase)
#print(fin_li)
#print(kumiawase,kumi_kazu)
print(sum(fin_li)/kumi_kazu)

Measured memory_bytes: 56568
#include <bits/stdc++.h>
#include <atcoder/all>

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

using namespace std;
using namespace atcoder;

using ll = long long;
using P = pair<int,int>;
constexpr int INF = 1001001001;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main() {
    int n, q;
    cin >> n >> q;
    
    dsu d(n);
    rep (i, q) {
        int t, u, v;
        cin >> t >> u >> v;
        if (t == 0)
            d.merge(u, v);
        else
            cout << d.same(u, v) << endl;
    }
    
    return 0;
}


Measured memory_bytes: 4068
# -*- coding: utf-8 -*-

N, K = map(int, input().split())
A = list(map(int, input().split()))

sum_a = sum(A)
# dc:Divisor Candidate(割る数の候補)
#dc_list = [x for x in reversed(range(1, sum_a + 1)) if sum_a % x == 0]
dc_list = []
for i in range(1, int(sum_a ** 0.5) + 1):
    if sum_a % i == 0:
        dc_list.append(i)
        if i != sum_a // i:
            dc_list.append(sum_a // i)

dc_list.sort(reverse = True)

for d in dc_list:
    mods = [a % d for a in A]
    mod_sum = sum(mods)
    if mod_sum % d != 0:
        continue
    mods = sorted(mods)

    op = 0
    mod_len = len(mods)
    for i, mod in enumerate(mods):
        op += mod

        if op > K:
            break

        if (mod_len - (i + 1)) * d == mod_sum and op <= K:
            print(d)
            exit(0)


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

using namespace std;

constexpr int64_t modulo = UINT64_C(1000000007);

struct solved_t {
  constexpr solved_t() : answers() {
    int64_t fact = 1;
    answers[0][1] = fact * 2;
    answers[1][1] = fact * 2;
    for (int i = 2; i < 100001; i++) {
      fact *= i;
      fact %= modulo;
      fact *= i;
      fact %= modulo;
      answers[0][i] = (fact * (i + 1)) % modulo;
      answers[1][i] = (fact * 2) % modulo;
    }
  }
  int64_t answers[2][100001];
};
static constexpr solved_t solved{};

int main() {
  int n, m;
  std::cin >> n >> m;
  if (n < m) {
    std::swap(n, m);
  }
  std::cout << (n - m >= 2 ? INT64_C(0) : solved.answers[n == m][m])
            << std::endl;
  return 0;
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define FOR(i, s, e) for (ll(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (ll(i) = (s); (i) > (e); (i)--)
#define debug(x) cout << #x << ": " << x << endl
#define mp make_pair
#define pb push_back
const ll MOD = 1000000007;
const int INF = 1e9;
const ll LINF = 1e16;
const double PI = acos(-1.0);
int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1};
int dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

/* -----  2017/04/29  Problem: ARC 073 A / Link: http://arc073.contest.atcoder.jp/tasks/arc073_a  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

ll N;

ll ans = 0LL;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  ll t;
  cin >> N>>t;
  ll a[200010];

  FOR(i, 0, N) {
	  cin >> a[i];
  }
  a[N] = a[N-1]+t;
  int now = 0;
  FOR(i, 0, N) {
	  if (a[i] + t >= a[i + 1])ans += a[i + 1] - a[i];
	  else ans += t;
  }


  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue> 
 
using namespace std;
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N, K;

	cin >> N >> K;

	int count = 1;

	int num = K;

	while(num - 1 < N) {
		num *= K;
		count++;
	}

	cout << count << endl;
}

Measured memory_bytes: 256
while True:
    c = 0
    ans = 0
    a = int(input())
    left = 0
    right = 0
    if a == 0:
        break
    b = input()
    b = b.split(" ")
    for i in b:
        if i == "lu":
            left = 1
        elif i == "ru":
            right = 1
        elif i == "rd":
            right = 0
        elif i == "ld":
            left = 0
        if left == right:
            if before[0] != i[0]:
                ans = ans + 1
        c = c + 1
        before = i
    print(ans)
    


Measured memory_bytes: 5616
#include<stdio.h>
#include<stdlib.h>

#define WHITE 0
#define GRAY 1
#define BLACK -1

int t = 0;

typedef struct {
  int t1;
  int t2;
  int *v;
  int color;
  int k;
}DP;



void dfs(DP *G, int n){
  int i;
  for(i=0; i<n; i++){
    G[i].color = WHITE;
  }
    for(i=0; i<n; i++){
      if(G[i].color == WHITE){
        visit(G, i);
      }
    }
}

void visit(DP *G, int i){
  int j;
  G[i].color = GRAY;
  G[i].t1 = ++t;
  for(j=0; j<G[i].k; j++){
    //printf("%d\n", G[i].v[j]);
    //printf("%d--------------------\n", G[G[i].v[j]].color);
    if(G[G[i].v[j]-1].color == WHITE){
      visit(G, G[i].v[j]-1);
    }
  }
  G[i].color = BLACK;
  G[i].t2 = ++t;
  return;
}

int main(){

  int n, i, j, u, k, l[100];
  DP *G;

  scanf("%d", &n);
  G = (DP *)malloc(sizeof(DP)*n);

  for(i=0; i<n; i++){
    scanf("%d%d", &u, &k);
    G[u-1].v = (int *)malloc(sizeof(int)*(k+1));
    G[u-1].k = k;
    for(j=0; j<k; j++){
      scanf("%d", &G[u-1].v[j]);
    }
  }

  dfs(G, n);

  for(i=0; i<n; i++){
    printf("%d %d %d\n", i+1, G[i].t1, G[i].t2);
  }

  return 0;
}


Measured memory_bytes: 2056
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        final int N = Integer.parseInt(sc.next());
        long[] ar = new long[N + 1];
        
        out.println(lucasNumber(N, ar));
        
        out.flush();
    }
    
    public static long lucasNumber(int n, long[] memo) {
        memo[0] = 2;
        memo[1] = 1;
        if (memo[n] != 0) return memo[n];
        return memo[n] = lucasNumber(n - 1, memo) + lucasNumber(n - 2, memo);
    }
}

Measured memory_bytes: 21844
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    char op;
        while(true){
        cin >> a >> op >> b;
        if(op == '?'){
            break;
        }
        if(op == '+'){
        cout << (a+b) << endl;
        }
        if(op == '-'){
        cout << (a-b) << endl;
        }
        if(op == '*'){
        cout << (a*b) << endl;
        }
        if(op == '/'){
        cout << (a/b) << endl;
        }
    }
}


Measured memory_bytes: 3080
n=int(input())
S=[]
H=[]
C=[]
D=[]

for i in range(n):
    k,l=input().split()
    l=int(l)
    if k=="S":
        S.append(l)
    if k=="H":
        H.append(l)    
    if k=="C":
        C.append(l)
    if k=="D":
        D.append(l)

for i in range(1,14):
    if not i in S:
        print("S",i)
        
for i in range(1,14):
    if not i in H:
        print("H",i)
        
for i in range(1,14):
    if not i in C:
        print("C",i)

for i in range(1,14):
    if not i in D:
        print("D",i)


Measured memory_bytes: 5612
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  string s;
  cin >> n >> s;
  int l = 0, r = 0;
  rep(i, 0, n) {

    if (i != n - 1 && s[i] == '(' && s[i + 1] == ')')
      i++;
    else {
      if (s[i] == '(')
        r++;
      else {
        if (r > 0)
          r--;
        else
          l++;
      }
    }
  }

  cout << string(l, '(') << s << string(r, ')') << endl;
}


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

int main() {
  char c;
  cin >> c;
  
  if (c == 'a'){
    cout << "vowel" << endl;
  }
  else if (c == 'i'){
    cout << "vowel" << endl;
  }
  else if (c == 'u'){
    cout << "vowel" << endl;
  }
  else if (c == 'e'){
    cout << "vowel" << endl;
  }
  else if (c == 'o'){
    cout << "vowel" << endl;
  }
  else cout << "consonant" << endl;
}


Measured memory_bytes: 256
program main
	implicit none
	character(10) s,t,u
	integer a,b
    
    read(*,*) s,t
    read(*,*) a,b
    read(*,*) u
    
    if(u==s) then
       write(*,'(i0,a,i0)') a-1,' ',b
    else
       write(*,'(i0,a,i0)') a,' ',b-1
    end if
end program main

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#define MAXN (1000000 + 5)
#define pii pair<int, int>
using namespace std;
int n, ans[MAXN];
pii a[MAXN];
int main()
{
//    cout << "Hello world!" << endl;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i].first), a[i].second = i;
	sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; i++)
		ans[a[i].second] = ((i > (n >> 1)) ? a[n >> 1].first : a[(n >> 1) + 1].first);
	for (int i = 1; i <= n; i++)
		printf("%d\n", ans[i]);
    return 0;
}

// 2 4 4 3
// 2 3 4 4


Measured memory_bytes: 7808
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    char a,b;
    cin>>a>>b;
    if(a==b)cout<<"H"<<endl;
    else cout<<"D"<<endl;
}

Measured memory_bytes: 256
import sys
from operator import itemgetter
import math

sys.setrecursionlimit(10**9)
input = sys.stdin.readline

def ii(): return int(input())
def mi(): return map(int, input().split())
def lmi(): return list(map(int, input().split()))
def lmif(n): return [list(map(int, input().split())) for _ in range(n)]
def ss(): return input().split()

def main():
    n, k = mi()

    ans = 0
    for i in range(1, n+1):
        t = 0
        while i < k:
            i *= 2
            t += 1
        ans += 0.5 ** t
    ans /= n
    print(f"{ans:.12f}")
    return

main()


Measured memory_bytes: 9384
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

int countup(vector<pair<int,int>> &AB, int a, int b) {
  int upper = a-1;
  int cnt = 0;
  for (auto p:AB) {
    if (p.second < a || p.first > b) {
      continue;
    }

    if (upper >= min(p.second, b)) {
      continue;
    }

    cnt += min(p.second, b) - max(p.first-1, upper);
    upper = min(p.second, b);
  }

  return cnt;
}

void solve() {
  int N;
  cin >> N;

  vector<int> A, B;
  vector<pair<int,int>> AB;

  for (int i = 0; i < N; i++) {
    int a, b; cin >> a >> b;
    A.push_back(a);
    B.push_back(b);
    AB.emplace_back(a, b);
  }

  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(AB.begin(), AB.end());

  int ap, bp;
  if (N % 2 == 1) {
    ap = A[N/2];
    bp = B[N/2];
    cout << bp-ap+1 << endl;
    return;
  }


  int ans = 0;
  ap = A[N/2-1] + A[N/2];
  bp = B[N/2-1] + B[N/2];
  cout << (bp-ap)+1 << endl;
}

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


Measured memory_bytes: 9420
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String alpha = sc.next();
        String A=alpha.toUpperCase();
        
        if (A.equals(alpha)) {
            System.out.println("A");
        }else{
            System.out.println("a");
        }
        sc.close();
    }
}

Measured memory_bytes: 35464
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    ll M = 1;
    while( N > 0 ){
        if(N / 10 == 0){
            break;
        }
        N /= 10;
        M++;
    }
    return M;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n;
    cin>>n;
    ll x[n][n];
    for(ll i=0;i<n;++i){
        for(ll j=0;j<n;++j){
            x[i][j] = INF;
        }
    }
    for(ll i=0;i<n;++i){
        ll a;
        cin>>a;
        for(ll j=0;j<a;++j){
            ll p, q;
            cin>>p>>q;
            x[i][p-1] = q;
        }
    }

    ll ans = 0;
    for(ll bit=0;bit<(1<<n);++bit){
        vector<ll> s;
        for(ll i=0;i<n;++i){
            if(bit & (1<<i)){
                s.push_back(i);
            }
        }
        ll m = s.size();
        vector<bool> bl(n, false);
        for(ll val : s){
            bl[val] = true;
        }
        bool flag = false;
        for(ll i=0;i<n;++i){
            if(bl[i] == true){
                continue;
            }
            for(ll j=0;j<n;++j){
                if(x[i][j] == INF){
                    continue;
                }else if(x[i][j] == 1 and bl[j] == false){
                    continue;
                }else if(x[i][j] == 0 and bl[j] == true){
                    continue;
                }
                flag = true;
                break;
            }
            if(flag == true){
                break;
            }
        }
        if(flag == true){
            continue;
        }
        ans = max(ans, n - m);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil,pi,factorial
    from operator import itemgetter
    def I(): return int(input())
    def MI(): return map(int, input().split())
    def LI(): return list(map(int, input().split()))
    def LI2(): return [int(input()) for i in range(n)]
    def MXI(): return [[LI()]for i in range(n)]
    def SI(): return input().rstrip()
    def printns(x): print('\n'.join(x))
    def printni(x): print('\n'.join(list(map(str,x))))
    inf = 10**17
    mod = 10**9 + 7
#main code here!
    x,y=MI()
    if x%y==0:
        print(-1)
    else:
        print(x)
        
        



        
        
        
        
        
    
if __name__=="__main__":
    main()



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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()
#define SZ(x) ((int)(x).size())

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; ++i) cin >> vec[i];
    sort(vec.begin(), vec.end());

    int ans = 0;

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < i; ++j) {
            for (int k = 0; k < j; ++k) {
                if (vec[k] != vec[j] and vec[i] != vec[j] and
                    vec[k] + vec[j] > vec[i]) {
                    ans++;
                }
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3616
#include<stdio.h>
#define N 36

struct card{
  char a;
  char b;
};

main(){
  struct card A1[N], A2[N], a;
  int i, j, n, min;
  
  scanf("%d", &n);

  for(i = 0; i < n; i++){
    scanf(" %c%c", &A1[i].a, &A1[i].b);
    A2[i] = A1[i];
  }

  for(i = 0; i < n; i++){
    for(j = n-1; j > i; j--){
      if(A1[j].b < A1[j-1].b){
	a = A1[j];
	A1[j] = A1[j-1];
	A1[j-1] = a;
      }
    }
  }

  for(i = 0; i < n; i++){
    printf("%c%c", A1[i].a, A1[i].b);
    if(i == n-1) break;
    printf(" ");
  }

  printf("\nStable\n");

  for(i = 0; i < n; i++){
    min = i;
    for(j = i; j < n; j++){
      if(A2[j].b < A2[min].b)
	min = j;
    }
    if(A2[i].b != A2[min].b){
      a = A2[i];
      A2[i] = A2[min];
      A2[min] = a;
    }
  }

  for(i = 0; i < n; i++){
    printf("%c%c", A2[i].a, A2[i].b);
    if(i == n-1) break;
    printf(" ");
  }

  for(i = 0; i < n; i++){
    if(A1[i].b == A2[i].b){
      if(A1[i].a == A2[i].a)
	j = 1;
      else {
	j = 0;
	break;
      }
    }
  }

  if(j == 1)
    printf("\nStable\n");
  else printf("\nNot stable\n");

  return 0;
}

Measured memory_bytes: 612
#include <iostream>
#define rep(i,n) for (int i=0; i<(n); i++)
using namespace std;

int main(){
    int n,k,q;
    cin >> n >> k >> q;
    int a[q];
    rep(i,q){
        cin >> a[i];
        a[i]--;
    }
    int score[n];
    rep(i,n) score[i]=k-q;

    for(int i=0; i<q; i++){
        score[a[i]]++;
    }

    for(int i=0; i<n; i++){
        if(score[i]>=1){
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
int n,ans,maxx;
int a[100000+10],shu[100000+10];
void AC()
{
	for(int i=1;i<=maxx;i++)
	{
		if(shu[i]>1)
			ans+=shu[i]-1;
	}
	if(ans%2!=0)ans++;
	cout<<n-ans<<"\n";
	exit(0);
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		shu[a[i]]++;
		if(a[i]>maxx) maxx=a[i];
	}
	AC();
}

Measured memory_bytes: 1024
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

int main(){
    string a,b,c;
    cin>>a>>b>>c;

    int flag=0;//A=0,B=1,C=2
    while(true){
        if(flag==0){
            switch(a[0]){
                case 'a':flag = 0;break;
                case 'b':flag = 1;break;
                case 'c':flag = 2;break;
                default : cout<<"A";return 0;
            }
            a.erase(a.begin());
        }
        else if(flag==1){
            switch(b[0]){
                case 'a':flag = 0;break;
                case 'b':flag = 1;break;
                case 'c':flag = 2;break;
                default : cout<<"B";return 0;
            }
            b.erase(b.begin());
        }
        else{
            switch(c[0]){
                case 'a':flag = 0;break;
                case 'b':flag = 1;break;
                case 'c':flag = 2;break;
                default : cout<<"C";return 0;
            }
            c.erase(c.begin());
        }
    }
}

Measured memory_bytes: 256
io = STDIN
gi =-> {io.gets.split.map(&:to_i)}
n,m = gi[]
ar = gi[].sort
chunk=[0]
m.times do
  if ar.size == 0 || chunk[-1]>=ar[-1]
    a=chunk.pop/2
  else
    a=ar.pop/2
  end
  ix=chunk.bsearch_index{|x|x>=a}
  chunk.insert(ix||1,a)
end
p (chunk+ar).inject(:+)


Measured memory_bytes: 15468
N,x = map(int,input().split())
a_list = [int(i) for i in input().split()]
result = 0
for i in range(N-1):
	if a_list[i] + a_list[i+1] > x:
		result+=a_list[i+1] - (x-a_list[i])
		a_list[i+1] = max(0,x-a_list[i])
print(result)

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

int main() {
    int n,k;
    cin>>n>>k;
    int ans=0;
    int x;
    for (size_t i = 0; i < n; i++)
    {
        cin>>x;
        ans+=std::min(abs(x),abs(k-x));
    }
    cout <<ans*2<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long X = sc.nextLong();
    System.out.println(makeBurger(N,X));
  }




  public static long makeBurger(int N,long X){
    if(N == 0){
      return 1L;
    }else{
      if(X == 1L){
        return 0L;

      }else if(2L <= X && X <= pow(2L,N + 1) - 2L){
        return makeBurger(N - 1,X - 1);

      }else if(X == pow(2L,N + 1) - 1L){
        return pow(2L,N);
       
      }else if(pow(2L,N + 1) <= X && X <= pow(2L,N + 2) - 4L){
        return pow(2L,N) + makeBurger(N - 1,X - pow(2L,N + 1) + 1L);

      }else{
        return pow(2L,N + 1) - 1L;
      }
    }
  }

  public static long pow(long num,int power){
    long number = num;
    for(int i = 0;i < power - 1;i++){
      number *= num;
    }
    return number;
  }
}


Measured memory_bytes: 22996
#include<stdio.h>
int main()
{
	long long  a,b,t;
	scanf("%lld%lld",&a,&b);
	t=((((a+b)>(a-b))?(a+b):(a-b))>(a*b))?(((a+b)>(a-b))?(a+b):(a-b)):(a*b);
	printf("%lld\n",t);
	return 0;
}

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

map <long long, long long> X, Y;
vector <vector <long long>> adjx, adjy;
vector <bool> markx, marky;

pair <long long, long long> dfs(bool f, long long v){
	long long ans[2] = {0, 0};
	ans[f] ++;
	if (!f)
		markx[v] = true;
	else
		marky[v] = true;
	if (!f)
	for (auto u: adjx[v]){
		if (!f && !marky[u]){
			auto Y = dfs(!f, u);
			ans[0] += Y.first;
			ans[1] += Y.second;
		}
		if (f && !markx[u]){
			auto Y = dfs(!f, u);
			ans[0] += Y.first;
			ans[1] += Y.second;
		}
	}
	else
	for (auto u: adjy[v]){
		if (!f && !marky[u]){
			auto Y = dfs(!f, u);
			ans[0] += Y.first;
			ans[1] += Y.second;
		}
		if (f && !markx[u]){
			auto Y = dfs(!f, u);
			ans[0] += Y.first;
			ans[1] += Y.second;
		}
	}
	return {ans[0], ans[1]};
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	long long n;
	cin >> n;
	long long tx = 1, ty = 1;
	for (long long i = 0; i < n; i++){
		long long v, u;
		cin >> v >> u;
		if (X[v] == 0){
			X[v] = tx;
			adjx.push_back({});
			tx ++;
		}
		if (Y[u] == 0){
			Y[u] = ty;
			ty ++;
			adjy.push_back({});
		}
		adjx[X[v] - 1].push_back(Y[u] - 1);
		adjy[Y[u] - 1].push_back(X[v] - 1);
	}
	markx.resize(tx - 1);
	marky.resize(ty - 1);
	long long ans = 0;
	for (long long i = 0; i < tx - 1; i++){
		if (!markx[i]){
			auto Y = dfs(0, i);
			ans += Y.first * Y.second;
		}
	}
	cout << ans - n;
}

Measured memory_bytes: 18152
#include <stdio.h>
#include <stdlib.h>

typedef struct _Bar {
	int h;
	int p;
	int q;
} Bar;

int
main(void)
{

	char line[80];
	int n;
	int m;
	int a;

	Bar b[1000];

	while (true) {
		if (fgets(line, sizeof line, stdin) == NULL) {
			return 1;
		}
		if (sscanf(line, "%d %d %d", &n, &m, &a) != 3) {
			return 1;
		}

		if (n == 0 && m == 0 && a == 0) {
			break;
		}

		for (int i = 0; i < m; i++) {
			if (fgets(line, sizeof line, stdin) == NULL) {
				return 1;
			}
			if (sscanf(line, "%d %d %d",
					   &(b[i].h), &(b[i].p), &(b[i].q)) != 3) {
				return 1;
			}
		}
		
		qsort(b, m, sizeof (Bar),
			  	[](const void* a, const void* b) -> int {
					return (((Bar*)b)->h -((Bar*)a)->h);
				});

		for (int i = 0; i < m; i++) {
			if (b[i].p == a) {
				a = b[i].q;
			} else if (b[i].q == a) {
				a = b[i].p;
			}
		}
		printf("%d\n", a);
	}

	return 0;
}

Measured memory_bytes: 1088
#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<map>
#include<string>
#include<vector>
 
#define mx(ans, cnt) ans = max(ans, cnt)
#define fauto(a) for(auto i : a) cout << i << " "; cout << endl;
#define sp(n) fixed << setprecision(n)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define _ << " " <<
#define swp(x, y) if (x > y) swap(x, y);
#define swpg(x, y) if (x < y) swap(x, y);
#define ff first
#define ss second
#define xx first
#define yy second
#define pb push_back
#define nn end1
 
 
using ll = long long;
using ull = unsigned long long;
using namespace std;
int main ()
{
    ll n,i,j,c=0;
    vector<ll> v;
    cin>>n;
    for(i=0;i<n-1;i++)
    {ll q; cin>>q; v.pb(q);}
    if(n==2)
    {cout<<2*v[0]<<endl;}
    else
    {
        c=c+v[0];
        c=c+v[n-2];
        for(i=0;i<n-2;i++)
        {c=c+min(v[i+1],v[i]);}
        cout<<c<<endl;
    }
    return 0;
}

Measured memory_bytes: 3588
S = input()
T = input()

for i in range(len(S)-len(T),-1,-1):
  flag = True
  j = 0
  while (j<len(T)):
    if S[i+j] == '?' or S[i+j] == T[j]:
      j += 1
    else:
      flag = False
      break
  if flag:
    S = list(S)
    for j in range(len(T)):
      S[i+j] = T[j]
    print(''.join(S).replace('?','a'))
    exit()
print('UNRESTORABLE')


Measured memory_bytes: 38384
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))

n, k = map(int, input().split())
ans = [0 for _ in range(n)]
for _ in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for x in a:
        ans[x - 1] += 1
cnt = 0
for x in ans:
    if x == 0: cnt += 1
print(cnt)

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

using namespace std;

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


int main() {
    int N;
    cin>>N;
    string s;
    cin>>s;
    vector<vector<long long > > sums(3,vector<long long>(N,0));
    for(int c=0;c<s.size();c++) {
        if(c>0) {
            for(int c2=0;c2<3;c2++) {
                sums[c2][c] += sums[c2][c-1];
            }
        }
        if(s[c] == 'R') sums[0][c] ++;
        if(s[c] == 'G') sums[1][c] ++;
        if(s[c] == 'B') sums[2][c] ++;

    }

    long long res = 0;

    for(int c=s.size()-1;c>=1;c--) {
        for(int c2=c-1;c2>=1;c2--) {
            if(s[c] == s[c2]) continue;
            int target = 0;
            char car = '0';
            if(s[c] != 'R' && s[c2] != 'R'){
                target = 0;
                car='R';
            }
            if(s[c] != 'G' && s[c2] != 'G'){
                target = 1;
                car='G';
            }
            if(s[c] != 'B' && s[c2] != 'B'){
                target = 2;
                car='B';
            }
            res += sums[target][c2-1];
            int badOne = c2-(c-c2);
            if(badOne >= 0 && badOne < c2) {
                if(s[badOne] == car) res--;
            }
        }
    }
    cout<<res;
}


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

const int N = 200005;
int a[N];
ll b[N];
ll t[N];

int main(void)
{
    int n;
    scanf("%d", &n);

    for (int i = 1; i <= n; ++i)
    {
        scanf("%d", &a[i]);
        ++t[a[i]];
    }

    for (int i = 1; i <= n; ++i)
    {
        b[a[i]] = t[a[i]] * (t[a[i]] - 1) / 2;
    }

    ll sum = 0;
    for (int i = 1; i <= n; ++i)
        sum += b[i];

    for (int i = 1; i <= n; ++i)
    {
        printf("%lld\n", sum - t[a[i]] + 1);
    }
    return (0);
}

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

long result = 0;
int n;

long Calc(string str)
{
    int n = str.size();
    long res = 0;
    long now = 0;

    for (int i = 0; i < n; i++)
    {
        char c = str.at(i);

        //cout << c << " ";

        if (c == '+')
        {
            res += now;
            now = 0;
        }
        else
        {
            int number = (int)c - 48;
            //cout << number<<" ";
            now = now * 10 + (number);
            //cout << now << "  ";
            //cout << now << endl;
            if (i == n - 1)
                res += now;
        }

        
    }
    //cout << res << endl;
    return res;
}

void Make(char c[], string& str, int i)
{
    if (i == n)
    {
        result += Calc(str);
        return;
    }
    else if (i == 0)
    {
        str.push_back(c[i]);
        Make(c, str, i + 1);
    }
    else
    {
        for (int j = 0; j < 2; j++)
        {
            if (j == 0)
            {
                str.push_back(c[i]);
                Make(c, str, i + 1);
                str.pop_back();
            }
            else
            {
                str.push_back('+');
                str.push_back(c[i]);
                Make(c, str, i + 1);
                str.pop_back();
                str.pop_back();
            }
        }
    }
}


int main()
{
    string s;
    cin >> s;
    n = s.size();
    char* c = new char[n];
    for (int i = 0; i < n; i++)
        c[i] = { ' ' };

    for (int i = 0; i < n; i++)
    {
        c[i] = s.at(i);
    }

    string str;
    Make(c, str, 0);

    cout << result << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
string str;
ll n, s;
int main(void){
    // Your code here!
    cin >> n;
    str = to_string(n);
    for (ll i = 0; i < str.length(); i++) {
        s += str[i] - '0';
    }
    if (n % s) cout << "No" << endl;
    else cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<tuple<string, int, int>> a;
    for(int i = 1; i <= n; i++){
        string s;
        int p;
        cin >> s >> p;
        p = -p;
        a.push_back(tie(s,p,i));
    }
    sort(a.begin(), a.end());
    for(int i = 0; i < n; i++){
        cout << get<2>(a[i]) << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#include <time.h>
#include <random>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int i = a; i <= (b); ++i) 
#define mREP(a,b) for (int i = a; i == (b); --i) 
typedef long long ll;
using namespace std;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
/*
	　　　  　 ,ﾍ／L──- 、
	　　　   　Lﾆ)r_」=＝= ｲ
	　　 　,ﾍ、i ﾉノλﾉﾊﾉﾍ
	　　   ,'　｀(ﾊﾘ ﾟ ヮﾟﾉi)　',
	　　 .i　　 >〈(つ,i!と)　　i
	　　  vﾍγk´_/___i,ゝﾍノ
	　　　　　 ｀ﾞr_,ｨ_ｧﾞ´
*/
int n;
cin >> n;
long double a, b;
int ans = 0;
long double nownear = 99121213;
cin >> a >> b;
vector<long double>H(n);
rep0(i, n - 1)cin >> H[i];
rep0(j, n - 1){
	if (nownear  > abs(b - (a - (H[j] * 0.006)))) {
		nownear = abs(b - (a - (H[j] * 0.006)));
		ans = j + 1;
	}
	
}
cout << ans << endl;
return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <unordered_map>
#include <map>
#include <string>
using namespace std;

int main()
{
	string tmp;
	cin >> tmp;
	if (tmp[2] == tmp[3] && tmp[4] == tmp[5])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

}

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

//関数
int ue(int x){
    if(x%10==0){
        return x;
    }else{
        return (x/10 +1)*10;
    }
}
int sita(int x){
    if(x%10==0){
        return 0;
    }else{
        return 10-(x%10);
    }
}
//main関数
int main() {
    
    
    
    //入力
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    
    
    
    //計算
    
    //出力
    cout<<ue(a)+ue(b)+ue(c)+ue(d)+ue(e)- max(sita(a),max(sita(b),max(sita(c),max(sita(d),sita(e)))))<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstdio>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <set>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> P;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
const int MAXN = 100000;
const int MAXE = 100000;
const int MAXV = 10000;
const int inf = 1e9;
const ll INF = 2e18;
const ll MOD = 1e9 + 7;

struct UnionFind{
    vector<int> par,rank;
    UnionFind(int n):par(n),rank(n){
        for(int i=0;i<n;++i) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        int rx=root(x),ry=root(y);
        if(rx==ry) return ;
        if(rank[ry]>rank[rx]) par[rx]=ry;
        else par[ry]=rx;
        if(rank[rx]==rank[ry]) rank[rx]++;
    }
    bool same(int x,int y){
        return root(x)==root(y);
    }
};

vector<ll> fac,inv,finv;

void initcom(){
    fac=inv=finv=vector<ll>(1e6);
    fac[0]=fac[1]=1;
    inv[1]=1;
    finv[0]=finv[1]=1;
    for(ll i=2;i<1e6;++i){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}

ll com(int n,int k){
    if(n<0||k<0) return 0;
    if(n<k) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll x,ll y){
    if(y==0) return x;
    return gcd(y,x%y);
}
ll mopow(ll a,ll x,ll mod){
    ll res=1;
    while(x>0){
        if(x&1) res=res*a%mod;
        a=a*a%mod;
        x>>=1;
    }
    return res;
}

int main(){
    int n,x,t;cin>>n>>x>>t;
    cout<<t*((n+x-1)/x)<<endl;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
     
    using namespace std;
     
    unsigned long long f(unsigned long long n){
        unsigned long long ans = (n + 1) * (n / 2);
        if(n % 2 == 1){
            ans += (n + 1) / 2;
        }
        return ans;
    }
     
    int main()
    {
        int X, x = 0, ans = 0;
        cin >> X;
        vector <int> v;
        int sum = 0, t = 0;
     
        unsigned long long l = 1, r = 1000000000, midd, last;
        while(1){
            midd = (l + r) / 2;
            if(X < f(midd)){
                r = midd - 1;
                last = midd;
            }
            else if(X > f(midd)){
                l = midd + 1;
            }
            else{
                ans = midd;
                cout << ans;
                return 0;
                break;
            }
            if(l > r){
                ans = last;
                break;
            }
        }
        cout << last;
        return 0;
    }

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
using ll = long long;
const ll mod = 1000000007;
const ll infi = 1000000000000000;
const ll md = 998244353;
using namespace std;
using vl = vector<ll>;
using pll =  pair<ll,ll>;


void  solve(){
    ll a,b,sq;
    cin>>a>>b;
    sq = sqrt(min(a,b));
    vl fact;
    for(int i=1;i<=sq;i++){
        if(a%i==0&&b%i==0){
            fact.push_back(i);
        }
        if(i!=sq&&a%i==0&&a%(a/i)==0&&b%(a/i)==0){
            fact.push_back(a/i);
        }
        if(i!=sq&&b%i==0&&a%(b/i)==0&&b%(b/i)==0){
            fact.push_back(b/i);
        }
    }
    sort(fact.begin(),fact.end());
   // for(int i=0;i<fact.size();i++) cout<<fact[i]<<" ";
    for(int i=1;i<fact.size();i++){
        //cout<<fact[i]<<" ";
        for(int j=i+1;j<fact.size();j++){
            if(fact[i] == -1)break;
            if(fact[j]%fact[i]==0) { fact[j] =-1;}
        }
    }
    //cout<<endl;
    int cnt=0;
    for(int i=0;i<fact.size();i++){
        //cout<<fact[i]<<" ";
        if(fact[i] !=-1) cnt++;
    }
    cout<<cnt;
}
        
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //int n; cin>>n; for(int i=0;i<n;i++)
        solve();
    return 0;
}

Measured memory_bytes: 512
from collections import deque
from itertools import groupby
N = int(input())
S = input()

B = [len(list(x[1])) for x in groupby(S)]

q = deque(B)
if S[0] == 'R':
    q.popleft()
if S[-1] == 'W':
    q.pop()

ans = 0
while q:
    if len(q) == 1:
        break
    l, r = q.popleft(), q.pop()
    if l == r:
        if len(q) >= 2:
            q.popleft()
            q.pop()
        ans += l
    elif l < r:
        if len(q):
            q.popleft()
            q.append(r-l)
        ans += l
    else:
        if len(q):
            q.pop()
        q.appendleft(l-r)
        ans += r

print(ans)


Measured memory_bytes: 10932
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace At
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadInts();
            if (input[0] + input[1] == input[2]) WriteLine("Yes");
            else if (input[1] + input[2] == input[0]) WriteLine("Yes");
            else if (input[2] + input[0] == input[1]) WriteLine("Yes");
            else WriteLine("No");

        }
       

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        //最大公約数
        public static int Gcd(int a, int b)
        {
            if (a < b)
            {
                return Gcd(b, a);
            }
            while (b != 0)
            {
                var reminder = a % b;
                a = b;
                b = reminder;
            }
            return a;
        }

        //最小公倍数
        public static int Lcm(int a, int b)
        {
            return a * b / Gcd(a, b);
        }

    }
}


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

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			long n = long.Parse(Console.ReadLine());

			long length = long.MaxValue;

			for (long i = 1; i <= Math.Sqrt(n); i++)
			{
				if (n % i == 0)
				{
					if (n / i + i - 2 < length) length = n / i + i - 2;
				}
			}

			Console.WriteLine(length);

			return;
		}
	}

}


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

int main(void)
{
  int n = 0;
  std::cin >> n;
  std::vector<std::pair<int, int>> placeList;
  placeList.reserve(n);
  int x = 0;
  int y = 0;
  double sum = 0.0;
  for(int count = 0; n > count; ++count)
  {
    std::cin >> x >> y;
    for(const std::pair<int, int>& place : placeList)
    {
      sum += std::sqrt(std::pow(place.first - x, 2.0) + std::pow(place.second - y, 2.0));
    }
    placeList.emplace_back(x, y);
  }
  printf("%f", sum / static_cast<double>(n) * 2.0);
}

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

int main() {
  int X, N, d, S;
  cin >> X;
  N = X;
  
  for (int i = 0; i < 9; i++) {
    if (N != 0) {
      d = N % 10;
      N /= 10;
      S += d;
    }    
    else {
      break;
    }
  }
  
  if (X % S == 0) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3584
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int N_MAX = 100000;
int main()
{
  string s,t;
  cin >> s >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end(),greater<char>());
  if(s<t)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <cstdio>
int N, M, a[500][500];
int main()
{
	scanf("%d%d", &N, &M);
	for (int i = 0; i < N; i++)
	{
		static char _i[501];
		scanf("%s", _i);
		for (int j = 0; j < M; j++)
			a[i][j] = _i[j] == '#';
	}
	for (int i = 0; i < N; puts(""), i++)
		for (int j = 0; j < M; j++)
			putchar(a[i][j] || (j == 0 || !(i & 1)) && j != M - 1 ? '#' : '.');
	puts("");
	for (int i = 0; i < N; puts(""), i++)
		for (int j = 0; j < M; j++)
			putchar(a[i][j] || (j == M - 1 || (i & 1)) && j != 0 ? '#' : '.');
	return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+10;
int n,q[N],h=1,t=0;
char a[N],b[N];
int main() {
    cin>>n;
    scanf("%s%s",a+1,b+1);
    if(!strcmp(a+1,b+1)) return puts("0"),0;
    int ans=0;
    for(int i=n,pos=n;i;i--) {
        if(b[i]==b[i-1]) continue;
        pos=min(pos,i);
        while(pos&&a[pos]!=b[i]) pos--;
        if(!pos) return puts("-1"),0;
        while(h<=t&&q[h]-t+h>i) h++;
        if(pos!=i) q[++t]=pos;
        ans=max(ans,t-h+1);
    }
    printf("%d\n",ans+1);
    return 0;
}


Measured memory_bytes: 6144
N,M = map(int,input().split())
A = []
B = []
for i in range(N):
    line = input()
    A.append(line)
for j in range(M):
    line = input()
    B.append(line)
res = 0
for i in range(N-M+1):
    for j in range(N-M+1):
        counter = 0
        for k in range(M):
            if B[k] != A[k+j][i:i+M]:
                break
            counter +=1
        if counter == M:
            res +=1
if res >=1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define rep(i, o) for (ll i = 0; i < (o);i++)
#define rep_s(i, o) for (int i = 1; i <= (o);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
#define NUM 1e5

typedef long long ll;
typedef unsigned long long ull;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll c, ll d) { return c / gcd(c, d) * d; }


template<class T>
bool chmax(T &a, const T &b) { if (a < b) { return b; } return a; }

template<class T>
bool chmin(T &a, const T &b) { if (a > b) { a = b; return a; } return a; }

int main() {
    ll n, k; cin >> n >> k;
    vector<ll> a(n), c(n);
    rep(i, n) { 
        cin >> a[i];
    }
    sort(a.begin(), a.end());

    ll cnt = 1; 
    rep(i, n) { 
        if (a[i] == a[i+1]) cnt++;
        else
        {
            /* code */
            c.push_back(cnt);
            cnt = 1;
        }
    }
    sort(c.begin(), c.end(), greater<ll>());

    // rep(i, n) { 
    //     cout << c[i] << endl;
    // }
    ll ans;
    ans = 0; ll prev = 20000000; ll i = 0;
    rep (i, n)
    {
        if (i >= k) ans += c[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5760
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner  sc = new Scanner(System.in);
int[][][] house  = new int[4][3][10];
int n = sc.nextInt();

for(int i = 0;i < n;i++){
  int b = sc.nextInt();
  int f = sc.nextInt();
  int r = sc.nextInt();
  int v = sc.nextInt();
  house[b-1][f-1][r-1] += v;
}//mainLoop

for(int i = 0;i < 4;i++ ){
  for(int j = 0;j < 3;j++){
    for(int k = 0 ;k < 10;k++){
      System.out.print(" ");
System.out.print(house[i][j][k]);
    }
    System.out.println("");
  }
  if(i != 3){
  System.out.println("####################");
}else{

}
}



  }//main

}//class


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

#define pb  push_back
#define ll  long long
#define INF 0x3f3f3f3f
#define pii pair<int, int>
#define ull unsigned long long int

const int t = 100005;
bool vis[t];
vector<int> grafo[t];
vector<int> rec;

void dfs(int x) {
    vis[x] = true;
    for (int v: grafo[x]) {
        if (!vis[v])
            dfs(v);
    }
    rec.pb(x);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m;
    int a, b;
    int ans = 0;
    
    cin >> n >> m;
    vector<int> dp(n + 1, 0);
    
    while (m--) {
        cin >> a >> b;
        grafo[a].pb(b);
    }
    for (int i = 1; i <= n; i++) {
        if (!vis[i])
            dfs(i);
    }
    for (int x: rec) {
        for (int v: grafo[x]) {
            dp[x] = max(dp[x], dp[v] + 1);
        }
        ans = max(ans, dp[x]);
    }
    cout << ans << "\n";
    
    //cerr << "\n" << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    return 0;
}

Measured memory_bytes: 8956
#include <bits/stdc++.h>
using namespace std;
#define EPS                 0.00000001
#define LL_MAX              1e18
#define LL_MIN              -1e18
#define MAX                 0x3f3f3f3f
#define MIN                 -0x3f3f3f3f
#define MOD                 1000000007
#define DEBUG(x)            cout << '>' << #x << ':' << x << endl;
#define REP(i,n)            for(int i=0;i<(n);i++)
#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 n1                  '\n'

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef complex<ld> pt;
typedef vector<pt> pol;

ll power(ll b, int e) {
    ll res = 1;
    for ( ; e>0; e/=2) {
        if (e&1) res = res*b % MOD;
        b = b*b % MOD;
    }
    return res;
}

inline void IOS() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

int main()
{
    IOS();
    int n, k;
    cin >> n >> k;
    vector<int> arr(n);
    REP(i, n) {
        cin >> arr[i];
    }
    vector<int> dp(n, MAX);
    dp[0] = 0;
    FOR(i, 1, n-1) {
        FOR(j, max(0, i-k), i-1) {
            dp[i] = min(dp[i], abs(arr[i] - arr[j]) + dp[j]);
        }
    }
    cout << dp[n-1] << n1;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>


 int main(){
 int H,W,i,j;
 while(1){
 scanf("%d %d",&H ,&W);
 if(H==0&&W==0){break;};
 for(i=1;i<=H;i++){
 for(j=1;j<=W;j++){printf("#");
 };
 printf("\n");};
 printf("\n");
 }
 return 0;}



Measured memory_bytes: 2044