akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
long long fac[100002];
long long fast_pow(long long x,long long y){
    if(y==0)return 1;
    if(y==1)return x%MOD;
    long long ret=fast_pow(x,y/2);
    if(y%2==0)return (ret*ret)%MOD;
    return (((ret*ret)%MOD)*x)%MOD;
}
long long c(int x,int y){
    if(x<y)return 0;
    long long top=fac[x];
    long long bot=(fac[x-y]*fac[y])%MOD;
    return (top*fast_pow(bot,MOD-2))%MOD;
}
int n,a[100001];
int main(){
    fac[0]=1;
    for(int i=1;i<=100001;i++)fac[i]=(fac[i-1]*i)%MOD;
    scanf("%d",&n);
    long long twice=0;
    for(int i=0;i<n+1;i++){
        scanf("%d",&a[i]);
        twice=twice+a[i];
    }
    twice=twice-(((long long)n*((long long)n+1ll))/2ll);
    int d=0;
    for(int i=0,j=0;i<n+1;i++){
        if(a[i]==twice)j=!j;
        if(j)d++;
    }
    for(int k=1;k<=n+1;k++){
        printf("%lld\n",(c(n+1,k)-c(n-d,k-1)+MOD)%MOD);
    }
    return 0;
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int tp=0;
    int hp=0;
    for(int i=0;i<n;i++){
        string T,H;
        cin>>T>>H;
        if(T<H) hp+=3;
        else if(T>H) tp+=3;
        else{
            tp+=1;
            hp+=1;
        }
    }
    cout<<tp<<' '<<hp<<endl;
}


Measured memory_bytes: 3156
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll mod = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

ll h, w, a, b;

ll gcd(ll a, ll b){
	return b == 0LL ? a : gcd(b, a%b);
}
ll lcm(ll a, ll b){
	return a / gcd(a, b) * b;
}
ll extgcd(ll a, ll b, ll &x, ll &y){
	ll g = a;
	x = 1LL;
	y = 0LL;
	if(b != 0) g = extgcd(b, a%b, y, x), y-= (a/b)*x;
	return g;
}

ll fact[200010], ifact[200010];
ll mod_inverse(int a){
	ll x, y;
	extgcd(a, mod, x, y);
	return(mod+x%mod)%mod;
}

ll c(int n, int r){
	if(n < 0 || r < 0 || r > n) return 0;
	if(r > n / 2) r = n-r;
	return fact[n]*ifact[n-r]%mod*ifact[r]%mod;
}

