akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int INF = 100000000;
ll i,j,k;
ll mod=1000000007;

int main(){
    ll n;cin>>n;
    map<pair<ll,ll>,ll> H;
    vector<pair<ll,ll>> P(n);
    for(i=0;i<n;i++){
        ll x,y,h;
        cin>>x>>y>>h;
        P[i]=make_pair(x,y);
        H[make_pair(x,y)]=h;//座標と高さの情報
    }

    ll h;
    for(i=0;i<=100;i++){
        for(j=0;j<=100;j++){
            for(k=0;k<n;k++){
                if(H[P[k]]!=0){
                    //高さが0のものは情報として弱い
                    //(例えば、高さが0のときは、xが1centerから離れても、高さは0のままであるので、centerを特定する情報としては弱い)
                    h=H[P[k]]+abs(P[k].first-i)+abs(P[k].second-j);//centerを(i,j)と仮定したときのpyramidの高さ(一意に定まるので、H!=0ならどこを選んでもよい)
                    break;
                }
            }
            
            bool ok=true;
            for(k=0;k<n;k++){
                if(max(h-abs(P[k].first-i)-abs(P[k].second-j),(ll)0)!=H[P[k]]){//他の情報に一致するのか
                    ok=false;
                }
            }
            if(ok){cout<<i<<" "<<j<<" "<<h<<endl;return 0;}//他の情報全てと一致したら答え
        }
    }

    return 0;
}

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

#define fast ios::sync_with_stdio(0) , cin.tie(0)
#define pb push_back
#define deb(x) cout << "[ " << #x << " = " << x << " ]\n"
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()


const int SZ = 1e5 + 5;

int main(){
   fast;
   Long a,b,c,k;
   cin >> a >> b >> c >> k;
   Long ans = min(a,k);
   k -= ans;
   if(k){
      k-= min(b,k);
      if( k){
         ans -= min(c,k);
         k -= ans;
      }
   }
   cout << ans;
   return 0;
}

Measured memory_bytes: 3652
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return 1;} return 0; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }

// gcc拡張マクロ
#define gcd __gcd
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll n; cin >> n;
    vector<string> s(n); REP(i, n) cin >> s[i];

    ll ans = 0;

    // naive guys
    REP(i, n) {
        REP(j, s[i].size() - 1) {
            if (s[i][j] == 'A' && s[i][j+1] == 'B') {
                ans++;
            }
        }
    }

    ll _a = 0;
    ll b_ = 0;
    ll ba = 0;
    REP(i, n) {
        char f = s[i].front();
        char b = s[i].back();
        if (f == 'B' && b == 'A') {
            ba++;
        } else if (f == 'B') {
            b_++;
        } else if (b == 'A') {
            _a++;
        }
    }
    
    if (ba) {
        ans += ba-1 + !!_a + !!b_;
        if (_a) _a--;
        if (b_) b_--;
    }
    ans += min(_a, b_);

    cout << ans << endl;

    
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
// #include <numeric>
#include <complex>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define repr(i, a, b) for(int i=int(a); i>=int(b); i--)
#define reps(i,n) for(int i=1;i<=int(n);++i)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define iceil(x,y) (x+y-1)/y
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;
typedef long long int ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<int, PII> PP;

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

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

	int e,o;
	if (k%2==0) {
		e = k/2;
		o= ((k-1)/2) + 1;
	}
	else {
		e = ((k-1)/2) + 1;
		o = k/2;
	}

	cout << e*o << "\n";

	return 0;
}

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

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

struct Card {
    suit: char,
    number: u8,
}

fn main() {
    let mut cards: Vec<Card> = vec![];
    for suit in "SHCD".chars() {
        for number in 1..14 {
            let card = Card {
                suit: suit,
                number: number,
            };
            cards.push(card);
        }
    }

    let n: u8 = read();
    for _ in 0..n {
        let suit_str: String = read();
        let suit_char: char = suit_str.chars().next().unwrap();
        let number: u8 = read();
        cards.retain(|c| c.suit != suit_char || c.number != number);
    }

    for card in cards {
        println!("{} {}", card.suit, card.number)
    }
}



Measured memory_bytes: 5028
package main
import "fmt"

func main() {
	var a, b, k int
	fmt.Scan(&a, &b, &k)

	if k >= a {
		k -= a
		a = 0
		if k >= b {
			b = 0
		} else if k < b {
			b -= k
		}
	} else if k < a {
		a -= k
	}

	fmt.Println(a, b)
}

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

