akhauriyash/Code-Regression huggingface dataset:
package main

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

// define
var (
	sc = bufio.NewScanner(os.Stdin)
)

func scanIntLine(len int) []int{
	arr := make([]int, len)
	for i:=0; i<len; i++{
		sc.Scan()
		tmp, err := strconv.Atoi(sc.Text())
		if err == nil{
			arr[i] = tmp
		}
	}
	return arr
}

func scanStringLine(len int) []string{
	arr := make([]string, len)
	for i:=0; i<len; i++{
		sc.Scan()
		arr[i] = sc.Text()
	}
	return arr
}

func scanIntSplit(len int) []int{
	arr := make([]int, len)
	sc.Scan()
	for i, v := range strings.Split(sc.Text(), " "){
		tmp, err := strconv.Atoi(v)
		if err == nil{
			arr[i] = tmp
		}
	}
	return arr
}

func main(){
	check_map := make(map[int]bool, 0)
	abc := scanIntSplit(3)
	A, B, C := abc[0], abc[1], abc[2]
	for i:=1; ; i++{
		check := (A*i - C) % B
		if check == 0 {
			fmt.Println("YES")
			break
		} else if check_map[check] {
			fmt.Println("NO")
			break
		} else {
			check_map[check] = true
		}
	}
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mxn= 2e5+5;
// check for forloop
// intialize variable
// overflow
// go for easy solution
#define mod 1000000007
ll INF = 1000000000000000005LL;
#define endl '\n'
void rishabh(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
int main(){
    int n;
    cin>>n;
    int arr[n];
    int good=1, bad=1;
    for(int i=0;i<n;i++){
        cin>>arr[i];
        if(arr[i]%2==0)bad=bad*2;
        good = good*3;
    }
    cout<<good-bad;
}

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

using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<int> d(N);
    rep(i, N) cin >> d[i];
    sort(d.begin(), d.end());
    int ans = d[N / 2] - d[N / 2 - 1];
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
#define LL long long
#define mod 1000000007
#define G() Cr=getchar()
int Xr;char Cr;
inline int rd(){   //读入优化
    Xr=0,G();
    while(Cr<'0'||Cr>'9')G();
    while(Cr>='0'&&Cr<='9')Xr=(Xr<<3)+(Xr<<1)+Cr-'0',G();
    return Xr;
}
string s;
int main(){
    cin>>s;
    if(s.size()!=6){
    	puts("No");
    	return 0;
	} 
    for(int i=0;i<5;i++){
    	if(s[i]<'a'||s[i]>'z'){
    		puts("No");
    		return 0;
		} 
	}
	if(s[2]!=s[3]||s[4]!=s[5]){
		puts("No");
    	return 0;
	}
	puts("Yes");
}

Measured memory_bytes: 256
#include <iostream>

template <typename T>
struct Vector
{
    T x , y;

    auto operator - (Vector v) -> Vector
    {
        return Vector <T> {x - v.x , y - v.y};
    }
    auto cross (Vector v) -> T
    {
        return x * v.y - y * v.x;
    }
};

auto equal0 (double v) -> bool
{
    constexpr auto esp = 1e-10;
    return -esp < v && v < esp;
}

auto main () -> int
{
    int n;
    std::cin >> n;
    for (auto i = 0; i < n; ++ i)
    {
        Vector <double> A , B , C , D;
        std::cin >> A.x >> A.y >> B.x >> B.y >> C.x >> C.y >> D.x >> D.y;
        auto AB = B - A;
        auto CD = D - C;
        auto d = AB.cross (CD);
        std::cout << (equal0 (d) ? "YES" : "NO") << std::endl;
    }
}

Measured memory_bytes: 3076
def main():
	N, P = map(int, input().split())
	S = [int(c) for c in input()]

	if 10 % P == 0:
		ans = 0
		for i in range(N):
			if S[i] % P == 0:
				ans += (i + 1)

		print(ans)
		return


	M = [0] * (N + 1) #左からi番目から最後までの数字のmod p

	t = 1
	for i in range(N - 1, -1, -1):
		M[i] = (M[i + 1] + t % P * S[i]) % P
		t = (t * 10) % P

	C = [0] * 10000

	for v in M:
		C[v] += 1

	ans = 0
	for v in C:
		if v > 0:
			ans += v * (v - 1) // 2

	print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 48076
n = int(input())
dat = list(map(int,input().split()))

d = dict()

for i in dat:
    if d.__contains__(i):
        d[i]+=1
    else:
        d[i]=1
d = list(d.items())
d.sort()
minus = 0
twos = 0
for num,cnt in d:
    while cnt>2:
        cnt-=2
        minus+=1
    if cnt==2:
        twos += 1
minus += twos//2
if twos%2:
    minus+=1
print(n-minus*2)


Measured memory_bytes: 21084
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 20

int dp[1<<18][50];

int main() {
  int N, A[SIZE], B[SIZE];

  cin >> N;

  for (int i=0; i<N; i++) cin >> A[i];
  for (int i=0; i<N; i++) cin >> B[i];

  for (int i=0; i<N; i++) {
    A[i]--; B[i]--;
  }

  for (int i=0; i<(1<<N); i++)
    for (int j=0; j<50; j++)
      dp[i][j] = INF;

  dp[0][0] = 0;

  for (int i=0; i<(1<<N); i++) {
    for (int k=0; k<50; k++) {
      if (dp[i][k] == INF) continue;

      for (int j=0; j<N; j++) {
        if (i & (1 << j)) continue;

        int maskR = ((1 << N) - 1) - ((1 << (j+1)) - 1);
        int maskL = ((1 << j) - 1);

        int cR = __builtin_popcount(i & maskR);
        int cL = j - __builtin_popcount(i & maskL);


        if ((cL + cR) % 2) {
          if (k <= B[j]) {
            dp[i|(1<<j)][B[j]] = min(dp[i|(1<<j)][B[j]], dp[i][k] + cL);
          }
        } else {
          if (k <= A[j]) {
            dp[i|(1<<j)][A[j]] = min(dp[i|(1<<j)][A[j]], dp[i][k] + cL);
          }
        }
      }
    }
  }

  int ans = INF;

  for (int i=0; i<50; i++) {
    ans = min(ans, dp[(1<<N)-1][i]);
  }

  if (ans == INF) ans = -1;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 51584
let rec f a b = if b = 0 then a else f b (a mod b)
let rec g a b = a / f a b * b
let n, m, s, t, l = Scanf.scanf "%d %d %s %s" @@ fun n m s t -> n, m, s, t, g n m
let n', m' = l / n, l / m
let _ = for k = 0 to (n - 1) / m' do if k * n' < m && s.[k * m'] <> t.[k * n'] then (print_endline "-1"; exit 0) done; Printf.printf "%d\n" l

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

#define REP(i, s,  n) for(int i = s;i < (n);i++)
#define VSORT(v) sort(v.begin(), v.end());
#define int64 long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> PP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

//---------------------------------------------------------------
// 19:16
//---------------------------------------------------------------

int N, K;
int X[100001];

signed main(){
	cin >> N >> K;
	REP(i, 0, N) scanf("%d",&X[i]);
	int ans = INF, wk;
	REP(i, 0, N - K + 1) {
		wk = abs(X[i]) + abs(X[i + K - 1] - X[i]);
//		cout << "[" << i << "] = " << abs(X[i]) << " + " << abs(X[i + K - 1] - X[i]) << endl;
		if(ans > wk) 	ans = wk;
		wk = abs(X[i + K - 1]) + abs(X[i + K - 1] - X[i]);
//		cout << "[" << i << "] = " << abs(X[i + K - 1]) << " + " << abs(X[i + K - 1] - X[i]) << endl;
		if(ans > wk) 	ans = wk;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define REP(i,x,n) for(int i = (x); i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);

int main(void)
{
    ll x; cin >> x;
    if(x==0) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>
int main(void)
{
  int N,K,h[100000];
  int a=0;
  scanf("%d%d",&N,&K);
  for (int i=0;i<N;i++) {
    scanf("%d",&h[i]);
    if (h[i]>=K){
      a=a+1;
    }
  }
  printf("%d",a);
  return 0;
}
  


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

typedef long long ll;
typedef unsigned long long u64;
typedef unsigned __int128 u128;

struct _hash_ {
	static std::hash <u64> H;
	inline size_t operator () (const u128 x) const {return H(u64(x >> 64)) * 20030731llu + H(u64(x));}
};

typedef std::unordered_map <u128, int, _hash_> map;
const int mod = 998244353;

map f;

inline int lg2(u128 x) {u64 *p = (u64*)&x; return p[1] ? std::__lg(p[1]) + 64 : *p ? std::__lg(*p) : -1;}

int solve(u128 x) {
	map::iterator it = f.find(x);
	if (it != f.end()) return it->second;
	int i, j, L = lg2(x), ret = (1 + ll(x & 1)) * solve(x >> 1) % mod;
	for (i = 1; (j = 2 * i) <= L; ++i) {
		u128 U = x, bit = (u128)1 << i, mask = bit - 1;
		for (; j <= L; j += i)
			U &= U >> i, ret = (ret + (ll)solve((U & mask) | bit) * solve(x >> j)) % mod;
	}
	return f.emplace(x, ret), ret;
}

int main() {
	char s[128], *p = s; u128 n = 1;
	for (scanf("%s", s); *p; ++p) n = n * 2 + (*p & 1);
	f.emplace(1, 1);
	printf("%d\n", solve(n));
	return 0;
}

Measured memory_bytes: 4236
#include<iostream>
#include<cmath>
using namespace std;
int main() {
    int n, x, count;
    cin >> n;
    count = n;
    for(int i=0; i<n; i++) {
        cin >> x;
        if(x%2==0 && x!=2) {
            count--;
        } else {
            for(int j=3; j<=sqrt(x); j+=2) {
                if (x%j==0) {
                count --;
                break;
                }
            }
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

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

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int a,b,c;
	cin >> a >> b >> c;
	cout << (c >= a && c <= b?"Yes":"No") << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    string S, T; cin >> S >> T;
    int A, B; cin >> A >> B;
    string U; cin >> U;
    if (S == U) A--;
    if (T == U) B--;
    cout << A << ' ' << B << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

int main() {
  i64 n, k;
  cin >> n >> k;
  i64 ans = 0;
  while (n--) {
    i64 x;
    cin >> x;
    ans += min(x, k - x);
  }
  cout << 2 * ans << '\n';
  return 0;
}



Measured memory_bytes: 256
let bin_search x (a : int array) =
  let rec doit l r =
    if l >= r then false
    else
      let m = (l + r) / 2 in
      if x = a.(m) then true
      else if x < a.(m) then doit l m
      else doit (m + 1) r in
  doit 0 (Array.length a)

let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let () =
  let read_seq () = List.map int_of_string (split_on_char ' ' (read_line ())) in
  let _ = read_int () in
  let s = Array.of_list (read_seq ()) in
  let _ = read_int () in
  let t = read_seq () in
  Printf.printf "%d\n" (List.fold_left (fun acc e -> acc + (if bin_search e s then 1 else 0)) 0 t)

Measured memory_bytes: 17004
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
bool solve(){
  int i,j;
  int n,m;
  int tmp;
  int ans=0;
  cin>>n>>m;
  if(n==0 && m==0)return false;
  vector<int> h,w;
  vector<int> h_sum,w_sum;
  for(i=0;i<n;i++){
    cin>>tmp;
    h.push_back(tmp);
  }
  for(i=0;i<m;i++){
    cin>>tmp;
    w.push_back(tmp);
  }
  for(i=0;i<n;i++){
    tmp=h[i];
    h_sum.push_back(tmp);
    for(j=i+1;j<n;j++){
      tmp+=h[j];
      h_sum.push_back(tmp);
    }
  }
  for(i=0;i<m;i++){
    tmp=w[i];
    w_sum.push_back(tmp);
    for(j=i+1;j<m;j++){
      tmp+=w[j];
      w_sum.push_back(tmp);
    }
  }
  sort(h_sum.begin(),h_sum.end());
  sort(w_sum.begin(),w_sum.end());
  tmp=0;
  for(i=0;i<h_sum.size();i++){
    for(j=tmp;j<w_sum.size();j++){
      if(h_sum[i]==w_sum[j]){
        ans++;
        if(w_sum[tmp]<w_sum[j])tmp=j;
      }
      if(h_sum[i]<w_sum[j])break;
    }
  }
  cout<<ans<<endl;
  return true;
}
int main(){
  while(solve());
  return 0;
}


Measured memory_bytes: 19716
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
    n=parseInt(readline())
    s=[chomp(readline()) for _ in 1:n]
    cnt=Dict{String,Int}()
    for i in s
        if haskey(cnt,i)
            cnt[i]+=1
        else
            cnt[i]=1
        end
    end
    M=maximum(values(cnt))
    st=sort(collect(Set(s)))
    for i in st
        if cnt[i]==M
            println(i)
        end
    end
end
main()

Measured memory_bytes: 187908
package main

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

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

const yes = "Yes"
const no = "No"

func solve(a int64, b int64, c int64) bool {
	if a == b && b != c {
		return true
	}
	if b == c && c != a {
		return true
	}
	if c == a && a != b {
		return true
	}
	return false
}

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	a := nextInt()
	b := nextInt()
	c := nextInt()
	if solve(a, b, c) {
		fmt.Fprintln(out, yes)
	} else {
		fmt.Fprintln(out, no)
	}
}

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

func nextStringAsBytes(n int64) []byte {
	sc.Scan()
	return []byte(sc.Text())
}

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

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

func nextInts(n int64) []int64 {
	ret := make([]int64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

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

func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

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, "orz")
	}
}

// mapからkeysとvaluesを返す
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "orz")
	}
	return
}


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<pair<double, int> > bmi(n);
        for(int i=0; i<n; ++i){
            int h, w;
            cin >> bmi[i].second >> h >> w;
            bmi[i].first = abs(22 - w/pow(h/100.0, 2.0));
        }
        cout << min_element(bmi.begin(), bmi.end())->second << endl;
    }
}

Measured memory_bytes: 0
input = gets.to_s
numOfPlate = input.split(" ")[0].to_i
heightOfPlate = input.split(" ")[1].to_i
lengthOfPlate = input.split(" ")[2].to_i

numOfPlateOfAccept = 0

for times in 1..numOfPlate do
 inputSize = gets.to_s
 inputHeight = inputSize.split(" ")[0].to_i
 inputWidth  = inputSize.split(" ")[1].to_i

 if inputHeight >= heightOfPlate && inputWidth >= lengthOfPlate then
   numOfPlateOfAccept = numOfPlateOfAccept + 1
 end

 inputSize = []
 inputWidth = 0
 inputHeight = 0

end

p numOfPlateOfAccept

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

int main(){
  string s; cin>>s;
  int r = 753;
  for(int i=0;i<s.size()+1-3;i++){
    int temp = atoi(s.substr(i,3).c_str());
    temp = abs(753-temp);
    if(temp<r) r = temp;
  }
  cout << r << endl;
  
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static int N;
	static boolean match;

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

		N = sc.nextInt();
		dfs(0, 0);
		System.out.println(match ? "Yes" : "No");
	}

	static void dfs(int x, int y) {
		if (x * 4 + y * 7 > N)
			return;
		if (x * 4 + y * 7 == N) {
			match = match || true;
		}
		dfs(x + 1, y);
		dfs(x, y + 1);
	}
}


Measured memory_bytes: 22996
import sys
#DEBUG=True
DEBUG=False
if DEBUG:
    f=open("202007_2nd/B_input.txt")
else:
    f=sys.stdin
N=int(f.readline().strip())
A=list(map(int,f.readline().split()))
ans=0
for _ in range(N):
    ans=ans+1 if (_+1)%2 and (A[_]%2) else ans
print(ans)
f.close()

Measured memory_bytes: 9040
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}*/

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

	string s, t;
	cin >> s >> t;

	vector<vector<int>> dp((int)s.size() + 1, vector<int>((int)t.size() + 1, 0));

	Rep(i, 1,(int)s.size() + 1) {
		Rep(j, 1, (int)t.size() + 1) {
			//cout << s[i - 1] << " " << t[j - 1] << endl;
			if (s[i - 1] == t[j - 1]) dp[i][j] = dp[i - 1][j - 1] + 1;
			else {
				if (dp[i][j - 1] >= dp[i - 1][j])
					dp[i][j] = dp[i][j - 1];
				else
					dp[i][j] = dp[i - 1][j];
			}
		}
	}

	string ans = "";
	int i = (int)s.size();
	int j = (int)t.size();

	while (i > 0 && j > 0) {
		if (dp[i][j] == dp[i - 1][j]) {
			i--;
		}
		else if (dp[i][j] == dp[i][j - 1]) {
			j--;
		}
		else {
			ans = s[i - 1] + ans;
			i--; j--;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
#pragma GCC diagnostic ignored "-Wmissing-declarations"

#define FINAL_OUT(x) {cout << (x) << '\n'; exit(0);}

#define SHOW(x) std::cout << #x << " = " << x << std::endl;

inline int safe_mul(int x, int y) __attribute__ ((warn_unused_result));

int const maxn = 200005;
int a[maxn];

long long solve(int l, int r)
{
    if (l == r) return 0;
    if (l + 1 == r) return a[l] >= 0 ? 1 : 0;
    auto mid = (l + r) >> 1;

    vector<long long> mask;
    mask.reserve(mid - l);
    long long sum = 0;
    for(int i = mid - 1; i >= l; --i)
    {
        sum += a[i];
        mask.push_back(sum);
    }
    sort(begin(mask), end(mask));
    long long ans = 0;
    sum = 0;
    for(int i = mid; i < r; ++i)
    {
        sum += a[i];
        ans += mask.end() - lower_bound(begin(mask), end(mask), -sum);
    }
    ans += solve(l, mid) + solve(mid, r);
    return ans;
}

int main()
{
//    freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    ios_base::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;

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

    cout << solve(0, n) << endl;
}


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, c;
	cin >> n >> c;
	vector<pair<pii, int>> v(n);

	REP(i, n) {
		cin >> v[i].first.first >> v[i].first.second >> v[i].second;
		v[i].second--;
		
	}
	sort(ALL(v));
	vector<pii> cap;
	REP(i, n) {
		int p = -1;
		REP(j, cap.size()) {
			if (v[i].second == cap[j].second) {
				if (cap[j].first <= v[i].first.first) {
					p = j;
					break;
				}
			}
			else {
				if (cap[j].first < v[i].first.first) {
					p = j;
					break;
				}
			}
		}
		if (p == -1)cap.push_back(pii{ v[i].first.second,v[i].second });
		else {
			cap[p] = { v[i].first.second,v[i].second };
		}
		sort(ALL(cap));
	}
	cout << cap.size() << endl;
}


Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
const ll MOD=998244353;
struct mint{
  ll x;
  mint(ll x=0):x(x%MOD){}
  mint& operator+=(const mint a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator-=(const mint a){
    if((x += MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator*=(const mint a){
    (x*=a.x)%=MOD;
    return *this;
  }
  mint operator+(const mint a) const{
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const{
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const{
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const{
    if(!t) return 1;
    mint a = pow(t>>1);
    a*=a;
    if(t&1) a*=*this;
    return a;
  }
  
  //for prime mod
  mint inv() const{
    return pow(MOD-2);
  }
  mint& operator/=(const mint a){
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const{
    mint res(*this);
    return res/=a;
  }
};
mint dp[3100][3100];
int main()
{
  int n,s;cin >> n >> s;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  // vector<vector<mint>> dp(n+1,vector<mint>(s+1));
  // dp[0][0].x = 1;

  // mint res;
  // rep(st,n){
  //   rep(i,n+1) rep(j,s+1) dp[i][j].x = 0;
  //   dp[st][0].x = 1;
  //   for( int i = st;i < n;++i){
  //     rep(j,s+1){
  // 	if(j - a[i] >= 0) dp[i+1][j] = dp[i][j - a[i]] + dp[i][j];
  // 	else dp[i+1][j] = dp[i][j];
  //     }
  //   }
  //   for( int i = st;i <= n;++i) res += dp[i][s];
  // }
  // cout << res.x << "\n";


  mint res;
  rep(i,n+1) rep(j,s+1) dp[i][j].x = 0;
  rep(i,n+1){
    rep(j,s+1){
      if(j - a[i] >= 0) dp[i+1][j] = dp[i][j - a[i]] + dp[i][j];
      else dp[i+1][j] = dp[i][j];
    }
    dp[i+1][0] += (mint)1;
    dp[i+1][a[i]] += (mint)1;
  }

  // rep(i,n+1){
  //   rep(j,s+1) cout << dp[i][j].x << " ";
  //   cout  << "\n";
  // }

  rep(i,n+1) res += dp[i][s];
  cout << res.x << "\n";
  return 0;
}


Measured memory_bytes: 75392
#include <bits/stdc++.h>
#define int long long
#define N 310
using namespace std;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
typedef pair<int,int> P;
vector<int> G[N];
int g[N][N],can[N][N];
unordered_set<int> childs[N];
 
void addChild(int pos,int start,int flag = 0){
  if((!flag && childs[pos].count(start))) return;
  if(pos != start) childs[pos].insert(start);
  can[pos][start] = 1;
  can[start][pos] = -1;
  for(int to:G[pos]) addChild(to,start);
}
 
void merge(vector<P> &A,vector<P> &B,vector<P> &C,int c){
  if(c == 1) {
    for(P c:C) G[c.second].push_back(c.first);
    for(P c:C) g[c.second][c.first] = 1;

    vector<int> used(N,0);
    for(P c:C){
      if(used[c.second]++) continue;
      addChild(c.second,c.second,1);
      for(int to:childs[c.second]){
        if(used[to]++) continue;
        addChild(c.second,to,1);
      }
    }
  }
   
  if(c == -1){
    for(P c:C) B.push_back(c);
    for(P c:C) can[c.first][c.second] = -1;
  }
}
 
signed main(){
  string a,b;
  cin>>a>>b;
  map<string,int> idx;
  int num = 0; idx[a] = num++, idx[b] = num++;
  int n;
  cin>>n;
 
  map<P,unordered_set<int> > DB;
  vector<vector<P> > rule;
  for(int i=0;i<n;i++){
    int m;
    cin>>m;
    vector<P> g(m);
    for(int j=0;j<m;j++){
      string a,b;
      cin>>a>>b;
      if(!idx.count(a)) idx[a] = num++;
      if(!idx.count(b)) idx[b] = num++;
      int na = idx[a],nb = idx[b];
      g[j] = P(na,nb);
      DB[P(na,nb)].insert(i);
    }
    rule.push_back(g);
  }
   
  vector<P> A({P(idx[a],idx[b])}),B;
  G[idx[b]].push_back(idx[a]);
  childs[idx[a]].insert(idx[b]);
   
  int K = idx.size();
  vector<int> used(n,0);
  can[idx[a]][idx[b]] = 1;
  can[idx[b]][idx[a]] = -1;
 
  int update = 1;    
  while(update){
    update = 0;
    for(int i=0;i<K;i++)
      for(int j=0;j<K;j++){
        if(i == j || can[i][j] == 0 || !DB.count(P(i,j))) continue;
        unordered_set<int> &db = DB[P(i,j)];
        for(auto idx:db){
          if(used[idx]++) continue;
          update = 1;
          merge(A,B,rule[idx],can[i][j]);
        }
        DB.erase(P(i,j));
      }
  }
  
  int ans = 1;
  for(int k=0;k<K;k++)
    for(int i=0;i<K;i++)
      for(int j=0;j<K;j++) g[i][j] |= (g[i][k] && g[k][j]);
   
  for(int i=0;i<K;i++) ans &= (g[i][i] == 0);
  for(P b:B) ans &= !childs[b.first].count(b.second);
  cout<<(ans? "Yes":"No")<<endl;
   
  return 0;
}

Measured memory_bytes: 24696
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, math.MaxInt64)
}

func readInt() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func div(arr []int) ([]int, bool) {
	div := []int{}
	for _, v := range arr {
		if v%2 != 0 {
			return arr, false
		} else {
			div = append(div, v/2)
		}
	}
	return div, true
}

func main() {
	n := readInt()
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = readInt()
	}
	cnt := 0
	for {
		if div, result := div(arr); result {
			cnt++
			arr = div
			continue
		}
		break
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ve vector
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

int main(){
    using ti = tuple<int,int,int>;
    int l;
    cin >> l;
    ve<ti> ans;
    int i = 1;
    while(pow(2,i)<=l){
        ans.push_back(ti(i,i+1,pow(2,i-1)));
        ans.push_back(ti(i,i+1,0));
        i++;
    }
    int n = pow(2,i-1);
    while(1){
        int k = l-n;
        int j = 0;
        while(k){
            k /= 2;
            j++;
        }
        if(j == 0)break;
        ans.push_back(ti(j,i,n));
        n += pow(2,j-1);
    }
    sort(ans.begin(), ans.end());
    cout << i<<" "<< ans.size() << endl;
    rep(i,ans.size()){
        printf("%d %d %d\n", get<0>(ans[i]), get<1>(ans[i]), get<2>(ans[i]));
    }
    return 0;
}


Measured memory_bytes: 4008
#include <iostream>
using namespace std;
int main(void){
  int x,y,a;

  while (true) {
       cin>>x>>y;
       if(x==0 && y==0){
           break;
       }
   if(y<x){
   a=y;
   y=x;
   x=a;
   }
   cout<<x<<" "<<y<<endl;
  }
}


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

int main() {
	int X, Y;
	cin >> X >> Y;
	if (X == 1 && Y == 1) {
		cout << 1000000 << endl;
	}
	else {
		cout << (max(4 - X, 0) + max(4 - Y, 0)) * 100000 << endl;
	}
	return 0;
}

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

int main() {
    ll a, b, x;
    cin >> a >> b >> x;

    auto f = [&](ll n) {
        return (n == -1 ? 0 : n / x + 1);
    };
    cout << f(b) - f(a - 1) << endl;
}

Measured memory_bytes: 256
#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>;
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

int n,k;
ll solve(vector<ll>x){
    ll ans=1LL<<60;
   rep(i,n-k+1){
      int j=i+k-1;
      ll l=abs(x[i])+abs(x[j]-x[i]);
      ll r=abs(x[j])+abs(x[j]-x[i]);
      chmin(ans,l);
      chmin(ans,r);
   }
   return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin>>n>>k;
    vector<ll>x(n);
    rep(i,n)cin>>x[i];
    cout<<solve(x)<<endl;
    return 0;
}

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


int main()
{
  int a, b;
  cin >> a >> b;
  cout << (b - 1 + a - 2) / (a - 1) << endl;
  return 0;
}

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

int main(){
  string s;cin >> s;
  for(int i=0;i<s.length();i++){
    if((i+1)%2 == 0){//even
      if(s[i] != 'L' && s[i] != 'U' && s[i] != 'D'){
        cout << "No" << endl;
        return 0;
      }
    }else{//odd
      if(s[i] != 'R' && s[i] != 'U' && s[i] != 'D'){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

// https://atcoder.jp/contests/abc159/tasks/abc159_a
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		sc.close();


		System.out.println(n*(n-1)/2+m*(m-1)/2);



	}
}


Measured memory_bytes: 21844
function charset(s, i)
	count = 0
	left = Set(s[1:i])
	right = Set(s[i+1:length(s)])
	for key in left
		if in(key, right)
			count += 1
		end
	end
	return(count)
end
function main()
	n = parse(readline())
	s = chomp(readline())
	sum = 0
	for i in 1:n-1
		sum = max(sum, charset(s,i))
	end
	print(sum)
end

main()

Measured memory_bytes: 116344
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    String S = sc.next();
    long K = sc.nextLong();

    sc.close();

    String[] s = S.split("");
    
    HashMap<Integer, Integer> map = new HashMap<>();

    int count = 0;
    map.put(count, 1);
    for (int i = 1; i < s.length; i++) {
      if (s[i - 1].equals(s[i])) {
        int v_ = map.get(count);
        map.put(count, v_ + 1);
      } else {
        count++;
        map.put(count, 1);
      }
    }

    if (map.size() == 1) {
    
      System.out.println(s.length * K / 2);
    
    } else {

      int result = 0;
      int size = map.size();
      
      if (!s[0].equals(s[s.length-1])){
        for (int i = 0; i < size; i++) {
          int v_ = map.get(i);
          result += v_ / 2;
        }
        System.out.println(result * K);
      } else {
        for (int i = 0; i < size; i++) {
          int v_ = map.get(i);
          result += v_ / 2;
        }
        int a1 = map.get(0) / 2 + map.get(size - 1) / 2;
        int a2 = (map.get(0) + map.get(size - 1)) / 2;
        //System.out.println("a1:" + a1 + "a2:" + a2);
        System.out.println(result * K + (a2 - a1) * (K - 1));
      }

    }

  }

}

Measured memory_bytes: 23252
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>
#include <complex>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	cin >> n;
	vector<vector<pair<int, int> > > graph(n);
	for(int i = 0; i < n - 1; i++){
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		graph[a].push_back(make_pair(b, i));
		graph[b].push_back(make_pair(a, i));
	}
	int root = 0;
	for(int i = 1; i < n; i++){
		if(graph[i].size() > graph[root].size()){
			root = i;
		}
	}
	vector<int> ans(n, -1);
	queue<pair<int, int> > qu;
	qu.push(make_pair(root, 0));
	while(!qu.empty()){
		int now = (qu.front()).first;
		int used = (qu.front()).second;
		qu.pop();
		int cnt = 1;
		for(int i = 0; i < graph[now].size(); i++){
			int child = graph[now][i].first;
			int ind = graph[now][i].second;
			if(ans[ind] >= 0) continue;
			if(cnt == used) cnt++;
			ans[ind] = cnt;
			qu.push(make_pair(child, cnt));
			cnt++;
		}
	}
	cout << graph[root].size() << endl;
	for(int i = 0; i < n - 1; i++){
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 7040
while True:
    n, r = map(int, input().split())

    if n == 0 and r == 0:
        break

    cards = list(range(1, n+1))[::-1]

    for _ in range(r):
        p, c = map(int, input().split())
        cards = cards[p-1:p-1+c] + cards[:p-1] + cards[p-1+c:]

    print(cards[0])

Measured memory_bytes: 7664
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>

int *key, *prev, *visit, **matrix;

void Prim(int, int);
int main(void)
{
  int i, j, n, w, cost = 0;
  scanf("%d", &n);
  matrix = (int**)malloc(sizeof (int*) * n);
  key = (int*)malloc(sizeof (int) * n);
  prev = (int*)malloc(sizeof (int) * n);
  visit = (int*)malloc(sizeof (int) * n);
  for (i = 0; i < n; i++) {
    matrix[i] = (int*)malloc(sizeof(int) * n);
    for (j = 0; j < n; j++) {
      scanf(" %d", &w);
      matrix[i][j] = w;
    }
  }
  Prim(0, n);
  for (i = 0; i < n; i++) {
    cost += key[i];
    free(matrix[i]);
  }
  printf("%d\n", cost);
  free(matrix);
  free(key);
  free(prev);
  free(visit);
}

void Prim(int p, int size)
{
  int i;
  for (i = 0; i < size; i++) {
    key[i] = INT_MAX;
    prev[i] = -1;
    visit[i] = 0;
  }
  key[p] = 0;
  while (1) {
    int u = -1, min = INT_MAX;
    for (i = 0; i < size; i++) {
      if (visit[i] == 0 && key[i] < min) {
        u = i;
        min = key[i];
      }
    }
    if (u == -1) break;
    visit[u] = 1;
    for (i = 0; i < size; i++) {
      if (visit[i] ==0 && matrix[u][i] != -1) {
        if (key[i] > matrix[u][i]) {
          key[i] = matrix[u][i];
          prev[i] = u;
        }
      }
    }
  }
}


Measured memory_bytes: 2040
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(int n);            // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// class
// ------------------------------------------------
class Combi
{
  public:
    Combi();
    long long Combination(long long n, long long k);
  private:
    vector<vector<long long>> memo;
    long long n_num;
    long long k_num;
    void Resize(long long n, long long k);
};

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<long> vll;
// code
// ------------------------------------------------
int main() {
  ll k;
  string s;
  cin >> k >> s;

  if(sz(s) <= k)
    cout << s << endl;
  else
  {
    rep(i,k)
      cout << s[i];
    cout <<"..." << endl;
  }
  

  return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(int n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 1)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Combi::Combi(){
  n_num = -1;
  k_num = -1;
};
ll Combi::Combination(ll n, ll k)
{
  Resize(n,k);

  ll ret;
  if(memo[n][k] != 0)
  {
    ret = memo[n][k];
  }
  else if(n == k || k == 0)
  {
    memo[n][k] = 1;
    ret = 1;
  }
  else
  {
    ret = Combination(n - 1, k - 1) + Combination(n - 1, k);
    memo[n][k] = ret;
  }
  return ret;
}

void Combi::Resize(ll n, ll k)
{
  if(n_num <= n || k_num <= k)
  {
    n_num = (n + 1) * 2;
    k_num = (k + 1) * 2;
    memo.resize(n_num);
    for(auto itr = memo.begin(); itr != memo.end(); ++itr)
    {
      itr->resize(k_num);
    }
  }
}

Measured memory_bytes: 3624
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#include<vector>
#include<map>

#define For(i,a,b) for(int i=a;i<=b;i++)
#define ForD(i,a,b) for (int i=a;i>=b;i--)
#define LL long long
#define INF (2147483647)
#define sqr(x)	((x)*(x))

using namespace std;

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

inline void write(int x){
	if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0`');
} 

int main(){	
	For(i,1,3){
		char s[1000];cin>>s;
		putchar(s[0]+65-97);
	}
} 

Measured memory_bytes: 256
from bisect import bisect_right as right

#import sys
#readline = sys.stdin.buffer.readline

N = int(input())
A = [int(input()) for _ in range(N)][::-1]

INF = 10**10
dp = [INF] * (N+1)

answer = 0
for a in A:
  r = right(dp, a)
  if dp[r] > a:
    if dp[r] == INF:
      answer += 1
    dp[r] = a
print(answer)

Measured memory_bytes: 52952
N, M, C = map(int, input().split(' '))
B = list(map(int, input().split(' ')))
A = []
for i in range(N):
    A.append(list(map(int, input().split(' '))))
AB = []
for i in range(len(A)):
    matmul = C
    for j in range(len(B)):
        matmul += A[i][j] * B[j]
    AB.append(1 if matmul > 0 else 0)
print(sum(AB))

Measured memory_bytes: 3064
//by azidoazideazide(c2n14)
#include<iostream>
#include<vector>
using namespace std;

class BIT{
    private:
        int size;
        vector<int> a;
    public:
        BIT(int n): size(n), a(n+1) {}  
        
        void add(int ind, int x){
            for(;ind<=size;ind+= ind & -ind) a[ind]+=x;
        }
        
        int range_sum(int ind){
            if(ind<1) return 0;
            
            int rt=0;
            for(;ind;ind-= ind & -ind) rt+=a[ind];  
            return rt;
        }
        
        void get_sum(int l, int r){
            cout<<range_sum(r)-range_sum(l-1)<<endl;
        }
};

int main(){
    int n, q;
    cin>>n>>q;
    BIT ans(n);
    while(q--){
        int com, x, y;
        cin>>com>>x>>y;
        if(!com)
            ans.add(x,y);
        else
            ans.get_sum(x,y);
    }
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
#define inf 1e9
#define ll long long
#define ull unsigned long long
#define M 1000000007
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265


string g(string s,int k){
  string t;
  t+=s[0];
  rep(i,s.length()){
    if(t.length()>=k) break;
    if(s[i]=='a'||s[i]=='i'||s[i]=='u'||s[i]=='e'||s[i]=='o'){
      if(i+1==s.length()) break;
      t+= s[i+1];
    }

  }
  return t;
}


void f(int n){
  string s[100];

  rep(i,n){
    cin>>s[i];
  }

  int k = 1;
  bool flag = true;
  while(1){
    flag = true;
    map<string,bool> mp;
    rep(i,n){
      string t = g(s[i],k);
      if(mp[t])
        flag = false;
      mp[t] = true;
    }
    if(flag){
      break;
    }
    k++;
    if(k>100){
      cout<<-1<<endl;
      return;
    }
  }

  cout<<k<<endl;
}


int main(){
  int n;
  while(1){
    cin>>n;
    if(n==0) break;
    f(n);
  }

}


Measured memory_bytes: 3244
#include<stdio.h>

int main()

{

  int a,b,res;
  char c;

  scanf ("%d %c %d",&a, &c, &b);
  switch(c)
  {
    case '+': res=a+b;
    printf("%d",res);
    break;

    case '-': res=a-b;
    printf("%d",res);
    break;

  }

  return 0;
}


Measured memory_bytes: 1684
n = int(input())
min_v=int(input())
max_v=int(input())
hold_R=max_v-min_v
min_v=min(min_v, max_v)
for i in range(n-2):
    r_t=int(input())
    hold_R = max(hold_R, r_t-min_v)
    min_v = min(min_v, r_t)
print(hold_R)


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

int main() {
  long long N,M,A,B,C,ans,a,b;
  cin >>N;
  for(long long i=0;i<1000;i++){
    for(long long j=-1000;j<i;j++){
      if(i*i*i*i*i-j*j*j*j*j==N){
        cout<<i<<" "<<j<<endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 3636
import java.util.*;

class Main{
    public static void main(String[] args){
      Scanner scan = new Scanner(System.in);
      String str = scan.nextLine();
      String[] coffee = str.split("");
      if(Objects.equals(coffee[2], coffee[3])){
        if(Objects.equals(coffee[4], coffee[5])) System.out.println("Yes");
        else System.out.println("No");
      } else System.out.println("No");
    }
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define int long long
#define vi vector<int> 
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >  
#define N 200001
#define mod 1000000007
#define ll long long
ll fastexpom(ll a,ll b,ll m)
{
  ll res=1;
      while(b>0)
      {
        if(b%2==1)
          res=(((res)%m)*((a)%m))%m;
        a=(((a)%m)*((a)%m))%m;
        b/=2;
      }
      return res;
}
ll modinv(ll a, ll m=1000000007)
{
  return fastexpom(a,m-2,m);
}


int fact[N+1];
int ifact[N+1];

void preprocess()
{
    fact[0] = ifact[0] =1;
    for(int i = 1;i < N;i++)
    {
        fact[i] = (fact[i-1]*i)%mod;
        ifact[i] = modinv(fact[i]);
        
    }
}

int func(int r,int c)
{
    int total = fact[r+c];
    total = (total*ifact[r])%mod;
    total = (total*ifact[c])%mod;
    return total;
}

int32_t main()
{
    IOS;
   \
    preprocess();
    int n,m,k;
    cin>>n>>m>>k;
    vector<pair<int,int>> v(k+1);
    for(int i = 0;i < k;i++)
        cin>>v[i].ff>>v[i].ss;
    v[k] = {n,m};
    sort(v.begin(),v.end());
    int dp[k+1];
    for(int i = 0;i <= k;i++)
    {
        int total = func(v[i].ff-1,v[i].ss-1);
        for(int j = 0;j < i;j++)
        {
            if(v[j].ss<=v[i].ss and v[j].ff<=v[i].ff)
            {
                int r = v[i].ff-v[j].ff;
                int c= v[i].ss-v[j].ss;
                int num = (dp[j] * func(r,c))%mod;
                total= (total - num + mod)%mod;
            }
        }
        dp[i] = total;
    }
    cout<<dp[k];
    return 0;
}

Measured memory_bytes: 3456
//0038 Poker Hand

#include<iostream>
#include<algorithm>
using namespace std;


int main(void)
{
	const int N = 5;
	while(1)
	{
		int hand[N];
		char dummy;
		int i, j;
		for(i = 0; i < N; i++)
		{
			if(i)
				cin >> dummy;
			cin >> hand[i];
		}
		if(!cin)
			break;

		sort(hand, hand+N);

		if(hand[0] == hand[3] ||
			hand[1] == hand[4])
			cout << "four card" << endl;
		else if( (hand[0] == hand[1] && hand[2] == hand[4]) ||
				(hand[0] == hand[2] && hand[3] == hand[4]) )
			cout << "full house" << endl;
		else if( (hand[0] == 1 && hand[1] == 10 && hand[2] == 11 && hand[3] == 12 && hand[4] == 13) ||
			(hand[0]+1==hand[1] && hand[1]+1==hand[2] && hand[2]+1==hand[3] && hand[3]+1==hand[4]) )
			cout << "straight" << endl;
		else if( (hand[0] == hand[2] || hand[1] == hand[3] || hand[2] == hand[4]) )
			cout << "three card" << endl;
		else if( (hand[0]==hand[1] && hand[2]==hand[3]) ||
				(hand[0]==hand[1] && hand[3]==hand[4]) ||
				(hand[1]==hand[2] && hand[3]==hand[4]) )
			cout << "two pair" << endl;
		else if( hand[0]==hand[1] || hand[1]==hand[2] || hand[2]==hand[3] || hand[3]==hand[4] )
			cout << "one pair" << endl;
		else
			cout << "null" << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<cassert>
#include<numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
const int INF = 1001001001;
const long long LINF = 1001002003004005006ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int k;
    cin >> k;
    int t = 0;
    while(a>=b){
        b*=2;
        t++;
    }
    while(b>=c){
        c*=2;
        t++;
    }
    if(t<=k)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3672