int main(){
	cin>>h>>w>>a>>b;
	int n = h+w;
	fact[0]=ifact[0] = 1LL;
	for(int i = 1; i <= n; i++){
		fact[i] = fact[i-1]*i%mod;
		ifact[i] = mod_inverse(fact[i]);
	}
	ll ans = c(h+w-2, w-1);
	for(int i = 0; i < b; i++){
		ll tmp = c(h-a-1+i, h-a-1)*c(a-1+w-i-1, a-1) % mod;
		ans -= tmp;
		(ans+=mod) %= mod;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3328
#include <stdio.h>

typedef struct { char suit, value; } Card;

void bubble(Card A[], int N) {
  int i,j;
  Card t;
  for(i = 0; i<N; i++) {
    for(j = N-1; j >= i; j--) {
      if(A[j].value < A[j-1].value) {
        t = A[j]; A[j] = A[j-1]; A[j-1] = t;
      }
    }
  }
}

void selection(Card A[], int N) {
  int i,j,minj;
  Card t;
  for(i=0;i<N;i++) {
    minj = i;
    for(j=i; j<N; j++) {
      if(A[j].value < A[minj].value) minj = j;
    }
    t = A[i]; A[i] = A[minj]; A[minj] = t;
  }
}

void print(Card A[], int N) {
  int i;
  for(i=0; i<N; i++) {
    if(i>0) printf(" ");
      printf("%c%d",A[i].suit,A[i].value);
  }
  printf("\n");
}

int isStable(Card C1[], Card C2[], int N) {
  int i;
  for(i=0; i<N; i++) {
    if(C1[i].suit != C2[i].suit) return 0;
  }
  return 1;
}

void str2Card(Card *t,char str[]) {
    t->suit  = str[0];
    t->value = str[1] - '0';
}

int main(void) {
  Card C1[100], C2[100];
  int N,i;
  char str[3];

  scanf("%d",&N);
  for(i=0;i<N; i++) {
    scanf("%s",str);
    str2Card(&C1[i],str);
  }

  for(i=0; i<N; i++) C2[i] = C1[i];

  bubble(C1,N);
  selection(C2,N);

  print(C1,N);
  printf("Stable\n");
  print(C2,N);
  if(isStable(C1,C2,N)) {
    printf("Stable\n");
  } else {
    printf("Not stable\n");
  }

  return 0;
}


Measured memory_bytes: 2096
import java.io.*;
import java.util.*;


class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        int n=sc.nextInt();
        int cc=sc.nextInt();
        ArrayList<Long>[]ode=new ArrayList[cc];
        Arrays.setAll(ode,x->new ArrayList<Long>());
        for(int i=0;i<n;++i){
            int s=sc.nextInt();
            int t=sc.nextInt();
            int c=sc.nextInt()-1;
            ode[c].add((long)s<<32|t);
        }
        int[]timeline=new int[110000];
        for(int c=0;c<cc;++c){
            Collections.sort(ode[c]);
            int len=ode[c].size();
            int es=-1;
            int et=-1;
            for(int i=0;i<len;++i){
                long nxt=ode[c].get(i);
                int fs=(int)(nxt>>>32);
                int ft=(int)nxt;
                if(et==fs)et=ft;
                else{
                    if(es>=1){
                        for(int j=es-1;j<et;++j)timeline[j]++;
                    }
                    es=fs;
                    et=ft;
                }
            }
            if(es>=1)for(int i=es-1;i<et;++i)timeline[i]++;
        }
        int ans=0;
        for(int t:timeline)ans=Math.max(ans,t);
        out.println(ans);
        out.close();
    }
    // http://codeforces.com/blog/entry/7018
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 48028
#include<bits/stdc++.h>
using namespace std;
typedef pair< int, int > Pi;
const int vy[] = {0, 1, 0, -1}, vx[] = {1, 0, -1, 0};


map< Pi, Pi > futon;
map< Pi, int > head;

bool check(const Pi& point)
{
  head[point] = 1;
  head[futon[point]] = -1;
  bool flag = true;
  for(int i = 0; i < 4 && flag; i++) {
    const int nx = point.first + vx[i], ny = point.second + vy[i];
    if(make_pair(nx, ny) == futon[point]) continue;
    if(head.find({nx, ny}) != head.end()) {
      if(head[{nx, ny}] == -1) flag = false;
    } else if(futon.find({nx, ny}) != futon.end()) {
      if(!check({nx, ny})) flag = false;
    }
  }
  
  for(int i = 0; i < 4 && flag; i++) {
    const int nx = futon[point].first + vx[i], ny = futon[point].second + vy[i];
    if(make_pair(nx, ny) == point) continue;
    if(head.find({nx, ny}) != head.end()) {
      if(head[{nx, ny}] == 1) flag = false;
    } else if(futon.find({nx, ny}) != futon.end()) {
      if(!check(futon[{nx, ny}])) flag = false;
    }
  }
  
  if(flag) return(true);
  head.erase(futon[point]);
  head.erase(point);
  return(false);
}

int main()
{
  int N;
  while(cin >> N, N) {
    while(N--) {
      int x, y;
      char dir;
      cin >> x >> y >> dir;
      if(dir == 'x') {
        futon[{x, y}] = {x + 1, y};
        futon[{x + 1, y}] = {x, y};
      } else {
        futon[{x, y}] = {x, y + 1};
        futon[{x, y + 1}] = {x, y};
      }
    }
    while(!futon.empty()) {
      auto decide = *futon.begin();
      if(head.find(decide.first) == head.end()) {
        if(!check(decide.first) && !check(decide.second)) break;
      }
      futon.erase(futon.begin());
    }
    if(futon.empty()) cout << "Yes" << endl;
    else cout << "No" << endl;

    head.clear();
    futon.clear();
  }
}

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

int main() {
  vector<vector<int>>B(3,vector<int>(3));
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin>>B.at(i).at(j);
    }
  }
  int N;
  vector<int>A(N);
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        if(A.at(i)==B.at(j).at(k)){
          B.at(j).at(k)=0;
        }
      }
    }
  }
  for(int i=0;i<3;i++){
    int b=0;
    for(int j=0;j<3;j++){
      if(B.at(i).at(j)==0){
        b++;
      }
    }
    if(b==3){
      cout<<"Yes"<< endl;
      return 0;
    }
  }
  for(int i=0;i<3;i++){
    int c=0;
    for(int j=0;j<3;j++){
      if(B.at(j).at(i)==0){
        c++;
      }
    }
    if(c==3){
      cout<<"Yes"<< endl;
      return 0;
    }
  }
  int d=0;
  for(int i=0;i<3;i++){
    if(B.at(i).at(i)==0){
      d++;
    }
  }
  if(d==3){
    cout<<"Yes"<< endl;
    return 0;
  }
  int e=0;
  for(int i=0;i<3;i++){
    if(B.at(i).at(2-i)==0){
      e++;
    }
  }
  if(e==3){
    cout<<"Yes"<< endl;
    return 0;
  }
  cout<<"No"<< endl;
}
    
   
    
      
      



