akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H, W; cin >> H >> W;
  vector<string> S;
  REP(i, H){
    string s; cin >> s;
    bool flag = false;
    REP(j, W){
      if(s[j] == '#') flag = true;
    }
    if(flag) S.push_back(s);
  }
  int N = S.size();
  vector<bool> b(W, false);
  REP(i, W){
    REP(j, N){
      if(S[j][i] == '#') b[i] = true;
    }
  }
  vector<string> ans;
  REP(i, N){
    string a;
    REP(j, W){
      if(b[j]) a += S[i][j];
    }
    ans.push_back(a);
  }
  for(auto i : ans){
    cout << i << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
 

 int main(){
  ll n ; cin>>n ;
  vector<ll> A(n) ;
  rep(i,n) cin>>A[i] ;
  ll cnt=0 ;
  ll ans=0 ;
  rep(i,n){
    if(A[i]==i+1) cnt++ ;
    else{
      ans+= (cnt+1)/2 ;
      cnt=0 ;
    }

    if(i==n-1){
     ans+= (cnt+1)/2 ;
    }
  }
  cout<<ans<<endl ;
   return 0 ;
}



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

int main(){
	int n;
	scanf("%d", &n);
	set<int> s;
	for(int i = 0; i < n; i++) {
		int id, x;
		scanf("%d%d", &id, &x);
		if(id == 0) {
			s.insert(x);
			printf("%lu\n", s.size());
		}else if(id == 1) {
			printf("%lu\n", s.count(x));
		}
	}
}



Measured memory_bytes: 12588
import fractions


def main():
    N = int(input())
    gcd = int(input())
    lcm = gcd
    for _ in range(N-1):
        curr_t = int(input())
        gcd = fractions.gcd(lcm, curr_t)
        lcm = (lcm*curr_t)//gcd
    print(lcm)


if __name__ == "__main__":
    main()


Measured memory_bytes: 5048
//https://caddi2018.contest.atcoder.jp/tasks/caddi2018_a
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}}star;
#define DEBUG if(0)
#endif
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}
class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};


int main(){
    LL N;
    LL P;
    cin>>N>>P;
    if(N==1){
        cout<<P<<endl;
        return 0;
    }
    LL ret=1;
    for(int i:range(2,1123456)){
        if(P%i==0){
            int cnt=0;
            while(P%i==0){
                P/=i;
                cnt++;
            }
            cnt/=N;
            for(int j:range(cnt)){
                ret*=i;
            }
        }
    }
    cout<<ret<<endl;
    return 0;
}

Measured memory_bytes: 256
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let nl: Vec<usize> = read_vec();
    let n = nl[0];
    let l = nl[1] as u64;
    let a: Vec<u64> = read_vec();
    let mut max = 0;
    let mut id = 0;
    for i in 1..n {
        let tmp = a[i - 1] + a[i];
        if tmp > max {
            max = tmp;
            id = i;
        }
    }
    if max < l {
        println!("Impossible");
        return;
    }

    println!("Possible");

    for i in 1..id {
        println!("{}", i);
    }
    for i in (id + 1..n).rev() {
        println!("{}", i);
    }
    println!("{}", id);
}


Measured memory_bytes: 8444
#include <stdio.h>

int isTriangle(int n) {
	int left,right,mid;
	long long now;
	left=0;right=n;
	while(left<=right) {
		mid=(left+right)/2;
		now=(long long)mid*(mid-1)/2;
		if(now==n)return 1;
		else if(now<n)left=mid+1;
		else right=mid-1;
	}
	return 0;
}

#define BLOCK_MAX 1000010

int blocks[BLOCK_MAX];
int block_max;

void theOperation(void) {
	int i,max=block_max,now;
	for(i=0;i<max;i++) {
		if(blocks[i]>0)blocks[i]--;
	}
	blocks[max]=max;
	for(i=now=0;i<=max;i++) {
		if(blocks[i]>0)blocks[now++]=blocks[i];
	}
	block_max=now;
	for(;now<=max;now++)blocks[now]=0;
}

int blockIsTriangle(void) {
	int i;
	for(i=0;i<block_max;i++) {
		if(blocks[i]!=i+1)return 0;
	}
	return 1;
}

int main(void) {
	int n,i,sum;
	while(scanf("%d",&n)==1 && n>0) {
		sum=0;
		for(i=0;i<n;i++) {
			scanf("%d",&blocks[i]);
			sum+=blocks[i];
		}
		block_max=n;
		if(!isTriangle(sum))puts("-1");
		else if(blockIsTriangle())puts("0");
		else {
			for(sum=1;sum<=10000;sum++) {
				theOperation();
				if(blockIsTriangle())break;
			}
			printf("%d\n",sum<=10000?sum:-1);
		}
	}
	return 0;
}

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


