akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n)　for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod 1e9 +7;

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    string s;
    ll count=0,max=0,n;
    cin >> n >> s;
    rep(i,n){
        if(count >= max)max = count;
        if(s[i] == 'I')count++;
        else if(s[i] == 'D')count--;
        if(count >= max)max = count;
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;

public class Main {
	static String s, s2;
	static int[][] memo;
	static BufferedReader br;
	static PrintWriter out;
	static final int uncal = -1;
	public static void main(String[] args)throws Exception {
		// TODO Auto-generated method stub
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		s = br.readLine();
		s2 = br.readLine();
		int i = s.length();int j = s2.length();
		memo = new int[i][j];
		for(int[]a:memo)
			Arrays.fill(a, uncal);
		findLCS(0, 0);
		trace(0, 0);
		out.close();
	}
	static int findLCS(int i,int j) {
		if(i == s.length() || j == s2.length())
			return 0;
		if(memo[i][j] != uncal)
			return memo[i][j];
		if(s.charAt(i) == s2.charAt(j))
		{
			return memo[i][j] = 1 + findLCS(i+1, j+1);
		}
		int choice1 = findLCS(i+1, j);
		int choice2 = findLCS(i, j+1);
		return memo[i][j] = Math.max(choice1, choice2);
	}
	static void trace(int i,int j) {
		if(i == s.length() || j == s2.length()) return;
		int opt = findLCS(i, j);
		if(s.charAt(i) == s2.charAt(j) && findLCS(i+1, j+1) == opt-1) {
			out.print(s.charAt(i));
			trace(i+1, j+1);
			return;
		}
		if(findLCS(i+1, j) == opt) {
			trace(i+1, j);
			return;
		}
		if(findLCS(i, j+1) == opt)
			trace(i, j+1);
	}
}


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

signed main() {
  long long N, F=0;
  cin >> N;
  long long N2=N;
  for(int i=0; i<18; i++) {
    F+=N2%10;
    N2/=10;
    if(N2==0) {
      break;
    }
  }
  if(N%F==0) {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define MAX 110000
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
using namespace __gnu_pbds; 
using namespace std;

typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> new_data_set; 

ll dp[MAX];
ll dfs(ll start,vector<ll>* adj){
	if(dp[start]!=-1) return dp[start];
	ll ans=0;
	for(ll x:adj[start]){
		ll temp = dfs(x,adj)+1;
		ans = max(ans,temp);
	}
	dp[start]=ans;
	return ans;
}

int main(){
	ios_base::sync_with_stdio(false);
	memset(dp,-1,sizeof(dp));
	ll n,m;cin>>n>>m;
	vector<ll> adj[n];
	For(i,0,m){
		ll u,v;cin>>u>>v;u--;v--;
		adj[u].pb(v);
	}
	ll ans=0;
	For(i,0,n) {
		ans = max(ans,dfs(i,adj));
	}
	cout<<ans<<endl;
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int k; cin >> k;
    vi a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << a[k-1] << '\n';


    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
// typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;


int main() {
// int A, B, C; cin >> A >> B >> C;
VI abc(3); cin >> abc[0] >> abc[1] >> abc[2];
sort(ALL(abc));

int op = 0, minop=1e9, cal, Ap, Bp, Cp;
op = abc[2] - abc[1];
abc[0] += op;
op += (abc[2] - abc[0]) / 2;
abc[0] += 2 * ((abc[2] - abc[0]) / 2);
if (abc[0] != abc[2]) op +=2;


cout << op << "\n";

return 0;
}

// 境界，出力文字列 チェック
// int は ± 2*10⁹.


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

#define fastio std::ios::sync_with_stdio(false);
#define ll long long
#define scann(n) scanf("%d",&n)
#define scand(n) scanf("%lf",&n)
#define scans(s) scanf("%s",&s)
#define pb push_back
#define ppb pop_back
#define full v.begin(),v.end()
#define debug cout<<"Bug! Vag! Bagh!"<<endl;
#define pi acos(-1)
#define mx 10010
#define inf 10e10

int main()
{
    string s;
    cin>>s;
    ll ans=0;
    for(ll i=0;i<s.size();i++)
    {
        ans=ans+s[i]-'0';
    }
    if(ans%9==0)
    {
        cout<<"Yes"<<endl;
    }
    else

    {
        cout<<"No"<<endl;
    }
    return 0;
}
///arBishal_2017331022


Measured memory_bytes: 3692
import itertools
N = int(input())
L = list(map(int, input().split()))
Lset= list(set(L))
ans = 0
count = 0

for n in itertools.combinations(Lset, 3):
    if n[0]+n[1]>n[2] and n[1]+n[2]>n[0] and n[2]+n[0]>n[1]:
        ans += 1
        count += ans*L.count(n[0])*L.count(n[1])*L.count(n[2])
        ans = 0
print(count)

Measured memory_bytes: 9200
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <cassert>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const ll MOD = 1e9+7;
const double EPS = 1e-9;

ll count(string s){
  ll ret = 0;
  for(int i=1; i<s.size(); i++){
    if(s[i-1] == s[i]) {
      ret++;
      i++;
    }
  }
  return ret;
}


int main(int argc, const char * argv[]) {
  string S; cin >> S;
  string T = S + S;
  ll K; cin >> K;
  
  ll mae = 0, ushiro = 0;
  for(int i=1; i<T.size(); i++){
    if(i < S.size() && T[i-1] == T[i]) {
        mae++;
        i++;
    } else if (T[i-1] == T[i]){
        ushiro++;
        i++;
    }
  }
  
  bool same = true;
  for(int i=1; i<S.size(); i++){
    if(S[i-1] != S[i]){
      same = false;
      break;
    }
  }
  
  ll ans;
  if(same && ((int)S.size()) % 2 == 1){
    ans = (mae + ushiro) * (K/2);
    if (K%2){
      ans += mae;
    }
  } else{
    ans = mae + ushiro * (K-1);
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int Atest[] = new int[4];
        int Btest[] = new int[4];
        
        int Asum = 0, Bsum = 0;
        
        for(int i=0; i<4; i++){
            Atest[i] = sc.nextInt();
    	}
        for(int i=0; i<4; i++){
         	Btest[i] = sc.nextInt();   
        }
        
        for(int i=0; i<4; i++){
            Asum += Atest[i];
            Bsum += Btest[i];
        }
        
        if(Asum > Bsum){
        	System.out.println(Asum);
        }else if(Asum < Bsum){
         	System.out.println(Bsum);   
        }else{
         	System.out.println(Asum);   
        }
    }
}


Measured memory_bytes: 26168
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#define max(x,y)(x>y?x:y)
#define min(x,y)(x>y?y:x)
#define MOD 1000000007
typedef long long int ll;
typedef unsigned long long int ull;
ll gcd(ll x,ll y){if(!y)return x;return gcd(y,x%y);}
ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
void swap(ll *x,ll *y){ll tmp=*x;*x=*y;*y=tmp;}
int asc_cmp(const void* X,const void* Y){ll x=*(int*)X,y=*(int*)Y;if(x<y)return -1;else if(x==y)return 0;else return 1;}
int desc_cmp(const void* X,const void* Y){ll x=*(int*)X,y=*(int*)Y;if(x<y)return 1;else if(x==y)return 0;else return -1;}

ll modpow(ll a,ll n){
    ll res=1;
    while(n>0){
        if(n&1){res*=a;res%=MOD;}
        a*=a;a%=MOD;
        n>>=1;
    }
    return res;
}   
ll nCr(ll n,ll r){
    ll res,x,y;
    res=x=y=1;
    for(int i=0;i<r;i++){
        x*=(n-i);x%=MOD;
        y*=(r-i);y%=MOD;
    }
    res=modpow(y,MOD-2)%MOD;
    res=(res*x)%MOD;
    return res;
}


int main(){
    ll n,a,b;scanf("%lld %lld %lld",&n,&a,&b);

    ll x=modpow(2,n)-1;
    ll y=nCr(n,a)+nCr(n,b);
    y%=MOD;
    printf("%lld\n",(modpow(2,n)-1-y+MOD)%MOD);
}


Measured memory_bytes: 128
/**
 * ITP1_1_C Rectangle
 */
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();
        System.out.println((a*b) + " " + 2*(a+b));
    }
}

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

int main(void){
  string s;
  cin >> s;
  if(s[0] != s[1] && s[1] != s[2] && s[0] != s[2]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 384
package main

import (
	"fmt"
	"strconv"
)

type Card struct {
	suit  rune
	value int
}

func (c Card) String() string {
	return fmt.Sprintf("%c%d", c.suit, c.value)
}

func BubbleSort(a []Card) ([]Card, int) {
	var count int
	flag := true
	for flag {
		flag = false
		for i := len(a) - 1; i > 0; i-- {
			if a[i].value < a[i-1].value {
				a[i], a[i-1] = a[i-1], a[i]
				flag = true
				count++
			}
		}
	}
	return a, count
}

func SelectionSort(a []Card) ([]Card, int) {
	var minj, count int
	n := len(a)
	for i := 0; i < n; i++ {
		minj = i
		for j := i; j < n; j++ {
			if a[j].value < a[minj].value {
				minj = j
			}
		}
		if a[i].value > a[minj].value {
			count++
			a[i], a[minj] = a[minj], a[i]
		}
	}
	return a, count
}

func printCards(a []Card) {
	for i, v := range a {
		fmt.Print(v)
		if i < len(a)-1 {
			fmt.Print(" ")
		} else {
			fmt.Println()
		}
	}
}

func IsStable(a []Card, sorted []Card) bool {
	for i := 1; i < len(sorted); i++ {
		prev := sorted[i-1]
		curr := sorted[i]
		if prev.value == curr.value && prev.suit != curr.suit {
			prevFound := len(a)
			for j, v := range a {
				if v == prev {
					prevFound = j
				}
				if v == curr && prevFound > j {
					return false
				}
			}
		}
	}
	return true
}

func printStable(a []Card, b []Card) {
	if IsStable(a, b) {
		fmt.Println("Stable")
	} else {
		fmt.Println("Not stable")
	}
}

func main() {
	var n int
	fmt.Scan(&n)

	var s string
	cards := make([]Card, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&s)
		cards[i].suit = rune(s[0])
		cards[i].value, _ = strconv.Atoi(string(s[1]))
	}

	sortedB, sortedS := make([]Card, n), make([]Card, n)

	copy(sortedB, cards)
	sortedB, _ = BubbleSort(sortedB)
	printCards(sortedB)
	printStable(cards, sortedB)

	copy(sortedS, cards)
	sortedS, _ = SelectionSort(sortedS)
	printCards(sortedS)
	printStable(cards, sortedS)
}



Measured memory_bytes: 1152
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int n, bsum = 0;
    cin >> n;
    vector<int> a(n+1), b(n+1);
    for(int i = 1; i <= n; i++){
        scanf("%d", &a[i]);
        if(n/2 < i){
            b[i] = a[i];
            bsum += b[i];
        }
    }
    for(int i = n/2; i >= 1; i--){
        for(int j = i*2; j <= n; j += i){
            b[i] += b[j];
        }
        b[i] = (b[i] % 2 != a[i] ? 1 : 0);
        bsum += b[i];
    }
    cout << bsum << endl;
    for(int i = 1; i <= n; i++){
        if(b[i]) printf("%d\n", i);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ld long double
#define mem(a,b) memset(a,b,sizeof(a) )
#define M 4000010
#define md 1000000007

ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}
/*inline ll add(ll a,ll b){return (a+b)%md;}
inline ll mul(ll a,ll b){return (a*b)%md;}
ll f[M],iv[M];
ll C(ll n,ll r){return mul(f[n],mul(iv[r],iv[n-r]));}
void prep_fac(){
    f[0]=1;
    rep(i,1,M)f[i]=mul(i,f[i-1]);
    iv[M-1]=power(f[M-1],md-2,md);
    for(ll i=M-2;i>=0;--i)iv[i]=mul(i+1,iv[i+1]);
}*/



int main()
{
	IOS;
	int n;
	cin>>n;
	if(n>=30)
	cout<<"Yes";
	else
	cout<<"No";
}



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

int main(void)
{
	int n, bucket[100001] = {}, a, m = 0;

	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a;
		bucket[a]++;
		if (a != 0) bucket[a - 1]++;
		bucket[a + 1]++;
	}
	m = bucket[0];
	for (int i = 1; i < 100001; i++){
		m = max(m, bucket[i]);
	}
	cout << m << endl;

	return 0;
}
		


Measured memory_bytes: 640
def Int():
    return int(input())
def Ints():
    return map(int,input().split())
def IntList():
    return list(Ints())
def IntMat(N):
    return [IntList() for i in range(N)]

import sys
sys.setrecursionlimit(4100000)
rl = sys.stdin.readline

H1,M1,H2,M2,K = Ints()

S = (H2-H1)*60+(M2-M1)

print(S-K)

Measured memory_bytes: 79064
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mpr make_pair
#define fi first
#define se second
using ll=long long int;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

ll n,k;
vector<vector<ll>>g;
vector<ll>fact,inv;
ll ans=1;

//繰り返し二乗法
template <typename T>
T doubling(T a, T p) {
	if (p == 0)return 1;//出口
	if (p % 2 == 0) {//pを半分にしていく
		T half = doubling<T>(a, p / 2);
		return (half%mod * half % mod)%mod;
	}
	else {//pが奇数ならpを偶数にする
		return (a * doubling<T>(a, p - 1))%mod;
	}
}

void dfs(ll v,ll p){
	ll ch=0;
	for(auto x:g[v]){
		if(x==p)continue;
		++ch;
		dfs(x,v);
	}
	if(k<ch){
		ans=0;
		return;
	}
	if(p==-1){
		if(k-1-ch<0)ans=0;
		ans*=(fact[k-1]%mod*inv[k-1-ch]%mod);
		ans%=mod;
	}
	else {
		if(k-2-ch<0)ans=0;
		ans*=(fact[k-2]%mod*inv[k-2-ch]%mod);
		ans%=mod;
	}
}

int main(){
	cin>>n>>k;
	fact.resize(k+5);
	inv.resize(k+5);
	fact[0]=1;
	rep(i,k){
		fact[i+1]=(fact[i]*(i+1))%mod;
		fact[i+1]%=mod;
	}
	inv[k]=doubling<ll>(fact[k],mod-2);
	inv[k]%=mod;
	for(int i=k-1;i>=0;--i){
		inv[i]=(inv[i+1]%mod*(i+1));
		inv[i]%=mod;
	}
	g.resize(n);
	rep(i,n-1){
		ll a,b;
		cin>>a>>b;
		a--;b--;
		g[a].pb(b);
		g[b].pb(a);
	}
	dfs(0,-1);
	ans*=k;
	ans%=mod;
	cout<<ans<<endl;
	return 0;
}




Measured memory_bytes: 9216
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
#include <set>

using namespace std;
using ll = long long;
#define rep(i,a,b) for(ll i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define pai 3.14159265358979323846
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main() {
    ll n;
    cin >> n;
    ll s =n;
    ll sum = 0;
    if (n >=10) {
        while(n >= 10) {
            int val = n % 10;
            n /= 10;
            sum += val;
        }
    }
    sum += n;
    if (s% sum == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3124
#include<bits/stdc++.h>
#define N 1000005
#define p 998244353
#define int long long 
using namespace std;

inline void rd(int &x){
	x=0;char ch=0;int w=0;
	while(!isdigit(ch)) ch=getchar(),w|=ch=='-';
	while( isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	x=w?-x:x;
}

int n,m,ans;
int f[N],inv[N];

inline int POW(int a,int b=p-2,int ans=1){
	for(;b;b>>=1,a=a*a%p)
		if(b&1) ans=ans*a%p;
	return ans;
}

inline int C(int n,int m){
	return f[n]*inv[m]%p*inv[n-m]%p;
}
signed main(){
	cin>>n>>m;if(n<m) swap(n,m);
	for(int i=f[0]=inv[0]=1;i<=n+m;i++)
		f[i]=f[i-1]*i%p,inv[i]=POW(f[i]);
	for(int i=1;i<=m;i++)
		ans=(ans+C(i<<1,i)*C(n-i+m-i,n-i))%p;
	ans=ans*inv[2]%p*POW(C(n+m,n))%p;
	cout<<(ans+n)%p;
}

Measured memory_bytes: 15872
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
#include<random>
#include<bitset>


using namespace std;

#define rep(i,n) for(int i=0;i<n;i++) //0から
#define REP(i,n) for(int j=i;j<n;j++) //iから

typedef long long ll;



//英字ならture、数字ならfalse
bool isalpha(char s){
    if(('A'<=s&&s<='Z')||('a'<=s&&s<='z')){
        return 1;
    }else{
        return 0;
    }
}
//全ての文字が英字ならture、数字ならfalse
bool Isalpha(string s){
    ll n;
    bool tmp = true;
    rep(i,n){
        if(isalpha(s[i])){
            tmp = false;
        }
    }
    return tmp;
}




using Graph = vector<vector<ll>>;



//cout<<fixed<<setprecision(10);

ll binary_search(vector<ll> a, ll n, ll key){
    ll right = n, left = -1;
    ll md = (right + left) / 2;

    while(right - left > 1){
        if(a[md] <= key){
            right = md;
        }else{
            left = md;
        }
        md = (right + left) / 2;
    }
    if(left == -1) return -1; //無い場合
    return right;
}



int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n){
        cin>>a[i];
    }

    ll x=0;
    rep(i,n){
        x = x ^ a[i];
    }

    ll m;
    rep(i,n){
        m=x^a[i];
        cout<<m<<' ';
    }cout<<endl;


    return 0;
}



Measured memory_bytes: 4840
namespace Coder {
  class Scanner {
    private buffer: string = '';
    private stdinQueue: any = [];

    constructor() {
      process.stdin.resume();
      process.stdin.setEncoding('utf8');
      process.stdin.on(
        'data',
        (chunk): void => {
          this.buffer += chunk;
          while (this.stdinQueue.length > 0) {
            const i = this.buffer.indexOf('\n');
            if (i < 0) {
              break;
            }
            let line = this.buffer.substr(0, i);
            if (line.endsWith('\r')) {
              line = line.slice(0, -1);
            }
            this.buffer = this.buffer.substr(i + 1);
            this.stdinQueue.shift()(line);
          }
        },
      );
    }
    public getLine(): Promise<string> {
      return new Promise((resolve, reject) => {
        const i = this.buffer.indexOf('\n');
        if (i >= 0 && this.stdinQueue.length === 0) {
          let line = this.buffer.substr(0, i);
          if (line.endsWith('\r')) {
            line = line.slice(0, -1);
          }
          this.buffer = this.buffer.substr(i + 1);
          resolve(line);
        } else {
          this.stdinQueue.push(resolve);
        }
      });
    }

    public close(): void {
      process.stdin.pause();
    }
  }

  async function solve() {
    const sc = new Scanner();
    let [A, B]: number[] = (await sc.getLine()).split(' ').map((x) => +x);
    let ans = 0;
    for (let i = 0; i < 2; i += 1) {
      if (A > B) {
        ans += A;
        A -= 1;
      } else {
        ans += B;
        B -= 1;
      }
    }
    console.log(ans);

    sc.close();
  }

  solve();
}


Measured memory_bytes: 7628
// Problem : D - Replacing
// Contest : AtCoder - AtCoder Beginner Contest 171
// URL : https://atcoder.jp/contests/abc171/tasks/abc171_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

void solve(){
    int n,a,sum=0;
    cin>>n;
    mi m;
    for(int i=0;i<n;i++){
        cin>>a;
        sum += a;
        m[a]++;
    }
    int q;
    cin>>q;
    while(q--){
        int b,c;
        cin>>b>>c;
        int cnt = m[b];
        sum += cnt*(c-b);
        m.erase(b);
        m[c] += cnt;
        cout<<sum<<endl;
    }
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 7608
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  if (n%2)
    cout << b[n/2]-a[n/2]+1 << endl;
  else {
    int l1 = a[n/2-1], r1 = b[n/2-1];
    int l2 = a[n/2], r2 = b[n/2];
    int l = l1+l2;
    int r = r1+r2;
    cout << r-l+1 << endl;
  }
  return 0;
}

Measured memory_bytes: 4756
def resolve():
    import math
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    suma = 0
    dab = 0
    dba = 0
    for i in range(n):
        suma += b[i]-a[i]
        if a[i] < b[i]:
            dab += math.ceil((b[i]-a[i])/2)
        else:
            dba += a[i]-b[i]
    if max(dba, dab) > suma:
        print("No")
    else:
        print("Yes")
resolve()

Measured memory_bytes: 68740
#include "bits/stdc++.h"
#define ed cout<<"\n";
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

int main() {
	SPEED;
	int sum;
	int lastGap=0;
	for (int i = 0; i < 5; i++) {
		int time;
		cin >> time;
		int gap = time % 10;
		if (gap == 0) {
			sum += time;
		}
		else {
			sum += time + (10 - gap);
			lastGap = max(lastGap, 10 - gap);
		}
	}
	cout << sum - lastGap;
	ed;
	return 0;
}

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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second

ll n,m,k,ans,a[11][11];
vector<int> r,c;

void solve(int i)
{
    if (i>n+m)
    {
        int aa[7][7] = {} , black=0;
        for(int j=1; j<=n; j++)
        {
            for(int jj=1; jj<=m; jj++)
                aa[j][jj] = a[j][jj];
        }
        for(auto j : r)
        {
            for(int jj=1; jj<=m; jj++)
                aa[j][jj]= 0;
        }
        for(auto j : c)
        {
            for(int jj=1; jj<=n; jj++)
                aa[jj][j] = 0;
        }
        for(int j=1; j<=n; j++)
        {
            for(int jj=1; jj<=m; jj++)
                if (aa[j][jj]) black++;
        }
        if (black==k) ans++;
        return;
    }

    if (i <= n)
    {
        r.push_back(i);
        solve(i+1);
        r.pop_back();
        solve(i+1);
    }
    else
    {
        c.push_back(i-n);
        solve(i+1);
        c.pop_back();
        solve(i+1);
    }
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    cin >> n >> m >> k;
    for(int i=1; i<=n; i++)
    {
        for(int j=1; j<=m; j++)
        {
            char ch;
            cin >> ch;
            if (ch=='#') a[i][j]=1;
        }
    }

    solve(1);

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
const int maxn=200009;
int c[29];
long long ret;
char s[maxn];
int main()
{
	cin>>s;
	for(int i=0;s[i];i++)
	{
		ret-=c[s[i]-97];
		c[s[i]-97]++;
		ret+=i;
	}
	cout<<ret+1<<endl;
	return 0;
}

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

using namespace std;

void BuildStairs()
{
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; i++) cin >> h[i];

  bool flag = true;
  for (int i = 0; i < n - 1; i++)
  {
    if (h[i] - h[i + 1] > 1) {
      flag = false;
      break;
    }
    else if (h[i] - h[i + 1] == 1)
    {
      h[i + 1] = h[i + 1] + 1;
    }
  }
  if (flag == true)cout << "Yes" << endl;
  else cout << "No" << endl;
}


int main()
{
  BuildStairs();
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  std::string s; std::cin >> s;
  int da[4], db[4];
  da[0] = db[0] = da[3] = -1;
  da[1] = db[1] = db[3] = 1;
  int a0 = 0, a1 = 1, b0 = 0, b1 = -1;
  int c0 = a0-b0, c1 = a0-b1, c2 = a1-b0, c3 = a1-b1;
  for(auto c: s) {
    a0 += da[c&3]; if(a0 < 0) a0 += 2;
    a1 += da[c&3]; if(a1 < 0) a1 += 2;
    b0 += db[c&3]; if(b0 > 0) b0 -= 2;
    b1 += db[c&3]; if(b1 > 0) b1 -= 2;
    c0 = std::max(c0, a0-b0);
    c1 = std::max(c1, a0-b1);
    c2 = std::max(c2, a1-b0);
    c3 = std::max(c3, a1-b1);
  }
  fin(std::min(std::min(c0, c1), std::min(c2, c3)));
  return 0;
}


Measured memory_bytes: 4772
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef long long ll;
typedef pair<int,ll> P;
typedef vector<P> vip;

void solve(){
    string n;cin>>n;
    bool flag=false;
    int a = n.size();
    fol(i,a){
        if(n[i]=='9') flag=true;
    }
    cout <<(flag?"Yes":"No")<<endl;
}

int main(){
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <cctype>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <set>
#include <deque>
#include <map>
#include <bitset>
#include <functional>
#include <cmath>

#define INF 1000000000
using namespace std;

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

    string s = "";
    while(n != 0){
        n -= 1;
        s += ('a' + (n%26));
        n /= 26;
    }
    reverse(s.begin(), s.end());
    cout << s << endl;
}


Measured memory_bytes: 3624
//                        DushtuBunny
//                        Rahul Halder    
//    Indian Institute of Engineering Science & Technology,Shibpur


#include <bits/stdc++.h>

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define int long long
#define f first
#define se second
#define LB lower_bound
#define UB upper_bound
#define pb push_back
#define mp make_pair
#define vll vector<ll>
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define pie 3.14159265358979323846264338327950288
const unsigned int MOD = 1000000007;

using namespace std;

int32_t main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif

    IOS;
    int T;
    // cin>>T;
    T=1;

    while(T--)
    {
        ll n;cin>>n;
        ll key = n%10;
        if(key==3)
            cout<<"bon";
        else if(key==0 || key==1 ||key==6 || key==8)
            cout<<"pon";
        else
            cout<<"hon";
    }
    

    return 0;
}

Measured memory_bytes: 3640
#include <iostream>

bool search(int val, int * A, int a_idx, int a_num, int q) {
    if (val == q) {
        return true;
    }
    if (val > q || a_idx >= a_num) {
        return false;
    } 
    
    return search(val + A[a_idx], A, a_idx + 1, a_num, q) ||
        search(val, A, a_idx + 1, a_num, q);
}

int main() {
    int n;
    std::cin >> n;
    
    int A[n];
    for (int i = 0; i < n; i++) {
        std::cin >> A[i];
    }

    int q;
    std::cin >> q;
    for (int i = 0; i < q; i++) {
        int m;
        std::cin >> m;
        if (search(0, A, 0, n, m)) {
            std::cout << "yes" << std::endl;
        } else {
            std::cout << "no" << std::endl;
        }
    }
}



Measured memory_bytes: 3092
N = int(input())
S = input()
for kind1 in range(2):
    for kind2 in range(2):
        T = [0] * (N + 2)
        T[0] = kind1
        T[1] = kind2
        for i in range(1, N + 1):
            if T[i] == 0 and S[i % N] == 'o':
                T[i + 1] = T[i - 1]
            elif T[i] == 0 and S[i % N] == 'x':
                T[i + 1] = T[i - 1] ^ 1
            elif T[i] == 1 and S[i % N] == 'o':
                T[i + 1] = T[i - 1] ^ 1
            else:
                T[i + 1] = T[i - 1]
        if T[0] == T[-2] and T[1] == T[-1]:
            print(''.join("SW"[t] for t in T[:-2]))
            quit()
print(-1)


Measured memory_bytes: 6228
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ac = 0;
        int wa = 0;
        int tle = 0;
        int re = 0;
        for(int i=0; i<n; i++) {
            String s = sc.next();
            switch(s) {
            case "AC":
                ac++;
                break;
            case "WA":
                wa++;
                break;
            case "TLE":
                tle++;
                break;
            case "RE":
                re++;
                break;
            default:
                break;
            }
        }
        System.out.println("AC x " + ac);
        System.out.println("WA x " + wa);
        System.out.println("TLE x " + tle);
        System.out.println("RE x " + re);
    }
}

