akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;


#define reps(i,f,n) for(int i=f;i<int(n);i++)
#define rep(i,n) reps(i,0,n)

typedef pair<int,int> pii;

#define x first
#define y second

class UF{
public:
  vector<pii> per;
  void init(int n){
    per = vector<pii>(n+1);
    rep(i,per.size()){
      per[i].x = i;
      per[i].y=0;
    }
  }

  int find(int a){
    if(per[a].x == a)return a;

    int ret = find(per[a].x);
    per[a].y += per[per[a].x].y;
    per[a].x = ret;
    return ret;
  }

  void uni(int a, int b, int dist){
    int s = find(a);
    int t = find(b);

    if(s==t)return;//assert(0);

    int c = per[b].y - per[a].y;
    per[t].x = s;
    per[t].y = -(c+dist);
  }

  bool same(int a, int b){
    return find(a)==find(b);
  }

  void print(){
    reps(i,1,per.size())printf("(%d,%d) ",per[i].x,per[i].y);puts("");
  }

};


UF uf;
int n,m;

bool input(){
  cin>>n>>m;
  return n!=0;
}

void uni(int a, int b, int c){
  uf.uni(a,b,c);
}

string itostr(int n){
  stringstream s;
  s<<n;
  return s.str();
}

string compare(int a, int b){
  if(!uf.same(a,b))return "UNKNOWN";
  int ans = -(uf.per[b].y - uf.per[a].y);
  return itostr(ans);
}

void solve(){
  uf.init(n);

  rep(i,m){
    char ch;
    int a,b,c;

    cin>>ch;
    if(ch=='!'){
      cin>>a>>b>>c;
      uni(a,b,c);
    }else{
      cin>>a>>b;
      cout<<compare(a,b)<<endl;
    }
    //uf.print();
  }
}


int main(){
  while(input())solve();
}

Measured memory_bytes: 3580
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N);
    rep(i,N) cin >> A[i];
    rep(i,N) cin >> B[i];
    rep(i,N) cin >> C[i];

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());
    
    vector<long long> count_B(N);
    long long count = 0;
    for (int i = N - 1; i >= 0; i--) {
        auto iter = upper_bound(C.begin(), C.end(), B[i]);
        int index = distance(C.begin(), iter);
        count += C.size() - index;
        count_B[i] = count;
    }

    long long ans = 0;

    rep(i,N) {
        auto iter = upper_bound(B.begin(), B.end(), A[i]);
        int index = distance(B.begin(), iter);
        if (index < B.size()) ans += count_B[index];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repA(i,a,b) for(int i=a;i<=b;i++)
#define repD(i,b,a) for(int i=b;i>=a;i--)
#define fill(a) memset(a,0,sizeof(a))
#define f first
#define s second
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
int main()
{
    int n;
    cin>>n;
    string str;
    set<string>s;
    rep(i,0,n){
        cin>>str;
        s.insert(str);
    }
    cout<<s.size()<<endl;
}



Measured memory_bytes: 19228
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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 (b<a) { a = b; return 1; } return 0; }

constexpr int MAX_N = 86;
long memo[MAX_N] = {2, 1};
long lucas(int n) {
  if (memo[n] != 0) return memo[n];
  return memo[n] = lucas(n-1) + lucas(n-2);
}

void _main() {
  int N;
  cin >> N;
  cout << lucas(N) << "\n";
}

Measured memory_bytes: 256
# dfsか？
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
rr = range


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols
    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])
    return ret


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_map_as_int(H):
    '''
    #→1,.→0として読み込む
    '''
    ret = []
    for _ in range(H):
        ret.append([1 if s == '#' else 0 for s in read()[:-1]])
        # 内包表記はpypyでは若干遅いことに注意
        # #numpy使うだろうからこれを残しておくけど
    return ret


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right
from fractions import gcd


def lcm(a, b):
    # 最小公倍数
    g = gcd(a, b)
    return a * b // g


K = read_a_int()

# bfsで全探索したほうが良くない？
cnt = 0

candi = set()


def dfs(now: int):  # 上の桁からやってく
    if len(str(now)) >= 11:
        return
    candi.add(now)
    right = now % 10  # 下一桁
    # 探索
    if right == 0:
        tmp = [right, right + 1]
    elif right == 9:
        tmp = [right - 1, right]
    else:
        tmp = [right - 1, right, right + 1]
    for ad in tmp:
        dfs(now * 10 + ad)


# print(sorted(candi))
for i in range(1, 10):
    dfs(i)
print(sorted(candi)[K - 1])


Measured memory_bytes: 120024
use std::io::*;
use std::str::FromStr;

// 入力関数
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect(("failed to parse token"))
}