int main(void) {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> s;
    vector<int> p;
    s.resize(m);
    for(int i = 0; i < m; i++) {
        int k;
        cin >> k;
        for(int j = 0; j < k; j++) {
            int tmp;
            cin >> tmp;
            s[i].push_back(tmp-1);
        }
    }

    for(int i = 0; i < m; ++i) {
            int tmp;
            cin >> tmp;
            p.push_back(tmp);
    }
    int ans = 0;
    for(int bit = 0; bit < (1 << n); bit++) {
        bool flag[n];

        for(int i = 0; i < n; ++i) {
            if(bit & (1 << i)) {
                flag[i] = true;
            }else{
                flag[i] = false;
            }
        }

        int total= 0;
        for(int i = 0; i < m; ++i) {
            int swich= 0;
            int num = s[i].size();
            for(int j = 0; j < num; ++j) {
                int targ = s[i][j];
                if(flag[targ]) swich++;
            }
            if(swich%2==p[i]) {
                total++;
            }
        }
        if(total == m) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
  int n;
  cin>> n;
  if(n < 100)cout << min(9,n) << endl;
  else if(n < 10000) cout<< min(909,n-90) << endl;
  else cout << min(90909,n-9090) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int a[4],b[4];
	
	while( scanf("%d %d %d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &b[0], &b[1], &b[2], &b[3]) != EOF ) {
		int hit=0, blow=0, i,j;
		
		for(i=0; i<4; i++) {
			for(j=0; j<4; j++) {
				if(i == j && a[i] == b[j]) hit++;
				else if(i != j && a[i] == b[j]) blow++;		
			}
		}
	
	printf("%d %d\n", hit, blow);
	
	}
	
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
using namespace std;
int main(void){
    long long num,goal,ans;
    cin>>num>>goal;
    if(num<goal){
        ans=goal-num;
        if(goal-(num)*(-1)<ans&&goal-(num)*(-1)>=0){
            ans=goal-(num)*(-1)+1;
        }
        if(num*(-1)-goal+1<ans&&num*(-1)-goal+1>=0){
            ans=num*(-1)-goal+1;
        }
        cout<<ans<<endl;
        return 0;
    }else if(num>goal){
        ans=goal-num*(-1)+1;
        if(ans<0||goal*(-1)-num*(-1)+2<ans){
            ans=goal*(-1)-num*(-1)+2;
            if(goal*(-1)-num+1<ans&&goal*(-1)-num+1>=0){
                ans=goal*(-1)-num+1;
            }
        }
        cout<<ans<<endl;
        return 0;
    }else{
        cout<<0<<endl;
        return 0;
    }
}


Measured memory_bytes: 256
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

n = inn()
ls = []
rs = []
z = 0
for i in range(n):
    ss = ins()
    l = r = 0
    for c in ss:
        if c=='(':
             l += 1
        else:
            if l>0:
                l -= 1
            else:
                r += 1
    rr = r
    l = r = 0
    for j in range(len(ss)-1,-1,-1):
        c = ss[j]
        if c==')':
             r += 1
        else:
            if r>0:
                r -= 1
            else:
                l += 1
    r = rr
    if l>r:
        ls.append((r,l-r))
    elif l<r:
        rs.append((l,r-l))
    else:
        z = max(z,r)
ls.sort()
rs.sort()
#ddprint(ls)
#ddprint(rs)
#ddprint(z)
l = r = 0
for rr,ll in ls:
    if l<rr:
        print('No')
        exit()
    l = l+ll
for ll,rr in rs:
    if r<ll:
        print('No')
        exit()
    r = r+rr
print('Yes' if l==r>=z else 'No')


Measured memory_bytes: 172912
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>

#define EPS 1e-7

using namespace std;
int main(){
    vector<int> in(3);
    while(cin >> in[0] >> in[1] >> in[2]){
        sort(in.begin(),in.end());
        if(in[2] == 0)break;
        int n;
        cin >> n;
        double l = hypot(in[1], in[0]);
        for(int i = 0; i < n; i++){
            double r;
            cin >> r;
            if(l + EPS < r*2)cout << "OK" << endl;
            else cout << "NA" << endl;
        }
    }
}



Measured memory_bytes: 3188
using System;
using System.Linq;
using static System.Console;

namespace a {

static class Extensions {
   public static int ToInt(this string str) {
      return int.Parse(str);
   }
}

class Program {
   public static void Main(string[] args) {
      var b = Read();

      switch(b) {
         case 'A':
            WriteLine("T");
            break;
         case 'C':
            WriteLine("G");
            break;
         case 'G':
            WriteLine("C");
            break;
         case 'T':
            WriteLine("A");
            break;
      } 
   }
}

}


Measured memory_bytes: 13140
A, B, C = list(map(int, input().split()))
count = 0
while True:
	if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
		break
	else:
		AA = int((B + C) / 2)
		BB = int((C + A) / 2)
		CC = int((A + B) / 2)
		if AA == BB and BB == CC:
			count = -1
			break
		else:
			A = AA
			B = BB
			C = CC
			count += 1
print(count)

Measured memory_bytes: 3064
#pragma region Include
#include <bits/stdc++.h>
// #include <algorithm>
// #include <bitset>
// #include <climits>
// #include <cmath>
// #include <iostream>
// #include <iterator>
// #include <map>
// #include <queue>
// #include <sstream>
// #include <stack>
// #include <string>
// #include <unordered_map>
// #include <unordered_set>
// #include <vector>
#pragma endregion

using namespace std;

#pragma region Macros
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define all(c) (c).begin(), (c).end()
#define newl "\n"
#define out(x) cout << (x) << newl
#define dump(x) \
  cout << "Line " << __LINE__ << " : " << #x << " = " << (x) << newl
template <class T>
using VV = vector<vector<T>>;
#define Uni(v) (v).erase(unique((v).begin(), (v).end()), (v).end());

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  os << "[";
  rep(i, vec.size()) os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  os << "]";
  return os;
}

template <typename T>
ostream& operator<<(ostream& os, vector<vector<T>>& mat) {
  os << "[";
  rep(i, mat.size()) os << mat[i] << (i + 1 == mat.size() ? "" : ",\n ");
  os << "]";
  return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x;
  return is;
}

template <typename V, typename H>
void resize(vector<V>& vec, const H head) {
  vec.resize(head);
}

template <typename V, typename H, typename... T>
void resize(vector<V>& vec, const H& head, const T... tail) {
  vec.resize(head);
  for (auto& v : vec) resize(v, tail...);
}
constexpr double EPS = 1e-10;
const int INF = 0x3f3f3f3f;

string tostring(int i, int digit) {
  auto cur = cout.flags();
  stringstream ss;
  ss << setw(4) << setfill('0') << i;
  string ret = ss.str();
  cout.flags(cur);
  return ret;
}

template <class T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
bool chmin(T& a, const T& b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

#pragma endregion

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  char c;
  cin >> c;
  cout << (char)(c + 1) << newl;
  return 0;
}

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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;
const ll INF = 1e9+5;

vector <int> v[100005];

int memo[100005][2];

int dp(int node, int par, int c) {
	if (memo[node][c] != -1) return memo[node][c];
	ll sol = 1;
	ll dod = 0;
	for (int i=0 ; i<v[node].size() ; i++) {
		int nx = v[node][i];
		if (nx == par) continue;
		sol = (sol * dp(nx, node, 0)) % MOD;
	}
	if (c == 0) {
		dod = 1;
		for (int i=0 ; i<v[node].size() ; i++) {
			int nx = v[node][i];
			if (nx == par) continue;
			dod = (dod * dp(nx, node, 1)) % MOD;
		}
	}
	return memo[node][c] = (sol + dod) % MOD;
}

int main() {
	memset(memo, -1, sizeof memo);
	int n;
	scanf("%d", &n);
	for (int i=0 ; i<n-1 ; i++) {
		int x, y;
		scanf("%d%d", &x, &y);
		v[x].pb(y);
		v[y].pb(x);
	}
	printf("%d\n", dp(1, 0, 0));
	return 0;
}

Measured memory_bytes: 16820
import copy

N, M, Q = list(map(int, input().split()))
a = [0] * Q

for i in range(Q):
    a[i] = list(map(int, input().split()))

mscore = 0

def createArray(num,arr):
    global mscore
    arr.append(num)
    if len(arr) < N:
        for i in range(num,M+1):
            arrr = copy.deepcopy(arr)
            createArray(i,arrr)
    else:
        score = 0
        for item in a:
            if arr[item[1]-1] - arr[item[0]-1] == item[2]:
                score += item[3]
        mscore = max(mscore, score)

for i in range(M):
    arr = []
    createArray(i+1,arr)

print(mscore)

Measured memory_bytes: 9312
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>


using namespace std;

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


int main() {
	int sx, sy, tx, ty;

	cin >> sx >> sy >> tx >> ty;

	int dx = tx - sx;
	int dy = ty - sy;

	rep(i ,dy) {
		cout << "U";
	}
	rep(i ,dx) {
		cout << "R";
	}
	rep(i ,dy) {
		cout << "D";
	}
	rep(i ,dx) {
		cout << "L";
	}


	cout << "L";

	rep(i ,dy + 1) {
		cout << "U";
	}
	rep(i ,dx + 1) {
		cout << "R";
	}
	cout << "D";
	
	cout << "R";
	rep(i ,dy + 1) {
		cout << "D";
	}
	rep(i ,dx + 1) {
		cout << "L";
	}
	cout << "U" << endl;	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define forloop(n) for(int i = 0; i < n; i++)
#define ll long long
 
#define mod 1000000007
long long exp(long long taban, long long us) {
    long long carpan = taban;
    long long temp = us;
    long long res = 1;
    for(int i = 0;;i++){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
        if(temp == 0) break;
    }
    return res;
}
ll ebob(ll a, ll b){
	if(!a)return b;
	return ebob(b%a, a);
}
ll ekok(ll a, ll b){
	return (((a*b)%mod)*(exp(ebob(a,b), (ll)mod-2))) % mod;
}
ll fact[600005];
ll komb(ll a, ll b){
	return (fact[a] * exp(fact[a-b] * fact[b], mod - 2)) % mod;
}
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	ll n, k; cin>>n>>k;
	ll tmp = k;
	k = min(n-1, k);
	fact[0] = 1;
	for(ll i = 1; i < 600005; i++){
		fact[i] = (fact[i-1]*i) % mod;
	}
	ll res = 0;
	for(ll i = 0; i <= k; i++){
		//cout<<n-1<< " "<<i<<endl;
		res = (res + (fact[n] * exp(fact[n-i]*fact[i]%mod, mod - 2) %mod) * (fact[n-1]*(exp(fact[n-1-i]*fact[i]%mod, mod - 2))%mod))%mod;
	}
	cout<<res<<endl;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned ll
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<typename T> using v2 = vector<vector<T>>;
template<typename T> using v3 = vector<vector<vector<T>>>;
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int MOD = 1e9 + 7;
const int INF = 1e9 + 200;
const ll INFLL = 2e18 + 200;

int main() {
    ll A;
    ll B, C;
    char temp;
    cin >> A >> B >> temp >> C;
    cout << A * B + (A * C) / 100 << endl;
}


Measured memory_bytes: 3604
import string

normal_set = set()
def reccursion(n, _s, cur):

    if len(_s) == n:
        global normal_set
        normal_set.add(_s)
        
        return

    for i in range(cur + 1):
        next_s = _s + string.ascii_lowercase[i]
        reccursion(n, next_s, cur)
    
    if cur + 1 < n:
        next_cur = cur + 1
        next_s = _s + string.ascii_lowercase[cur + 1]
        reccursion(n, next_s, next_cur)

def solve():
    n = int(input())
    reccursion(n, "a", 0)

    global normal_set
    normal_set = sorted(list(normal_set))
    
    for _s in normal_set:
        print(_s)

if __name__ == "__main__":
    solve()

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

#define int long long

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  string s;
  cin >> s;

  if ( s[0] == 'S' ) cout << "Cloudy" << endl;
  if ( s[0] == 'R' ) cout << "Sunny" << endl;
  if ( s[0] == 'C' ) cout << "Rainy" << endl;
  
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/
 
 
 
 
 
 
 
 
 
 
 
int N, A[303], C[4];
double dp[303][303][303];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> A[i];
    rep(i, 0, N) C[A[i]]++;

    rep(c3, 0, N + 1) rep(c2, 0, N + 1) rep(c1, 0, N + 1) {
        int sm = c1 + c2 + c3;
        if (sm == 0) continue;

        dp[c1][c2][c3] = 1.0 * N / sm;
        if (c1) dp[c1][c2][c3] += dp[c1 - 1][c2][c3] * c1 / sm;
        if (c2) dp[c1][c2][c3] += dp[c1 + 1][c2 - 1][c3] * c2 / sm;
        if (c3) dp[c1][c2][c3] += dp[c1][c2 + 1][c3 - 1] * c3 / sm;
    }

    printf("%.10f\n", dp[C[1]][C[2]][C[3]]);
}

Measured memory_bytes: 217344
#include <stdio.h>

int main(void)
{
	int x1,x2;
	scanf("%d %d",&x1,&x2);
	if(x2>x1){
		printf("%d\n",x2-x1);
	}
	else if(x1>x2){
		printf("%d\n",x1-x2);
	}
	else{
		printf("%d\n",x1-x2);
	}
	return 0;
}


Measured memory_bytes: 2140
#include<bits/stdc++.h>
using namespace std;
const int maxx=1e5+10;
typedef long long ll;
int a[maxx];
queue<int> q[maxx];
vector<int> b[10];
bool vis[maxx];
int num[maxx];
int pos[1008][1008];
int main(){
    int n; cin>>n;
    int f=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<n;j++){
            int x;scanf("%d",&x);
            q[i].push(x);
            pos[i][x]=j;
        }
        num[i]=1;
    }
    ll sum=1ll*n*(n-1);
    for(int i=1;i<=n;i++){
        if(vis[i]) continue;
        int x=q[i].front();
        if(pos[x][i]==num[x]){
            vis[x]=vis[i]=1;
            num[i]++;
            num[x]++;
            q[i].pop();
            q[x].pop();
            sum-=2;
            if(q[i].size()){
                int y=q[i].front();
                if(pos[y][i]==num[y]){
                    b[f].push_back(i);
                    b[f].push_back(y);
                    vis[y]=1;
                }
            }
            if(q[x].size()){
                int y=q[x].front();
                if(pos[y][x]==num[y]){
                    b[f].push_back(x);
                    b[f].push_back(y);
                    vis[y]=1;
                }
            }
        }
    }
    memset(vis,0,sizeof vis);
    int cnt=1;
    int flag;
    while(b[f].size()){
        cnt++;
        for(auto x : b[f]){
            if(vis[x]) continue;
            int y=q[x].front();
            if(pos[y][x]==num[y]){
                vis[y]=vis[x]=1;
                num[y]++;
                num[x]++;
                q[y].pop();
                q[x].pop();
                sum-=2;
                if(q[x].size()){
                    int z=q[x].front();
                    if(pos[z][x]==num[z]){
                        b[f^1].push_back(x);
                        b[f^1].push_back(z);
                    }
                }
                if(q[y].size()){
                    int z=q[y].front();
                    if(pos[z][y]==num[z]){
                        b[f^1].push_back(y);
                        b[f^1].push_back(z);
                    }
                }
            }
        }
        for(auto x:b[f]){
            vis[x]=0;
        }
        b[f].clear();
        f^=1;
    }
    if(sum) return 0*puts("-1");
    cout<<cnt<<endl;
}


