akhauriyash/Code-Regression huggingface dataset:
from sys import stdin

def main():
    N, M = map(int, input().split())
    X = list(map(int, input().split()))

    if N >= M:
        print(0)
        return

    X.sort()
    n1 = [(i + 1, X[i+1] - X[i]) for i in range(M - 1)]
    n1.sort(reverse=1, key=lambda x: x[1])
    n2 = n1[:N-1]
    n2.sort()

    ans, i = 0, 0
    for j, _ in n2:
        ans += X[i:j][-1] - X[i:j][0]
        i = j
    ans += X[i:][-1] - X[i:][0]
    print(ans)

input = lambda: stdin.readline()
main()


Measured memory_bytes: 18752
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <math.h>

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

int main(){
	int n,m;
	while(cin >> n, n){
	
	cin >> m;
	
	int val,res,sugo;
	res = 0;
	sugo = 1;

	vector<int> data,dice;
	
	rep(i,n){
		cin >> val;
		data.push_back(val);
	}
	
	rep(i,m){
		cin >> val;
		dice.push_back(val);
	}
	
	rep(i,m){
		val = dice[i];
		//cout << "dice." << val << endl;
		sugo += val;
		//cout << "," << sugo << endl;
		val = sugo - 1;
		//cout << "..." << sugo << endl;		
		
		if(0 < data[val]) sugo += abs(data[val]);
		else if(data[val] < 0) sugo -= abs(data[val]);
		else sugo += 0;
		
		//cout << "," << data[val] << endl;
		//cout << "..." << sugo << endl;		
		
		if(sugo >= n) break;
		res++;
	}

	cout << res + 1 << endl;
	/*
	rep(i,5) sugo += -1;
	cout << "//" << sugo << endl;
	*/
	}
	
	return 0;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define INF INT_MAX/3

int main(){
  cin.sync_with_stdio(false);
  string s;
  int x, y;
  cin >> s >> x >> y;
  s += "T";
  int sx = 0, sy = 0, p = 0;
  while(p < s.size() && s[p] == 'F') sx++, p++;
  vector<int> xx, yy;
  bool dx = false;
  int cnt = 0, sumx = 0, sumy = 0;
  repl(i, p + 1, s.size()) {
    if (s[i] == 'T') {
      if (dx) {
        if (cnt > 0) xx.pb(cnt);
        sumx += cnt;
      } else {
        if (cnt > 0) yy.pb(cnt);
        sumy += cnt;
      }
      dx = !dx;
      cnt = 0;
    } else {
      cnt++;
    }
  }

  if (abs(x - sx) > sumx || abs(y - sy) > sumy) {
    cout << "No" << endl;
  } else {
    sumx -= abs(x - sx); sumy -= abs(y - sy);
    if (sumx % 2 == 1 || sumy % 2 == 1) {
      cout << "No" << endl;
    } else {
      sumx /= 2, sumy /= 2;
      bool ok = true;
      bool num[8001];
      memset(num, 0, sizeof(num));
      num[0] = true;
      rep(i, xx.size())repr(j, 8001, 0) {
        if (num[j]) num[j + xx[i]] = true;
      }
      if (!num[sumx]) ok = false;
      memset(num, 0, sizeof(num));
      num[0] = true;
      rep(i, yy.size())repr(j, 8001, 0) {
        if (num[j]) num[j + yy[i]] = true;
      }
      if (!num[sumy]) ok = false;
      if(ok) cout << "Yes" << endl;
      else cout << "No" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
/*
Author : Devil088
*/
#include<bits/stdc++.h>
using namespace std;
#define MOD 998244353
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int t,dis=0;
	cin>>t;
	unordered_map<string,int> M;
	while(t--){
		string s;
		cin>>s;
		if(M[s]==0){
			dis++;
			M[s] = 1;
		}
	}
	cout<<dis<<"\n";
}


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

int main() {
  int x, a, b, c; //aは百, bは十, cは一の位
  cin >> x;
  a = x/100; 
  b = (x - a*100)/10; 
  c = x - a*100 - b*10; 
  int answer = a + b + c; 
  cout << answer << endl;
}


Measured memory_bytes: 256
"use strict"
function KP(callback) {
    this.data = [];
    this.reader = require('readline').createInterface({
        input: process.stdin,
        output: process.stdout
    });
    this.id = 0;
    this.start = function(callback) {
        self.reader.on('line', function(line) {
            var dt = line.split(" ");
            for (var i = 0; i < dt.length; ++i) {
                self.data.push(dt[i]);
            }
        });
        self.reader.on('close', function() {
            callback(self);
        });
    }
    this.input = function() {
        var id = self.id++;
        if (id >= self.data.length) {
            self.error("reached eof");
        }
        return self.data[id];
    }
    this.output = function(data) {
        if (arguments.length > 1) {
            data = [];
            for (var i = 0; i < arguments.length; ++i) {
                data[i] = arguments[i];
            }
        }
        else if (typeof data !== "object") {
            data = [data];
        }
        console.log(data.join(" "));
    }
    this.error = function(err) {
        console.error(err);
        console.abort();
    }
    var self = this;
};

new KP().start(function(kp) {
    var a = +kp.input();
    var b = +kp.input();
    kp.output([a*b, (a+b)*2]);
    process.exit(0);
});

Measured memory_bytes: 16384
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    x,y=map(int,input().split())
    ans=0
    if(x==1):
        ans+=3
    elif(x==2):
        ans+=2
    elif(x==3):
        ans+=1
    if(y==1):
        ans+=3
    elif(y==2):
        ans+=2
    elif(y==3):
        ans+=1
    if(x==1 and y==1):
        ans+=4
    print(ans*100000)
resolve()

Measured memory_bytes: 38384
import sys
N, M, *PS = sys.stdin.read().strip().split()
N = int(N)
ac = [0] * N
wa = [0] * N
for p, s in zip(*[iter(PS)] * 2):
  p = int(p) - 1
  if s == "AC":
    ac[p] = 1
  elif ac[p] == 0:
    wa[p] += 1
penalties = sum(w if a > 0 else 0 for a, w in zip(ac, wa))
print(sum(ac), penalties)

Measured memory_bytes: 18092
ABCD=input()
# a=int(ABCD[0])
# b=int(ABCD[1])
# c=int(ABCD[2])
# d=int(ABCD[3])


for i in range(2**3):
    count=int(ABCD[0])
    ans=ABCD[0]
    for j in range(3):
        if i&(1<<j):
            count+=int(ABCD[j+1])
            ans+="+"
        else:
            count-=int(ABCD[j+1])
            ans+="-"
        ans+=ABCD[j+1]
    if count==7:
        ans+="=7"
        print(ans)
        quit()


Measured memory_bytes: 38384
#include<stdio.h>
int main(void)
{
        int a,b;
        scanf("%d %d",&a,&b);
        if(a<b){
                printf("a < b\n");
        }else if(a>b){
                printf("a > b\n");
        }else{
                printf("a == b\n");
        }
        return 0;
}


Measured memory_bytes: 2100
import java.util.*;

/**
 * Created by Santa.
 */
public class Main {

    static long N;
    static int M;
    static int A;
    static long B;
    static long C;
    static int[][] map;
    static int min = 9999999;
    static int[] moto = new int[3];

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

        moto[0] = scanner.nextInt();
        moto[1] = scanner.nextInt();
        moto[2] = scanner.nextInt();

        Arrays.sort(moto);

        System.out.println((moto[1] - moto[0]) + (moto[2] - moto[1]));



    }




}



Measured memory_bytes: 23764
A = 'abcdefghijklmnopqrstuvwxyz'
 
while True:
    try: s = input()
    except: exit()
 
    for x in range(1, 27):
        ans = s[:-1].translate(str.maketrans(A, A[x:] + A[:x]))
        if 'the' in ans or 'this' in ans or 'that' in ans:
            print(ans + '.')
            break


Measured memory_bytes: 5572
from sys import stdin


def main() -> None:
    s = next_str()
    print(s[::2])


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
	int a,b,c,d;
	cin>>a>>b;
	int r=ceil(float(a)/0.08);
	int s=ceil(float(a+1)/0.08-1);
	int t=ceil(float(b)/0.1);
	int u=ceil(float(b+1)/0.1-1);
//	cout<<r<<" "<<s<<" "<<t<<" "<<u<<" ";
	if(t>s||u<r) cout<<-1;
	else cout<<max(r,t);
}


Measured memory_bytes: 256
import sys
import math
import fractions
import time
import random
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

start = time.perf_counter()

D = int(input())
c = list(map(int, input().split()))
s = []
last = [0] * 26
for _ in range(D):
    line = list(map(int, input().split()))
    s.append(line)


def calc_one_score(t, d, sat):
    t -= 1
    sat += s[d][t]
    last[t] = d + 1
    for i in range(26):
        sat -= c[i] * (d + 1 - last[i])
    return sat


def calc_score(ts):
    sat = 0
    for d in range(D):
        sat = calc_one_score(ts[d], d, sat)
    return sat


max_score = -1000000000000

ts = [1] * D
while time.perf_counter() - start < 1.70:
    last = [0] * 26
    score = calc_score(ts)
    d = random.randrange(D)
    i = random.randrange(1, 27)
    old = ts[d]
    ts[d] = i
    if max_score < score:
        # print(ts, score)
        max_score = score
    else:
        ts[d] = old

for t in ts:
    print(t)
# print(max_score)


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

using ll = long long;
template <class T> using p = pair<T, T>;
template <class T> using vt = vector<T>;

#define rep(i, n)   for (int i = 0; i < (n); i++)
#define sz(x)       (int)(x).size()
#define eb          emplace_back
#define pb          push_back
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

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

  int h, w, m;
  cin >> h >> w >> m;
  int mxh = 0, mxw = 0;
  vt <unordered_set <int> > H(h + 1);
  vt <unordered_set <int> > W(w + 1);
  rep (i, m) {
    int hh, ww;
    cin >> hh >> ww;
    H[hh].insert(ww);
    W[ww].insert(hh);
    mxh = max(sz(H[hh]), mxh);
    mxw = max(sz(W[ww]), mxw);
  }
  bool minus1 = true;

  vt<int> okh, okw;
  for (int i = 1; i <= h; ++i) if (sz(H[i]) == mxh) okh.pb(i);
  for (int i = 1; i <= w; ++i) if (sz(W[i]) == mxw) okw.pb(i);

  for (auto i : okh) {
    if (sz(H[i]) < mxh) continue;
    for (auto j : okw) {
      if (sz(W[j]) < mxw) continue;
      if (!H[i].count(j) || !W[j].count(i)) {
        minus1 = false;
        break;
      }
    }
    if (!minus1) break;
  }

  if (minus1) cout << mxh + mxw - 1 << endl;
  else cout << mxh + mxw << endl;

  return 0;
}