int main(){
  int p;
  string a[2],c,ans;
  while(1){
    cin>>a[0];
    if(a[0]=="-")break;
    cin>>a[1]>>c;
    p=1;
    while(c.size()){
      if(c[0]==a[p][0]){
	if(c.size())c=c.substr(1,c.size()-1);
	if(a[p].size())a[p]=a[p].substr(1,a[p].size()-1);
	p=0;
      }else{
	ans+=a[p][0];
	if(a[p].size())a[p]=a[p].substr(1,a[p].size()-1);
	p=1;
      }
    }
    ans+=a[0];
    ans+=a[1];
    cout<<ans<<endl;
    ans.clear();
    a[0].clear();
    a[1].clear();
    c.clear();
  }
  return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N; 
  cin >> N;

  vector<vector<int>> F(N, vector<int>(10));
  REP(i, N) REP(j, 10) cin >> F[i][j];

  vector<vector<int>> P(N, vector<int>(11));
  REP(i, N) REP(j, 11) cin >> P[i][j];


  int ans = -INF;
  FOR(bit, 1, (1<<10)){
    int ret = 0;
    REP(i, N){
      int cnt = 0;
      REP(j, 10){
        if(F[i][j] && ((bit >> j)&1)) cnt++;
      }
      ret += P[i][cnt];
    }
    chmax(ans, ret);
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define pii pair<int, int>
#define ff first
#define ss second
#define PI acos(-1)
#define ld long double
const int mod = 1e9+7, N = 2e5+5;

int a[N], n, m, k;

void solve(int test_case){
	int i, j;
	cin >> n;
	int pr = (n+999)/1000*1000;
	cout << pr-n ;
	return;
}

signed main(){
	FASTIO;
#define MULTITEST 0
#if MULTITEST
	int ___T;
	cin >> ___T;
	for(int T_CASE = 1; T_CASE <= ___T; T_CASE++)
		solve(T_CASE);
#else
	solve(1);
#endif
	return 0;
}


Measured memory_bytes: 3648
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << '\n';
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) {
        std::cout << i << ' ';
        vdeb(da[i]);
    }
    std::cout << '\n';
}

using namespace std;

const int MAX_M = 1001000;

bool li[1001000];

int main() {
    int n; cin >> n;
    vector<int> da(n);
    rip(i,n,0) cin >> da[i];
    unordered_set<int> st;
    rip(i,MAX_M,0) {
        li[i] = false;
    }
    rip(i,n,0) {
        if(st.count(da[i])) li[da[i]] = true;
        else {
            st.insert(da[i]);
            for(int j = da[i]*2;j < MAX_M; j+= da[i]) li[j] = true;
        }
    }
    int ans = 0;
    rip(i,n,0) if(!li[da[i]]) ++ans;
    cout << ans << endl;
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void solve(){
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll ans=max({b*d,a*d,b*c,a*c});
  cout<<ans<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3672
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;

      a=a*a%mod;
      b/=2;

      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }


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

    // ifstream fin(".in");
    // ofstream fout(".in");
bool is=true;

string s;
cin>>s;
int n=s.size();
if(n%2==0)is=false;
int j=(n-1)/2;
j--;
int i=0;
while(i<j)
{
  if(s[i]==s[j])i++,j--;
  else {is=false;i++,j--;}
}
i=0,j=n-1;
while(i<j)
{
  if(s[i]==s[j])i++,j--;
  else {is=false;i++,j--;}
}
i=(n+3)/2;
i--;
j=n-1;
while(i<j)
{
  if(s[i]==s[j])i++,j--;
  else {is=false;i++,j--;}
}
if(is)cout<<"Yes";
else cout<<"No";
    return 0;
  }


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll N;
    cin >> N;
    vector<ll> a(N), b(N);
    Rep (i, N) {
        cin >> a[i];
        a[i]--;
        b[a[i]] = i;
    }

    set<ll> pos;
    pos.insert(-1);
    pos.insert(N);

    ll ans = 0;
    Rep (i, N) {
        pos.insert(b[i]);
        auto itr = pos.find(b[i]);
        itr++;
        ll l = *itr;
        itr--;
        itr--;
        ll r = *itr;
        ans += (i+1) * (l-b[i]) * (b[i]-r);
    }

    cout << ans << endl;
}

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

int main(){
 	int N;
  	cin >> N;
  	for(; N > 0 ; N -= 7){
      	if(N % 7 == 0 || N % 4 == 0){
         	N = -8;
          	break;
        }
    }
  	if(N == -8) cout << "Yes" << endl; else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタ
		Scanner in = new Scanner(System.in);

		int l = in.nextInt();
		int r = in.nextInt();
		int d = in.nextInt();
		int count = 0;

		for(int i=l;i<=r;i++) {
			if(i%d==0) {
				count++;
			}
		}
		System.out.println(count);

	}

}


Measured memory_bytes: 35852
n = gets.to_i
songs = []
n.times do |i|
  s , t = gets.chomp.split
  songs[i] = [s, t.to_i]
end
x = gets.chomp
# p x
# p n, songs , x
ans = 0
f = songs.find_index {|n| n[0] == x} + 1
songs[f..-1].each do |i|
  ans += i[1]
end
puts ans