Measured memory_bytes: 75648
#include<iostream>
#include <vector>
#include<string.h>
#include<cmath>
using namespace std;

int main() 
{ 
    int K,X;
    cin>>K>>X;
    if((500*K)>=X){
        cout<<"Yes"<<endl; 
    } 
    else{
        cout<<"No"<<endl; 
    }
    return 0; 
} 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
    return a * b / gcd(a, b);
}

ll choose2(ll n){
    return n*(n-1)/2;
}

int main(){
    string s;
    cin>>s;
    rep(i,0,s.length()-2){
        if(s[i]==s[i+1]){
            cout<<"Bad"<<endl;
            return 0;
        }
    }
    cout<<"Good"<<endl;
    return 0;
}

Measured memory_bytes: 256
n,k = map(int,input().split())
a = list(map(int,input().split()))

awk = 0
aix = k - 1
for i in range(k):
  awk += a[i]
a_max = awk

for i in range(k,n):
  awk = awk + a[i] - a[i-k]
  if a_max < awk:
    a_max =  awk
    aix   = i

ans = 0.0
#print('aix={}'.format(aix))
for i in range(aix-k+1,aix+1 ):
  #print(a[i])
  ans += ( 1 + a[i] )  / 2.0

print(ans)  

Measured memory_bytes: 24556
N,K = map(int,input().split())
S = list(input())
if S[K-1] == 'A' :
    S[K-1] = 'a'