fn main() {
    let id : String = read();   //iteratorのchars()
    let new_id : String = read();

    let mut succeed:bool = false;
    //idのイテレーターを最後まで調べる
    //start_with()は入れた文字列で開始するか:bool
    if new_id.starts_with(&id) {
        if new_id.len() == id.len() + 1{
            succeed = true
        }
    }

    if succeed {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 2072
//#define NDEBUG
#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <thread>
#include <mutex>
#include <iomanip>
#include <cassert>

#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define INF(a) memset(a, 0x3f, sizeof(a))
#define ALL(t) (t).begin(),(t).end()
#define FILL(a,c) fill(a, a+ sizeof(a)/sizeof(*a),c)
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
#define REP(i,m) for(int i=0;i<(m);++i)
// closed interval, inverse repeat
#define CIREP(i,start,fin) for(int i=(start);i>=(fin);i--)
#define CREP(i,start,fin) for(int i=(start);i<=(fin);i++)
#define RNG(i,start,fin) for(int i=(start);i<(fin);i++)
#define IN(a, x, b) (a<=x && x<b)
#define PB push_back
#define SZ(x) (int)(x).size()

using namespace std;

using LL = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<LL,LL>;
using VI = vector<int>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VVI = vector<VI>;
const LL LINF = 1001002003004005006ll;
/* 
template<typename T>inline istream& operator>>(istream&i,vector<T>&v)
{REP(j,SZ(v))i>>v[j];return i;}

template<typename T>string join(const vector<T>&v)
{stringstream s;REP(i,SZ(v))s<<' '<<v[i];return s.str().substr(1);}

template<typename T>inline ostream& operator<<(ostream&o,const vector<T>&v)
{if(SZ(v))o<<join(v);return o;}
*/

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




/*
constant values
*/

//const int dx[] = {1,0,-1,0};
//const int dy[] = {0,1,0,-1};
//const int MX = 31001;

//const ll INF= 1LL<<60 ;//INF = 1001001001001; //1e9


// Main program
void solve(){
    int N;cin >> N;
    cout << max(min(N-9999,90000),0)+max(0,min(N-99,900))+min(N,9) << endl;
    return;
}



// ----------------------------------------------
int main(){

    int T=1; 

    for (int i = 0; i < T; ++i) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 256
# coding: utf-8

n,m = map(int,input().split(" "))
ac_list = [0] * n
wa_list = [0] * n


wa = 0

for i in range(m):
    a,b = input().split(" ")
    if ac_list[int(a) - 1]:
        continue
    if b == "AC":
        ac_list[int(a) - 1] = 1
        wa += wa_list[int(a)-1]
    else:
        wa_list[int(a)-1] += 1
        
print(sum(ac_list),wa)

Measured memory_bytes: 4596
//////////////////////////
/*      _        ____   */
/*  U  /"\  u U /"___|  */
/*   \/ _ \/  \| | u    */
/*   / ___ \   | |/__   */
/*  /_/   \_\   \____|  */
/*   \\    >>  _// \\   */
/*  (__)  (__)(__)(__)  */
/*   Compro by emame©   */
//////////////////////////
#include<iostream>
#include<stack>
using namespace std;

int main() {
  
  int n, a, b;

  cin >> n;
  a = n / 1000;
  a = a + 1;

  b = a * 1000 - n;

  if (b == 1000) {
    cout << "0" << endl;
  }
  else {
    cout << b << endl;
  }
  return 0;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define max 1000000
#define pb push_back
#define pairs pair<int, int>
#define vi vector<int>
#define vb vector<bool>
#define vii vector<pairs>
#define lb lower_bound
#define ub upper_bound
#define lli long long int
#define endl '\n'
#define FastInput ios_base::sync_with_stdio(false), cin.tie(NULL);
#define Cases  cout << "Case " << ++Case << ": ";
#define __test int tt; int Case=0; cin >> tt; while(tt--)
#define read(x) freopen(x, "r", stdin)
#define write(x) freopen(x, "w", stdout)
#define InputArray(a,n) for(int i=0;i<n;i++) cin >> a[i];
#define CopyArray(a,temp,n) for(int i=0;i<n;i++) temp[i]=a[i];
#define PrintArray(a,n) for(int i=0;i<n;i++) cout << a[i] << " "; cout << endl;
using namespace std;
#define PI 3.14159265358979323846264338327950L


void solve() {
	int a, b, h, m;
	cin >> a >> b >> h >> m;

	long double angle = PI * 2 * ((long double) h / 12.0 + ((long double) (m / 60.0)) / 12.0 - (long double) m / 60.0);

	long double res = (long double) (a * a + b * b) - (long double) (2 * a * b * cosl(angle));

	printf("%.20Lf\n", sqrtl(res));
}

int main() {
#ifdef Niloy
	read("input.txt");
	write("output.txt");
#endif
	FastInput;
	solve();

	cerr << "time = " << (clock() / CLOCKS_PER_SEC) << " sec" << '\n';
	return 0;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

long long P;

ll power(ll e, ll x) {
  if (x == 0) return 1;
  if (x % 2 == 0) return power((e * e) % P, x / 2);
  return (e * power(e, x - 1)) % P;
}

vvl mul(vvl a, vvl b) {
  int n = a.size();
  int m = b[0].size();
  vvl ret(n, vector<ll>(m));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      for (int k = 0; k < a[i].size(); k++) {
        ret[i][j] += (a[i][k] * b[k][j]) % P;
        ret[i][j] %= P;
      }
    }
  }
  return ret;
}


int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll l, a, b;
  cin >> l >> a >> b >> P;

  ll p10[1010] = {0};
  p10[0] = 1;
  for (int i = 0; i < 19; i++) p10[i + 1] = p10[i] * 10;
  ll ans = 0;

  for (int first = 1; first <= 19 && l > 0; first++) {
    ll mx = p10[first];
    if (mx <= a) continue;
    ll sz = min(l, (mx - a + b - 1) / b);

    vvl v({{ans, a % P, 1}});

    vvl S({
              {p10[first] % P, 0,     0},
              {1,              1,     0},
              {0,              b % P, 1},
          });
    vvl I({{1, 0, 0},
           {0, 1, 0},
           {0, 0, 1}});

    for (ll k = sz; k > 0; k >>= 1) {
      if (k % 2 == 1) {
        I = mul(S, I);
      }
      S = mul(S, S);
    }

    S = mul(v, I);

    ans = S[0][0];

    l -= sz;
    a += b * sz;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
s = list(input())
K = int(input())

l =[]

for i in range(len(s)):
    tmp = ''
    for j in range(i, len(s)):
        if j > i + 4: break
        tmp += s[j]
        l.append(tmp)
l.sort()

l2 = []
for x in l:
    if len(l2) > 6:
        break
    if x not in l2:
        l2.append(x)


ans = l2[K - 1]

print(ans)


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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
#define guard(x) if( not ( x ) ) continue;
typedef int64_t Int;
typedef std::vector<Int> LI;
const double pi = 3.14159265358979323846264338;
const Int mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(Int& x) { if( scanf("%" PRId64, &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
template<> void scan1(LI& xs) { for(Int &x : xs) scan1(x); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      Int n; scan(n);
      std::vector<Int> xs(n); scan(xs);
      Int res = 1;
      for(Int i = 0; i < n; ++i) {
         res *= 3;
      }
      Int t = 1;
      for(Int i = 0; i < n; ++i) {
         if( xs[i] % 2 == 0 ) t *= 2;
      }
      res -= t;
      printf("%ld\n", res);
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
void a(){
    ll a,b,c;
    cin >> a >>b >>c;
    cout << (a==b&&b==c?"No":
             a==b?"Yes":
             a==c?"Yes":
             b==c?"Yes":"No");
}

int main(){
    a();
    return 0;
}

Measured memory_bytes: 256
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
LL dp[SIZE];
int main(){
    REPP(i,1,SIZE)dp[i]=i;
    for(int x=6;x<SIZE;x*=6){
        REPP(i,x,SIZE)dp[i]=min(dp[i],dp[i-x]+1);
    }
    for(int x=9;x<SIZE;x*=9){
        REPP(i,x,SIZE)dp[i]=min(dp[i],dp[i-x]+1);
    }
    int N;
    R(N);
    W(dp[N]);
    return 0;
}


Measured memory_bytes: 8064
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
typedef long long LL;

int main() {
  int r, D, x; std::cin >> r >> D >> x;
  for (int i = 1; i <= 10; ++i) {
    x = r * x  -  D;
    std::cout << x << std::endl;
  }
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D solver = new D();
        solver.solve(1, in, out);
        out.close();
    }

    static class D {
        static long MOD = (long) 1e9 + 7;

        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();
            long[] A = in.nextLongArray(N);

            long ans = 0;
            for (int i = 0; i < 61; i++) {
                long d = 1L << i;
                long count = 0;
                for (int j = 0; j < N; j++) {
                    if ((A[j] & d) > 0) {
                        count++;
                    }
                }
                long temp = (count * (N - count)) % MOD;
                ans += (d % MOD) * temp % MOD;
                ans %= MOD;
            }

            out.println(ans);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public long[] nextLongArray(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextLong();
            }
            return a;
        }

    }
}



Measured memory_bytes: 80972
#include <stdio.h>

int selection_sort(int n, int A[])
{
    int i, j, minj, v;
int count = 0;

    for (i=0; i<n-1; i++){
        minj = i;

        for (j=i; j<n; j++){
            if (A[j] < A[minj]) {
                minj = j;
            }
        }
        v = A[i];
        A[i] = A[minj];
        A[minj] = v;
        if (minj != i)
            count++;
    }
    return count;
}

int main(void)
{
    int i;

    int n;
    scanf("%d", &n);

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

    int count;
    count = selection_sort(n, A);

    for (i=0; i<n-1; i++)
        printf("%d ", A[i]);
    printf("%d\n", A[n-1]);

    printf("%d\n", count);

    return 0;
}



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

int dp[1<<20];
vector<int>a;
signed main(){
	for(int i=0;i<1<<8;i++){
		a.push_back((i+1)*(i+1));
		}
		for(int c=0;c<a.size();c++){
			dp[a[c]]++;
			}
			for(int c=0;c<a.size();c++){
			for(int d=c;d<a.size();d++){
			dp[a[c]+a[d]]++;
			}
			}
		for(int c=0;c<a.size();c++){
			for(int d=c;d<a.size();d++){
			for(int e=d;e<a.size();e++){
				dp[a[c]+a[d]+a[e]]++;
				}
			}
			}
			for(int c=0;c<a.size();c++){
			for(int d=c;d<a.size();d++){
			for(int e=d;e<a.size();e++){
				for(int f=e;f<a.size();f++){
					dp[a[c]+a[d]+a[e]+a[f]]++;
					}
				}
			}
			}
			int K;
			while(cin>>K,K)cout<<dp[K]<<endl;
		}	

Measured memory_bytes: 4064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int mod = 1e9 + 9;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1 ;
	//cin >> t;
	while(t--){
		string a,b;
		cin >> a >> b;
		int m = a.length();
		int n = b.length();
		int dp[m+1][n+1];
		for(int i = 0; i <= m; i++){
			for(int j = 0; j <= n; j++){
				if(i == 0 || j == 0)
					dp[i][j] = 0;
				else if(a[i-1] == b[j-1])
					dp[i][j] = 1 + dp[i-1][j-1];
				else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
			}
		}
		int index = dp[m][n];
		char ans[index+1];
		ans[index] = '\0';
		while(m > 0 && n > 0){
			if(a[m-1] == b[n-1]){
				ans[index-1] = a[m-1];
				index--;
				m--;
				n--;
			}
 
			else if(dp[m-1][n] > dp[m][n-1])
				m--;
			else n--;
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 38844
import java.util.*;

class Main{
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		
		int N  = sc.nextInt();
		int YY = sc.nextInt() / 1000 ;  // 1000 |Y 
		
		int S = YY - N ;
		int x = 0;
		
		
		while(true){
			int y_4 = YY - N - 9 * x ;
			int y = y_4 / 4 ;
			int z = N - x - y ;
			if(y_4 >= 0){ // 
				if(y_4 % 4 == 0 && z >= 0){
					System.out.printf("%d %d %d ",x,y ,z);
					break;
				}
				x++;
			}else{
				System.out.println("-1 -1 -1");
				break;
			}
		}
	}
}


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

int main(){
  string s, t;
  cin >> s >> t;
  int x = stoi(s+t);
  
  for(int i = 0 ;i<1000; i++){
    if(i*i == x){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

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

const long long INF = 1LL << 60;

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

  int sum = 0;
  REP(c, 1, n-1){
    int a = n - c;
    int ans = 1;
    for (int i = 2; i <= sqrt(a); i++) {
      int cnt = 0;
      while (a % i == 0) {
        cnt++;
        a /= i;
      }
      ans *= (cnt + 1);
      if (a == 1) break;
    }
    if (a != 1) ans *= 2;
    sum += ans;
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 3676
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int d[4][3][10];

int main()
{
  int n, b, f, r, v;
  cin >> n;
  for(int i = 0; i < n; i++)
  {
    cin >> b >> f >> r >> v;
    d[b - 1][f - 1][r - 1] += v;
  }

  for(int i = 0; i < 4; i++)
  {
    for(int j = 0; j < 3; j++)
    {
      for(int k = 0; k < 10; k++)
      {
        cout << " " << d[i][j][k];      
      }
      cout << endl;
    }
    if(i == 3)
      break;
    for(int j = 0; j < 20; j++)
      cout << "#";
    cout << endl;
  }
  return 0;
}

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

using namespace std;

int main(void){
    int p;
    cin >> p;
    string br;
    cin >> br;
    int counter=0;

    for(int i=0;i < p;i++){
        if(br[i] == 'R'){
            counter = counter + 1;
        }else{
            counter = counter - 1;
        }
        }

        if(counter >= 1){
            cout << "Yes" << endl;
         }else{
            cout << "No" << endl;
         }

         return 0;
         }
    


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

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

	for (int re = 0;re < a;re++) {
		int ou = 0;
		int r = 0;
		int ap = 0;

		while (ou != 3) {
			string s;
			cin >> s;

			if (s == "OUT")ou++;

			else if (s == "HIT") {
				r++;
				if (r == 4) {
					ap++;
					r--;
				}
			}

			else if (s == "HOMERUN") {
				ap += r;
				r = 0;
				ap++;
			}
		}
		cout << ap << endl;
	}
	return 0;
}

Measured memory_bytes: 3104
import numpy as np
n,s = map(int,input().split())
A = list(map(int,input().split()))
mod = 998244353
ans = 0
dp = np.zeros(s+1,np.int64)
for i in A:
    dp[0] += 1
    dp[i:] += dp[:-i].copy()
    dp %= mod
    ans += dp[-1]
print(ans%mod)

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define rof_(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))

using lint = long long;
using pii = pair< int, int >;

template< typename T > using Vec = vector< T >;

template< typename T > bool in_range(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool in_range(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }

template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }

int bitCount(int x) { return __builtin_popcount(x); }
int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double EPS = 1e-9;
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//

int N, A[200005], B[200005];

lint calc(int b) {
	lint res = 0;
	for_(i,0,N) res += abs(A[i] - (b+i+1));
	return res;
}

int main() {
	cin >> N;
	for_(i,0,N) cin >> A[i];
	for_(i,0,N) B[i] = A[i] - (i+1);
	
	int lb = *min_element(B, B+N), ub = *max_element(B, B+N);
	for_(i,0,100) {
		int lft = lb + (ub - lb) / 3;
		int rgt = lb + (ub - lb) * 2 / 3;
		if (calc(lft) < calc(rgt)) ub = rgt;
		else lb = lft;
	}
	
	lint ans = 1L << 60;
	for_(b,lb,ub+1) minUpdate(ans, calc(b));
	cout << ans << endl;
}
//--------------8---------------->> coding space <<-----------------8-------------//


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N, D, X; cin >> N >> D >> X;
    int cnt = 0;
    for (int i = 0; i < N; ++i) {
        int a; cin >> a;
        for (int j = 1; j <= D; j += a) cnt++;
    }
    printf("%d\n", cnt + X);
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int h[501],fac[10001],a[501],n,k;
bool check(int d){
	int t=0,sum=0,s=0;
	for(int i=1;i<=n;i++){
		h[i]=a[i]%d;	
		t+=d-h[i];
	}
	sort(h+1,h+n+1);
	for(int i=1;i<=n;i++){
		sum+=h[i];s+=d-h[i];
		if(sum>k)return false;
		if(t-s==sum)return true;
	}
}
int main(){
	int sum=0,cnt=0,ans=0;
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i],sum+=a[i];
	for(int i=1;i*i<=sum;i++){
		if(sum%i==0){
			if(check(sum/i)){printf("%d",sum/i);return 0;}
			if(check(i)){ans=max(ans,i);}
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <string.h>

using namespace std;

string A;

int K[200005];
vector<int> cpos[26];

int main()
{
    cin >> A;
    int used[26];
    int cnt = 0;
    int k = 1;
    memset(used, 0, sizeof(used));
    for (int i = A.length() - 1; i >= 0; i--)
    {
        char c = A[i];
        int n = c - 'a';
        cpos[n].insert(cpos[n].begin(), i);
        if(used[n] == 0)
        {
            used[n] = 1;
            cnt++;
        }
        if(cnt == 26)
        {
            memset(used, 0, sizeof(used));
            cnt = 0;
            k++;
        }
        K[i] = k;
    }
    string ans = "";
    int anslen = 0;
    int cp = 0;
    //cout << "K[0] = " << K[0] << endl;
    for (int i = 0; anslen != K[0];)
    {
        //cout << "i = " << i << endl;
        for (int j = 0; j < 26; j++)
        {
            
            int flag = 0;
            vector<int>::iterator r = cpos[j].begin();
            int p = -1;
            if (cpos[j].size() != 0)
            {
                r = lower_bound(cpos[j].begin(), cpos[j].end(), i);
                p = *r;
                if (K[p + 1] == K[i] - 1 || r == cpos[j].end())
                {
                    flag = 1;
                }
            }
            else
            {
                flag = 1;
            }
            if (flag == 1)
            {
                ans += j + 'a';
                anslen++;
                i = p + 1;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2172
#include <cstdio>

int main()
{
  int n;
  char s[100001];
  char ans[100001];
  scanf("%d%s", &n, s);
  for (int i = 0; i < 4; ++i)
  {
    ans[0] = (i & 1) ? 'W' : 'S';
    ans[1] = (i & 2) ? 'W' : 'S';
    for (int j = 2; j < n; ++j)
    {
      ans[j] = ans[j - 2] ^ (ans[j - 1] == 'S' xor s[j - 1] == 'o' ? 4 : 0);
    }
    if (ans[0] == (ans[n - 2] ^ (ans[n - 1] == 'S' xor s[n - 1] == 'o' ? 4 : 0)) &&
        ans[1] == (ans[n - 1] ^ (ans[0]     == 'S' xor s[0]     == 'o' ? 4 : 0)))
    {
      ans[n] = 0;
      puts(ans);
      return 0;
    }
  }
  puts("-1");
  return 0;
}


Measured memory_bytes: 512
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');

        for (int i = 1; i <= input.Length; i++)
        {
            if (input[i - 1].Equals("0"))
            {
                Console.WriteLine(i);
                return;
            }
        }
    }
}

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

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define inf 100000000000010
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
#define all(x) (x).begin(), (x).end()

typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pi;

bool isprime(ll n)
{
    if(n<=1)return false;
    if(n<=3)return true;
    if(n%2==0||n%3==0)return false;
    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0||n%(i+2)==0)return false;
    }
    return true;
}

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)r=(r*a)%m;
        b = b>>1;
        a=(a*a)%m;
    }
    return r%m;
}

struct CustomCompare
{
    bool operator()(const int& lhs, const int& rhs)
    {
        return lhs < rhs;
    }
};

bool comp(pair<ll, ll>a,pair<ll,ll>b)
{
    return a.fi>b.fi;
}

ll builtin_popcount(ll x)
{
    ll cnt = 0;
    for(ll i=60;i>=0;i--)
    {
        if((1LL<<i)&x)cnt++;
    }
    return cnt;
}

ll addmod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    return (a+b)%mod;
}
ll mulmod(ll a,ll b)
{
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}
/*
const int mxn = 5*(1e6) +10;
vi spf(mxn);
void sieve()
{
    for(ll i =0;i<mxn;i++)spf[i]  = i;
    for(ll i=2;i<mxn;i+=2)spf[i] = 2;
    for(ll i = 3;i*i<mxn;i++)
    {
        if(spf[i]==i)
        {
            for(ll j = i*i;j<mxn;j+=i)
            {
                if(spf[j]==j)spf[j] = i;
            }
        }
    }
}
*/

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
ll x; cin>>x;
if(x>=400&&x<=599)cout<<8<<endl;
else if(x>=600&&x<=799)cout<<7<<endl;
else if(x>=800&&x<=999)cout<<6<<endl;
else if(x>=1000&&x<=1199)cout<<5<<endl;
else if(x>=1200&&x<=1399)cout<<4<<endl;
else if(x>=1400&&x<=1599)cout<<3<<endl;
else if(x>=1600&&x<=1799)cout<<2<<endl;
else cout<<1<<endl;
return 0;
}
/*
23 5
10 3 3
2 1 4 11 8 10 5 6 7 9 12 3 14 13 16 18 21 15 17 19 20 23 22
4 6 3 18 23
*/


Measured memory_bytes: 3640
import sys
input = sys.stdin.readline

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

for _ in range(K):
    imos = [0]*(N+1)
    
    for i in range(N):
        imos[max(0, i-A[i])] += 1
        imos[min(N-1, i+A[i])+1] -= 1
    
    for i in range(1, N+1):
        imos[i] += imos[i-1]
        
    for i in range(N):
        A[i] = imos[i]
    
    if A==[N]*N:
        print(*A)
        exit()

print(*A)

Measured memory_bytes: 168368
W, H, N = [int(x) for x in input().split()]
x_min, x_max, y_min, y_max = 0, W, 0, H
num_lists = [[int(x) for x in input().split()] for _ in range(N)]

for num_list in num_lists:
    if num_list[2] == 1 and num_list[0] > x_min:
        x_min = num_list[0]
    if num_list[2] == 2 and num_list[0] < x_max:
        x_max = num_list[0]
    if num_list[2] == 3 and num_list[1] > y_min:
        y_min = num_list[1]
    if num_list[2] == 4 and num_list[1] < y_max:
        y_max = num_list[1]

if x_min > x_max or y_min > y_max:
    print(0)
else:
    print((x_max-x_min)*(y_max-y_min))

Measured memory_bytes: 9136
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;

const int mxn=2e5+1;

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

  int t=1;
  //cin>>t;
  int tt=1;
  while(t--){
    ll r,x,d;
    cin>>r>>d>>x;
    int i;
    fr(i,0,10)
    {
      x=r*x-d;
      cout<<x<<"\n";
      
       //cout<<"Case #"<<tt<<": ";
       //tt++;
    }
    }
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i > 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
  ll N, M; cin >> N >> M;

  cout << (M == N ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <numeric>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
int INF = 1e9;


int main(){
	int a,b,c;cin >> a >> b >> c;
	set<int> s;
	s.insert(a);
	s.insert(b);
	s.insert(c);
	cout << s.size() << endl;



} 


Measured memory_bytes: 3564
#include <stdio.h>

int	main()
{
	double	H;
	long long	num;
	long long	attack;

	num = 1;
	attack = 0;
	scanf("%lf\n", &H);
	while (H >= 1)
	{
		H /= 2;
		attack += num;
		num *= 2;
	}
	printf("%lld\n", attack);
	return (0);
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
int main()
{
	for(int n; ; )
	{
		scanf("%d", &n);
		if(!n)
		{
			return 0;
		}
		vector<int> a(n);
		for(int i = 0; i < n; ++i)
		{
			scanf("%d", &a[i]);
		}
		vector<vector<int>> dp(n, vector<int>(n + 1, 0));
		for(int i = n - 1; i >= 0; --i)
		{
			for(int j = i + 1; j <= n; ++j)
			{
				if(i + 2 <= j && abs(a[i] - a[j - 1]) <= 1 && dp[i + 1][j - 1] == j - i	 - 2)
				{
					dp[i][j] = j - i;
				}
				for(int k = j + 1; k <= n; ++k)
				{
					dp[i][k] = max(dp[i][k], dp[i][j] + dp[j][k]);
				}
			}
		}
		printf("%d\n", dp[0][n]);
	}
}



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

int main(){
	string w,t;
	int ans=0;
	cin >> w;
	while(cin >>t){
		if(t=="END_OF_TEXT") break;
		transform(t.begin(),t.end(),t.begin(),::tolower);

		if(t==w) ans++;
	}
	cout << ans << endl;
	return 0;
}

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

inline int read()
{
	int x=0, w=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')w=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*w;
}

bool re[100002]; int wh[100002];

int main()
{
	int n, m; cin>>n>>m;
	re[1]=1;
	for(int i=1; i<=n; i++){
		wh[i]+=1;
	}
	for(int i=1;i<=m;i++){
		int a=read(), b=read();
		if(re[a]==1){
			re[b]=1;
			if(wh[a]==1){
				re[a]=0;
			}
		}
		wh[b]+=1; wh[a]-=1;
	}
	int ans=0;
	for(int i=1; i<=n; i++){
		if(re[i]==1) ans += 1;
	}
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#include<math.h>
#include <iostream>
#include <vector>
#include <queue>

using namespace std;
int main() {
  

  int INF=-1;
  
  
  int N,M;
  
  cin>>N>>M;
  
  vector<vector<char>> maze(N, vector<char>(M));
  for(int i=0; i<N;i++){
    for(int j=0; j<M;j++){
      cin>>maze[i][j];
    }
  }
  vector<vector<int>> d(N, vector<int>(M)); 
  int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
  
  
    
  int ans=0;
for(int sx=0; sx<N;sx++){
  for(int sy=0; sy<M;sy++){
    for(int gx=0; gx<N;gx++){
      for(int gy=0; gy<M;gy++){
        queue<pair<int,int>> que;
    if(maze[sx][sy]=='#'){
      continue;
    }
    for(int i=0; i<N;i++){
      for(int j=0; j<M;j++){
        d[i][j]=INF;
      }
    }
    que.push(pair<int,int>(sx,sy));
    d[sx][sy]=0;
    
    while(!que.empty()){
      pair<int,int> p=que.front();que.pop();
      if(p.first==gx&&p.second==gy){
        continue;
      }
      
      for(int i=0; i<4;i++){
        int nx=p.first+dx[i],ny=p.second+dy[i];
        
        if (0<=nx&&nx<N&&0<=ny&&ny<M&&maze[nx][ny]!='#'&&d[nx][ny]==INF){
          que.push(pair<int,int>(nx,ny));
          d[nx][ny]=d[p.first][p.second]+1;
        }
      }
    }
    ans=max(ans,d[gx][gy]);
      }
    }
  }
}

  
  
 

  cout<<ans<<endl;
}




Measured memory_bytes: 384
// =====================================================================================
//
//       Filename:  cp.cpp
//
//        Version:  1.0
//       Revision:  none
//       Compiler:  g++
//
//         Author:  Priyank Kumar Singh ()
//   Organization:  RVCE Bangalore
//
// =====================================================================================


#include<bits/stdc++.h>
using namespace std;

#define ll long long 
#define pb push_back
#define mp make_pair
#define F first
#define S second 
#define pl pair<long ,long >
#define pi pair<int ,int >
#define lb(v,x) lower_bound(v.begin(),v.end(),x)-v.begin();
#define ub(v,x) upper_bound(v.begin(),v.end(),x)-v.begin();
#define ct(i) cout<< i << "\n";
#define sv(v) sort(v.begin(),v.end());
#define mod 1000000007
#define M 100005
vector<int> s[10];
/*
void dfs(int i, int j){
    int c=s[i][j];
    if(i==n-1 && j==m-1 ){
        ans = min(ans, c);
        return;
    }
    
    if(j+1<m) dfs(i,j+1);
    c+=s[i][j];
    if(i+1<n) dfs(i+1,j);
    c+=s[i][j];
}
int c1=0;
*/


void answer(){
    ll n,m;
    string s,t;
    cin>>s>>t;
    n = s.size();
    m = t.size();
    int dp[n+1][m+1];
    for(int i=0;i<=n;i++)
        for(int j=0;j<=m;j++)
            dp[i][j] = 0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            if(s[i-1]==t[j-1])
                dp[i][j] = max(dp[i-1][j-1]+1,dp[i][j-1]);
            else
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
        }
    }
    int i = n,j=m;
    vector<char> v;
    while(1){
        if(dp[i-1][j]==dp[i][j-1] && dp[i][j]!=dp[i][j-1]){
            v.pb(t[j-1]);
            i--;j--;
        }
        else if(dp[i][j-1]==dp[i][j]){
            j--;
        }
        else i--;
        if(i==0 || j==0) break;
    }
    for(int i=0;i<v.size();i++){
        cout<<v[v.size()-1-i];
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    int q;
    //cin>>q; while(q--)
        answer();

    return 0;
}


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

using namespace std;

int a, b, c;
int ans;

int main(){
	cin >> a >> b >> c;
	int x = max(a, max(b, c));
	if(3*x % 2 == (a+b+c) % 2) ans = (3*x-(a+b+c))/2;
	else ans = (3*(x+1)-(a+b+c))/2;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define EB emplace_back

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;

const int INF = 1e9 + 7;

int a[100005];

int main()
{
	IO_OP;
	
	int n;
	cin >> n;
	for(int i=0;i<n;i++)
		cin >> a[i];
	sort(a, a+n);
	cout << a[n/2] - a[n/2-1] << endl;
	
}



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

int h,w,a,b;

int main(){
	scanf("%d%d%d%d",&h,&w,&a,&b);
	string tmp = "";
	for(int i=0;i<a;i++){
		tmp.push_back('0');
	}
	for(int i=a;i<w;i++){
		tmp.push_back('1');
	}
	for(int i=0;i<b;i++){
		cout << tmp << endl;
	}
	for(int i=0;i<w;i++){
		if(tmp[i] == '1') tmp[i] = '0';
		else tmp[i] = '1';
	}
	for(int i=b;i<h;i++){
		cout << tmp << endl;
	}
	return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vi t(n),v(n);
    int T=0;
    rep(i,n){
        cin>>t[i];
        T += t[i];
    }
    vector<double> vmax(2*T+1, 1000);
    rep(i,n) cin>>v[i];
    int tmp=0;
    rep(i,n){
        rep(j,2*t[i]+1){
            chmin(vmax[2*tmp+j], (double)v[i]);
        }
        tmp+=t[i];
    }
    vmax.front() = 0.0;
    vmax.back() = 0.0;
    FOR(i,1,2*T) chmin(vmax[i], vmax[i-1]+0.5);
    RFOR(i,2*T-1,0) chmin(vmax[i], vmax[i+1]+0.5);
    // for(auto e:vmax){
    //     cout<<e<<" ";
    // }cout<<endl;
    double ans=0.0;
    FOR(i,1,2*T) ans+=(vmax[i-1]+vmax[i])*0.25;
    cout<<setp(12)<<ans<<"\n";
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); ++i)

typedef long long ll;

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, n) {
    cin >> p[i];
  }

  int result = 0;

  int minVal = p[0];
  result++;
  for (int i = 1; i < n; i++) {
    int a = p[i];
    if (a < minVal) {
      result++;
    }
    minVal = min(minVal, a);
  }

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 1024
from collections import deque

N = int(input())
b = list(map(int, input().split()))

qa = deque([]) 

while len(b) >= 1:
    t = False
    for i in range(len(b), 0, -1):
        if b[i-1] == i:
            b.pop(i-1)
            qa.appendleft(i)
            t = True
            break
    if not(t):
        print(-1)
        break

if t:
    for i in range(len(qa)):
        print(qa[i])


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define x first
#define y second
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
#define pb push_back
#define rep(i, a, b) for(int i = a; i < b; i++)
#define mem(i) memset((i), (-1), (sizeof(i)))
using namespace std;

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

int n;
int h[100005];
int dp[100000];

int f(int x)
{
	if (x >= n - 1) return 0;
	int &ret = dp[x];
	if (ret != -1) return ret;

	ret = f(x + 1) + abs(h[x] - h[x + 1]);
	ret = min(ret, f(x + 2) + abs(h[x] - h[x + 2]));
	return ret;
}

int main()
{
	fastio;
	cin >> n;
	rep(i, 0, n) cin >> h[i];
	h[n + 2] = h[n + 1] = h[n] = h[n - 1];
	mem(dp);
	cout << f(0);
}

Measured memory_bytes: 4224
import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;

void main() {
	auto input = readln.split.to!(int[]);
	auto A = input[0], B = input[1], C = input[2], D = input[3];
	
	writeln( (C%B == 0 ? C/B : C/B+1) <= (A%D == 0 ? A/D : A/D+1) ? "Yes" : "No");
}



Measured memory_bytes: 2764
#include<iostream>
using namespace std;
#define df 0
#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
typedef long int li;

int main(){
  if(df) printf("*debug mode*\n");
  int n,k; cin >>n >>k;
  int r,s,p; cin >>s >>p >>r;
  string str; cin >>str;
  li ans=0;
  rep(i,n){
    int hand;
    if(str.at(i)=='r') hand=r;
    if(str.at(i)=='p') hand=p;
    if(str.at(i)=='s') hand=s;
    if(i>=k and str.at(i)==str.at(i-k)){
      hand=0;
      str.at(i)='x';
    }
    ans+=hand;
  }
  cout << ans;
}

/// confirm df==0 ///


Measured memory_bytes: 512
fun com(a: Int, b: Int) =
  when {
    a < b -> "a < b"
    a > b -> "a > b"
    else -> "a == b"
    }
    
    
fun main(args: Array<String>) {
  val (a, b) = readLine()!!.split(" ").map(String::toInt)
  println(com(a, b))
  }


Measured memory_bytes: 31844
#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>;

int main(){
    string s;
    cin >> s;
    if (s[0] >= 'a' && s[0] <= 'z') {
        cout << 'a' << endl;
    } else {
        cout << 'A' << endl;
    }
    return 0;
}

Measured memory_bytes: 3616