Measured memory_bytes: 77680
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
const int INF = 100100100;

int main() {
  int a, b, m;
  cin >> a >> b >> m;
  vector<ll> A(a), B(b);
  rep(i, a) cin >> A[i];
  rep(i, b) cin >> B[i];
  vector<int> x(m), y(m), c(m);
  rep(i, m) cin >> x[i] >> y[i] >> c[i];
  ll mn = INF;
  //つかうなら
  rep(i, m) { mn = min(mn, A[x[i] - 1] + B[y[i] - 1] - c[i]); }

  sort(A.begin(), A.end());
  sort(B.begin(), B.end());  //ソート

  rep(i, min(a, b)) { mn = min(mn, A[i] + B[i]); }  //つかわないなら

  cout << mn;
  return 0;
}


Measured memory_bytes: 2944
#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(){
    int n, m;
    cin >> n >> m;
    if(n <= m){
        cout << "unsafe" << endl;
    }else{
        cout << "safe" << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
#include <string>
#include <cmath>
#include <utility>
#include <algorithm>
#include <iostream>
 
 
using namespace std;
int main(void){
    // Your code here!
    string tmp;
    cin >> tmp;
    if(tmp == "Sunny"){
        cout << "Cloudy" << endl;
    }else if(tmp == "Cloudy"){
        cout << "Rainy" << endl;
    }else{
        cout << "Sunny" << endl;
    }
}


Measured memory_bytes: 764
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
using namespace std;
char _;
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define io() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#ifdef _getchar_nolock
#define getchar _getchar_nolock
#endif
#ifdef _putchar_nolock
#define putchar _putchar_nolock
#endif
#ifdef getchar_unlocked
#define getchar getchar_unlocked
#endif
#ifdef putchar_unlocked
#define putchar putchar_unlocked
#endif
typedef __gnu_pbds::tree<int, __gnu_pbds::null_type, less<int>, __gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
template <typename t> void scan (t& x) {do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0);}
void scan(pii &x) {scan(x.first); scan(x.second);}
template <typename t, typename ...r> void scan (t& x, r&... xs) {scan(x); scan(xs...);}
const int MN = 1e5+2, MM = 1e6+2, MOD = 1e8, BASE = 131;
int fpow (int base, int ex) {int res = 1;while (ex) {if (ex&1) res = res*1LL*base%MOD;base = base*1LL*base%MOD;ex>>=1;}return res;}
ll lcm (ll a, ll b) {return a*b/__gcd(a,b);}
int moddiv (int a, int b) {return a*1LL*fpow(b,MOD-2)%MOD;}
char s[MN];
int main () {
    int n,k;
    scan(n,k);
    scanf("%s",s);
    int groupr = 0, groupl = 0, happ = 0;
    s[0]=='L'?++groupl:++groupr;
    for (int i = 1; i < n; i++) if (s[i] != s[i-1]) s[i]=='L'?++groupl:++groupr;
    for (int i = 0; i < n; i++) if ((i && s[i]=='L'&&s[i-1]=='L')||(i!=n-1&&s[i]=='R'&&s[i+1]=='R')) ++happ;
    int groups = groupl + groupr;
    if (k >= groupl || k >= groupr) printf ("%d\n",n-1);
    else if (k >= groups-2) printf ("%d\n",min(n-1,happ+(groups-2)*2+(k-groups+2)));
    else printf ("%d\n",min(n-1,happ+k*2));
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

vector<vector<int> > G;
vector<int> dp;
int dfs(int u) {
  if(dp[u] >= 0) return dp[u];
  if(G[u].size() == 0) return dp[u] = 0;
  for(const int v : G[u]) chmax(dp[u], dfs(v) + 1);
  return dp[u];
}
void answer() {
  int n, m;
  cin >> n >> m;
  G.resize(n);
  dp.assign(n, -1);
  rep(i, m) {
    int x, y;
    cin >> x >> y;
    x--; y--;
    G[x].emplace_back(y);
  }
  int ans = 0;
  rep(i, n) chmax(ans, dfs(i));
  cout << ans << "\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 10968
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll Q = 123123121;
const ll B = 3213211;
int main() {
    ll n, s;
    ll sum2 = 0;
    ll q = Q;
    /*
    while(q) {
        sum2 += q%B;
        cout<<q%B<<'\n';
        q /= B;
    }
    */
    cin>>n>>s;
    //n = Q;
    //s = sum2;
    //cout<<n<<' '<<s<<'\n';
    ll sq = sqrt(n)*2+100;
    for(ll i = 2; i < sq; ++i) {
        ll sum = 0;
        ll q = n;
        while(q) {
            sum += q%i;
            q /= i;
        }
        if(sum == s) {
            cout<<i<<'\n';
            return 0;
        }
    }
    ll ans = 1e18;
    for(ll i = 1; i < sq; ++i) {
        ll lo = 1;
        ll hi = n;
        ll mi = n+1;
        while(lo <= hi) {
            ll mid = (lo+hi)/2;
            if(n/ mid > i) {
                lo = mid+1;
            }
            else if(n/mid == i) {
                hi = mid-1;
                mi = mid;
            }
            else {
                hi = mid-1;
            }
        }
        lo = 1;
        hi = n;
        ll ma = -1;
        while(lo <= hi) {
            ll mid = (lo+hi)/2;
            if(n / mid < i) {
                hi = mid-1;
            }
            else if(n/mid == i) {
                ma = mid;
                lo = mid+1;
            }
            else {
                lo = mid+1;
            }
        }
        /*
        if(i == 38) {
            cout<<"LOL\n";
            cout<<mi<<' '<<ma<<'\n';
        }
        */
        if(mi <= ma) {
            lo = mi;
            hi = ma;
            ll best = -1;
            while(lo <= hi) {
                ll mid = (lo+hi)/2;
                if(i + n%mid == s) {
                    best = mid;
                    hi = mid-1;
                }
                else if(i + n%mid > s) {
                    lo = mid+1;
                }
                else {
                    hi = mid-1;
                }
            }
            if(best != -1) {
         //       cout<<i<<' '<<mi<<' '<<ma<<'\n';
                ans = min(ans, best);
            }
        }
    }
    if(s == 1) {
        //cout<<n<<'\n';
        ans = min(ans, n);
    }
    if(s == n) {
        ans = min(ans, n+1);
    }
    if(ans == 1e18) {
        cout<<-1<<'\n';
        return 0;
    }
    cout<<ans<<'\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(nullptr); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N, K;
    cin >> N >> K;
    long double ans = 0;
    rep(i, 1, N + 1) {
        int cnt = 0;
        rep(k, 0, K + 1) {
            if ((i << k) >= K) break;
            cnt++;
        }
        long double tmp = 1.0 / pow(2, cnt) / N;
        ans += tmp;
    }
    cout << ans << endl;
    return (0^_^0);
}



Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int P, Q, R,a[2],i=0,x;
	scanf("%d %d %d", &P, &Q, &R);
	if (P <= Q) {
		a[i]=P;
		i++;
		x = Q;
	}
	else {
		a[i]=Q;
		i++;
		x = P;
	}
	if (R <= x) {
		a[i] = R;
	}
	else {
		a[i]=x;
	}
	
	printf("%d", a[0] + a[1]);

    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define arep(i, x, n) for (int i = int(x); i < (int)(n); i++)
#define rep(i, n) for (long long i = 0; i < n; ++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9 + 7
using ll = long long;

int main() {
    int n;
    int m;
    int x;
    cin >> n >> m >> x;
    int a[m];

    rep(i, m) { cin >> a[i]; }

    int score1 = 0;
    int score2 = 0;
    for (int i = x; i < n + 1; i++) {
        rep(j, m) {
            if (i == a[j]) {
                score1++;
            }
        }
    }

    for (int i = x; i > -1; i--) {
        rep(j, m) {
            if (i == a[j]) {
                score2++;
            }
        }
    }

    cout << min(score1, score2) << endl;
}

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

int main() {
    string s;
    cin>>s;
    if(s=="SUN") cout<<"7"<<endl;
    else if(s=="MON") cout<<"6"<<endl;
    else if(s=="TUE") cout<<"5"<<endl;
    else if(s=="WED") cout<<"4"<<endl;
    else if(s=="THU") cout<<"3"<<endl;
    else if(s=="FRI") cout<<"2"<<endl;
    else if(s=="SAT") cout<<"1"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int money = 100000;
	int i, n;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		money += (money * 0.05);
		if (money % 1000 != 0){
			money = (money + 1000) / 1000 * 1000;
		}
	}
	
	printf("%d\n", money);
	
	return (0);
}

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

using namespace std;

int main()
{
	int label[6];
	string order;

	for (int i = 0; i < 6; i++) {
		cin >> label[i];
	}
	cin >> order;

	int temp;
	for (int i = 0; i < order.length(); i++) {
		if (order[i] == 'N')
		{
			temp = label[0];
			label[0] = label[1];
			label[1] = label[5];
			label[5] = label[4];
			label[4] = temp;
		}
		if (order[i] == 'E')
		{
			temp = label[0];
			label[0] = label[3];
			label[3] = label[5];
			label[5] = label[2];
			label[2] = temp;
		}
		if (order[i] == 'W') 
		{
			temp = label[0];
			label[0] = label[2];
			label[2] = label[5];
			label[5] = label[3];
			label[3] = temp;
		}
		if (order[i] == 'S')
		{
			temp = label[0];
			label[0] = label[4];
			label[4] = label[5];
			label[5] = label[1];
			label[1] = temp;
		}
	}
	cout << label[0] << "\n";
}

Measured memory_bytes: 1208
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N,M=get_i
ab=array(N)
N.times do|i|
  ab[i]=get_i
end
cd=array(M)
M.times do|i|
  cd[i]=get_i
end
ab.each do|x,y|
    min_i=0
    M.times do|j|
        val=(x-cd[j][0]).abs+(y-cd[j][1]).abs
        if val<((x-cd[min_i][0]).abs+(y-cd[min_i][1]).abs)
            min_i=j
        end
    end
    puts min_i+1
end

Measured memory_bytes: 14132
a,b,x = gets.chomp.split(' ').map(&:to_i)
unless a == b
  if a % x == 0
    puts (b/x) - (a/x) + 1
  else
    puts (b/x) - (a/x) 
  end
else
  if a % x == 0
    puts 1
  else
    puts 0
  end
end

Measured memory_bytes: 14324
n = int(input())
cards = list(map(int, input().split()))

for i in range(n):
    v = cards[i]
    j = i-1
    while j >= 0 and cards[j] > v:
        cards[j+1] = cards[j]
        j -= 1
    cards[j+1] = v
    print(' '.join(map(str, cards)))


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

typedef long long llint;
typedef long double ld;
typedef pair<int,int> P;

#define inf 1e18
#define mod 1000000007
#define sort(v) sort(v.begin(),v.end())
#define reverse(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)


priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }


#define N 100

int g[N][N];
int d[N];
int f[N];
int t=0;


bool flag[N];
int n;

void dfs(int i){
    flag[i]=true;
    d[i]=++t;
    rep(j,0,n){
        if(g[i][j]==1 && !flag[j]){
            dfs(j);
        }
    }
    f[i]=++t;
}

void solve(){
    cin >> n;
    int u,k;
    rep(i,0,n){
        cin >> u >> k;
        u--;
        rep(j,0,k){
            int v;
            cin >> v;
            v--;
            g[u][v]=1;
        }
    }
    rep(i,0,n){
        if(!flag[i]){
            dfs(i);
        }
    }
    rep(i,0,n){
        cout << i+1 << " " << d[i] << " " << f[i] << endl;
    }
}

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






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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(auto i=0;i<(n);i++)
#define rep1(i,n) for(auto i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()

using namespace std;


struct init{ init(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20); }; }aaaaaaa;



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

  rep(i, 3){
    if(s[i] == s[i+1]){
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;


  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
int inp[100005];
int p[100005];
int find(int a){
    if(a==p[a]) return a;
    return p[a]=find(p[a]);
}
bool merge(int a, int b){
    a=find(a),b=find(b);
    if(a==b) return 0;
    p[a]=b;
    return 1;
}
int idx[100005];
int main(){
    int N,M,a,b; scanf("%d %d",&N,&M);
    for(int i=1;i<=N;i++){
        scanf("%d",inp+i);
        p[i]=i;
        idx[inp[i]]=i;
    }
    while(M--){
        scanf("%d %d",&a,&b);
        merge(a,b);
    }
    int ans=0;
    for(int i=1;i<=N;i++){
        int j=idx[i];
        if(find(j)==find(i)){
            ans++;
            swap(inp[i],inp[j]);
            swap(idx[inp[i]],idx[inp[j]]);
        }
    }
    printf("%d",ans);
}

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

    using namespace std;

    const int Nmax = 10006;

    char ans, a[Nmax];
    int A, B, n, i, st[Nmax], nr;

    int main()
    {
      //  freopen("input", "r", stdin);
        cin.sync_with_stdio(false);

        cin >> A >> B;

        if(A <= B)
        {
            cout << "Impossible\n";
            fflush(stdout);
            return 0;
        }

        n = A + B;
        st[nr = 1] = 0;

        for(i=1; i<n; ++i)
        {
            if(!nr)
            {
                st[++nr] = i;
                continue;
            }

            cout << "? " << st[nr] << ' ' << i << '\n';
            fflush(stdout);
            cin >> ans;

            if(ans == 'N') --nr;
                else st[++nr] = i;
        }

        for(i=0; i<n; ++i)
        {
            cout << "? " << st[nr] << ' ' << i << '\n';
            fflush(stdout);
            cin >> ans;

            a[i] = (ans == 'Y') + '0';
        }

        cout << "! " << a << '\n';
        fflush(stdout);

        return 0;
    }


Measured memory_bytes: 724
// input! macro is published in the following URLs.
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
// https://github.com/tanakh/competitive-rs.git
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input! {
        n: usize,
        m: usize,
        abs: [(i64, i64); n],
        cds: [(i64, i64); m],
    }
    let min_indices = abs
        .into_iter()
        .map(|(a, b)| {
            cds.iter()
                .enumerate()
                .min_by(|l, r| {
                    let lv = (a - (l.1).0).abs() + (b - (l.1).1).abs();
                    let rv = (a - (r.1).0).abs() + (b - (r.1).1).abs();
                    match lv.cmp(&rv) {
                        std::cmp::Ordering::Equal => std::cmp::Ordering::Less,
                        ordering => ordering,
                    }
                })
                .unwrap()
                .0
                + 1
        })
        .collect::<Vec<_>>();
    let ans = min_indices
        .iter()
        .map(|x| x.to_string())
        .collect::<Vec<_>>()
        .join("\n");
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	int N, Y;
	int x = -1, y = -1, z = -1;

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		N = Integer.parseInt(tokens[0]);
		Y = Integer.parseInt(tokens[1]);
	}

	void calc() {
		for (int i = 0; i * 10000 <= Y; ++i) {
			int remain0 = Y - i * 10000;
			for (int j = 0; j * 5000 <= remain0; ++j) {
				int remain1 = remain0 - j * 5000;
				if (remain1 / 1000 + i + j == N) {
					x = i;
					y = j;
					z = remain1 / 1000;
					return;
				}
			}
		}
	}

	void showResult() {
		System.out.println(x + " " + y + " " + z);
	}
}