elif S[K-1] == 'B' :
    S[K-1] = 'b'
elif S[K-1] == 'C' :
    S[K-1] = 'c'

buf = ''
for i in range(N) :
    buf += S[i]
print(buf)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#N, L = map(int, input().split())
w = str(input())

if len(w)%2 == 1 :
  print ("No")
  exit()
else :
  dict = {}
  for i in range(len(w)) :
    if w[i] not in dict :
      dict[w[i]] = 1
    else :
      dict[w[i]] += 1

list = list(dict.values())
for j in range(len(list)) :
  if list[j] % 2 != 0 :
    print ("No")
    exit()
print ("Yes")

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

class Problem0500
{
    static void Main(string[] args)
    {
        foreach (List<int[]> dataset in GetInputDatasets())
        {
            int scoreA = 0;
            int scoreB = 0;
            foreach (int[] pair in dataset)
            {
                int a = pair[0];
                int b = pair[1];
                if (a > b)
                {
                    scoreA += a + b;
                }
                else if (a == b)
                {
                    scoreA += a;
                    scoreB += b;
                }
                else
                {
                    scoreB += a + b;
                }
            }
            Console.WriteLine(scoreA.ToString() + " " + scoreB.ToString());
        }
        Console.ReadLine();
    }

    static IEnumerable<List<int[]>> GetInputDatasets()
    {
        var CurrentDataSet = new List<int[]>();
        foreach (string line in GetInputLines())
        {
            if (line.Split().Length == 1)
            {
                if (CurrentDataSet.Count > 0)
                {
                    yield return CurrentDataSet;
                    CurrentDataSet = new List<int[]>();
                }
                if (line == "0")
                {
                    yield break;
                }
            }
            else
            {
                CurrentDataSet.Add(line.Split().Select(int.Parse).ToArray());
            }
        }
    }