Measured memory_bytes: 1788
#include<stdio.h>

int A[100000],n;

int partition(int p,int r){

  int x,i,j,tmp;

  x = A[r];
  i = p-1;

  for(j=p;j<r;j++){
    if(A[j] <= x){
      i++;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }
  }

  tmp = A[i+1];
  A[i+1] = A[r];
  A[r] = tmp;

  return i+1;
}

int main(){
  int i,flag;

  scanf("%d",&n);

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

  flag = partition(0,n-1);

  for(i=0;i<n;i++){
    if(i==0) printf("%d",A[i]);
    else if(i==flag) printf(" [%d]",A[i]);
    else printf(" %d",A[i]);
  }

  printf("\n");

  return 0;
}
  
      



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

namespace ABC077C
{
    class Program
    {

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] A = ReadInt();
            int[] B = ReadInt();
            int[] C = ReadInt();
            A = A.OrderBy(x => x).ToArray();
            B = B.OrderBy(x => x).ToArray();
            C = C.OrderBy(x => x).ToArray();

            long[] Bunder = new long[N];
            for (int i = 0; i < N; i++)
            {
                int indexA = LowerBound(A, B[i]);
                Bunder[i] = indexA;
                if (i > 0) Bunder[i] += Bunder[i - 1];
            }

            long[] Cunder = new long[N];
            for (int i = 0; i < N; i++)
            {
                int indexB = LowerBound(B, C[i]) - 1;
                if (indexB >= 0) Cunder[i] = Bunder[indexB];
            }

            long ans = Cunder.Sum();
            Console.WriteLine(ans);
            Console.ReadKey();
        }


        public static int LowerBound<T>(T[] a, T v)
        {
            return LowerBound(a, v, Comparer<T>.Default);
        }

        public static int LowerBound<T>(T[] a, T v, Comparer<T> cmp)
        {
            var l = 0;
            var r = a.Length - 1;
            while (l <= r)
            {
                var mid = l + (r - l) / 2;
                var res = cmp.Compare(a[mid], v);
                if (res == -1) l = mid + 1;
                else r = mid - 1;
            }
            return l;
        }

        static int[] ReadInt()
        {
            int[] ret = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return ret;
        }
        static long[] ReadLong()
        {
            long[] ret = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return ret;
        }
    }
}


Measured memory_bytes: 42348
#include <cmath>
#include <iostream>
#include <string>
#include <vector> 
#include <algorithm>
#include <numeric>

#define FOR(i,a,b) for(i=(a);i<(b);++i) 
#define FORR(i,a,b) for(i=(a);i>(b);--i)
#define REP(i,n) for(i=0;i<(n);++i)
#define REPR(i,n) for(i=(n);i>0;--i)
#define PB push_back
#define ll long long
#define INT_MAX 2147483647
#define LL_MAX 9223372036854775807

using namespace std;

long long GCD(long long a, long long b) {
	if (a < b)
		swap(a, b);
	if (b == 0) return a;
	else return GCD(b, a % b);
}
bool sosuu_check(int num) {
	int i;
	for (i = 2; i <= sqrt(num); ++i) {
		if (num%i == 0)
			return false;
	}
	return (num < 2) ? false : true;
}
int main() {
	int N,K,a,i,ans=0;
	cin >> N >> K;
	vector<int> vec(200000);
	REP(i, N) {
		cin >> a;
		vec[a]++;
	}
	sort(vec.begin(), vec.end(), greater<int>());
	REP(i, K) {
		ans += vec[i];
	}
	cout << N - ans << endl;

}

Measured memory_bytes: 1152
#include<iostream>

using namespace std;

int n,s,ans;//?????????????????°??§??£?¨?????????¨dfs?????§?????§??§??????????????§??°?????????????????°??§??£?¨?

void dfs(int now,int sum,int times){//now??????????????´??° sum?????????????¨? times??????????????§????????´??°?????°
	if(n < times)//???????????´??°???n?????????????????°??????
		return;
	if(n == times && s == sum){//???????????¶
		ans++;
		return;
	}
	for(int i = now + 1; i <= 9; i++)//????????¨????????´??°????????????
		dfs(i,sum + i, times + 1);//?????°??????
}