Measured memory_bytes: 384
#include<stdio.h>
int main(void){
int n,i;
long long t,a,anst=1,ansa=1,tt,ta;
scanf("%d",&n);
for(i=0;i<n;i++){
scanf("%lld %lld",&t,&a);
if(anst%t)tt=anst/t+1;
else tt=anst/t;
if(ansa%a)ta=ansa/a+1;
else ta=ansa/a;
if(tt>ta){
anst=t*tt;
ansa=a*tt;
}
else{
anst=t*ta;
ansa=a*ta;
}
}
printf("%lld\n",anst+ansa);
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, k; cin >> k >> n;
	if(k%2 == 0){
		cout << k / 2 << " ";
		for(int i = 0; i < n - 1; i++) cout << k << " ";
		cout << endl;
	} else {
		vector<int> ans;
		for(int i = 0; i < n; i++) ans.push_back((k + 1) / 2);
		for(int i = 0; i < n / 2; i++){
			if(ans.back() == 1){
				ans.pop_back();
				continue;
			}
			ans.back()--;
			while(ans.size() < n) ans.push_back(k);
		}
		for(int v : ans) cout << v << " "; cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3568
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!coution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	X := nextInt64()
	for i := int64(0); i <= 1000; i++ {
		for j := int64(0); j < i; j++ {
			pi := pow(i, 5)
			pj := pow(j, 5)
			if pi-pj == X {
				fmt.Println(i, j)
				return
			}
			if pi+pj == X {
				fmt.Println(i, -j)
				return
			}
		}
	}
}

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func split(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "fuck")
	}
}

// -*-*-*-*-*-*-*-*-
// * tool snippets *
// -*-*-*-*-*-*-*-*-
func duplicate2Int(base [][]int) (ret [][]int) {
	ret = make([][]int, len(base))
	for i, v := range base {
		ret[i] = append([]int{}, v...)
	}
	return
}

// -*-*-*-*-*-*-*-*-*-*-*-*-*-
// * Algorithms Utility Zone *
// -*-*-*-*-*-*-*-*-*-*-*-*-*-

// -*-*-*-*-*-*-*-
// * 1. nibutan  *
// -*-*-*-*-*-*-*-
func lower_bound(arr []int, target int) int {
	l, r := 0, len(arr)
	for l < r {
		mid := (l + r) / 2
		if arr[mid] < target {
			l = mid + 1
		} else {
			r = mid
		}
	}
	return l
}

func upper_bound(arr []int, target int) int {
	l, r := 0, len(arr)
	for l < r {
		mid := (l + r) / 2
		if target < arr[mid] {
			r = mid
		} else {
			l = mid + 1
		}
	}
	return l
}

// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
// * math flavor typical theories *
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
func gcd(a, b int) int {
	if a > b {
		return gcd(b, a)
	}
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

func pow(a int64, b int) (ret int64) {
	ret = a
	// 10^2 = 100ってことは10に10を1回掛けることだね
	// なので初期値を含めると上限b-1未満
	for i := 0; i < b-1; i++ {
		ret *= a
	}
	return
}

func powMod(n, m, mod int) (ret int) {
	ret = 1
	for m > 0 {
		if m&1 == 1 {
			ret *= n
			ret %= mod
		}
		n *= n
		n %= mod
		m >>= 1
	}
	return ret
}


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

const int MAX = 2000000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int X,Y;
    cin >> X >> Y;
    if((X+Y)%3){
        cout << 0 << endl;
        return 0;
    }
    COMinit();
    int N = (2*X-Y) / 3;
    int M = (2*Y-X) / 3;

    cout << COM(N+M, N) << endl;
    return 0;
}

Measured memory_bytes: 47104
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
template <typename T>
struct Fenwick {
	int n;
	vector<T> bit;
	Fenwick(int _n) : n(_n) {
		bit.resize(n + 1);
	}
	void update(int p, T v) {
		for (; p <= n; p += p & -p) bit[p] += v;
	}
	T query(int p) {
		T ret{};
		for (; p; p -= p & -p) ret += bit[p];
		return ret;
	}
	// multiset with count strictly less; values contain all inserted values
	vector<ll> values;
	Fenwick(vector<ll>& _values) : values(_values) {
		sort(values.begin(), values.end());
		n = unique(values.begin(), values.end()) - values.begin();
		values.resize(n);
		bit.resize(n + 1);
	}
	void insert(ll val) {
		int pos = lower_bound(values.begin(), values.end(), val) - values.begin();
		update(pos + 1, 1);
	}
	int countLess(ll val) {
		int pos = lower_bound(values.begin(), values.end(), val) - values.begin();
		return query(pos);
	}
	// Assumes val already exists
	void erase(ll val) {
		int pos = lower_bound(values.begin(), values.end(), val) - values.begin();
		update(pos + 1, -1);
	}
};
int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	vector<int> a(n);
	vector<ll> S(n + 1);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &a[i]);
		S[i + 1] = S[i] + a[i] - k;
	}
	Fenwick<int> fenw(S);
	fenw.insert(0);
	ll ans = 0;
	for (int i = 1; i <= n; ++i) {
		ans += fenw.countLess(S[i] + 1);
		fenw.insert(S[i]);
	}
	printf("%lld\n", ans);
}


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