    static IEnumerable<string> GetInputLines()
    {
        string line;
        while (!string.IsNullOrEmpty(line = System.Console.ReadLine()))
        {
            yield return line;
        }
    }
}

Measured memory_bytes: 10984
#include <iostream>
using namespace std;
const int N = 100000 + 10;

int n, a[N];

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

    int ans = 0, cnt = 0;
    a[n+1] = -1;
    for (int i = 1; i <= n+1; i ++) {
        if (a[i] != i) {
            ans += (cnt + 1) / 2;
            cnt = 0;
        } else {
            cnt ++;
        }
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 640
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        r: usize,
        c: usize,
        k: usize,
        rcv: [(usize, usize, usize); k],
    }
    let mut v = vec![vec![0; c + 1]; r + 1];
    for &(ri, ci, vi) in &rcv {
        v[ri][ci] = vi;
    }
    let mut dp = vec![vec![vec![0; 4]; c + 1]; r + 1];
    for i in 1..=r {
        for j in 1..=c {
            dp[i][j][0] = *dp[i - 1][j].iter().max().unwrap();
        }
        for j in 1..=c {
            dp[i][j][1] = dp[i][j - 1][1];
            if v[i][j] > 0 {
                dp[i][j][1] = max(dp[i][j][1], dp[i][j - 1][0] + v[i][j]);
                dp[i][j][1] = max(dp[i][j][1], dp[i - 1][j].iter().max().unwrap() + v[i][j]);
            }
        }
        for j in 1..=c {
            for k in 2..=3 {
                dp[i][j][k] = dp[i][j - 1][k];
                if v[i][j] > 0 {
                    dp[i][j][k] = max(dp[i][j][k], dp[i][j - 1][k - 1] + v[i][j]);
                }
            }
        }
    }
    // for k in 0..4 {
    //     for i in 0..=r {
    //         for j in 0..=c {
    //             eprint!("{:?} ", dp[i][j][k]);
    //         }
    //         eprintln!("");
    //     }
    //     eprintln!("");
    // }
    println!("{}", dp[r][c].iter().max().unwrap());
}


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

int main()
{
		int N,Y;
		int x,y,z;
		
		cin>>N>>Y;
		
		for (x=0;x<=Y/10000;x++)
		   for(y=0;y<=Y/5000;y++)
		   {
		   	  z=N-x-y;
		   	  if ((z>=0) && (x*10000+y*5000+z*1000==Y))   
		   	  {
		   	  	cout<<x<<" "<<y<<" "<<z;
		   	  	
		   	  	return 0;
		   	  }
		   	  
		   }
	   
		   cout<<" -1 -1 -1"<<endl;
		   
		   return 0;
	}


Measured memory_bytes: 256
import sys,os,math
from collections import Counter, defaultdict, deque
import bisect
from sys import stdin, stdout
from itertools import repeat