int main(){
	while(cin >> n >> s,n+s != 0){
		ans = 0;
		for(int i = 0; i <= 9; i++){//??¨????????´??°????????????
			dfs(i,i,1);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int A, B;
    cin >> A >> B;
    if (A >= 13)
        cout << B;
    else if (A >= 6)
        cout << B/2;
    else
        cout << 0;
    cout << endl;
    return 0;
};


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


long long a, b;
int main()
{
cin >> a >>b;
for(int i = 1; i <= b; i++)
{
	if((a*i)%b == 0)
	{
		cout << a*i << endl;
		break;
	}
}
return 0;

}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.*;
public class Main{
	/*static double res=0;
	 static void help(int p,int r,int n){
		double tmp=p;
		for(int i=1;i<=n;i++){
			double x=1+(double)r/1200 ;
			tmp*=x;
		}
		res+=tmp;
		int k=100000,m=360;
		for(int i=m;i>0;i--){
			help(k,5,i);
		}
		System.out.println("paid amount "+k*m+" ");
		System.out.println((long)res);
	}
*/
public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n=s.nextInt();
		int x=n/2;
		if(n%2==1){x++;}
		
		System.out.println((double)x/n);	
		}
    }
	
		
	













Measured memory_bytes: 22996
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e9+9
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

string s;
string table[2] = { "23456789", "kstnhmyr" }, table2[2] = { "TLURD", "aiueo" };

int main(){
	cin >> s;
	for (int i = 0; i < s.size(); i += 2){
		if (s[i] != '1'){
			if (s[i] == '0'){
				if (s[i + 1] != 'U'){
					cout << 'w';
				}
				else{
					cout << "nn";
					continue;
				}
			}
			else{
				REP(j, table[0].size()){
					if (s[i] == table[0][j]){
						cout << table[1][j];
						break;
					}
				}
			}
		}
		REP(j, table2[0].size()){
			if (s[i + 1] == table2[0][j]){
				cout << table2[1][j];
				break;
			}
		}
	}
	cout << endl;
}

Measured memory_bytes: 1196
n,l=map(int,input().split())
if l + n -1 <=0 :
    print((n-1)*(l+(l+n-2)) // 2)
elif l >= 0 :
    print((n-1)*((l+1)+l+n-1) // 2 )
else :
    print(n*(l+(l+n-1)) // 2)

Measured memory_bytes: 2940
N = 1000000

@primeArr = Array.new(N, 1)
@primeArr[0..1] = [0, 0]

def calcPrimeNum(n) 
  nsqrt = ("%d" % N**0.5).to_i
  (2..nsqrt).each do |checknum|
    (checknum*2).step(N-1, checknum) do |notprime|
      @primeArr[notprime] = 0
    end
  end
end

calcPrimeNum(N)

while n = gets do
  n = n.chomp.to_i
  p @primeArr[0..n].sum
end


Measured memory_bytes: 18620
n=int(input())
a,b=[0]*n,[0]*n
for i in range(n):
    a[i],b[i]=map(int,input().split())
a.sort()
b.sort()
if n&1:
    print(b[n//2]-a[n//2]+1)
else:
    print(1+(b[n//2]+b[(n-1)//2])-(a[n//2]+a[(n-1)//2]))


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

int N;

int main() {
    cin >> N;
    vector<int> P(N), Pinverse(N);
    for (int i = 0; i < N; i++) {
        int p;
        cin >> p;
        Pinverse[p - 1] = i;
    }
    
    int n = 1, m = 1;   //動かさなくていいものの数m
    for (int i = 0; i < N - 1; i++) {
        if (Pinverse[i] < Pinverse[i + 1]) {
            n++;
        } else {
            m = m > n? m: n;
            n = 1;
        }
    }
    m = m > n? m: n;
    
    cout << N - m << endl;
}

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

typedef long long                   ll;
typedef long double                 ld;
typedef pair<ll,ll>                 pll;
typedef pair<ld,ld>                 pld;


#define all(x)          (x).begin(),(x).end()
#define Sort(x)         sort(all(x))
#define sep             ' '

#define endl            '\n'
#define tab             '\t'
#define X               first
#define Y               second
#define fast_io         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define file_io         freopen("in.txt" , "r" , stdin) ; freopen("out.txt" , "w" , stdout);
#define set_random      mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll MOD = 1e9 + 7,
         MAXN= 1e6+10,
         INF=1e18;
ll x[11][10],n,d,ans;
int main()
{
    fast_io;
    cin>>n>>d;
    for(ll i=0;i<n;i++){
        for(ll j=0;j<d;j++){
            cin>>x[i][j];
        }
    }
    for(ll i=0;i<n;i++){
        for(ll j=i+1;j<n;j++){
            ll t=0;
            for(ll k=0;k<d;k++){
                t+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
            }
            for(ll k=1;k<=t;k++){
                if(k*k==t){
                    ans++;
                    break;
                }
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

void __start__() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef MY
    freopen("/home/ainur/CLionProjects/wow/input.txt", "r", stdin);
    freopen("/home/ainur/CLionProjects/wow/output.txt", "w", stdout);
#else
#define endl '\n'
    //freopen("search.in", "r", stdin);
    //freopen("search.out", "w", stdout);
#endif
}

#define sz(x) (int)x.size()
#define yes cout<<"Yes\n"
#define  no cout << "No\n"
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define ft first
#define sd second
#define read(a) for(auto &qwqw:a)cin >> qwqw;
#define print(a) for(auto qwqw:a)cout<<qwqw<<' ';
#define print_plus(a) for(auto qwqw:a)cout<<qwqw+1<<' ';
//#define FOR(i, b, n) for(int i=b;i<n;i++) #define FOR(i, n) FOR(i, 0, n) #define FOR(n) FOR(i, 0, n)
mt19937_64 rnd(time(0));
#define int long long
using ll = long long;
using vi = vector<int>;
using ld = long double;
using vb = vector<bool>;
using pii = pair<int, int>;
using vd = vector<long double>;


int log2(int q) {
    int c = 0;
    while (q) {
        q >>= 1;
        c++;
    }
    return c;
}


void test_case() {
    int n, cnt1 = 0, cnt = 0;
    cin >> n;
    vi a(n), b(n), c(n);
    read(a);
    read(b);
    bool t = 1;
    iota(all(c), 1);
    while (t) {
        if (c == a)
            break;
        cnt1++;
        t = next_permutation(all(c));
    }
    iota(all(c), 1);
    t = 1;
    while (t) {
        if (b == c)
            break;
        cnt++;
        t = next_permutation(all(c));
    }
    cout << abs(cnt - cnt1);

}

signed main() {
    __start__();
    int Q = 1;
    //cin >> Q;
    while (Q--) {
        test_case();
    }
}




Measured memory_bytes: 3588
# -*- coding: utf-8 -*-
# 
import math
import sys
import itertools
import numpy as np

# いっこ入力
n =int(input())

# 空白区切りの数列をリストに代入
a = [int(i) for i in input().split()]

b = [0]*n

for i in range(n-1,(n-1)//2,-1):
    b[i]=a[i]
#print(b)
for i in range(n//2,-1,-1):
    p=a[i]
    for j in range(2*i+1,n,i+1):
        p = (p ^ b[j])
    b[i]=p
#print(b)
ball = 0
for i in range(n):
    ball += b[i]
print(ball)
for i in range(n):
    if b[i]==1:
        print(i+1,end=' ')
print("")




Measured memory_bytes: 17556
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

typedef struct {
	vector <int> to;
	int cost;
	bool is_visited;
} edge;
int main( void ){
	ll X, Y; cin >> X >> Y;
	ll times = Y/X;
	int cnt = 1;
	while(times!= 1){
		cnt++;
		times/=2;
	}
	cout << cnt << endl;
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 256
import numpy as np
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

from numba import njit


def getInputs():
    D = int(readline())
    CS = np.array(read().split(), np.int32)
    C = CS[:26]
    S = CS[26:].reshape((-1, 26))
    return D, C, S


def _compute_score(output, i, d, last):
    mask = np.zeros((26, ))
    mask[i] = 0
    score = S[d][i] - np.sum(C * (d + 1 - last) * mask)

    return score


def solve():
    output = []
    last = np.zeros((26, ))
    #SCORE = 0
    for d in range(D):
        max_score = float('-inf')
        best_i = 0
        for i in range(26):
            output.append(i)
            score = _compute_score(output, i, d, last)
            if max_score < score:
                max_score = score
                best_i = i + 1
            output.pop()
        output.append(best_i)
        last[best_i - 1] = d + 1
        #SCORE += max_score
        #print(SCORE)

    return output


if __name__ == "__main__":
    D, C, S = getInputs()
    ans = solve()
    print('\n'.join(map(str, ans)))

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rept(i,k,n) for(ll i = (k); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<long long,long long> Pll;
typedef tuple<int,int,int> Tii;



int main(){
    char c;
    cin>>c;
    if(int(c)>=96) cout<<'a';
    else cout<<'A';
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, cnt=0;
  cin >> N;
  cin >> K;
  vector<int> h(N);
  for (int i = 0; i < N; i++){
    cin >> h.at(i);
  }
  for (int i = 0; i < N; i++){
    if (K<=h.at(i)){
      cnt+=1;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void) {
	int d, i;
	scanf("%d", &d);
	for(i = 0; d > i; i++){
		int j,b, umax = 0, dmax = 0;
		int bdan = -1, dan;
		scanf("%d", &b);
		for(j = 0; b > j; j++){
			scanf("%d", &dan);
			if(bdan > -1) {
				if(dan > bdan){
					if(dan - bdan > umax) umax = dan-bdan;
				}
				else if(bdan - dan > dmax) dmax = bdan - dan;
			}
			bdan = dan;
		}
		printf("%d %d\n", umax, dmax);
	}
	return 0;
}

Measured memory_bytes: 596
from collections import deque
import sys
read = sys.stdin.read
readline = sys.stdin.readline

n, u, v = map(int, readline().split())
m = map(int,read().split())
data = list(zip(m,m))

graph = [[] for _ in range(n+1)]
for a,b in data:
    graph[a].append(b)
    graph[b].append(a)

def dfs(v):
    dist = [None] * (n + 1)
    dist[v] = 0
    stack = deque([v])
    while stack:
        x = stack.popleft()
        for y in graph[x]:
            if dist[y] is None:
                dist[y] = dist[x] + 1
                stack.append(y)
    return dist[1:]


print(max(j for i, j in zip(dfs(u), dfs(v)) if i <= j) - 1)


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

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

    for(int i=0; i<=(y/10000)+1; i++){
        for(int j=0; j<=(y/5000)+1; j++){
            int k = y/1000 - 10*i - 5*j;
            if(k >= 0 && n == i+j+k){
                cout << i << " " << j << " " << k << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    int N; cin >> N;
    vel B(N); rep(i,N) cin >> B[i];
    vel copy(N); 
    copy = B;
    sort(all(copy));

    rep(i,N) {
        if(B[i] <= copy[N/2 - 1]) cout << copy[N/2] << endl;
        else cout << copy[N/2 - 1] << endl;
    }
}

Measured memory_bytes: 5376
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

void pollock(int po[], int od[]) {
	int i = 1, j = 1;
	while (po[i - 1] < 1000000) {
		po[i] = (i * (i + 1) * (i + 2)) / 6;
		if (po[i] % 2 == 1) {
			od[j] = po[i];
			j++;
		}
		i++;
	}
}

int main() {
	int po[200] = {}, od[200] = {};
	pollock(po, od);
	int n;
	while (cin >> n && n) {
		vector<int> tmp(1000000, 100);
		tmp[0] = 0;
		int t = 1;
		while (po[t] <= n) t++;
		for (int i = 1; i <= t; ++i) {
			for (int j = 0; j + po[i] <= n; ++j) {
				tmp[j + po[i]] = min(tmp[j + po[i]], tmp[j] + 1);
			}
		}
		cout << tmp[n] << " ";

		for (int i = 1; i < 1000000; ++i) tmp[i] = 1000000;
		tmp[0] = 0;
		t = 1;
		while (od[t] <= n) t++;
		for (int i = 1; i <= t; ++i) {
			for (int j = 0; j + od[i] <= n; ++j) {
				tmp[j + od[i]] = min(tmp[j + od[i]], tmp[j] + 1);
			}
		}
		cout << tmp[n] << endl;
	}

	return 0;
}


Measured memory_bytes: 6968
import java.util.Scanner;

public class Main {

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

        if ((a*b)%2 == 0) {
            System.out.println("Even");
        } else {
            System.out.println("Odd");
        }
    }
}

Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> a(N);
  for(auto& i: a) cin >> i;

  auto nex = [&](int i) {return (i + a[i]) % N;};

  vector<int> indegree(N);
  for(auto i = 0; i < N; ++i) ++indegree[nex(i)];

  int ans = N;
  queue<int> q;
  for(auto i = 0; i < N; ++i) if(!indegree[i]) q.emplace(i);
  while(!q.empty()) {
    auto n = nex(q.front());
    q.pop();
    --ans;
    if(! --indegree[n]) q.emplace(n);
  }
  cout << ans << endl;
}

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

class Edge{
public:
    int from,to,value;
    Edge(ll a,ll b,ll c){
        from = a;
        to = b;
        value = c;
    }
    Edge(ll a,ll b){
        from = a;
        to = b;
    }
};

void solve(long long N, long long M, std::vector<long long> u, std::vector<long long> v, long long S, long long T){

    vector<Edge> E;
    for(int i = 0;i < M;i++){
        u[i]--,v[i]--;
        E.push_back(Edge(u[i], v[i]+N, 1));
        E.push_back(Edge(u[i]+N, v[i]+N+N, 1));
        E.push_back(Edge(u[i]+N+N, v[i], 1));
    }

    int s = S-1;
    std::vector<ll> ans(3 * N,1e9);
    std::vector<std::vector<Edge>> Edges(3 * N);
    for(auto e : E){
        Edges.at(e.from).push_back(e);
    }
    priority_queue<pair<ll,ll>, std::vector<pair<ll,ll>>, greater<pair<ll,ll>>> que;
    ans.at(s)= 0;
    que.push(make_pair(0,s));
    while(!que.empty()){
        pair<ll,ll> p = que.top();que.pop();
        if(ans.at(p.second) < p.first)continue;
        for(int i = 0;i < Edges.at(p.second).size();i++){
                if(ans.at(p.second) + Edges.at(p.second).at(i).value < ans.at(Edges.at(p.second).at(i).to)){
                ans.at(Edges.at(p.second).at(i).to) = ans.at(p.second) + Edges.at(p.second).at(i).value;
                que.push(make_pair(ans.at(Edges.at(p.second).at(i).to),Edges.at(p.second).at(i).to));
            }
        }
    }
    cout<<(ans[T-1] == 1e9 ? -1 : ans[T-1]/3)<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> u(M);
    std::vector<long long> v(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&u[i]);
        scanf("%lld",&v[i]);
    }
    long long S;
    scanf("%lld",&S);
    long long T;
    scanf("%lld",&T);
    solve(N, M, std::move(u), std::move(v), S, T);
    return 0;
}


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

int main(int argc, char const *argv[])
{
	int n;
	cin>>n;
	long long a[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	map<long long,long long> mp;
	long long ans=0LL,s[n+5]={};
	++mp[0LL];
	for (int i = 0; i < n; ++i)
	{
		s[i+1]=s[i]+a[i];
		ans+=mp[s[i+1]];
		++mp[s[i+1]];
	}
	cout<<ans<<endl;
	return 0;
}


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

ll g1(ll n, int p) {
	if (n == 0) return 0;
	return n/p + g1(n/p, p);
}

ll g2(ll n, int p) {
	if (n%2 == 1) {
		return g1(n, p) - g2(n-1, p);
	}
	ll res = g1(n/2, p);
	if (p == 2) res += n/2;
	return res;
}

int main() {
	ll n;
	cin >> n;
	ll ans = min(g2(n, 2), g2(n, 5));
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fr(i,c,b) for(int i=c;i<b;i++)
#define frl(i,c,b) for(ll i=c;i<b;i++)
#define si(x) int x; scanf("%d", &x)
#define sll(x) ll x; scanf("%lld", &x)
#define pi(x) printf("%d", x)
#define pll(x) printf("%lld", x)
#define nl printf("\n")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define MAX 100001
#define M 1000000007
#define pb push_back

typedef long long int ll;

using namespace std;

int main()
{
    string s; cin>>s; 
    string t; cin>>t;
    int n=s.length();
    int m=t.length();
    ll dp[n+1][m+1];
    fr(i,0,n+1)
    {
        fr(j,0,m+1)
        {
            if(i==0||j==0)
                dp[i][j]=0;
            else if(s[i-1]==t[j-1])
            {
                dp[i][j]=1+dp[i-1][j-1];
            }
            else
            {
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
        }
    }
    
    string ans="";
   
    ll i=n,j=m;
    while(i!=0&&j!=0)
    {
        if(s[i-1]==t[j-1])
        {
            ans+=s[i-1];
            i--; j--;
        }
        else if(dp[i][j-1]>=dp[i-1][j])
        {
            j--;
        }
        else 
        {
            i--;
        }
    }
    
    
    reverse(ans.begin(),ans.end());
    
    cout<<ans;
}

Measured memory_bytes: 73948
from collections import deque
import time     #ズルです…
start = time.time()
N = int(input())
A = [deque(list(map(int, input().split()))) for _ in range(N)]
ans = 0
t = 0
z = 0
Atmp = []
for i in range(10**6):
    for k in range(N):
        if A[k] != deque([]):
            if A[k][0] == 0:
                A[k].popleft()
            else:
                z += 1
        else:
            t += 1
    if t == N:
        break
    if t+z == N and i != 0:
        ans = 0
        break
    z = 0
    t = 0
    for j in range(N):
        if A[j]:
            tmp = A[j][0]
        else:
            continue
        if tmp-1 > j and A[tmp-1][0] -1 == j:
            A[j][0] = 0
            A[tmp-1][0] = 0
    ans += 1
    aida = time.time()
    if aida-start > 1.7:
        print(N*(N-1)//2)       #ズル
        exit()
print(ans-1)

Measured memory_bytes: 73432
#include<bits/stdc++.h>
using namespace std;
int n,ans;
int a[22];
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=2; i<n; i++) {
		if((a[i]>a[i-1]&&a[i]<a[i+1])||(a[i]<a[i-1]&&a[i]>a[i+1]))ans++;
	}
	printf("%d",ans);
}


Measured memory_bytes: 256
#N=int(input())
#N,M=map(int, input().split())
#L=list(map(int, input().split()))
S = str(input())
if len(S)%2==1:
  print('No')
  exit()
n = 0
while len(S) > n:
    if n % 2 == 1 and S[n] != 'i':
        print('No')
        exit()
    elif n % 2 == 0 and S[n] != 'h':
        print('No')
        exit()
    n += 1

print('Yes')

Measured memory_bytes: 3060
W, A, B = gets.split.map(&:to_i)
(B..B+W).each do |i|
  if (A..(A + W)).include?(i)
    puts(0)
    exit
  end
end
puts [(A - B).abs, (A + W - B).abs, (A - (B + W)).abs, ((A + W) - (B + W)).abs].min

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define loop(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;
using ll = int64_t;
//
//
//
bool check(const int i, const int s[], const int c[], const int n, const int m){
    string num = to_string(i);
    if(num.size() != n) return false;
    rep(j, m){
        if((num[s[j]-1] - '0') != c[j]) return false;
    }
    return true;
}
 
int main(){
    int n, m; cin >> n >> m;
    int s[m], c[m];
    rep(i, m) cin >> s[i] >> c[i];
    
    rep(i, 1000){
        if(check(i, s, c, n, m)) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod ((long long)(1e9 + 7))
vector<long long> fact;
vector<long long> factInv;

long long pow_mod(long long a, long long b) {
  long long ret = 1;
  while (b > 0) {
    if (b & 1) ret = ret * a % mod;
    a = a * a % mod;
    b = b >> 1;
  }
  return ret;
}

void comb_init(long long n) {
  fact.resize(n + 1);
  factInv.resize(n + 1);
  fact[0] = 1;
  for (long long i = 1; i <= n; i++) {
    fact[i] = (fact[i - 1] * i) % mod;
    fact[i] %= mod;
  }
  factInv[n] = pow_mod(fact[n], mod - 2);
  for (long long i = n - 1; i >= 0; i--) {
    factInv[i] = factInv[i + 1] * (i + 1) % mod;
  }
}

long long comb(long long n, long long r) {
  if (n == 0 && r == 0) return 1;
  long long ret = factInv[n - r] * factInv[r] % mod;
  return ret * fact[n] % mod;
}

int main(void) {
  long long X, Y;
  cin >> X >> Y;
  long long n = (2 * X - Y) / 3, m = (2 * Y - X) / 3;
  if ((X + Y) % 3 != 0 || n < 0 || m < 0) {
    cout << 0 << endl;
  } else {
    comb_init(n + m);
    cout << comb(n + m, n) << endl;
  }
  return 0;
}

Measured memory_bytes: 10624
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
   int q;
   cin>>q;
   V<string> d(10);
   d[1]=".,!? ";
   d[2]="abc";
   d[3]="def";
   d[4]="ghi";
   d[5]="jkl";
   d[6]="mno";
   d[7]="pqrs";
   d[8]="tuv";
   d[9]="wxyz";
  while(q--){
    string s={};
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]!='0'){
            int now=s[i]-'0';
            int cnt=0;
            while(s[i+cnt]!='0')cnt++;
            cnt--;
            cout<<d[now][cnt%d[now].size()];
            i+=cnt;
        }
    }
    cout<<endl;
  }
 
}


Measured memory_bytes: 3240
a,b,c = map(int,input().split())
k = int(input())

for l in range(1,k+1):
  for i in range(l+1):
    for j in range(l+1-i):
      for k in range(l+1-i-j):
        if b*pow(2,j) > a*pow(2,i) and c*pow(2,k) > b*pow(2,j):
          print('Yes')
          exit()
print('No')

Measured memory_bytes: 61796
#include <iostream>
#include <bitset>
#include <vector>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector <int> a(n+1);
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }

    int cur = 1, counter = 0;
    bitset <100005> b;
    for(;cur != 2 && !b[cur]; ++counter){
        b[cur] = 1;
        cur = a[cur];
    }

    if(b[cur]){
        cout << -1 << "\n";
    }
    else{
        cout << counter << "\n";
    }
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i, n) for(int (i)=0 ;i <(n); ++(i))
#define REP(i,m,n) for(int (i) = (m); (i) <= (n); ++(i))
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)? "YES":"NO")
typedef long long ll;
using namespace std;

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

  switch(x) {
    case 1 : {
      cout << "Hello World" << endl;
      break;
    }
    case 2 : {
      int a, b;
      cin >> a >> b;
      cout << a + b << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
[n,m] = list(map(int,input().split(' ')))
L1 = [0]*n
Ln = [0]*n
i=0
while i < m:
    l0 = list(map(int,input().split(' ')))
    if l0[0] == 1:
        L1[l0[1]] = 1
    elif l0[1] == n:
        Ln[l0[0]] = 1
    i += 1
q = 0
while q < n:
    if L1[q] * Ln[q] == 1:
        print('POSSIBLE')
        q = 0
        break
    else:
        q += 1
if q != 0:
    print('IMPOSSIBLE')

Measured memory_bytes: 6260
#! /usr/bin/python
from collections import Counter
N = int(input())
V = list(map(int, input().split()))
#N = 4
#V = list(map(int, "1 2 3 2 2 2 2 2 1 1 2 3 4 5 2 12 1 1".split()))


def func(l, aa):
    counter = Counter(l)
    if counter[aa] == 0:
        c, count = counter.most_common()[0]
    else:
        c, count = counter.most_common()[1]
    #print(l, c, len(l) - count)
    return (c, len(l) - count)


if len(set(V)) == 1:
    print(N // 2)
else:
    c, count = func(V[::2], -1)
    c2, count2 = func(V[1::2], c)
    a = count + count2
    c2, count2 = func(V[1::2], -1)
    c, count = func(V[::2], c2)
    print(min(a, count + count2))


Measured memory_bytes: 17116
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int ans = 0;
        if(K==1){
            System.out.println(0);
        }else{
            ans = N-K;
            System.out.println(ans);
        }
    }
}


Measured memory_bytes: 35884