Measured memory_bytes: 22996
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 mut done: bool = false;
    while !done {
        let n: u16 = read();
        if n == 0 {
            done = true;
        } else {
            let mut scores: Vec<f32> = vec![];
            for _ in 0..n {
                let score: f32 = read();
                scores.push(score)
            }
            let scores_sum: f32 = scores.iter().fold(0.0, |sum, score| sum + score);
            let scores_ave: f32 = scores_sum / (scores.len() as f32);
            let sd_2: f32 = scores
                .iter()
                .fold(0.0, |sum, score| sum + (score - scores_ave).powf(2.0))
                / (scores.len() as f32);

            println!("{}", sd_2.sqrt());
        }
    }
}



Measured memory_bytes: 5060
import sys
import math
input = sys.stdin.readline

#a, b, c, d = (int(i) for i in input().split())
#a = [int(i) for i in input().split()]

N = int(input())

for i in range(1, 10):
    if N%i == 0 and N/i < 10:
        print("Yes")
        exit()

print("No")


Measured memory_bytes: 38472
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 2147483647;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<auto>& a,int n);

int n;

class SegmentTree{
    vector<int> tree;
    int index;
    int evaluation(int a,int b){
        return min(a,b);
    }
    public:
    int size=0;
    SegmentTree(int n){
        int len = 1;
        while(len<n)len *= 2;
        tree.resize(len*2-1,max_int);
        index = len-1;
        size = len;
    }
    void update(int a,int x){
        a += index;
        tree[a] = x;
        while(a>0){
            a = (a-1)/2;
            tree[a] = evaluation(tree[a*2+1],tree[a*2+2]);
        }
    }
    int query(int a,int b){
        return query(a,b,0,0,size);
    }
    int query(int a,int b,int k,int l,int r){
        if(b<=l||r<=a)return max_int;
        if(a<=l&&r<=b)return tree[k];
        int vl=query(a,b,2*k+1,l,(l+r)/2);
        int vr=query(a,b,2*k+2,(l+r)/2,r);
        return evaluation(vl,vr);
    }