# sys.stdin = open('input')
# n, k = map(int, raw_input().split())
# da = map(int, raw_input().split())
# db = map(int, raw_input().split())


def solve():

    pass

def main():
    n = map(int, raw_input().split())[0]
    print (n+1)/2/float(n)


main()


Measured memory_bytes: 28012
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int m = sc.nextInt();
    int[] a = new int[m];
    int ans = 0;

    for (int i = 0; i < n; i++) {
      int k = sc.nextInt();
      for (int j = 0; j < k; j++) {
        a[sc.nextInt() - 1]++;
      }
    }

    for (int i = 0; i < m; i++) {
      if (a[i] == n) {
        ans++;
      }
    }

    System.out.println(ans);

  }
}

Measured memory_bytes: 38508
N,T = map(int,input().split())
c_min = 1 << 60
ans = 'TLE'
for i in range(N):
    c,t = map(int,input().split())
    if t <= T:
        if c_min > c:
            c_min = c
            ans = str(c_min)
print(ans)


Measured memory_bytes: 2940
//be name khoda

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

#define pii pair<ll, ll>
#define mp make_pair
#define REP(i, n) for(int i = 0; i < (int)(n); i++)


const int N = 1e5 + 123;

map <int, int> m;
pii a[N];
int n;

ll work(ll cnt)
{
	ll ans = 0;
	for(int i = 0; i < n; i++)
		if((a[i].first & cnt) == a[i].first)
			ans += a[i].second;
	return ans;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll k, ans = 0;
	cin >> n >> k;
	int o = 0;
	for(int i = 0; i < n; i++)
	{
		int t, val;
		cin >> t >> val;
		if(m.find(t) == m.end())
		{
			m[t] = o;
			a[o++] = mp(t, val);
		}
		else
			a[m[t]].second += val;
	}
	n = o;
	ll cnt = 0;
	for(ll i = (1LL<<33); i > 0; i /= 2)
	{
		if(k & i)
		{
			ll t = work(cnt + i - 1);
			// cout << i << ' ' << cnt << ' ' << t << endl;
			ans = max(ans, t);
			cnt += i;
		}
	}
	ans = max(ans, work(cnt));
	cout << ans << endl;
	return 0;
}

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

using namespace std;
using LL = long long;
using P = pair<int,int>;
using E = pair<int,P>;
const int INF=1e9;

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

int main(){
	int H, W;
	cin >> H >> W;
	int Ch, Cw, Dh, Dw;
	cin >> Ch >> Cw >> Dh >> Dw;
	Ch--, Cw--, Dh--, Dw--;
	vector<string> S(H);
	rep(i,H) cin >> S[i];
	rep(i,1010){
		rep(j,1010) dist[i][j]=INF;
	}
	dist[Ch][Cw]=0;
	priority_queue<E,vector<E>,greater<E>> q;
	q.push(E(0,P(Ch,Cw)));
	while(!q.empty()){
		E e=q.top(); q.pop();
		int h=e.second.first, w=e.second.second;
		if(S[h][w]=='#') continue;
		int d=e.first;
		if(d>dist[h][w]) continue;
		rep(i,5){
			if(h+i-2<0 or h+i-2>=H) continue;
			rep(j,5){
				if(w+j-2<0 or w+j-2>=W) continue;
				if(i==2 and j==2) continue;
				if(dist[h+i-2][w+j-2]<=d+1) continue;
				dist[h+i-2][w+j-2]=d+1;
				q.push(E(d+1,P(h+i-2,w+j-2)));
			}
		}
		rep(i,4){
			if(h+dy[i]<0 or h+dy[i]>=H) continue;
			if(w+dx[i]<0 or w+dx[i]>=W) continue;
			if(S[h+dy[i]][w+dx[i]]=='#') continue;
			if(dist[h+dy[i]][w+dx[i]]<=d) continue;
			dist[h+dy[i]][w+dx[i]]=d;
			q.push(E(d,P(h+dy[i],w+dx[i])));
		}
	}
	if(dist[Dh][Dw]==INF) cout << -1 << endl;
	else cout << dist[Dh][Dw] << endl;

	return 0;
}

Measured memory_bytes: 9696
#include<stdio.h>

int main()
{
	int x,y,i=0;
	
	scanf("%d %d",&x,&y);
	while(x!=0||y!=0)
	{

		if(x>y)
		{
			printf("%d %d\n",y,x);
		}
		else
		{
			printf("%d %d\n",x,y);
		}
		scanf("%d %d",&x,&y);
	}
		return 0;
}

Measured memory_bytes: 600
#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))
#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF (int)1e9
#define MOD 0
//#define int ll
using namespace std;
typedef vector<int> vi;

