akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>

struct Card{
	char suit;
	int value;
};

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

void selectionSort(struct Card A[], int n){
	struct Card t;
	for(int i=0;i<n;i++){
		int minj=i;
 		for(int 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(struct Card A[], int n){
	for(int i=0; i<n-1; i++){
		printf("%c%d ",A[i].suit,A[i].value);
	}
	for(int i=n-1; i<n; i++){
		printf("%c%d",A[i].suit,A[i].value);
	}
	printf("\n");
}

int isStable(struct Card C1[], struct Card C2[], int n){
	for(int i=0; i<n; i++){
		if(C1[i].suit!=C2[i].suit){
			return 0;
		}
	}
	return 1;
}
int main(){
	struct Card C1[100],C2[100];
	int n;
	char ch;
	
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf(" %c%d",&C1[i].suit,&C1[i].value);
	}
	for(int i=0;i<n;i++){
		C2[i]=C1[i];
	}
	
	bubbleSort(C1,n);
	selectionSort(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: 2092
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K;
  cin >> K;
  
  if(K % 2 == 0)
    cout << K/2 * K/2 << endl;
  else
    cout << (K-1)/2 * (K+1)/2 << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	long long   a[105],p_;
	long long en = 0,sum=0;
	float n,p;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		sum += a[i];
	}
	p = sum / n;
	p_ = (long long)p;
	if (p - p_ > 0.5)
		p_++;
	for (int i = 0; i < n; i++)
	{
		en += (a[i] - p_) * (a[i] - p_);
	}
	cout << en << endl;
}
 
 

Measured memory_bytes: 256
a,b=map(int,input().split())
if a==0 or b==0 or abs(a)==b or (a<0 and b>0):
    print('Zero')
elif a>0 or b>0:
    print('Positive')
else:
    if (abs(a)+abs(b))%2==0:
        print('Negative')
    else:
        print('Positive')



Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
int main() {
  int n;
  vector<int> arr(68921);
  cin >> n;
  for (int i = 0; i < 68921; i++)
  {
    arr[i] = 0;
  }
  
  for (int i = 1; i <= 105; i++) {
    for (int j = 1; j <= 105; j++) {
      for (int k = 1; k <= 105; k++) {
        arr[i*(i+j+k)+j*(j+k)+k*k-1]++;
      }
    }
  }
  for (int i = 0; i < n; i++)
  {
    cout << arr[i] << endl;
  }
  
}

Measured memory_bytes: 3156
N,K = map(int,input().split())
A = [int(v)-1 for v in input().split()]
p = 0
memo = {}
for i in range(K):
  if p in memo:
    interval = i-memo[p]
    rest = (K-i-1)%interval
    for j in range(rest+1):
      p=A[p]
    print(p+1)
    exit()
  else:
    memo[p] = i
  p = A[p]
print(p+1)


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

template <int64_t N>
class modint {
    int64_t x;
public:
    modint(int64_t x = 0) : x((x % N + N) % N) {}
    modint operator-() const { return modint(-x); }
    modint& operator+=(const modint& a) { if ((x += a.x) >= N) x -= N; return *this; }
    modint& operator-=(const modint& a) { if ((x += N - a.x) >= N) x -= N; return *this; }
    modint& operator*=(const  modint& a) { (x *= a.x) %= N; return *this; }
    modint operator+(const modint& a) const { return modint(*this) += a; }
    modint operator-(const modint& a) const { return modint(*this) -= a; }
    modint operator*(const modint& a) const { return modint(*this) *= a; }
    modint pow(int64_t t) const {
        if (not t) return 1;
        modint a = pow(t >> 1); a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    // for prime mod
    modint inv() const { return pow(N - 2); }
    modint& operator/=(const modint& a) { return (*this) *= a.inv(); }
    modint operator/(const modint& a) const { return modint(*this) /= a; }
    friend ostream& operator<<(ostream& os, const modint& m){ os << m.x; return os; }
};
const int64_t mod = 1e9 + 7;
using mint = modint<mod>;

int main(){
    int n, m; cin >> n >> m;
    vector<bool> s(n, true);
    for (auto i = 0; i < m; i++) { int a; cin >> a; s[a] = false; }
    vector<mint> dp(n + 1, 0);
    dp[0] = 1;
    if(s[1]) dp[1] = 1;
    for (auto i = 2; i <= n; i++) if(s[i]) dp[i] = dp[i - 1] + dp[i - 2];
    cout << dp[n] << endl;
    return 0;
}

Measured memory_bytes: 3968
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
	    
		int W = sc.nextInt();
		int H = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();
		
//		int W = 5;
//		int H = 4;
//		int x = 2;
//		int y = 2;
//		int r = 1;
		
		if (((r <= x) && (x <= W-r)) && ((r <= y) && (y <= H - r))){
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 17356
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC115A
{
	class Program
	{
		static void Main(string[] args)
		{
			int d;
			string s = "Christmas";

			d = int.Parse(Console.ReadLine());

			for (int i=0; i<25-d; i++)
			{
				s += " Eve";
			}
			Console.WriteLine(s);

			Console.ReadKey();


		}
	}
}


Measured memory_bytes: 11092
use std::io;
use std::str::FromStr;

fn input_tuple() -> (u64, u64) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<u64> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn count_paty(level: u64) -> u64 {
    2u64.pow(level as u32 + 1) - 1
}

fn count_layer(level: u64) -> u64 {
    2u64.pow(level as u32 + 2) - 3
}

fn recur(level: u64, x: u64) -> u64 {
    if x == 0 {
        return 0;
    }
    if level == 0 {
        return 1;
    }
    let count = count_layer(level-1);
    if x <= count + 1 {
        return recur(level-1, x - 1)
    } else {
        return count_paty(level-1) + 1 + recur(level-1, x - count - 2)
    }
}

fn main() {
    let (n, x) = input_tuple();
    println!("{}", recur(n, x));
}


Measured memory_bytes: 2144
#include<stdio.h>
#include<math.h>

int main(void)
{
	double a[1000] = {0}, s[1000], Goukei,
			aa = 0, m = 0;
	int i;
	int n = 1;
	int q = 1;
	
	a[0] = 1;

	while(n){
		
		Goukei = 0;
		aa = 0;
		
		scanf("%d", &n);
		Goukei = 0;
		for(i=1; i<=n; i++){
			scanf("%lf", &s[i]);
			Goukei += s[i];}
		m = Goukei / n;
		
		for(i=1; i<=n; i++){
			aa += (s[i]-m)*(s[i]-m);}
			aa /= n;
		a[q] = sqrt(aa);
	q++;}
	
	for(i=1; i<q-1; i++){
		printf("%.8f\n", a[i]);}
}


Measured memory_bytes: 2112
#include <algorithm>  // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>     // bitset
#include <cctype>     // isupper, islower, isdigit, toupper, tolower
#include <cstdint>    // int64_t, int*_t
#include <cstdio>     // printf
#include <deque>      // deque
#include <iomanip>    // fixed, setprecision
#include <iostream>   // cout, endl, cin
#include <map>        // map
#include <queue>      // queue, priority_queue
#include <set>        // set
#include <stack>      // stack
#include <string>     // string, to_string, stoi
#include <tuple>      // tuple, make_tuple
#include <unordered_map>  // unordered_map
#include <unordered_set>  // unordered_set
#include <utility>        // pair, make_pair
#include <vector>         // vector
using namespace std;

int main() {
  int64_t A, B, K;
  cin >> A >> B >> K;
  if (A >= K) {
    A -= K;
    K = 0;
  } else {
    K -= A;
    A = 0;
  }

  if (B >= K) {
    B -= K;
    K = 0;
  } else {
    K -= B;
    B = 0;
  }

  cout << A << " " << B << endl;
}


Measured memory_bytes: 3168
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
input=sys.stdin.readline
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    from heapq import heappop, heappush, heappushpop
    from math import floor,ceil,sqrt,factorial
    """O(max(h)*log(n))なので無理
    N, A, B = MI()
    H = []
    #heapで最大を持ち続けたいのでマイナスにして格納するよ!(popするときは符号反転させる)
    for _ in range(N):
        h=I()
        heappush(H, -h)
    C = A - B
    
    for i in range(1, -H[0] // B + 2):
        heappushpop(H, H[0] + C)
        print(H[0],i,i*B)
        if - H[0] <= i * B:
            print(i)
            break
            """
    #操作回数で二分探索
    N, A, B = MI()
    H = LIN(N)
    C=A-B

    def is_ok(n):
        cnt = 0
        for h in H:
            cnt+=max(0,ceil((h-n*B)/C))
        return cnt <= n
        
    ok = 10 ** 9 // B + 1
    ng=0
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    print(ok)

        
        
        

if __name__ == '__main__':
    main()

Measured memory_bytes: 45276
S = input()
T = input()
ls = len(S)
lt = len(T)
if ls < lt:
    print('UNRESTORABLE')
    exit()

index = -1
for i in range(ls-lt+1):
    cnt = 0
    for j in range(lt):
        s = S[i+j]
        if s == '?':
            cnt +=1
        if s == T[j]:
            cnt +=1
    if cnt == lt:
        index = i
if index == -1:
    print('UNRESTORABLE')
    exit()
S = S[:index] + T + S[index+lt:]
S = S.replace('?', 'a')
print(S)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll cnt[214514];
int main(){
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(i)cnt[i]=cnt[i-1];
    if(s[i]=='B')cnt[i]++;
  }
  ll ans=0;
  for(int i=0;i<s.size();i++){
    if(s[i]=='W')ans+=cnt[i];
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 2180
N = int(input())
As = [A-1 for A in map(int, input().split())]
Bs = list(map(int, input().split()))
Cs = list(map(int, input().split()))

ans = 0
APrev = -100
for i in range(N):
    A = As[i]
    ans += Bs[A]
    if APrev == A-1:
        ans += Cs[APrev]
    APrev = A

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int INF = 9999;
const int coins[] = {1, 5, 10, 50};

int d[2000];
int c[4];

pair<int, vector<int> > search(int y, vector<int> v = vector<int>(4, 0), int i = 0)
{	
	if (i == 4){
		if (y < 0) return make_pair(INF, vector<int>(0));
		return make_pair(d[y], v);
	}
	
	pair<int, vector<int> > mini = make_pair(INF, vector<int>(0));
	
	for (int j = 0; j <= c[i]; j++){
		vector<int> tmp = v;
		tmp[i] = j;
		pair<int, vector<int> > tmpp = search(y + coins[i] * j, tmp, i + 1);
		tmpp.first += c[i] - j;
		mini = min(tmpp, mini);
	}
	
	return mini;
}

int main()
{	
	for (int i = 1; i < 2000; i++){
		d[i] = INF;
	}
	
	for (int i = 0; i < 1800; i++){
		for (int j = 0; j < 4; j++){
			d[i + coins[j]] = min(d[i + coins[j]], d[i] + 1);
		}
	}
	
	int y;
	bool f = false;
	while (scanf("%d", &y), y){
		if (f) puts("");
		f = true;
		
		for (int i = 0; i < 4; i++){
			scanf("%d", &c[i]);
		}
		
		vector<int> v = search(-y / 10).second;
		for (int i = 0; i < 4; i++){
			if (!v[i]) continue;
			printf("%d %d\n", coins[i] * 10, v[i]);
		}
	}
	
	return 0;
}

Measured memory_bytes: 1228
# -*- coding: utf-8 -*-
# abc140/abc140_b
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    A = i2nn()
    B = i2nn()
    C = i2nn()
    m = 0
    for j in range(N - 1):
        i = A[j] - 1
        m += B[i]
        if i + 1 == A[j + 1] - 1:
            m += C[i]
    m += B[A[N - 1] - 1]
    print(m)
    return

main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
#define SP << " " <<
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------
struct BIT
{
    int M;
    vector<ll> bit;
    BIT(int n): M(n), bit(M+1,0) {}

    void add(int a, ll w) { // aを +w  aは 1-indexed
        for(int x=a; x<=M; x+= x& -x){
            bit[x] += w;
        }
    }

    ll sum(int a) { // [1,a] 1-indexed
        ll ret=0;
        for(int x=a; x>0; x-= x& -x){
            ret+= bit[x];
        }
        return ret;
    } // 左上のものをすべて足す

    ll get(ll k){ // k-th number 1-indexed 二分探索
        //k-1までが全部入るresの1つ後を求める。
        ll res=0; // kがたまるまでresを増やす。
        ll N=1; while(N <= M) N*=2;
        for(int i=N/2; i>0; i/=2 ){
            if(res + i <= M and bit[res+i] <k){
            k = k-bit[res+i];
            res+=i;
            }
        }
        return res+1; // 1-indexed resまでは新kまでが全部入る
    }
};

//--MAIN-----------------------------------
void Main() {
    ll N,M;
    cin>>N>>M;
    vector<pair<ll,P>> A;
    rep(i,N){
        ll l,r; cin>>l>>r;
        A.emplace_back(r-l+1,(P){l,r});
    }
    SORT(A);
    ll now=0;
    BIT bit(M+2);
    reps(i,1,M+1){
        while(now<N and A[now].first<=i){
            ll l=A[now].second.first;
            ll r=A[now].second.second;
            bit.add(l,1);
            bit.add(r+1,-1);
            ++now;
        }
        ll ans=N-now;
        for(ll j=i;j<=M;j+=i){
            ans+=bit.sum(j);
        }
        cout<< ans<<"\n";
    }    

}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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

public class Main {
	static Scanner sc = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);
	static final int INF = (int) 1e9;
	static int n, m, k, dist[][];
	static char[][] adj;
	static int[] dx = {1,-1,0,0} , dy = {0,0,1,-1};
	
	static boolean valid(int r, int c) {
		return r >= 0 && r < n && c >= 0 && c < m && adj[r][c] != '@';
	}
	
	static void bfs(int x, int y, int x2, int y2) {
		dist[x][y] = 0;
		Queue<Pair> q = new LinkedList<>();
		q.add(new Pair(x, y, 0));
		
		while(!q.isEmpty()) {
			int r = q.peek().r, c = q.peek().c;
			if(q.poll().d > dist[r][c]) continue;
			
			for(int i = 0; i < 4; i++) {
				for(int j = 1; j <= k; j++) {
					int nr = dx[i] * j + r, nc = dy[i] * j + c;
					if(!valid(nr, nc) || dist[nr][nc] <= dist[r][c]) break;
					if(dist[nr][nc] > dist[r][c] + 1)
						q.add(new Pair(nr, nc, dist[nr][nc] = dist[r][c] + 1));
				}
			}
			
			if(r == x2 && c == y2) break;
		}
	}

	public static void main(String[] args) throws Exception {
		n = sc.nextInt();
		m = sc.nextInt();
		k = sc.nextInt();
		
		int x1 = sc.nextInt() - 1, y1 = sc.nextInt() - 1;
		int x2 = sc.nextInt() - 1, y2 = sc.nextInt() - 1;
		
		dist = new int[n][m];
		adj = new char[n][];
		for(int i = 0; i < n; i++) {
			adj[i] = sc.nextLine().toCharArray();
			Arrays.fill(dist[i], INF);
		}
		
		bfs(x1, y1, x2, y2);
		out.println(dist[x2][y2] == INF ? -1 : dist[x2][y2]);
		out.close();
	}

}

class Pair{
	int r, c, d;
	public Pair(int r, int c, int d) {
		this.r = r;
		this.c = c;
		this.d = d;
	}
}

class Scanner {
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream system) {
		br = new BufferedReader(new InputStreamReader(system));
	}

	public Scanner(String file) throws Exception {
		br = new BufferedReader(new FileReader(file));
	}

	public String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public String nextLine() throws IOException {
		return br.readLine();
	}

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

	public double nextDouble() throws IOException {
		return Double.parseDouble(next());
	}

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


Measured memory_bytes: 55712
/*input 
4 8
3 1 4 1
3 1 4 1
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()
#define all(x) beg(x), en(x)
#define resz resize

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;
const ld PI = 4*atan((ld)1);

ll modpow(ll x, ll p) {
	return !p ? 1 : modpow((x * x) % MOD, p / 2) * (p & 1 ? x : 1) % MOD;
}

ll pre[401][401];
ll N, C;
vi A, B;
ll dp[401][401];
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);

	cin >> N >> C;
	A.pb(0);
	FOR(i, 1, N + 1) {
		A.pb(0); cin >> A[i];
	}
	B.pb(0);
	FOR(i, 1, N + 1) {
		B.pb(0); cin >> B[i];
	}

	F0R(i, 401) {
		FOR(j, 1, 401) {
			pre[i][j] = (pre[i][j - 1] + modpow(j, i)) % MOD;
		}
	}

	FOR(i, 1, N + 1) {
		F0R(j, C + 1) {
			if (i == 1) {
				dp[i][j] = (pre[j][B[i]] - pre[j][A[i] - 1]) % MOD; 
				while (dp[i][j] < MOD) dp[i][j] += MOD;
			}
			F0R(k, j + 1) {
				ll tmp = (pre[k][B[i]] - pre[k][A[i] - 1]) % MOD;
				tmp = (tmp * (dp[i - 1][j - k] % MOD)) % MOD;
				while (tmp < 0) tmp += MOD;
				dp[i][j] = (dp[i][j] + tmp) % MOD;
			}
		}
	}
	cout << dp[N][C] << '\n';
}


Measured memory_bytes: 2816
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <deque> 

using namespace std;


int a, b;

int main()
{
	scanf("%d%d", &a, &b);
	int ans;
	
	if (a >= 13)
		ans = b;
	else if ((6 <= a) && (a <= 12))
		ans = b / 2;
	else if (a <= 5)
		ans = 0;
		
	printf("%d\n", ans);
	
	
	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, x;
  cin >> a >> b;
  if((a + b) % 2 == 0) {
    x = (a + b) / 2;
  } else {
    x = ((a + b) / 2) + 1;
  }

  cout << x << endl;

  return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
signed main()
{
   SPEED;
   int n,k;
   cin>>n>>k;
   int freq[n+1]={0};
   for(int i=0;i<k;i++)
   {
       int t;
       cin>>t;
       for(int j=0;j<t;j++)
       {
           int a;
           cin>>a;
           freq[a]++;
       }
   }
   int cnt=0;
   for(int i=1;i<=n;i++)
   {
       if(freq[i]==0)
       {
           ++cnt;
       }
   }
   cout<<cnt;
}

Measured memory_bytes: 3656
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  int K, X; cin >> K >> X;
  for (int i = X - K + 1; i < X + K; ++i) {
    cout << i << " ";
  }
  cout << endl;
}


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

int main() {
    int w, h, n, x1, x2, y1, y2, ans;
    cin >> w >> h >> n;
    int x[n], y[n], a[n];
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i] >> a[i];
    }
    x1 = 0;
    x2 = w;
    y1 = 0;
    y2 = h;
    ans = 1;
    for (int i = 0; i < n; i++) {
        if (a[i] == 1) {
            if (x2 <= x[i]) {ans = 0;break;}
            else if (x1 <= x[i]) x1 = x[i];
        } else if (a[i] == 2) {
            if (x[i] <= x1) {ans = 0;break;}
            else if (x[i] <= x2) x2 = x[i];
        } else if (a[i] == 3) {
            if (y2 <= y[i]) {ans = 0;break;}
            else if (y1 <= y[i]) y1 = y[i];
        } else if (a[i] == 4) { 
            if (y[i] <= y1) {ans = 0;break;}
            else if (y[i] <= y2) y2 = y[i];
        }
    }
    if (ans == 0) cout << 0 << endl;
    else cout << (x2 - x1)*(y2 - y1) << endl;
}

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

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
	cin.sync_with_stdio(false); cin.tie(0);
	cin.exceptions(cin.failbit);
	
	int n, k; cin >> n >> k;
	double prob = 0.0;

	for (int i = 1; i <= n; i++) {
		if (i <= k - 1) {
			prob += 1.0 / n / pow(2, ceil(log2(1.0 * k / i)));
		} else if (i >= k) {
			prob += 1.0 / n;
		}
	}

	cout << fixed << setprecision(12) << prob << endl;
}


Measured memory_bytes: 256
#include <iostream>
typedef long long ll;
#include <cmath>
#include <vector>
#include <algorithm>

void dump(int a[],int n)
{
  for (int codeTest = 0; codeTest < n; ++codeTest) {
    if (codeTest!=0)std::cout << " ";
    std::cout << a[codeTest];
  }
  std::cout << '\n';
}

int main() {
  int n,h[100000],i,ans=0,tmp;
  std::cin >> n;
  for (i = 0; i < n; ++i) {
    std::cin >> tmp;
    h[tmp-1]=i+1;
  }
  dump(h,n);
}


Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;


int main()
{
	int n;
	cin >> n;
	bool ans = false;
	for (int i = 0; i < n; i++) {
		char candy;
		cin >> candy;
		if (candy == 'Y') {
			ans = true;
			break;
		}
	}

	if (ans) {
		cout << "Four" << endl;
	}
	else {
		cout << "Three" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
use List::Util qw(sum);
use List::Util qw(min);
my $N = <STDIN>;
chomp $N;
my @A = 0 x $N;
my @B = 0 x $N;
for ($i=0; $i<$N; $i++) {
  $input = <STDIN>;
  chomp $input;
  ($A[$i], $B[$i]) = split / /, $input;
}
my @C = (@A, @B);
@C = sort {$a <=> $b} @C;
my $bor = $C[$N-1];
my $res = sum @C[0..($N-1)];
my @a = 0 x $N;
my @b = 0 x $N;
my $stat = "NG";
my $stat2 = 0;
for ($i=0; $i<$N; $i++) {
  if ($A[$i] < $bor) { $a[$i]=1; }
  if ($A[$i] == $bor) { $a[$i]=2; }
  if ($B[$i] < $bor) { $b[$i]=1; }
  if ($B[$i] == $bor) { $b[$i]=2; }
  if ($A[$i] > $bor && $B[$i] > $bor) { $stat = "OK"; }
  if ($A[$i] == $bor && $B[$i] == $bor) { $stat2 = 2; }
}
if ( $stat eq "NG" ) {
  if ((sum @a) == 0 || (sum @b) == 0) { $stat = "OK"; }
  elsif (($C[$N-2]==$bor && $C[$N]==$bor) || $C[$N+1]==$bor)
  { $stat = "OK"; }
}
my $stat3 = 0;
my $dif = $C[-1];
if ( $stat eq "NG" ) {
  if ($C[$N]>$bor) {
    for($i=0;$i<$N;$i++) {
      if($a[$i]==2) {
        if($B[$i]==$C[$N]) {
          $stat3 = 1;
          $dif = min($dif,$C[$N+1]-$bor,$C[$N]-$C[$N-2]);
        } else {
          $dif = min($dif,$C[$N]-$bor);
        }
      }
      if($b[$i]==2) {
        if($A[$i]==$C[$N]) {
          $stat3 = 1;
          $dif = min($dif,$C[$N+1]-$bor,$C[$N]-$C[$N-2]);
        } else {
          $dif = min($dif,$C[$N]-$bor);
        }
      }
    }
  } elsif ($stat2==2) {
    $dif = min($C[$N+1]-$bor,$C[$N]-$C[$N-2]);
  } else {
    $dif = 0;
  }
  $res = $res+$dif;
}
print $res . "\n";

Measured memory_bytes: 51556
input_str = input()

for i in range(8):
    calc_str = input_str[0]
    opmaker = str(format(i, 'b')).zfill(3)
    for j, c in enumerate(opmaker):
        if c == '0':
            calc_str += '-'
        else:
            calc_str += '+'
        calc_str += input_str[j+1]
    if eval(calc_str) == 7:
        print(calc_str + '=7')
        exit()


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
 
int main(){
	long long N, K;
	cin>>N>>K;
	long long cnt1=0, cnt2=0;
	cnt1 = N/K;
	if (K % 2 == 0&& N>=(K/2)){
		cnt2 = (N - K/2) / K + 1;
         }
	cout<<cnt1*cnt1*cnt1 + cnt2*cnt2*cnt2<< endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 1000000000000000000
bool que(vector<int>x){
	flush(cout);
	cout<<'?';
	for(int i=0;i<x.size();i++)cout<<' '<<x[i];
	cout<<endl;
	string res;
	cin>>res;
	if(res[0]=='R')return true;
	else return false;
}
int n,q,ans[205];
vector<int>a,b,rd,br;
int main(void){
	cin>>n;
	for(int i=1;i<=n;i++)a.PB(i);
	for(int i=1;i<=n;i++)b.PB(n+i);
	bool pre=que(a);
	int l=-1,r=n-1;
	while(r-l>1){
		int m=(r+l)/2;
		for(int i=0;i<=m;i++)swap(a[i],b[i]);
		bool now=que(a);
		if(now!=pre)r=m;
		else l=m;
		for(int i=0;i<=m;i++)swap(a[i],b[i]);
	}
	for(int i=0;i<=r;i++)swap(a[i],b[i]);
	swap(a[r],b[r]);
	if(pre)ans[a[r]-1]=1;
	else ans[b[r]-1]=1;
	q=r;
	for(int i=0;i<n;i++){
		if(i==q)continue;
		swap(a[q],b[i]);
		bool now=que(a);
		if(now)ans[a[q]-1]=1;
		swap(a[q],b[i]);
	}
	for(int i=0;i<n;i++){
		if(i==q)continue;
		swap(b[q],a[i]);
		bool now=que(b);
		if(now)ans[b[q]-1]=1;
		swap(b[q],a[i]);
	}
	flush(cout);
	cout<<"! ";
	for(int i=0;i<n*2;i++){
		if(ans[i])cout<<'R';
		else cout<<'B';
	}
	cout<<endl;
	flush(cout);
}


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

#define int				long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define FORE( i, m, n ) FOR( i, m , n + 1 )
#define REP( i, n )     FOR( i, 0, n )
#define REPE( i, n )	FOR( i, 0, n + 1 )
#define REPA( i, n )	FOR( i, 1, n )
#define FORR( i, m, n ) for( int (i) = (m); (i) >= 0; (i)-- )
#define ALL( a )        (a).begin(), (a).end()             
#define MP( a, b )		make_pair( (a), (b) )
#define fi				first
#define se				second

const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main() {
	int h, w; cin >> h >> w;

	
	int ans = 0;
	REP( i, h ) {
		REP( j, w ) {
			int t; cin >> t;

			int right = w - j;
			int left = j + 1;
			int up = i + 1;
			int down = h - i;

			ans += t * right* left * up * down;

		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 3104
import collections
# from queue import Queue
k = int(input())
q = collections.deque()
Lunlun = []
for i in range(1, 10):
    q.append(i)
while True:
    if len(Lunlun) >= 10**5:
        break
    now = q.popleft()
    Lunlun.append(now)
    for i in range(-1, 2):
        if (now % 10) + i < 0 or 9 < (now % 10) + i:
            continue
        q.append(now*10 + (now % 10) + i)

print(Lunlun[k-1])


Measured memory_bytes: 16272
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	long long n;
	cin >> n;
		
	if(n % 2 == 0)
	{
		cout << n << endl;
	}
	else
	{
		cout << n * 2 << endl;
	}
	
	return 0;
}

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

using namespace std;

typedef long long ll;

const int MOD = 1e9 + 7;

int main(){
	ll n, k;
	cin >> n >> k;
	ll a[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	sort(a, a + n);
	if(a[n - 1] == 0 && k % 2){
		cout << 0 << '\n';
		return 0;
	}
	ll sol = 1;
	if(a[n - 1] <= 0 && k % 2){
		for(int i = n - 1;  i >= n - k; i--){
			sol = (sol * 1LL * a[i] + MOD) % MOD;
		}
		cout << sol << '\n';
		return 0;
	}

	ll i = 0, j = n - 1;
	if(k % 2){
		sol = (sol * 1LL *  a[j]) % MOD;
		j--;
		k--;
	}
	k /= 2;
	for(ll p = 0; p < k; p++){
		ll neg = (a[i] * 1LL * a[i + 1]);
		ll pos = (a[j] * 1LL * a[j - 1]);
		if(neg >= pos){
			sol = (sol * 1LL * (neg % MOD)) % MOD;
			i += 2;
		}else{
			sol = (sol * 1LL * (pos % MOD)) % MOD;
			j -= 2;
		}
	}
	cout << (sol + MOD) % MOD << '\n';
}


Measured memory_bytes: 5140
#include<bits/stdc++.h>
using namespace std;
#define int long long
void Digvijay()
{
    int n;
    cin>>n;
    int cnt=1;
    int val=n%10;

    if(val==1||val==3||val==9||val==7)
    {
        int rem=7%n;
        int val=rem;
        while(rem!=0)
        {
            cnt++;
           val=(val*10)%n;
           rem=(rem+val)%n;


        }
        cout<<cnt<<"\n";

    }
    else cout<<-1<<"\n";

}
signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int _=1;
    //cin>>_;
    for(int __=1;__<=_;__++)
    {
        Digvijay();
    }
}



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

int main() {
    int H, N; cin >> H >> N;
    int suma = 0;
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        suma += a;
    }
    if (suma >= H) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

public class Main {

	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		
		out.println((sc.nextInt()-sc.nextInt())+1);

		out.flush();
	}

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

class Pair<K, V> extends AbstractMap.SimpleEntry<K, V> {

    public Pair(final K key, final V value) {
        super(key, value);
    }
 }

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

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

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

    public double nextDouble() {
         return Double.parseDouble(next());
     }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

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

Measured memory_bytes: 21972
#include<stdio.h>

int main(){
    int N;
    scanf("%d", &N);
    int a[4] = {0, 0, 0, 0};
    for (int i = 0; i < 4; i++){
        a[i] = N % 10;
        N = N/10;        
    }

    bool isGood = true;
    if (a[0] == a[1]) isGood = false;
    if (a[1] == a[2]) isGood = false;
    if (a[2] == a[3]) isGood = false;

    if (isGood) {
        printf("Good");
    } else {
        printf("Bad");
    }
    return 0;
}

Measured memory_bytes: 128
import java.io.File;
import java.io.IOException;
import java.util.*;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		for(int i = 0; i < s.length(); i++){
			if(i % 2 == 0) System.out.print(s.charAt(i));
		}
		System.out.println();
	}
}

Measured memory_bytes: 30656
#include<cstdio>
typedef long long ll;
using namespace std;
int main(){
    int f;
    ll l,r,mid,a[50],n,sum,ans=0,x;
    scanf("%lld",&n);
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
    }
    do{
        f=1;
        sum=0;
        for(int i=0;i<n;i++){
            sum+=a[i]/n;
        }
        for(int i=0;i<n;i++){
            x=a[i]/n;
            a[i]+=sum-x-x*n;
            if(a[i]>=n){
                f=0;
            }
        }
        ans+=sum;
    }while(f==0);
    printf("%lld\n",ans);
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#define pb push_back
#define ll long long
using namespace std;
ll Knap(ll W,vector<ll>&wt,vector<ll>&val,ll N,vector<vector<ll>>&mat){
	if(N==0||W==0)return 0;
	else{
		if(wt[N-1]>W){
			if(mat[N-1][W]!=-1){return mat[N-1][W];}
			else{
				return Knap(W,wt,val,N-1,mat);
			}
		}else{
			ll a,b;
			if(mat[N-1][W]!=-1){a=mat[N-1][W];}
			else{a= Knap(W,wt,val,N-1,mat);}
			if(mat[N-1][W-wt[N-1]]!=-1){b=val[N-1]+mat[N-1][W-wt[N-1]];}
			else{b= val[N-1]+Knap(W-wt[N-1],wt,val,N-1,mat);}
			mat[N][W]=max(a,b);
			return mat[N][W];
		}
	}
}
int main(){
ll N,W;cin>>N>>W;
vector<ll>val;vector<ll>wt;
for(ll i=0;i<N;i++){ll w,v;cin>>w>>v;val.pb(v);wt.pb(w);}
vector<vector<ll>>mat;
vector<ll>temp;
for(ll i=0;i<=W;i++){temp.pb(0);}mat.pb(temp);
for(ll i=0;i<=W;i++){if(i==0){temp[i]=0;}else{temp[i]=-1;}}
for(ll i=0;i<N;i++){mat.pb(temp);}
cout<<Knap(W,wt,val,N,mat);
}


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

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> a(n+1,0);
    for(int i=1;i<=n;i++) cin >> a[i];
    ll l=0,r=(1<<30);
    while(l<r-1)
    {
        ll m=(l+r)/2;
        ll x=0;
        for(int i=1;i<=n;i++) x+=(((a[i]+m-1)/m)-1);
        if(x<=k) r=m;
        else l=m;
    }
    cout << r << "\n";
    return 0;
}


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

const int INF = 1e9;

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

    tuple<string, int, int> t[n];
    for (int i=0; i<n; i++) {
      string s;
      int p;
      cin>>s>>p;
      t[i] = make_tuple(s, -p, i+1);
    }
    sort(t, t+n);
    for (int i=0; i<n; i++) {
      cout<<get<2>(t[i])<<endl;
    }

}

Measured memory_bytes: 256
from collections import defaultdict
from collections import deque
from collections import OrderedDict
import itertools
from sys import stdin
input = stdin.readline


def main():
  A, B, C = list(map(int, input().split()))
  K = int(input())

  for i in range(K+1):
    for j in range(K-i+1):
      AA = A*(2**i)
      BB = B*(2**j)
      CC = C*(2**(K-i-j))
      if AA < BB < CC:
        print('Yes')
        return

  print('No')


if(__name__ == '__main__'):
  main()


Measured memory_bytes: 64792
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
struct XY{
int x,y;
};
int main(){
while(1){
int i,j,m,n,X,Y,a,b,cnt,r;
struct XY w[200],p[1000];
scanf("%d",&m);
if(m==0)return 0;
for(i=0;i<m;i++){
scanf("%d%d",&w[i].x,&w[i].y);
if(i!=0){
w[i].x=w[i].x-w[0].x;
w[i].y=w[i].y-w[0].y;
}
}
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d%d",&p[i].x,&p[i].y);
for(i=0;i<n;i++){
cnt=1;
for(j=1;j<m;j++){
for(r=0;r<n;r++){
if(p[r].x==p[i].x+w[j].x&&p[r].y==p[i].y+w[j].y)
cnt++;
}
}
if(cnt==m){
X=p[i].x-w[0].x;
Y=p[i].y-w[0].y;
break;
}
}
printf("%d %d\n",X,Y);
}
return 0;
}



Measured memory_bytes: 3180
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

int goal[25];
int p[25];

int main() {
    int L;
    cin >> L;
    ll now = 1;
    int M = 0;
    while (L > 3) {
        if (L % 2 != 0) {
            goal[now] = L - 1;
            M++;
        } else {
            goal[now] = -1;
        }
        p[now] = L / 2;
        M += 2;
        L = L / 2;
        now++;
    }
    if (L == 3) {
        goal[now] = 2;
        M++;
    } else {
        goal[now] = -1;
    }
    p[now] = 1;
    M += 2;
    cout << now + 1 << " " << M << endl;
    for (int i = 1; i <= now; i++) {
        if (goal[i] != -1) {
            cout << i << " " << now + 1 << " " << goal[i] << endl;
        }
        cout << i << " " << i + 1 << " " << 0 << endl;
        cout << i << " " << i + 1 << " " << p[i] << endl;
    }
}


Measured memory_bytes: 256
# F - LCS
from io import StringIO


def get_lcs(str_1: str, str_2: str) -> str:
    dp = [[0] * (len(str_2) + 1) for _ in range(len(str_1) + 1)]
    for i, s in enumerate(str_1):
        for j, t in enumerate(str_2):
            if s == t:
                dp[i + 1][j + 1] = dp[i][j] + 1
            else:
                dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1])

    i, j = len(str_1), len(str_2)
    buf = StringIO()
    while i and j:
        if str_1[i - 1] == str_2[j - 1]:
            i -= 1
            j -= 1
            buf.write(str_1[i])
            continue
        if dp[i - 1][j] > dp[i][j - 1]:
            i -= 1
        else:
            j -= 1
    buf.seek(0)
    return buf.read()[::-1]


def main():
    S, T = open(0).read().split()
    print(get_lcs(S, T))


if __name__ == "__main__":
    main()


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

using namespace std;

typedef long long ll;

const int __SIZE = 1 << 18;
char ibuf[__SIZE], *iS, *iT;

#define ge (iS == iT ? (iT = (iS = ibuf) + fread(ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS++)) : *iS++)
#define ri read_int()
#define rl read_ll()
#define FILE(s) freopen(s"in", "r", stdin), freopen(s"out", "w", stdout)

template<typename T>
inline void read(T &x) {
	char ch, t = 0; x = 0;
	while(!isdigit(ch = ge)) t |= ch == '-';
	while(isdigit(ch)) x = x * 10 + (ch ^ 48), ch = ge;
	x = t ? -x : x;
}
inline int read_int() { int x; return read(x), x; }
inline ll read_ll() { ll x; return read(x), x; }

template<typename T>
inline void chkmin(T&a, T b) { a = a < b ? a : b; }

const int MAXN = 100010;

int top;
ll a[MAXN];
ll c[MAXN];
ll tim[MAXN];

inline void solve(int p, ll x, ll t) {
	tim[p] += t * (x / a[p]), x %= a[p];
	p = upper_bound(a + 1, a + 1 + p, x) - a;
	if(p == 1) c[1] += t, c[x + 1] -= t;
	else solve(p - 1, x, t);
}

int main() {
#ifdef LOCAL
	FILE("");
#endif

	int n = ri, q = ri;

	a[++top] = n;
	for(int i = 1; i <= q; i++) {
		ll x = rl;
		while(a[top] >= x && top) --top;
		a[++top] = x;
	}

	tim[top] = 1;
	for(int i = top; i > 1; i--)
		solve(i - 1, a[i], tim[i]);

	for(int i = 1; i <= a[1]; i++)
		c[i] += c[i - 1];

	for(int i = 1; i <= a[1]; i++)
		printf("%lld\n", c[i] + tim[1]);
	n -= a[1];
	while(n--) puts("0");
	return 0;
}


Measured memory_bytes: 4352
#!/usr/bin/env python3

# from numba import njit

from collections import Counter
# from itertools import accumulate
# import numpy as np
# from heapq import heappop,heappush
# from bisect import bisect_left

# @njit
def solve(n,d,m,t):
  dd = Counter(d)
  dt = Counter(t)
  for k,v in dt.items():
    if k in dd.keys() and dd[k] >= v:
      pass
    else:
      return "NO"
  return "YES"



def main():
  N = int(input())
  d = list(map(int,input().split()))
  M = int(input())
  t = list(map(int,input().split()))
  print(solve(N,d,M,t))
  return

if __name__ == '__main__':
  main()


Measured memory_bytes: 57208
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

string sa[100000];

int main() {
    int n;
    ll cnt = 0, ans = 0;
    string s;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> s;
        sort(s.begin(), s.end());
        sa[i] = s;
    }
    sort(sa, sa + n);
    for (int i = 0; i + 1 < n; ++i) {
        if (sa[i] == sa[i + 1]) {
            cnt++;
        }
        else {
            ans += cnt * (cnt + 1) / 2;
            cnt = 0;
        }
    }
    ans += cnt * (cnt + 1) / 2;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5760
#include <cstring>
#include <map>
#include <deque>
#include <queue>
#include <stack>
#include <sstream>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <fstream>
#include <string>
#include <cstdlib>
#include <ctime>
#include <functional>
#include <algorithm>
#include <vector>
#include <set>
#include <complex>
#include <list>
#include <climits>
#include <cctype>
#include <bitset>
using namespace std;

#define PI 3.14159265359
#define all(v) v.begin(),v.end()
#define sortva(v) sort(all(v))
#define sortvd(v) sort(v.rbegin(),v.rend())
#define sortaa(a,n) sort(a,a+n)
#define sortad(a,n) sort(a,a+n),reverse(a,a+n)
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define sfstr(v) scanf("%s", v);
#define sz(v) (int)v.size()
#define ndl puts("")
#define SS stringstream
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

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

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

void PLAY() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	cout << fixed << setprecision(10);
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}


int main() {
	//PLAY();

	int a, b;
	cin >> a >> b;
	string s;
	cin >> s;
	int cnt1 = 0, cnt2 = 0;
	for (int i = 0; i < sz(s); i++) {
		if (s[i] == '-') cnt1++;
		else cnt2++;
	}
		
	if (s[a] == '-') {
		for (int i = 0; i < sz(s); i++) {
			if (i == a) continue;
			if (!isdigit(s[i])) {
				cout << "No" << endl;
				return 0;
			}
		}
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <list>
#include <set>
#include <bitset>
#include <iterator>
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;
using namespace std;
typedef long long int LL;
typedef unsigned long long int ULL;

const LL INF = 1LL << 60;

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

int main() {
    int n;
    cin >> n;
    vector<LL> h(n);
    rep(i, n) {
        cin >> h[i];
    }
    vector<LL> dp(n);
    rep(i, n) {
        dp[i] = INF;
    }

    dp[0] = 0;
    for (int i = 1; i < n; i++) {
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1) {
            chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
        }
    }
    cout << dp[n - 1] << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    vector<int> primes;
    primes.reserve(10000);
    primes.push_back(2);
    for (int i = 3; i < 1000; i += 2) {
        bool ok = true;
        for (int j = 0; j < primes.size(); j++) {
            if (i % primes[j] == 0) {
                ok = false;
                break;
            }
        }
        if (ok) {
            primes.push_back(i);
        }
    }
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    bool ok = true;
    for (int i = 0; i < primes.size(); i++) {
        int c = 0;
        for (int j = 0; j < n; j++) {
            if (a[j] % primes[i] == 0) {
                c++;
                do {
                    a[j] /= primes[i];
                } while(a[j] % primes[i] == 0);
            }
        }
        if (c == n) {
            cout << "not coprime" << endl;
            return 0;
        }
        if (c > 1) {
            ok = false;
        }
    }
    sort(a.begin(), a.end());
    if (a[0] == a[n-1] && a[0] != 1) {
        cout << "not coprime" << endl;
        return 0;
    }
    if (!ok) {
        cout << "setwise coprime" << endl;
        return 0;
    }
    for (int i = 0; i < n - 1; i++) {
        if (a[i] == a[i + 1] && a[i] != 1) {
            cout << "setwise coprime" << endl;
            return 0;
        }
    }
    cout << "pairwise coprime" << endl;
}


Measured memory_bytes: 7160
#include<stdio.h>
#include<string.h>
int main()
{
    char s[300], t[300], c[300];
    int length, i, j, loop=0;

    gets(s);
    gets(t);

    if(!strcmp(s,t))
    {
        printf("Yes\n");

        return 0;
    }

    length=strlen(s);



    while(loop< length)
    {
        strcpy(c,s);

        for(i=0,j=0; j<length; i++, j++)
        {
            if(j==0)
                s[j]=c[length-1];
            else
                s[j]=c[i-1];
        }

        if(!(strcmp(s,t)))
        {
            printf("Yes\n");

            return 0;
        }

        loop++;

    }

    printf("No\n");


    return 0;
}


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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int,int> dct;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define pi 3.14159265

bool compare(pll a, pll b){
    return (a.first*b.second) < (a.second*b.first);
}

const int mod = 1e9 + 7;
const ll inf = ll(1e18);

ll modexp(ll x,ll n){
    if(n==0)return 1;
    if(n%2==0)return modexp((x*x)%mod,n/2);
    return (x*modexp((x*x)%mod,n/2))%mod;
}
int main(){
    fastio;
    //clock_t tm = clock();
    ll n,x;
    cin>>n;
    ll ans=3;
    vl a(n,0);
    cin>>x;
    a[0]++;
    if(x==0) {
        f(i, 1, n) {
            cin >> x;
            if (x == 0)ans *= (3 - a[0]);
            else ans *= (a[x - 1] - a[x]);
            a[x]++;
            if (ans >= mod)ans %= mod;
        }
        cout << max(0ll, ans) << endl;
    }
    else cout<<0<<endl;
    //cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}

Measured memory_bytes: 1024