#define int long long

#define inf (int)1000000007
#define mod (int)1000000007

#define rep(i, n) for(int i = 0; i < (n); i++)
#define trep(i, n) for(int i = 0; i <= (n); i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rtrep(i, n) for(int i = (n); i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define mfor(i, s, t) for(int i = (s); i < (t); i++)
#define tfor(i, s, t) for(int i = (s); i <= (t); i++)
#define rfor(i, s, t) for(int i = (t) - 1; i >= (s); i--)

int dd[114514];

signed main() {
	int dn;
	cin >> dn;
	rep(i, dn) {
		cin >> dd[i];
	}
	int ans = 1;
	int nb = 0;
	rep(i, dn) {
		while(nb < dn - 1 && (nb + 1 - i) * 2 - 1 <= dd[nb]) {
			nb++;
		}
		ans = ans * (nb + 1 - i) % mod;
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
//g++ -Wall -Werror -O2 -std=c++11 main.cpp -o main && main.exe < in.txt
#include <bits/stdc++.h>

using namespace std;

#define INF 0x3f3f3f3f
#define ll long long

int main() {
	ios::sync_with_stdio(false);
	int N, Q;
	string S;
	cin >> N >> S >> Q;
	for (int i = 0; i < Q; i++) {
		int k;
		cin >> k;

		ll a = 0;
		ll b = 0;
		ll m = 0;
		ll ans = 0;
		for (int j = 0; j < N; j++) {
			if (S[j] == 'D') {
				a++;
			} else if (S[j] == 'M') {
				b += a;
				m++;
			} else if (S[j] == 'C') {
				ans += b;
			}

			if (j >= k - 1) {
				if (S[j-k+1] == 'D') {
					a--;
					b -= m;
				} else if (S[j-k+1] == 'M') {
					m--;
				}
			}
		}
		cout << ans << endl;
	}

    return 0;
}


Measured memory_bytes: 1948
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()
#define var(t, ...) t __VA_ARGS__;in,__VA_ARGS__;

void Calc();
int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
template<class A>int comp(A a, A b) { return a < b ? 1 : b < a ? -1 : 0; }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/


void Calc() {

  string s = in;
  string t = in;
  int c = -1;
  rrep(i, size(s) - size(t) + 1) {
    bool ok = true;
    rep(j, size(t)) {
      if (s[i + j] != t[j] && s[i + j] != '?')
        ok = false;
    }
    if (ok) {
      c = i;
      break;
    }
  }
  if (c == -1) {
    cout << ("UNRESTORABLE") << endl;
    return;
  }

  rep(i, c) {
    if (s[i] == '?')cout << 'a';
    else cout << s[i];
  }
  cout << t;
  rep(i, c + size(t), size(s)) {
    if (s[i] == '?')cout << 'a';
    else cout << s[i];
  }
  cout << endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

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

    while (true) {
      int h = scanner.nextInt();
      int w = scanner.nextInt();

      if (h == 0 && w == 0) break;

      for (int i = 0; i < h; i++) {
        String line = "";
        for (int j = 0; j < w; j++) {
          line += "#";
        }
        System.out.println(line);
      }
      System.out.println();
    }

    scanner.close();
  }
}

Measured memory_bytes: 51584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll a[600005];
ll ans=1000000000000000;
int main(void){
    ll k,n; cin>>k>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        a[n+i]=a[i]+k;
        a[n+n+i]=a[i]+k+k;
    }
    for(int i=0;i<n;i++){
        ans=min(ans,a[n+i]-a[i+1]);
        ans=min(ans,a[n+n+i-1]-a[n+i]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4992
<?php /*atcoder.php*/

$t = new temp();

$t->stdin();

unset($t);

class temp{
	
	public function __construct(){
	}

	public function stdin(){
		$yen = fgets(STDIN);	
		$buy1 = fgets(STDIN);	
		$buy2 = fgets(STDIN);

		$buf1 = $yen - $buy1;
		$buf2 = $buf1 / $buy2;

		$buf1 = $buf1 - (floor($buf2) * $buy2);
		echo $buf1;

	}
	
}

?>


Measured memory_bytes: 3828
def partition(A, p, r):
    x = A[r]
    i = p-1
    for j in range(p, r):
        if A[j] <= x:
            i = i+1
            A[i], A[j] = A[j], A[i]
    A[i+1], A[r] = A[r], A[i+1]
    return i+1

if __name__ == '__main__':
    n = int(input())
    A = list(map(int, input().split()))
    b = partition(A, 0, len(A)-1)
    a = list(map(str, A))
    a[b] = "[" + a[b] + "]"
    print(' '.join(a))


Measured memory_bytes: 16584
import sys
sys.setrecursionlimit(10**7)
n=int(input())
edge=[[] for _ in range(n)]
dist=[-1]*n
for i in range(n-1):
    x,y,z=map(int,input().split())
    edge[x-1].append([y-1,z])
    edge[y-1].append([x-1,z])
def dfs(node,d):
    dist[node]=d
    for i in edge[node]:
        if dist[i[0]]==-1:
            dfs(i[0],d+i[1])
dfs(0,0)
print(*[i%2 for i in dist],sep='\n')

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

int main() {
	int n; scanf("%d", &n);
	vector<vector<int>> days(3, vector<int>(n));

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

	vector<int> dp(3);

	for (int i = 0; i < n; i++) {
		vector<int> new_dp(3, 0);
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (j == k) continue;
				new_dp[j] = max(new_dp[j], dp[k] + days[j][i]);
			}
		}
		dp = new_dp;
	}

	int ans = 0;
	ans = max({ans, dp[0], dp[1], dp[2]});
	printf("%d\n", ans);
}

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

using namespace std;
const int BUF = 2*80*80+1;
bool D[81][81][BUF];

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int H, W;
    cin >> H >> W;
    vector<vector<int> > A(H, vector<int>(W)), B(H, vector<int>(W)), C(H, vector<int>(W));
    for (auto &a : A) for (auto &_a :a) cin >> _a;
    for (auto &b : B) for (auto &_b :b) cin >> _b;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            C[i][j] = abs(A[i][j] - B[i][j]);
        }
    }
    D[0][0][C[0][0]] = true;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            for (int k = 0; k < BUF; ++k) {
                if (i > 0 && D[i - 1][j][k]) {
                    D[i][j][abs(C[i][j] - k)] = true;
                    if (C[i][j] + k < BUF) D[i][j][C[i][j] + k] = true;
                }
                if (j > 0 && D[i][j - 1][k]) {
                    D[i][j][abs(C[i][j] - k)] = true;
                    if (C[i][j] + k < BUF) D[i][j][C[i][j] + k] = true;
                }
            }
        }
    }
    for (int k = 0; k < BUF; ++k) {
        if (D[H - 1][W - 1][k]) {
            printf("%d\n", k);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 81408
use std::io;


fn main() {
    let r = read_one::<usize>();
    if r < 1200 { println!("ABC"); }
    else if r < 2800 { println!("ARC"); }
    else { println!("AGC"); }
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h> 
#define ll long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define fr(i,a,b) for(long long int i=a; i<b; i++)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
using namespace std;
signed main() 
{
    fast
    ll t=1;
  // cin>>t;
    while(t--)
    {
           ll n,w;
           cin>>n>>w;
           ll wt[n],v[n];
           for(ll i=0;i<n;i++) cin>>wt[i]>>v[i];
           ll k[n+1][w+1];
           for (ll i = 0; i <=n; i++) 
           {
                  for (ll j= 0; j <= w; j++) 
                  { 
                         if (i == 0 || j == 0)  k[i][j] = 0; 
                         else if (wt[i - 1] <= j) 
                         {k[i][j] = max(v[i - 1] + k[i - 1][j - wt[i - 1]],k[i - 1][j]);} 
                         else  k[i][j] = k[i - 1][j]; 
                  }
           }
           cout<<k[n][w]<<"\n";
    }
}

Measured memory_bytes: 82404
#include<cstdio>

int main(void){
int H,W,i,j,h,w;
do {
scanf("%d%d",&H,&W);
h=H/2;
w=W/2;
if(H!=0||W!=0){
if((H%2==0)&&(W%2==0)){
for(i=1;i<=h;i++){
for(j=1;j<=w;j++){printf("#.");}printf("\n");
for(j=1;j<=w;j++){printf(".#");}printf("\n");}
printf("\n");
}else if(H%2==0){
for(i=1;i<=h;i++){
for(j=1;j<=w;j++){printf("#.");}printf("#\n");
for(j=1;j<=w;j++){printf(".#");}printf(".\n");}
printf("\n");
}else if(W%2==0){
for(i=1;i<=h;i++){
for(j=1;j<=w;j++){printf("#.");}printf("\n");
for(j=1;j<=w;j++){printf(".#");}printf("\n");
}for(j=1;j<=w;j++){printf("#.");}printf("\n");
printf("\n");
}else{
for(i=1;i<=h;i++){
for(j=1;j<=w;j++){printf("#.");}printf("#\n");
for(j=1;j<=w;j++){printf(".#");}printf(".\n");
}for(j=1;j<=w;j++){printf("#.");}printf("#\n");
printf("\n");
}
};
}while(H!=0||W!=0);
return 0;
}

Measured memory_bytes: 2612
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using vi = vector<int>;
using vl = vector<int64_t>;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}

const int MOD = 1e9 + 7;

const int MAX = 2e5;
//const int MOD = 1e9 + 7;
int64_t fac[MAX] = {}, inv[MAX] = {}, finv[MAX] = {};

void make_table() {
  fac[0] = 1; fac[1] = 1;
  finv[0] = 1; finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; ++i) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

int64_t com(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

  int64 n, k; cin >> n >> k;
  make_table();

  //int64 ans = 0;

  for (int i = 1; i <= k; ++i) {
    int64 ans = 0;
    (ans += com(n - k + 1, i) * com(k - 1, i - 1)) %= MOD;
    cout << ans << '\n';
  }


  return 0;
}


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

vi G[105];

int main()
{
	IO_OP;
	
	int n, k;
	cin >> n >> k;
	if(k > (n-1)*(n-2) / 2) {
		cout << -1 << endl;
		return 0;
	}
	for(int i=2;i<=n;i++)
		G[1].PB(i);
	int r = (n-1)*(n-2)/2 - k;
	for(int i=2;i<=n;i++) {
		for(int j=i+1;j<=n;j++) {
			if(r) {
				G[i].PB(j);
				r--;
			}
		}
	}
	int m = 0;
	for(int i=1;i<=n;i++)
		m += G[i].size();
	cout << m << endl;
	for(int i=1;i<=n;i++)
		for(int j:G[i])
			cout << min(i, j) << " " << max(i, j) << endl;
	
}



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

int check(int x)
{
    if (x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12)
        return 0;
    else if (x == 4 || x == 6 || x == 9 || x == 11)
        return 1;
    else
        return 2;
}

int main()
{
    int x, y;
    cin >> x >> y;
    int sx, sy;
    sx = check(x);
    sy = check(y);
    if (sx == sy)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Collections;
public class Remainder
{

  static long div = 1000000007;

    static public void Main()
    {
        var S = Console.ReadLine();
        var N = S.Length;
        var cum = new int[26,N];
        var que = new Queue<int>[26];
        for(int i = 0;i < 26;i++){
          que[i] = new Queue<int>();
        }
      
        for(int i = 0;i < N;i++){
          var cast = ((int)S[i])%97;
          cum[cast,i]++;
          que[cast].Enqueue(i);
        }
        
        for(int i = 0;i < 26;i++){
          for(int j = 1;j < N;j++){
            cum[i,j] += cum[i,j-1];
          }
        }
        //答えがあるかどうかのフラグ
      　var flag = false;
        var a = -1;
        var b = -1;
        //アルファベット順にキューから取り出し二分探索する
        for(int i = 0;i < 26;i++){
          while(que[i].Count > 0){
            //累積和の左側を計算
            var left  = que[i].Dequeue();
            var lsum = 0;
            if(left > 0){
              lsum = cum[i,left-1];
            }
            
            var right = left+1;
            if(right < N && (cum[i,right]-lsum) == 2){
              a = left;
              b = right;
              flag = true;
              break;
            }
            
            right = left+2;
            if(right < N && (cum[i,right]-lsum) == 2){
              a = left;
              b = right;
              flag = true;
              break;
            }
          }
          if(flag){
            break;
          }
        }
        
        if(flag){
          Console.WriteLine((a+1)+" "+(b+1));
        }else{
          Console.WriteLine(-1+" "+-1);
        }
        

    }

}


Measured memory_bytes: 23136
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

using fint64 = int_fast64_t;
template<fint64 MOD>
struct ModInt{
    fint64 x;
    ModInt():x(0){}
    ModInt(fint64 x):
        x(x>=0?x%MOD:(MOD-(-x)%MOD)%MOD)
        {}
    // 負号
    ModInt operator -() const{
        return ModInt(-x);
    }
    // 加算
    ModInt &operator +=(const ModInt &rhs){
        x+=rhs.x;
        if(x>=MOD) x-=MOD;
        return (*this);
    }
    ModInt operator +(const ModInt &rhs) const{
        return ModInt(*this)+=rhs;
    }
    // 減算
    ModInt &operator -=(const ModInt &rhs){
        x+=MOD-rhs.x;
        if(x>=MOD) x-=MOD;
        return (*this);
    }
    ModInt operator -(const ModInt &rhs) const{
        return ModInt(*this)-=rhs;
    }
    // 乗算
    ModInt &operator *=(const ModInt &rhs){
        x*=rhs.x;
        if(x>=MOD) x%=MOD;
        return (*this);
    }
    ModInt operator *(const ModInt &rhs) const{
        return ModInt(*this)*=rhs;
    }
    // 除算
    ModInt &operator /=(const ModInt &rhs){
        (*this)*=rhs.inverse();
        return (*this);
    }
    ModInt operator /(const ModInt &rhs) const{
        return ModInt(*this)/=rhs;
    }
    // 等号
    bool operator ==(const ModInt &rhs){
        return x==rhs.x;
    }
    bool operator !=(const ModInt &rhs){
        return x!=rhs.x;
    }
    // 累乗
    ModInt pow(fint64 n) const{
        fint64 tmp=x;
        fint64 ret=1;
        while(n>0){
            if(n&1) ret=ret*tmp%MOD;
            tmp=tmp*tmp%MOD;
            n>>=1ll;
        }
        return ModInt(ret);
    }
    // 逆元
    ModInt inverse() const{
        fint64 a=x,b=MOD,s=1,t=0;
        while(b>0){
            fint64 u=a/b;
            a-=u*b;
            s-=u*t;
            swap(a,b);
            swap(s,t);
        }
        return ModInt(s);
    }
    // 入出力
    friend istream &operator >>(istream &lhs,ModInt<MOD> &rhs){
        fint64 x; lhs>>x;
        rhs=ModInt<MOD>(x);
        return lhs;
    }
    friend ostream &operator <<(ostream &lhs,const ModInt<MOD> &rhs){
        return lhs<<rhs.x;
    }
};

using mint=ModInt<MOD>;

int n,m;
bool ng[100010];
mint dp[100010];
bool used[100010];

mint dfs(int from){
    if(ng[from]) return 0;
    if(used[from]) return dp[from];
    if(dp[from]!=0) return dp[from];
    if(from<0) return 0;
    used[from]=1;
    mint ret=0;
    ret+=dfs(from-1);
    ret+=dfs(from-2);
    dp[from]=ret;
    return ret;
}

int main(){
    cin>>n>>m;
    rep(i,m){
        int a; cin>>a;
        ng[a]=true;
    }
    dp[0]=1;
    dfs(n);
    cout<<dp[n]<<endl;
    return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

int main(){
    int N, T;
    cin >> N >> T;
    int ans = 1e9;
    for(int i = 0; i < N; i++){
        int c, t;
        cin >> c >> t;
        if(t <= T){
            ans = min(ans, c);
        }
    }
    if(ans > 1e9 - 100){
        cout << "TLE" << endl;
    }else{
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define ll long long
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;

int main(){
    ll n=1;
    cin>>n;
    queue<ll> q;
    ll ans=1;
    while(ans<10){
        if(n==ans){
            cout<<ans<<endl;
            return 0;
        }
        q.push(ans);
        ans+=1;
    }
    ans=1;
    while(true){
        if(n==ans){
            cout<<q.front()<<endl;
            return 0;
        }
        if(q.front()%10==0){
            q.push(q.front()*10);
            q.push(q.front()*10+1);
            q.pop();
            ans+=1;
        }
        else if(q.front()%10==9){
            q.push(q.front()*10+8);
            q.push(q.front()*10+9);
            q.pop();
            ans+=1;
        }
        else{
            q.push(q.front()*10+q.front()%10-1);
            q.push(q.front()*10+q.front()%10);
            q.push(q.front()*10+q.front()%10+1);
            q.pop();
            ans+=1;
        }
    }
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
        
        int32_t main() {
            
            ios::sync_with_stdio(false);
            cin.tie(0);
            cout.tie(0);
           
            int x,y;
            cin>>x>>y;
            if( (4*x-y)&1 ){
                cout<<"No"<<endl;
                return 0;
            }
            else if( (4*x-y)/2 >=0 && (4*x-y)/2 <=x )
                cout<<"Yes"<<endl;
            else
                cout<<"No"<<endl;
            return 0;
        }

 

Measured memory_bytes: 3648
# coding : utf-8

N,T = map(int,input().split(' '))

c = [i for i in range(N)]
t = [i for i in range(N)]

for i in range(N):
    c[i],t[i] = map(int,input().split(' '))

a = 9999
for i in range(N):
    if t[i] <= T and c[i] < a:
        a = c[i]

if a == 9999:
    print('TLE')
else:
    print(a)

Measured memory_bytes: 3064
N,D=map(int,input().split())
x=[]
ans=0
for i in range(N):
    x.append(list(map(int,input().split())))
for i in range(N):
    for j in range(i+1, N):
        t = 0
        for k in range(D):
            t += (x[i][k]-x[j][k])**2
        A=t**(1/2)   #距離
        A=int(A)   #いったん整数に戻す
        if A**2 == t:
            ans += 1
print(ans)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 
 ================================================================
 */


ll solve(){
    ll res = 0;
    string s1,s2; cin >> s1 >> s2;
    vector<vector<ll>> dp(s1.length()+1,vector<ll>(s2.length()+1,LINF));
    
    dp[0][0] = 0;
    for(int i = 0; i <= s1.length();i++) dp[i][0] = i;
    for(int j = 0; j <= s2.length();j++) dp[0][j] = j;
    
    for(int i = 1; i <= s1.length();i++){
        for(int j = 1; j <= s2.length();j++){
            dp[i][j] = min({dp[i-1][j]+1,dp[i][j-1]+1,dp[i-1][j-1]+(s1[i-1]==s2[j-1]?0:1)});

        }
    }
    res = dp[s1.length()][s2.length()];
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    auto ret = solve();
    cout << ret << endl;
    return 0;
}



Measured memory_bytes: 10712
import sys
input = sys.stdin.readline
import heapq
def main():
    N, M = map( int, input().split())
    d = dict()
    E = [[] for _ in range(N)]
    for i in range(N-1):
        E[i+1].append((0,i))
    for _ in range(M):
        l, r, c = map( int, input().split())
        l -= 1
        r -= 1
        E[l].append((c,r))
    q = [(0,0)]
    heapq.heapify(q)
    path = [10**17]*N
    path[0] = 0
    while q:
        _, v = heapq.heappop(q)
        for cost, e in E[v]:
            if path[e] > path[v] + cost:
                path[e] = path[v] + cost
                heapq.heappush(q, (path[e], e))
    if path[N-1] == 10**17:
        print(-1)
    else:
        print(path[N-1])
if __name__ == '__main__':
    main()


Measured memory_bytes: 43960
#include <bits/stdc++.h>
#define input() *istream_iterator<int>(cin)
using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define INF 1e9+7
#define all(x) x.begin(),x.end()
#define endl '\n'
typedef long long ll;
typedef pair<int,int> pii;


int main () {
    ios::sync_with_stdio(false); cin.tie(0);
    string s; cin>>s;
    if(s[1]=='R') cout<<"ABC"<<endl;
    else cout<<"ARC"<<endl;

}



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

int main(){
	int m, d, d1, d10, cnt;
	cin >> m >> d;
	cnt = 0;
	for(int i=1; i<=m; i++){
		for(int j=1; j<=d; j++){
			d1 = j%10;
			d10 = j/10;
			if(d1==1 || d10==1){
				continue;
			}else{
				if(i == (d1*d10)){
					cnt++;
					//cout << m << ", " << d10 << ", " << d1 << endl;
				}	
			}
		}
	}
	cout << cnt << endl;
	return 0;
}



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

class Program
{
    public static void Main(string[] args)
    {
        long n = long.Parse(Console.ReadLine());
        long[] a = new long[n];
        for (long i = 0; i < n; i++) a[i] = long.Parse(Console.ReadLine());
        long res = a[1] - a[0];
        long minv = Math.Min(a[0], a[1]);
        for (int i = 2; i < n; i++)
        {
            res = Math.Max(res, a[i] - minv);
            minv = Math.Min(minv, a[i]);
        }
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 23156
S = input().split('T')

N = len(S)
X = []
Y = []

for i in range(N):
    if i%2:
        Y.append(len(S[i]))
    else:
        X.append(len(S[i]))

Xsum = sum(X)
Ysum = sum(Y)

from collections import defaultdict

dpx = defaultdict(int)# 初期値を0にした辞書
dpy = defaultdict(int)# 初期値を0にした辞書

dpx[Xsum] = 1
dpy[Ysum] = 1

for k in range(1,len(X)):
    x = X[k]
    for i in range(-Xsum,Xsum+1):
        if dpx[i]:
            dpx[i-2*x] = 1

for y in Y:
    for i in range(-Ysum,Ysum+1):
        if dpy[i]:
            dpy[i-2*y] = 1

x,y = map(int,input().split())
print('Yes' if dpx[x] and dpy[y] else 'No')


Measured memory_bytes: 43996
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    long long N, K,sum = 0;
    cin >> N >> K;
    if(K > N)K = N;
    vector<long long> monster(N);
    for (int i = 0; i < N; i++){
        cin >> monster.at(i);
    }
    sort(monster.begin(), monster.end());
    reverse(monster.begin(), monster.end());
    for (int i = 0; i < K; i++){
        monster.at(i) = 0;
    }
    for (int i = 0; i < N; i++){
        sum += monster.at(i);
    }
    cout << sum << endl;
}

Measured memory_bytes: 1792
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real() * a.real() + a.imag() * a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main() {
	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());
	if (s < t) {
		cout << "Yes";
	}
	else cout << "No";
}


Measured memory_bytes: 256