signed main(){
    ll k,a,b,p,c;
    cin >> k >> a >> b;
    if(b-a <= 2 || k <= a-1) {
        cout << k+1 << endl;
        return 0;
    }
    k -= a-1;
    p = k/2;
    c = a + (b-a)*p;
    if(k & 1) c++;
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
 
int main() {
  int n;
  cin>>n;
  
  vector<int> x(n);
  vector<int> y(n);
  for (int i = 0; i < n; i++) {
    cin >> x.at(i)>>y.at(i);}
  
 
  long double sum=0;
   long double length=0;
  
  for(int i=0;i<n;i++){
    for(int j=0;j<i;j++){
      length=sqrt((x.at(i)-x.at(j))*(x.at(i)-x.at(j))
                  +(y.at(i)-y.at(j))*(y.at(i)-y.at(j)));
      sum+=length;
    }
  }
   long double avlen=sum*2/((n-1)*n);
  cout<<setprecision(10)<<avlen*(n-1)<<endl;
}
  

    


Measured memory_bytes: 256
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
def resolve():
    H1,M1,H2,M2,K=pin()
    t1=H1*60+M1
    t2=H2*60+M2
    print(t2-t1-K)
#%%submit!
    
resolve()

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

int main(){
  int64_t N,A,B,Q,R;
  cin>>N>>A>>B;
  Q=N/(A+B);
  R=N%(A+B);
  if(R>A){
    cout<<A*Q+A<<endl;
  }
  else{
    cout<<A*Q+R<<endl;
  }
}

Measured memory_bytes: 3504
import sys
input = sys.stdin.readline
#MAX_ARRAY_SIZE = 10**6

class Node:
    def __init__(self, init_data):
        self.data = init_data
        self.prev = None
        self.next = None

nil = Node(None)

#class DoublyLinkedList:
#    global nil
def init():
    nil.next = nil
    nil.prev = nil

def insert(x):
    node = Node(x)
    # 番兵の直後に要素を追加
    node.next = nil.next
    nil.next.prev = node
    nil.next = node
    node.prev = nil

def delete(x):
    # 検索したノードを削除
    deleteNode(listSearch(x))

def deleteFirst():
    deleteNode(nil.next)

def deleteLast():
    deleteNode(nil.prev)

def deleteNode(node):
    # nodeが番兵の場合は処理をしない
    if node is nil:
        return
    node.prev.next = node.next
    node.next.prev = node.prev
    del node

def listSearch(x):
    # 番兵の次の要素から辿る
    cur = nil.next
    while cur is not nil and cur.data != x:
        cur = cur.next
    return cur

#double_list = DoublyLinkedList()
init()

N = int(input())
for i in range(N):
    command = input().strip().split()
    if command[0] == 'deleteFirst':
        deleteFirst()
    elif command[0] == 'deleteLast':
        deleteLast()
    elif command[0] == 'delete':
        delete(command[1])
    elif command[0] == 'insert':
        insert(command[1])

while nil.next is not nil:
    if nil.next.next is not nil:
        print(nil.next.data, end=" ")
    else:
        print(nil.next.data)
    nil.next = nil.next.next


Measured memory_bytes: 227540
#include <bits/stdc++.h>
  #define ll  long long int
  #define N 100000
  #define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
  #define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
  #define po pop_back
  #define pb push_back
  #define lb lower_bound
  #define fi first
  #define se second
  #define debug(x) cout << #x << " = " << x << endl
  #define ub upper_bound
  #define ibs ios_base::sync_with_stdio(false)
  #define cti cin.tie(0)
  #define all(x) x.begin(),x.end()
  #define PI 3.14159265
  #define cot cout.tie(0)
  using namespace std;
    /**
      * @author :: Sawlani
      *
      */

      ll n,k;
      ll a[N+1];
      const ll M=1e9+7;
      ll modularExponentiation(ll x,ll n)
{
    ll result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x)%M;
        x=(x%M*x%M)%M;
        n=n/2;
    }
    return result;
}
ll modInverse(ll A)// when M is PRIME
{
    return modularExponentiation(A,M-2);
}
      ll fact(ll x)
      {
          ll res=1;
          f(i,1,x)
          res=(res*i)%M;

          return res;
      }


      int main()
      {

          cin >> n >> k;

          f(i,1,n) cin >> a[i];

          sort(a+1,a+n+1);

//          f(i,1,n)
//          cout << a[i] << " " ;
//          cout << endl;

          ll pre[n-k+1];
          pre[0]=1;
          ll j=1;
          ll ncr=1;

          f(i,k-1,n-2)
          {
              ncr=(ncr%M*i%M)%M;
              ncr=(ncr%M*modularExponentiation(i+2-k,M-2))%M;
              pre[j]=(pre[j-1]+ncr)%M;
              j++;
          }

          ll mini=0,maxi=0;

           j=n-k;
          f(i,1,n-k+1)
          {
              ll d=(a[i]%M*pre[j--]%M)%M;
              mini=(mini%M+d%M)%M;
          }

          j=0;
          f(i,k,n)
          {
              ll q=(a[i]%M*pre[j++]%M)%M;
              maxi=(maxi%M+q%M)%M;
          }

          ll ans=(maxi%M-mini%M+M)%M;

          cout << ans << endl;
      }


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

/*ソートの時に使う
int sort(const void *a, const void *b){
    return *(int*)a-*(int*)b ;
}
    qsort (data,sizeof(data),sizeof(int),sort); 
*/

int main(void){
    int n;
    scanf("%d",&n);
    int c[n],s[n],f[n];
    for (int i=0; i<n-1; i++){
        scanf("%d%d%d",&c[i],&s[i],&f[i]);
    }
    int ans;
    for (int i=0; i<n-1; i++){
        ans = s[i]+c[i];
        for (int j=i+1; j<n-1; j++){
            if (ans<s[j]){
                ans =s[j]+c[j];
            } else if (ans%f[j]==0) {
                ans += c[j];
            } else {ans += f[j]-ans%f[j]+c[j];
            }
        }
        printf ("%d\n",ans);
    }
    printf ("0\n");
	return 0 ;
}