Measured memory_bytes: 58620
#pragma GCC optimize("O4")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(1e9+7)
#define INF (1e17)
#define int ll
#define EPS (1e-6)
#define DB(x) #x<<" "<<x<<" "
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	b%=MOD;
	int ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

int dp[110][4][2];
//pos,k,== or <

int32_t main() {
#ifdef LOCAL_TEST
	freopen("D:\\input.in","r",stdin);
	freopen("D:\\output.out","w",stdout);
	freopen("D:\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);

	//code...
	int a,n; cin>>a>>n;
	int s=0,t;
	while(n--){
		cin>>t;
		s+=t;
	}
	if(a<=s) cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>

struct Node {
	int key;
	Node *next, *prev;
};

Node *nil;

Node* listSearch(int key)
{
	Node *cur = nil->next;
	while (cur != nil && cur->key != key)
	{
		cur = cur->next;
	}
	return cur;
}

void init()
{
	nil = (Node *)malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
}

void printList()
{
	Node *cur = nil->next;
	int isf = 0;
	while (1) 
	{
		if (cur == nil) break;
		if (isf++ > 0) printf(" ");
		printf("%d", cur->key);
		cur = cur->next;
	}
	printf("\n");
}

void deleteNode(Node *t) 
{
	if (t == nil) return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteFirst()
{
	deleteNode(nil->next);
}

void deleteLast()
{
	deleteNode(nil->prev);
}

void deleteKey(int key)
{
	deleteNode(listSearch(key));
}

void insert(int key)
{
	Node *temp = (Node *)malloc(sizeof(Node));
	temp->key = key;
	temp->next = nil->next;
	nil->next->prev = temp;
	nil->next = temp;
	temp->prev = nil;
}

int main()
{
	int key, n, i;
	int size = 0;
	char commend[20];
	int np = 0, nd = 0;
	scanf("%d", &n);
	init();
	for (i = 0; i < n; i++)
	{
		scanf("%s%d", commend, &key);
		if (commend[0] == 'i')
		{
			insert(key);
			np++;
			size++;
		}
		else if (commend[0] == 'd')
		{
			if (strlen(commend) > 6)
			{
				if (commend[6] == 'F') deleteFirst();
				else if (commend[6] == 'L') deleteLast();
			}
			else
			{
				deleteKey(key);
				nd++;
			}
			size--;
		}
	}
	printList();
	return 0;
}


Measured memory_bytes: 34452
#include<bits/stdc++.h>
using namespace std;
int main()
{ string s;
  int n;
  cin >> n >> s;
  for(int i=0;i<s.size();++i)
  {
  s.at(i)=s.at(i)+n;
  if(s.at(i)>'Z') s.at(i)=s.at(i)-'Z'+'A'-1;
  cout << s.at(i);
  }
return 0; 
}

Measured memory_bytes: 3656
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }


const int maxn = 1e5+5;
int dist[maxn], res[maxn], dp[maxn][2][3];
VI G[maxn]; map<PII,int> W;

int dfs(const int u, const int p, const int pc, const int wc)
{
    int& ans = dp[u][pc][wc];
    if (-1 == ans) {
        ans = 0;
        const int w = W[PII(u,p)];
        dist[u] = (dist[p]+w) % 2;
        if (!dist[u]) {         /* color u to B */
            ans = 1; res[u] = 1;
            FOR_ALL(v,G[u]) if (*v != p)
                ans &= dfs(*v,u,1,wc);
        }
        if (!ans) {             /* color u to W */
            if (!wc || (wc==1 && !dist[u]) || (wc==2 && dist[u])) { 
                ans = 1; res[u] = 0;
                FOR_ALL(v,G[u]) if (*v != p)
                    ans &= dfs(*v,u,0,dist[u]?2:1);
            }
        }
    }
    return ans;
}

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    int n;
    while (cin >> n) {
        FOR(i,1,n+1)
            G[i].clear();
        FOR(_,0,n-1) {
            int u,v,w; cin >> u >> v >> w;
            w %= 2;
            G[u].push_back(v);
            G[v].push_back(u);
            W[PII(u,v)] = W[PII(v,u)] = w;
        }
        memset(dp,-1,sizeof(dp));
        dist[1] = 0; res[1] = 1;
        FOR_ALL(v,G[1])
            dfs(*v,1,1,0);
        FOR(i,1,n+1)
            cout << res[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 27392
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )
typedef pair<int,int> P;
typedef long long ll;
const int INF = 100000000;
const double PI=3.14159265358979323846;

int main () {

    int N,K;
    cin >> N >> K;
    set<int> D;
    rep(i,0,K) {
        int tmp;
        cin >> tmp;
        D.insert(tmp);
    }
    int ans = 1000000;
    rep(i1,0,10) {
        rep(i2,0,10) {
            rep(i3,0,10) {
                rep(i4,0,10) {
                    rep(i5,0,10) {
                        int tmp = i1*10000+i2*1000+i3*100+i4*10+i5;
                        int tmp1 = tmp;
                        bool hoge = true;
                        while(tmp1>0) {
                            int tmp2 = tmp1%10;
                            if (D.count(tmp2)) {
                                hoge = false;
                            }
                            tmp1 /= 10;
                        }
                        if (hoge && tmp>=N) {
                            ans = min(ans,tmp);

                        }
                    }
                }
            }
        }
    }

    cout << ans << endl;
}









Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;

struct edge { int to; double cost; };

signed main() {
    // std::ios::sync_with_stdio(false);
    // std::cin.tie(0);

	int n, m, p, a, b;
	while (cin >> n >> m >> p >> a >> b, n) {
		a--; b--;
		vector<double> t(n);
		rep(i, n) cin >> t[i];
		vector<vector<edge>> G(m);
		rep(i, p) {
			int x, y;
			double z;
			cin >> x >> y >> z;
			x--; y--;
			G[x].emplace_back((edge){y, z});
			G[y].emplace_back((edge){x, z});
		}

		const double inf = 1e15;
		vector<vector<double>> d(m, vector<double>(1 << n, inf));
		d[a][0] = 0;
		queue<P> que;
	    que.push(P(a, 0));

	    while (!que.empty()) {
			int v, f;
			tie(v, f) = que.front(); que.pop();
	        for (auto e: G[v]) {
				int nv = e.to;
				double cost = e.cost;
				rep(i, n) {
					if (((f >> i) & 1) == 0) {
						int nf = f | (1 << i);
						if (d[nv][nf] > d[v][f] + cost / t[i]) {
							d[nv][nf] = d[v][f] + cost / t[i];
							que.push(P(nv, nf));
						}
					}
				}
	        }
	    }

		double ans = *min_element(all(d[b]));
		if (ans == inf) {
			// printf("Impossible\n");
            cout << "Impossible" << endl;
		} else {
			printf("%.3f\n", ans);
            // cout << ans << endl;
		}
	}
}

Measured memory_bytes: 3384
#include<bits/stdc++.h>
#define ll long long int
#define pragi(a,b) for(ll i = a;i<b;i++)
#define pragj(a,b) for(ll j = a;j<b;j++)
#define pragk(a,b) for(ll k = a;k>=b;k--)
#define all(v) (v.begin(),v.end())
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define KAKA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int mod = 1e9 + 7;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef long double ld;
typedef pair<int, int> pii;
//typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;

void Compute(ll n,ll m,ll k)
{
	KAKA
	vector<ll> a(n);
	vector<ll> b(m);
	pragi(0,n)
	{
		cin>>a[i];
	}
	pragi(0,m)
	{
		cin>>b[i];
	}
	vector<ll> prefixa(n),prefixb(m);
	prefixa[0] = a[0];
	prefixb[0] = b[0];
	pragi(1,n)
	{
		prefixa[i] = prefixa[i - 1] + a[i];
	}
	pragi(1,m)
	{
		prefixb[i] = prefixb[i - 1] + b[i];
	}
	ll mx = 0;
	auto it1 = ub(prefixb.begin(),prefixb.end(),k);
	mx = it1 - prefixb.begin();
	pragi(0,n)
	{
		ll x = i + 1;
		ll rem = k - prefixa[i];
		if(rem >= 0){
		auto it = ub(prefixb.begin(),prefixb.end(),rem);
		ll y = it - prefixb.begin();
		mx = max(mx,x + y);}
	}
	cout<<mx<<"\n";
}
int main()
{
	KAKA
	ll n,m,k;
	cin>>n>>m>>k;
	Compute(n,m,k);
}

Measured memory_bytes: 9532
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
// #pragma GCC optimize("unroll-loops")



#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include <ext/rope>
// using namespace __gnu_pbds;
// using namespace __gnu_cxx;
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
// #define Find order_of_key
// #define at find_by_order
#define x first
#define y second
#define ll long long
#define lll __int128
#define ull unsigned long long
#define ulll unsigned __int128
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#define gu getchar_unlocked()
#define pu putchar_unlocked()
#define all(x) x.begin(),x.end()
#define endl '\n'



struct dsu {
	vector<int> par, rnk, size; int c;
	dsu(int n) : par(n+1), rnk(n+1,0), size(n+1,1), c(n) {
		for (int i = 1; i <= n; ++i) par[i] = i;
	}
	int find(int i) { return (par[i] == i ? i : (par[i] = find(par[i]))); }
	bool same(int i, int j) { return find(i) == find(j); }
	int get_size(int i) { return size[find(i)]; }
	int count() { return c; } //connected components
	int add(int i, int j) {
		if ((i = find(i)) == (j = find(j))) return -1; else --c;
		if (rnk[i] > rnk[j]) swap(i, j);
		par[i] = j; size[j] += size[i];
		if (rnk[i] == rnk[j]) rnk[j]++;
		return j;
	}
};


int main()
{
	int n,m;
	cin>>n>>m;
	dsu d(n);
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		d.add(u,v);
	}
	cout<<d.count()-1<<endl;
	return 0;
}

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

int main(){
    ll x ,y;
    cin >> x >> y;

    ll ans = 0;
    
    if(x >= 0 && y >= 0){
        ans = abs(y - x);
        if(y <= x){
            if(y == 0){
                ans++;
            }else{
                ans += 2;
            }
        }
    }else if(x < 0 && y < 0){
        ans = abs(y - x);
        if(y <= x){
            ans += 2;
        }
    }else{
        if(x <= y){
            ans = abs(y - x);
            ll k = 0 - x;
            ll cou = 1;
            cou += abs(y - k);

            if(ans > cou){
                ans = cou;
            }
        }else{
            ans = abs(y - x);
            ans++;
            ll k = 0 - x;
            ll cou = 1;
            cou += abs(y - k);

            if(ans > cou){
                ans = cou;
            }
        }
    }

    cout << ans << endl;
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(0);
    cout.tie(0);
    int ans(1), n;
    string s;
    cin >> n >> s;
    for (int i = 1; i < n; ++i)
        ans += (s[i] != s[i - 1]);
    cout << ans;
    return 0;
}


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

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;



ll N = 0;
ll A, B, C;
ll tmp;
ll ret = INF;
vector<ll> l;

void input() {
  IN(N);
  IN(A);
  IN(B);
  IN(C);
  REP(i, N) {
    IN(tmp);
    l.pb(tmp);
  }
}

void solve() {
  REP(i, (1 << (2*N))) {
    ll mp = 0;
    ll sumA = 0;
    ll sumB = 0;
    ll sumC = 0;
    REP(j, N) {
      ll val = (i/(1 << (2*j)))%4;
      if (val == 1) {
        if (sumA != 0) {
          mp += 10;
        }
        sumA += l[j];
      } else if (val == 2) {
        if (sumB != 0) {
          mp += 10;
        }
        sumB += l[j];
      } else if (val == 3) {
        if (sumC != 0) {
          mp += 10;
        }
        sumC += l[j];
      }
    }
    if (sumA == 0 || sumB == 0 || sumC == 0) {
      continue;
    }
    mp += abs(A-sumA);
    mp += abs(B-sumB);
    mp += abs(C-sumC);
    ret = min(ret, mp);
  }
  PRINT(ret);
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 256