    void Print() {
        Debug(tree);
    }
};

signed main(){
    int q;
    cin >> n >> q;
    SegmentTree sg(n);
    REP(i,q){
        int tmp;
        cin >> tmp;
        if(tmp == 0){
            int x,y;
            cin >> x >> y;
            sg.update(x,y);
        }
        else{
            int x,y;
            cin >> x >> y;
            print(sg.query(x,y+1));
        }
    }
    //sg.Print();

    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<auto>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}



Measured memory_bytes: 4960
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main()
{
	int n, x;
	int i;
	int k = 0;
	int count = 1;
	int l[110];
	scanf("%d%d", &n, &x);
	l[0] = 0;
	for (i = 1;i <= n;i++)
	{
		scanf("%d", &l[i]);
	}
	for (i = 1;i <= n;i++)
	{
		k += l[i];
		if (k<= x)count++;
	}
	printf("%d\n", count);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
 
int main(){
    int N, K;
    scanf("%d %d", &N, &K);
    
    int score[N];
    for(int i = 0; i < N; i++) {
        scanf("%d", &score[i]);
    }
    for(int i = K; i < N; i++) {
        if(score[i] > score[i - K]) {
            printf("Yes\n");
        } 
		else {
            printf("No\n");
        }
    }
    return 0;
}

Measured memory_bytes: 2440
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
using namespace std;
const long long INF = 1LL << 60;    // 1.15x10^18
template<class T> inline bool chmin(T &a, T b) { return a > b ? (a = b, 1) : 0; }

int main() {
    int n; cin >> n;
    vector<pair<int, int>> ps;
    for (int i = 0; i < n; i++) {
        int a, b; cin >> a >> b;
        ps.emplace_back(a, i);
        ps.emplace_back(b, i + n);
    }
    sort(begin(ps), end(ps));
    long long sum = 0;
    vector<bool> used(n * 2);
    for (int i = 0; i < n; i++) sum += ps[i].first, used[ps[i].second] = true;
    int cnt = accumulate(begin(used), begin(used) + n, 0);
    if (cnt % n == 0) return !(cout << sum << endl);
    for (int i = 0; i < n; i++) {
        if (used[i] == used[i + n]) return !(cout << sum << endl);
    }
    long long mi = INF;
    for (int i = 0; i < n; i++) {
        bool eq = ps[i].second % n == ps[n].second % n;
        chmin(mi, sum - ps[i].first + ps[n + eq].first);
    }
    cout << mi << endl;
    return 0;
}


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

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

  ll H, times = 0;
  cin >> H;

  while (H > 0)
  {
    H = floor(H / 2);
    times++;
  }

  cout << setprecision(0) << fixed;
  
  cout << pow(2, times) - 1 << endl;
  
  return 0;
}