Measured memory_bytes: 128
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from functools import *
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def Golf():
    *a,=map(int,open(0))
def S_():
    return input()
def IS():
    return input().split()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def GGI(h,w,search=None,replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[1]*(w+2)
    found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[1]+[mp_def[j] for j in s]+[1]
    mp+=[1]*(w+2)
    return h+2,w+2,mp,found
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['YES','NO']

mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()
 
def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a
 
show_flg=False
show_flg=True
 
ans=0

s,t=input().split()
n,m=LI()
u=input()
if s==u:
    n-=1
else:
    m-=1

print(n,m)

Measured memory_bytes: 39404
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<vector<int>> g(N + 1);
	vector<int> p(N); rep(i, 0, N) {
		cin >> p[i];
		g[p[i]].emplace_back(i + 1);

		function<int(int)> dfs = [&](int x) {
			int ret = 0;
			bool odd = false;
			rep(i, 0, g[x].size()) {
				int r = dfs(g[x][i]);
				if (r % 2 == 1)
					odd = true;
				ret += (r / 2) * 2;
			}
			if (odd)
				ret += 2;
			else
				ret += 1;
			return ret;
		};

		int maxi = dfs(0);
		dump(maxi);
		cout << maxi / 2 << endl;

	}

	return 0;
}

Measured memory_bytes: 3268
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(ReadLine());
        var d = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        var mid = d.OrderBy(x => x).ToArray()[(N/2-1)..(N/2+1)];
        var ans = mid[1] - mid[0];

        WriteLine(ans);
    }
}


Measured memory_bytes: 36996
M, K = map(int, input().split())

if K == 0:
    a  = [i for i in range(2 ** M - 1, -1, -1)]
    a += [i for i in range(2 ** M)]
elif 2 <= M and K < 2 ** M:
    a  = [K] + [i for i in range(2 ** M - 1, -1, -1) if i != K]
    a += [K] + [i for i in range(2 ** M) if i != K]

else:
    a = [-1]

print(' '.join(map(str, a)))


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for (int i = a; i < (int)b; ++i)
#define rrep(i, n) for (int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int n, m, q;
int res = 0;
vector<int> a, b, c, d;
void dfs(vector<int> v) {
    if (v.size() == n) {
        int tmp = 0;
        rep (i, q) {
            if (v[b[i]] - v[a[i]] == c[i]) tmp += d[i];
        }
        res = max(res, tmp);
        return;
    }
    FOR (i, 1, m + 1) {
        if (v.size() != 0 && v.back() > i) continue;
        vector<int> w = v;
        w.push_back(i);
        dfs(w);
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    cin >> n >> m >> q;
    a.resize(q), b.resize(q), c.resize(q), d.resize(q);
    rep (i, q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--, b[i]--;
    }
    vector<int> x;
    dfs(x);
    cout << res << endl;
    
    return 0;
}



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

using namespace std;

int main(){
	long long n, t, ans = 0;
	cin >> n >> t;
	vector<long long> a(n);
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = 1; i < n; i++){
		ans += min(a[i] - a[i - 1], t);
	}
	ans += t;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>

template<class T>
using vec = std::vector<T>;

int main()
{
    int m, n, o, p, c;
    std::cin >> m >> n >> o >> p;
    int a, b;
    vec<vec<int>> cnt(n, vec<int>(m));
    for (int i = 0; i < p; i++) {
        std::cin >> a >> b >> c;
        cnt[b][a]++;
    }
    
    int s, res = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            std::cin >> s;
            if (s != 0) {
                res += cnt[i][j];
            }
        }
    }
    
    std::cout << res << std::endl;
    return 0;
}

Measured memory_bytes: 3136
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

int main() {
	char d;
	int a; double  b, c;
	while (cin >> a >> d >> b >> d >> c) {
		double bmi = b / c / c;
		if (bmi >= 25)cout << a << endl;
	}
	return 0;
}

Measured memory_bytes: 1232
#include<iostream>
using namespace std;
typedef long long ll;

int main() {
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    if (K % 2 == 0) {
        cout << A - B << endl;
    }
    else {
        cout << B - A << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<map>
using namespace std;

int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=(x<<3)+(x<<1)+c-48;c=getchar();}
	return x*f;
}

int k,m,n;
int main(){	
	n=read();
	for(register int i=1;i<=n;i++){
		int x=read();
		if(x%2==1)continue;
		if(x%3==0 || x%5==0)continue;
		puts("DENIED");return 0;
	}
	puts("APPROVED");
	return 0;
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define INF 1000000007
// cin.eof() 入力個数の問題
int main(){
string S;
cin>>S;
int ans=0;
for(int i=2;i<S.size();i+=2){
    bool flag=true;
    for(int k=0;k<i/2;k++){
if(S[k]!=S[k+i/2]){
    flag=false;
}
    }
if(flag){
    ans=i;
}
}
cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <unordered_map>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  string s_in, s[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  cin >> s_in;
  for (int i = 0; i < 7; ++i)
  {
    if (s_in == s[i])
    {
      cout << 7 - i;
      return 0;
    }
  }
}


Measured memory_bytes: 3628