Measured memory_bytes: 4284
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();

		if ( s.charAt(0) == s.charAt(1) && s.charAt(1) == s.charAt(2) ) {
			System.out.println("No");
		} else {
			System.out.println("Yes");
		}
	}
}


Measured memory_bytes: 23508
from collections import deque

def main():
    N = int(input())
    S = deque(input())
    A = ['A','B','C','D','E','F','G','H','I','J','K',
         'L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']

    ans = deque()

    while len(S)>0:
        s = S.popleft()
        i = A.index(s)+N
        ans.append(A[i%26])

    print(''.join(ans))

if __name__ == '__main__':
    main()

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
template<class T>bool chmin(T&a,const T&b){return a>b?(a=b,true):false;}
template<class T>bool chmax(T&a,const T&b){return a<b?(a=b,true):false;}

int nextInt() { int x; scanf("%d", &x); return x;}

const int MAX_N = 200000 + 10;
int A[MAX_N];
int cnt[MAX_N];
int cover[MAX_N];

void add(int p, int &zero) {
  if (p >= 1) {
    if (cover[p] == 0) zero--;
    cover[p]++;
  }
}
void sub(int p, int &zero) {
  if (p >= 1) {
    cover[p]--;
    if (cover[p] == 0) zero++;
  }
}
int main2() {
  memset(cnt, 0, sizeof(cnt));
  memset(cover, 0, sizeof(cover));
  int N = nextInt();
  int M = nextInt();
  int zero = N;
  REP(i, N) {
    int a = nextInt();
    A[i] = a;
    ++cnt[a];
    add(a - cnt[a] + 1, zero);
  }
  REP(mi, M) {
    int X = nextInt() - 1;
    int Y = nextInt();
    int x = A[X];
    A[X] = Y;
    sub(x - cnt[x] + 1, zero);
    --cnt[x];
    ++cnt[Y];
    add(Y - cnt[Y] + 1, zero);
    printf("%d\n", zero);
  }
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws) main2();
  return 0;
}



Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC exit(0);
using namespace std;
int n, a, b;
int main() {
    DAU
    cin >> n >> a >> b;
    cout << min(n * a, b);
    PLEC
}


Measured memory_bytes: 3612
#include <stdio.h>

int main(){
  int a[3][100];
  int ret;
  char bin;
  int num[3];
  for(int i = 0; i < 3; ++i){
    num[i] = 0;
    while(1){
      ret = scanf("%c",&bin);
      if(ret == EOF || bin == '\n') break;
      a[i][num[i]] = bin - 'a';
      //printf("%d\n",a[i][num[i]]);
      num[i]++;
    }
  }
  int point = 0;
  int count[3] = {0,0,0};
  while(1){
    count[point]++;
    if(count[point] > num[point]) break;
    point = a[point][count[point]-1];
  }
  printf("%c\n",point + 'A');
  return 0;
}

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

ans_array = [[0] * (W + 2) for i in range(H + 2)]
bomb_array = [[0] * W for i in range(H)]

for i in range(1, H + 1):
    s = list(input())
    for j in range(1, W + 1):
        if s[j - 1] == '#':

            ans_array[i - 1][j - 1] += 1
            ans_array[i - 1][j] += 1
            ans_array[i - 1][j + 1] += 1

            ans_array[i + 1][j - 1] += 1
            ans_array[i + 1][j] += 1
            ans_array[i + 1][j + 1] += 1

            ans_array[i][j - 1] += 1
            ans_array[i][j + 1] += 1

            bomb_array[i - 1][j - 1] = 1
    
ans_line = ''
for i in range(1, H + 1):
    for j in range(1, W + 1):
        if bomb_array[i - 1][j - 1] == 1:
            ans_line += '#'
        else:
            ans_line += str(ans_array[i][j])
    print(ans_line)
    ans_line = ''
        

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

template <typename T> T load() { T r; cin >> r; return r; }
template <typename T> vector<T> loadMany(int n) { vector<T> rs(n); generate(rs.begin(), rs.end(), &load<T>); return rs; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    auto s = load<string>();
    auto t = load<string>();
    auto dyn = vector<vector<int>>(s.size()+1, vector<int>(t.size()+1, 0));
    for (auto i=0; i<(int)s.size(); ++i) {
        for (auto j=0; j<(int)t.size(); ++j) {
            dyn[i+1][j+1] = max(dyn[i][j+1], dyn[i+1][j]);
            if (s[i] == t[j])
                dyn[i+1][j+1] = max(dyn[i+1][j+1], dyn[i][j] + 1);
        }
    }
    auto r = string();
    auto i = (int)s.size();
    auto j = (int)t.size();
    while (i != 0 and j != 0) {
        if (s[i-1] == t[j-1] and dyn[i][j] == dyn[i-1][j-1]+1)
            r += s[i-1], --i, --j;
        else if (dyn[i][j] == dyn[i-1][j])
            --i;
        else if (dyn[i][j] == dyn[i][j-1])
            --j;
    }
    reverse(r.begin(), r.end());
    cout << r << '\n';
}


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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var X = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var xSort = X.OrderBy(o => o).ToList();
            var center = N / 2;
            var result = new int[N];

            for (var i = 0; i < N; i++)
            {
                if (i < center)
                    result[i] = xSort[center];
                else
                    result[i] = xSort[center - 1];
            }

            // 最終的にO(N^2)にならないようにDictionaryに入れ替える
            var dict = new Dictionary<int, int>();
            for (var i = 0; i < N; i++)
                if (!dict.ContainsKey(xSort[i])) dict[xSort[i]] = result[i];

            for (var i = 0; i < N; i++)
                Console.WriteLine(dict[X[i]]);
        }
    }
}


Measured memory_bytes: 47436
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define sz(x) (int)(x).size();
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int32_t main()
{
	string s;
	cin>>s;
	int o=count(s.begin(),s.end(),'1');
	int e=count(s.begin(),s.end(),'0');
	cout<<2*min(o,e);
	
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
#define PI acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define nl printf("\n")
#define spc printf(" ")
#define sf scanf
#define pf printf
#define INF (ll)1e15
#define mod 1000000007
#define FI freopen("input.txt","r",stdin)
#define FO freopen("output.txt","w",stdout)
#define si(x) scanf("%d",&x)
#define sii(x,y) scanf("%d %d",&x,&y)
#define siii(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld %lld",&x,&y)
#define slll(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
 
///#define isValid(n,m,nx,ny)nx>=0&&nx<n&&ny>=0&&ny<m
///#define triangle_area(a,b,m,n,x,y) (a*(n-y)+m*(y-b)+x*(b-n))/2.0
///int kx[]={1, 1, -1, -1, 2, 2, -2, -2}; //knight moves
///int ky[]={2,-2,  2, -2, 1,-1,  1, -1}; //knight moves
///int dx[]={1,-1,0,0,1,-1,1,-1};//eight direction
///int dy[]={0,0,1,-1,1,-1,-1,1};//eight direction
 
///using namespace __gnu_pbds;
using namespace std;
 
///inline double toRad(double deg){return deg*PI/180;}
///inline double toDeg(double rad){return rad*180/PI;}
///typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
 
const int S=500006;
int main()
{
    #ifndef ONLINE_JUDGE
    //FI;
    //FO;
    #endif
    //ios_base::sync_with_stdio(0); cin.tie(0);
    ll a,b;
    while(sll(a,b)==2)
    {
    	ll Lcm=(a*b)/__gcd(a,b);
    	pf("%lld\n",Lcm);
    }
    return 0;
}
 









 




























Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstring>
#include <map>
#include <climits>
#include <bitset>

#define ll long long
const ll MOD = 1e9 + 7;
const ll INF = 1 << 29;

int main()
{
    ll N, Y;
    std::cin >> N >> Y;

    Y /= 1000;

    for (auto a=0; a<=N; ++a)
    {
        for (auto b=0; b<=N; ++b)
        {
            auto c = N - a - b;
            if (c < 0)
                continue;

            ll y = 10 * a + 5 * b + c;
            if (Y == y)
            {
                std::cout << a << " " << b << " " << c << std::endl;
                return 0;
            }
        }
    }

    std::cout << -1 << " " << -1 << " " << -1 << std::endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
typedef long long ll;
using namespace std;
int main(void){
  ll n,k,a;
  ll v[n+10]={0};
  cin >> n >> k;
  for(ll i=0;i<n;++i){
    cin >>a;
   	v[a-1]++;
  }
  ll ans=0;
  std::sort(v,v+n,greater<int>());
  for(ll i=0;i<k;++i){
     	ans += v[i];
  }
  cout << n-ans;
return 0;
}


Measured memory_bytes: 49408
while True:
    x, y = map(int, input().split())
    if x == y == 0:
        break
    for i in range(x):
        for j in range(y):
            if i % 2 == 0:
                if j % 2 == 0:
                    print("#", end="")
                else:
                    print(".", end="")
            else:
                if j % 2 == 0:
                    print(".", end="")
                else:
                    print("#", end="")
        print()
    print()



Measured memory_bytes: 7000