akhauriyash/Code-Regression huggingface dataset:
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int P=998244353;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=5e5+5;
char s[N];int a[N],b[N],c[N],st[N],n,res,tot,t;
int main(){
//	freopen("testdata.in","r",stdin);
	scanf("%d%s",&n,s+1);
	fp(i,1,n)a[i]=s[i]-'0';
	fp(k,1,n)if(n%k==0&&((n/k)&1)){
		++tot,b[tot]=k,c[tot]=0;
		R int d=__gcd(n,k<<1);
		fp(i,1,d)c[tot]=add(mul(c[tot],2),a[i]);
//		fp(i,1,d)c[tot]=(0ll+(c[tot]<<1)+a[i])%P;
//		fp(i,1,d)st[i]=a[i];
//		fp(i,d+1,n>>1)st[i]=st[i-d]^1;
		upd(c[tot],1);
		fp(i,d+1,n){
			R int x=1-a[i-d];
			if(x!=a[i]){
				if(x>a[i])upd(c[tot],P-1);
				break;
			}
		}
		upd(c[tot],P);
//		fp(i,d+1,n>>1)if(a[i]!=st[i]){
//			c[tot]-=(a[i]<st[i]);
//			break;
//		}
	}
	fp(i,1,tot)fp(j,1,i-1)if(b[i]%b[j]==0)upd(c[i],P-c[j]);
	fp(i,1,tot)upd(res,mul(c[i],mul(b[i],2)));
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define xrep(i, a, b) for (int i = int(a); i < int(b); ++i)
int main() {
    int X;
    cin >> X;
    int happy500, happy5;
    happy500 = X/500;
    happy5 = (X-happy500*500)/5;
    cout << 1000*happy500 + 5*happy5 << endl;

    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	string s,t,ss;
	cin >> s >> t;
	ss = s + s;
	int nxt[200010][26];
	for(int i = 0;i < 26;i++){
		int appeared = -1;
		for(int j = ss.length() - 1;j >= 0;j--){
			nxt[j][i] = appeared - j;
			if(ss[j] == i + 'a') appeared = j;
		}
	}
	int pos = 0;
	for(int i = 0;i < t.length();i++){
		if(!i && s[0] == t[0]) continue;
		int nxtpos = nxt[pos % s.length()][t[i] - 'a'];
		if(nxtpos < 0){
			cout << -1 << endl;
			return 0;
		}
		pos += nxtpos;
	}
	cout << pos + 1 << endl;
}

Measured memory_bytes: 41472
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
const ll INF = 1000000000000007;

using namespace std;

int main(){
    ll N;
    cin >> N;
    string S;
    cin >> S;

    ll cnt = 0;

    vector <ll> w_kazu(N+1,0);
    vector <ll> e_kazu(N+1,0);

    //'0→N'でWの数を調べる(自分は除く)
    REP(i,N)
    {
      w_kazu[i+1] = cnt;
      if(S[i] == 'W')cnt++;
    }
    cnt = 0;
    //'N→0'でEの数を調べる(自分は除く)Wの数の対応している?難しい
    for(ll i = N-1; i >= 0; --i)
    {
      e_kazu[i+1] = cnt;
      if(S[i] == 'E')cnt++;
    }

    ll iMin = INF;

    for(ll i = 1; i<=N; ++i)
    {
      iMin = min(iMin, w_kazu[i] + e_kazu[i]);

    }
    
    cout << iMin << endl;

    return 0;

}

Measured memory_bytes: 5380
#include <iostream>
#include <vector>
#define range(i, n) for(i=0; i<n; ++i)
using namespace std;
int i, j;

int main(void){
  int N, bin, num = 0;
  cin >> N;
  vector<int> A(N), result(N);
  range(i, N){
    cin >> A[i];
  }
  
  for(i = N-1; i >= 0; --i){
    bin = 0;
    for(j = 2*i+1; j < N; j += i+1){
      bin += result[j];
    }

    if(A[i] != bin%2){
      result[i] = 1;
      num += 1;
    }
    else{
      result[i] = 0;
    }
  }
  
  cout << num << endl;
  range(i, N){
    if(result[i] == 1){
      num -= 1;
      cout << i+1;
      if(num != 0){
        cout << " ";
      }
    }
  }
  cout << endl;  
  
  return 0;
}


Measured memory_bytes: 2432
import math
a, b, n = map(int, input().split())

if (b == 1) or (a == 1):
    temp = 0


if (b <= n):
    temp = a * (b - 1) / float(b)
#  ans = math.floor(temp)
else:
    temp = (a * n) / float(b)
   # ans =

ans = math.floor(temp)
print(ans)


Measured memory_bytes: 9056
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair

/*int P[10010];
void init(int n){//Union-find
    for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
    if(P[a]==a)return a;
    return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
    return root(a) == root(b);//代表元を求める
}
void unite(int a,int b){
    P[root(a)]=root(b);
}//対set,グラフ？
//セグメント木？？
*/

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }//内積
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }//外積
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }//投影
//対図形

#define mod 1000000007
/*ll f[2001];
//int n,k とかしておく

ll pw(ll x, ll y){//euclidの互除法より
    ll a= 1;
    while(y){
        if(y&1){//奇数なら
            a = a*x%mod;
        }
        x = x*x%mod;
        y /= 2;
    }
    return a;
}

ll modinv(ll x){//逆元を求める
    return pw(x, mod - 2 );
}

ll comb(int n,int r){
    if(n<r){
        return 0;
    }
    return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod;
}//対combination//ただしfは用意してね
*/

//cerrはコメントアウトしなくても通る

int main(){
    int n,k;
    cin >> n>> k;
    string s;
    cin >> s;
    int h=0;
    int l=0;
    rep(i,n-1){
        char temp=s[i];
        if(s[i+1]==s[i]){
            h++;
        }else{
            l++;
        }
    }
    cerr<<h<<endl;
    int ans;
    if(l%2==1){
        int pp=min(l/2,k);
        ans=h+2*pp;
        if(l/2+1<=k){
            ans++;
        }
        cout<<ans<<endl;
        return 0;
    }
    int pp=min(l/2,k);
    cerr<<l/2<<" "<<k<<endl;
    ans=h+2*pp;
    
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <iterator>

using namespace std;

#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(v) reverse((v).begin(),(v).end())
#define ANS(ans) cout<<(ans)<<endl;
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
typedef vector<int> VI;

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  for (int i = 0; i < (n); ++i)

int main() {
	VI v(4);
	REP(i, 4) {
		cin >> v[i];
	}

	SORT(v);

	if (v[0] == 1 && v[1] == 4 && v[2] == 7 && v[3] == 9) {
		ANS("YES");
	}
	else {
		ANS("NO");
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAXN = 500;

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int h, w, d;
    cin >> h >> w >> d;
    vector<pair<int, int>> place(h * w + 1);
    for(int i = 1; i <= h; ++i) {
        for(int j = 1; j <= w; ++j) {
            int x; cin >> x;
            place[x] = {i, j};
        }
    }
    vector<ll> dist(h * w + 1, 0);
    for(int i = 1; i <= d; ++i) {
        for(int j = i + d; j <=h * w; j += d) {
            pair<int, int> prev = place[j - d], curr = place[j];
            dist[j] = dist[j-d] + abs(prev.first - curr.first) + abs(prev.second - curr.second);
//            cout << j << " " << dist[j] << "\n";
        }
    }
    int q;
    cin >> q;
    while(q--) {
        int l, r;
        cin >> l >> r;
        cout << dist[r] - dist[max(0, l)] << "\n";
    }
    return 0;
}

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

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

	int vsize = n / 2;
	vector<int> va(vsize);
	vector<int> vb(vsize);
	{
		int ca = 0;
		int cb = 0;
		for (int i = 0; i < n; ++i) {
			if (i % 2) {
				cin >> vb[cb++];
			}
			else {
				cin >> va[ca++];
			}
		}
	}

	sort(va.begin(), va.end());
	sort(vb.begin(), vb.end());

	pair<int, int> a1(0, 0);
	pair<int, int> a2(0, 0);
	pair<int, int> b1(0, 0);
	pair<int, int> b2(0, 0);
	{
		int pre = va[0];
		int prei = 0;
		for (int i = 1; i <= vsize; ++i) {
			if (i == vsize || va[i] != pre) {
				if (a1.second < i - prei) {
					a2 = a1;
					a1.first = pre;
					a1.second = i - prei;
				}
				else if (a2.second < i - prei) {
					a2.first = pre;
					a2.second = i - prei;
				}

				if (i < vsize) {
					pre = va[i];
					prei = i;
				}
			}
		}
	}
	{
		int pre = vb[0];
		int prei = 0;
		for (int i = 1; i <= vsize; ++i) {
			if (i == vsize || vb[i] != pre) {
				if (b1.second < i - prei) {
					b2 = b1;
					b1.first = pre;
					b1.second = i - prei;
				}
				else if (b2.second < i - prei) {
					b2.first = pre;
					b2.second = i - prei;
				}

				if (i < vsize) {
					pre = vb[i];
					prei = i;
				}
			}
		}
	}

	int r = 0;
	if (a1.first != b1.first) {
		r += vsize - a1.second;
		r += vsize - b1.second;
	}
	else {
		int r1 = 0;
		int r2 = 0;
		r1 += vsize - a1.second;
		r1 += vsize - b2.second;
		r2 += vsize - a2.second;
		r2 += vsize - b1.second;
		if (r1 < r2) {
			r = r1;
		}
		else {
			r = r2;
		}
	}

	cout << r << endl;

	return 0;
}

Measured memory_bytes: 640
def cmb(n, r):
    if n - r < r:
        r = n - r
    if r == 0:
        return 1
    if r == 1:
        return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


def main():
    x, y = map(int, input().split())
    mod = 10**9+7

    if ((x+y) % 3 != 0) or (x > 2*y) or (y > 2*x):
        print(0)
        return

    a, b = x-(x+y)//3, y-(x+y)//3
    print(cmb(a+b, a) % mod)


if __name__ == '__main__':
    main()


Measured memory_bytes: 45812
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val s = sc.next.distinct.sorted
  val as = "abcdefghijklmnopqrstuvwxyz"

  val ss = s + "*" * (26 - s.size)
  val q = (ss zip as).find(c => c._1 != c._2)
  println(if (q.isEmpty) "None" else q.get._2)
}

Measured memory_bytes: 29444
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
typedef long double ld;
using ll=long long;
using namespace std;
const int mod=1e9+7;
const ld pi = (acos(-1));
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; }



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  
  int sx,sy,tx,ty; 
  cin >> sx >> sy >> tx >> ty;
  int x=tx-sx, y=ty-sy;
  rep(i,0,y) cout << 'U';
  rep(i,0,x) cout << 'R';
  rep(i,0,y) cout << 'D';
  rep(i,0,x) cout << 'L';
  cout << 'L';
  rep(i,0,y+1) cout << 'U';
  rep(i,0,x+1) cout << 'R';
  cout << 'D';
  cout << 'R';
  rep(i,0,y+1) cout << 'D';
  rep(i,0,x+1) cout << 'L';
  cout << 'U' << endl; 
}

Measured memory_bytes: 256
main = do
  n <- readLn :: IO Int
  print $ minimum $ solve n 1 

solve :: Int -> Int -> [Int]
solve n a
  | n == 1 = [1]
  | a*a > n = []
  | n `mod` a /= 0 = solve n (a+1)
  | otherwise = mab : solve n (a+1)
     where
       mab = max (len a) (len b)
       b = n `div` a
       len = length . show


Measured memory_bytes: 892
from functools import reduce

n = int(input())
a = list(map(int, input().split()))

c = []
for i in range(0, n, 2):
    diff = a[i] ^ a[i+1]
    c.append(diff)
all_xor = reduce(lambda x, y: x^y, c)
ans = []
for i in a:
    current = all_xor^i
    ans.append(current)
print(*ans)



Measured memory_bytes: 31980
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b % mod; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(12); // debuged
  int T;
  T = 1;
  while (T--) solve();
}

void solve() {
  int x;
  cin >> x;
  int n;
  cin >> n;
  vector<int> a(n);
  cin >> a;
  vector<int> table(105);
  rep(i, n) table[a[i]] = 1;

  int ans = inf;
  rep(i, 105) {
    if (table[i] == 0) {
      chmin(ans, abs(x - i));
    }
  }
  rep(i, 105) {
    if (table[i] == 0 && ans == abs(x - i)) {
      cout << i << endl;
      return;
    }
  }
}


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

using namespace std;

bool poss[100010];
int cant[100010];

int main(){
	
	int n, m;
	cin >> n >> m;
	
	int sol = 1;
	for(int i=1;i<=n;++i) cant[i] = 1;
	poss[1] = true;

	int a, b;
	while(m--){
		cin >> a >> b;
		cant[a]--;
		cant[b]++;
		if(poss[a]){
			if(!poss[b]){
				poss[b] = true;
				sol++;
			}
			if(!cant[a]){
				poss[a] = false;
				sol--;
			}		
		}
	}

	cout << sol << '\n';

	return 0;
} // br1


Measured memory_bytes: 768
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
//#define int long long int
using namespace std;





int main(){
ll N,K; cin>>N>>K;
vector <ll> p(N+1,0);
vector <double> e(N+1,0);

double ans =0;

for(int i=1;i<=N;i++){
    cin>>p[i];
    e[i] =  (double)((1+p[i]))/(double)(2);
}

for(int i=1;i<=N;i++){
    e[i] = e[i] + e[i-1];
}

for(int i=1;i<=N-K+1;i++){

    if(ans > e[i + K - 1] - e[i-1]) ans = ans;
    else ans = e[i + K - 1] - e[i-1];
}

cout<<setprecision(11)<<ans<<endl;


}

Measured memory_bytes: 3328
#include<cstdio>
#include<cctype>
#include<algorithm>
inline int getint() {
	register char ch;
	while(!isdigit(ch=getchar()));
	register int x=ch^'0';
	while(isdigit(ch=getchar())) x=(((x<<2)+x)<<1)+(ch^'0');
	return x;
}
int main() {
	const int a=getint(),b=getint(),c=getint();
	printf("%d\n",b+std::min(c,a+b+1));
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(){
    double a, b, h, m;
    cin >> a >> b >> h >> m;
    double anga, angb;
    anga = M_PI / 6.0 * h + M_PI / 360.0 * m;
    angb = M_PI / 30.0 * m;
    cout << fixed << setprecision(10);
    double theta;
    // if(abs(anga-angb)>M_PI){
    //     theta = 2.0 * M_PI - abs(anga-angb);
    // }else{
    //     theta = abs(anga-angb);
    // }
    theta = abs(anga-angb);
    cout << sqrt(a*a + b*b - 2.0 * a * b * cos(theta)) << endl;
    return 0;
}

Measured memory_bytes: 4200
#include<cstdio>
const long long MAXN=3505;
long long gcd(long long a,long long b)
{
	if(b==0)
		return a;
	return gcd(b,a%b);
}
long long lcm(long long a,long long b)
{return a*b/gcd(a,b);}
int main()
{
	long long m,n,d,l,si,sj,ti,tj;
	m=4;
	scanf("%I64d",&n);
	d=gcd(m,n);
	m/=d;
	n/=d;
	long long nn=n,mm=m;
	for(long long i=1;i<MAXN;i++)
		for(long long j=1;j<MAXN;j++)
		{
			n=nn;m=mm;
			si=i+j;sj=i*j;
			d=gcd(si,sj);
			si/=d;sj/=d;
			l=lcm(sj,n);
			si=si*(l/sj);sj=l;
			m=m*(l/n);n=l;
			if(si>=m)
				continue;
			ti=m-si;tj=l;
			d=gcd(ti,tj);
			ti/=d;tj/=d;
			if(ti==1)
			{
				printf("%I64d %I64d %I64d\n",i,j,tj);
				return 0;
			}
		}
	return 0;
}


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

int main(void)
{
    string s, t;
    cin >> s >> t;

    vector<vector<long long>> count(26);
    for (long long i = 0; i < s.size(); i++)
    {
        count[s[i] - 'a'].push_back(i);
    }
    long long mem = -1;
    long long ans = 0;
    for (long long i = 0; i < t.size(); i++)
    {
        if (count[t[i] - 'a'].size() == 0)
        {
            cout << -1 << endl;
            exit(0);
        }
        else
        {
            long long answer;
            long long min = -1;
            long long max = count[t[i] - 'a'].size();
            while (1)
            {
                if (max - min == 1)
                {
                    answer = max;
                    break;
                }
                else
                {
                    if (count[t[i] - 'a'][(max + min)/2] > mem)
                    {
                        max = (max + min)/2;
                    }
                    else
                    {
                        min = (max + min)/2;
                    }
                }
            }
            if (answer == count[t[i] - 'a'].size())
            {
                ans += s.size() - mem + count[t[i] - 'a'][0];
                mem = count[t[i] - 'a'][0];
            }
            else
            {
                ans += count[t[i] - 'a'][answer] - mem;
                mem = count[t[i] - 'a'][answer];
            }
            
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4860
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(a==1){
    if(a<b){cout<<"Alice"<<endl;}
    else if(a==b){cout<<"Draw"<<endl;}
  }
  else if(b==1){
    if(a>b){cout<<"Bob"<<endl;}
    else if(a==b){cout<<"Draw"<<endl;}
  }
  else{
    if(a>b){cout<<"Alice"<<endl;}
    else if(a<b){cout<<"Bob"<<endl;}
    else{cout<<"Draw"<<endl;}
  }
  
  return 0;
}


Measured memory_bytes: 256
/*
"Won't stop untill I'm Phenomenal"
- Phenomenal, EMINEM
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define ff first
#define Shazam ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define ss second
#define all(c) c.begin(),c.end()
#define endl "\n"
#define test() int t; cin>>t; while(t--)
#define fl(i,a,b) for(int i = a ; i <b ;i++)
#define get(a) fl(i,0,a.size())  cin>>a[i];
#define pra(a) fl(i,0,a.size()) cout<<a[i]<<" ";	cout<<endl;
#define pr(a,n) fl(i,0,n) cout<<a[i]<<" ";	cout<<endl;
const ll INF = 2e18;
const int inf = 2e9;
const int mod1 = 1e9 + 7;



int main(){
    Shazam;
    ll n; cin>>n;
    ll ans = 0;
    for(ll i = 1; i <= n; i++){
        ll k = n/i;
        ans += k*(k+1)/2*i;
    }
    cout<<ans<<endl;
    return 0;
}

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

using ll = long long;
using namespace std;

int main() {
  ll x;
  cin >> x;
  for (int a = -1000; a < 1000; a++) {
    ll a5 = 1;
    rep(i, 5) a5 *= a;
    for (int b = -1000; b < 1000; b++) {
      ll b5 = 1;
      rep(i, 5) b5 *= b;
      if (a5 - b5 == x) {
        printf("%d %d\n", a, b);
        return 0;
      }
    }
  }
  return 0;
}

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

#define debug(x) cerr<<#x<<'='<<x<<endl
#define set0(x) memset(x,0,sizeof(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pii;
template<typename T> void read(T &x){
	x = 0;char ch = getchar();ll f = 1;
	while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
	while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}

int dp[270000][160] = {0};

int n,a[20],b[20];
int main() {
	read(n);
	for(int i=0;i<n;i++)read(a[i]);
	for(int i=0;i<n;i++)read(b[i]);
	memset(dp,7,sizeof(dp));
	dp[(1<<n)-1][0] = 0;
	for(int i = (1<<n)-1;i;i--){
		int cto = n-__builtin_popcount(i);
		for(int j=0;j<160;j++){
			if(dp[i][j]>160)continue;
			//cout<<i<<' '<<j<<' '<<dp[i][j]<<endl;
			int fr = 0;
			for(int k=0;k<n;k++){
				if((i>>k)&1){
					int aft = cto-fr,mfr = k-fr;
					int cv = ((aft+mfr)%2 == 0)?a[k]:b[k];
					if(cv>=dp[i][j]){
						dp[i^(1<<k)][j+mfr] = min(dp[i^(1<<k)][j+mfr],cv);
					}
				}else{
					fr+=1;
				}
			}
		}
	}
	int ans = -1;
	for(int j=0;j<160;j++){
		if(dp[0][j]<100){
			ans = j;
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 168960
import sys
from collections import defaultdict as dd
import heapq
input = sys.stdin.readline
N, M = map(int, input().split())
e = dd(list)
for _ in range(M):
  a, b = map(int, input().split())
  e[a].append((b, 1))
  e[b].append((a, 1))
class dijkstra:
  def __init__(self, n, e):
    self.e = e
    self.n = n
  def path(self, s, t):
    d = [float("inf")] * (self.n + 1)
    vis = set()
    d[s] = 0
    h = [s]
    while not t in vis and len(h):
      v = heapq.heappop(h)
      v1 = v % (10 ** 6)
      v0 = v // (10 ** 6)
      if v1 in vis: continue
      vis.add(v1)
      for p in self.e[v1]:
        d[p[0]] = min(d[p[0]], d[v1] + p[1])
        if p[0] in vis: continue
        heapq.heappush(h, d[p[0]] * (10 ** 6) + p[0])
    return d[t]
d = dijkstra(N, e)
if d.path(1, N) > 2:
  print("IMPOSSIBLE")
else: print("POSSIBLE")

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

int main(){
	int N; long long K;
	cin>>N>>K;
	vi A(N+1); rep(i, N) cin>>A[i+1];
	vi index(N+1, -1), path(1, 1);
	while(index[path.back()] < 0){
		index[path.back()] = path.size();
		path.push_back(A[path.back()]);
	}
	int one = index[path.back()];
	int loops = path.size() - one;
	cout<< (K < one? path[K]: path[(K-one) % loops + one]) <<endl;
}


Measured memory_bytes: 5900
#include <bits/stdc++.h>
using namespace std; 
typedef long long lli;
#define mod 1000000007
const int INF = 1e6;
const int MAX = 1e5+10;
#define fori(n) for(int i=0;i<n;i++)
#define forj(n) for(int j=0;j<n;j++)
#define forli(n) for(lli i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define vi vector<int>
#define vli vector<lli>
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define print(a) cout<<a<<endl
#define print2(a,b) cout<<a<<" "<<b<<endl
#define print3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define sortvec(a) sort(a.begin(),a.end())
#define pdd pair<lli,lli>
 
//FUNCTONS
lli llipower(lli x, lli y){lli res = 1;x = x % mod; while (y > 0){if (y & 1) res = (res*x) % mod; y = y>>1;x = (x*x) % mod;}return res;}
lli gcd(lli a, lli b){ if (!a) return b; return gcd(b%a,a);}
lli binarySearch(vector<int> arr, int l, int r, int x){ 
	if (r >= l) { 
		lli mid = l + (r - l) / 2; 
		if (arr[mid] == x) return mid; 
		if (arr[mid] > x) return binarySearch(arr, l, mid - 1, x); 
		return binarySearch(arr, mid + 1, r, x); 
	} 
	return -1;
}

template <typename T>
void printvec(vector<T> inp){
	for(int i=0;i<inp.size();i++){
		cout<<inp[i]<<" ";
	}
	cout<<endl;
}
template <typename T>
T ceildiv(T x, T y){
	return 1 + ((x - 1) / y);
}

int main(){
	int n;
	cin>>n;
	lli sum=0;
	int temp;
	vector<int> nums(n);
	fori(n){
		cin>>temp;
		sum+=temp;
		nums[i]=temp;

	}
	lli avg=sum/n;
	lli ans=0;
	lli ans2=0;
	fori(n){
		ans+=(nums[i]-avg)*(nums[i]-avg);
		ans2+=(nums[i]-avg-1)*(nums[i]-avg-1);

	}
	cout<<min(ans,ans2);

}
 
 

Measured memory_bytes: 256
from fractions import gcd
N = int(input())
t, a = map(int, input().split())
x = gcd(t,a)
pT = t//x
pA = a//x
for i in range(1,N):
  t, a = map(int, input().split())
  mt = pT//t+1 if pT%t!=0 else pT//t
  ma = pA//a+1 if pA%a!=0 else pA//a
  m = max(mt,ma)
  pT = t*m
  pA = a*m

print(pT+pA)

Measured memory_bytes: 66028
#include <iostream>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

map<string,int> m;

int main()
{
	long long sum=0,n;
	cin>>n;
	while(n--)
	{
		string s;
		cin>>s;
		sort(s.begin(),s.end());
		m[s]++;
	}
	for(auto it=m.begin();it!=m.end();++it)
	{
		long long t=(it->second);
		sum+=t*(t-1)/2;
	}
	cout<<sum<<endl;
	return 0;
 } 

Measured memory_bytes: 8064
import numpy as np

n, m = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(m)]

root = []
for i in range(n):
    root.append(set())

for ab in AB:
    root[ab[0]-1].add(ab[1]-1)
    root[ab[1]-1].add(ab[0]-1)

sign = [0]*n
sign[0]=-1
list = [0]

while True:
    x = list.pop(0)

    for next in root[x]:
        if sign[next]==0:
            sign[next]=x+1
            list.append(next)

    if len(list)==0:
        break

print('Yes')
for p in sign[1:]:
    print(p)

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

using namespace std;
using ll = long long;

ll solve(ll N, ll K)
{
    ll ans;     // Número de pares (a, b) com a % b in [0, K - 1]

    // Para b in [1, K] o resto sempre está no intervalo [0, K - 1],
    // para qualquer a in [1, N]
    ans = N*K;

//using ii = pair<int, int>;
//cout << "Total: " << N*N << " pares\n";
//set<ii> xs;

//for (int b = 1; b <= K; ++b)
 //   for (int a = 1; a <= N; ++a)
  //      if (a % b < K)
   //         xs.insert(ii(a, b));

//cout << "set size = " << xs.size() << '\n';
//cout << "New  total = " << N*N - xs.size() << '\n';

    // Para b in [K + 1, N]
    for (ll i = K + 1; i <= N; ++i)
    {
        // Cada múltiplo completo tem K números com resto entre 0 e K - 1
        auto q = N / i;
        ans += (K*q);

        // O resto tem K - 1 números, no máximo, com resto entre 1 e K - 1
        if (K)
        {
            auto r = N % i;
            ans += min(r, K - 1);
        }

//cout << q << " multiplos de " << i << ", resto = " << r << '\n';
//cout << "removendo " << K*q << " dos múltiplos, " << min(r, K - 1) << " do resto\n";
    }

    // A resposta é o complementar de todos os pares
    return N*N - ans;
}

int main()
{
    int N, K;
    cin >> N >> K;

    cout << solve(N, K) << '\n';

    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
N, H = map(int, input().split())

A = []
A_append = A.append
B = []
B_append = B.append
for i in range(N):
    a, b = map(int, input().split())
    A_append(a)
    B_append(b)

A.sort(reverse = True)
B.sort(reverse = True)

# print (A)
# print (B)

count = 0
b = 0
while b < N and B[b] > A[0] and H > 0:
    count += 1
    H -= B[b]
    b += 1
if H > 0:
    count += (H + A[0] - 1) // A[0]
print (count)


Measured memory_bytes: 11360
#include<bits/stdc++.h>
//g++ -std=c++11 

using namespace std;
typedef long long ll;

#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define DIV 1000000007 //10^9+7

int main(){
	ll A, B;
	cin >> A >> B;
	ll num = 1;

	rep(i, 100) {
		if(num >= B) {
			cout << i << endl;
			return 0;
		}
		num += (A - 1);
	}

}

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

int main() {
  int A, B; cin >> A >> B;
  if( A == B ) cout << "Draw" << endl;
  else if( A == 1 ) cout << "Alice" << endl;
  else if( B == 1 ) cout << "Bob" << endl;
  else if( A > B ) cout << "Alice" << endl;
  else cout << "Bob" << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.*;

// 1 2 3 2 3 3
// 3 3 3 1 2 2

public class Main {
	

	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		
			int n=sc.nextInt(),k=sc.nextInt();
			int a[]=sc.readArray(n);
			int min=1,max=(int)1e9+100;
			while(min!=max) {
				int mid=(min+max)/2;
				if(isPossible(mid, k, a)) {
					max=mid;
				}
				else min=mid+1;
				
			}
			System.out.println(min);
		

	}
	public static boolean isPossible(int ans,int k,int a[]) {
		for(int i:a) {
			
			k-=(i+ans-1)/ans -1;
		}
		return k>=0;
	}

	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			while (!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

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

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

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

}

Measured memory_bytes: 55408
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
using namespace std;
#define int long long int
//#define double long double
#define FAST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,tree_order_statistics_node_update> new_data_set;
bool isprime(int n)
	{
    	if(n==1) return true;
    	for(int i = 2;i*i<=n;i++){
    		if(n%i==0) return false;
		}
		return true;
	}
int lcm(int a,int b){
	return (a*b)/__gcd(a,b);
}
int gcd(int a, int b) 
{ 
    if (b == 0){
    	return a;
	} 
    return gcd(b, a % b);  
      
} 
unsigned int factorial(unsigned int n) 
{ 
    if (n == 0) 
    return 1; 
    return n * factorial(n - 1); 
} 
const int inf=1e17+7;
int dsu[1000001],s[100005];
pair<int,int>pz[100001],po[100001];
void init(int n,int m){
	for(int i=1;i<=n;i++){
		dsu[i]=i;
		s[i]=1;
	}
}
int root(int x){
	while(dsu[x]!=x){
		x = dsu[x];
	}
	return x;
}
void uni(int x,int y){
	int p = root(x);
	int q = root(y);
	if(p==q){
		return;
	}
	else{
		if(s[p]<s[q]){
			s[q]+=s[p];
			dsu[p] = q;
		}
		else{
			s[p]+=s[q];
			dsu[q] = p;
		}
	}
}
int power(int x, unsigned int y)  
{  
    int res = 1;
    x = x ; 
    if (x == 0) return 0;  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x);   
        y = y>>1;  
        x = (x*x);  
    }  
    return res;  
}
bool visited[100001]={false};

//void dfs(int x){
//	visited[x]=true;
//	//ans.push_back(x);
//	//c[x]=1;
//	for(auto &child:graph[x]){
//		if(!visited[child]){
//			dfs(child);	
//			//c[x]+=c[child];
//		}
//	}
//}
signed main(){
	FAST
	string s,t;
	cin>>s>>t;
	int n = s.length(),m=t.length();
	int dp[n+1][m+1];
	for(int i=0;i<=n;i++)dp[i][0]=0;
	for(int i=0;i<=m;i++)dp[0][i]=0;
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(s[i-1]==t[j-1]){
				dp[i][j]=dp[i-1][j-1]+1;
			}
			else{
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	int i=n,j=m;
	string ans="";
	while(1){
		if(dp[i][j]==dp[i-1][j-1]+1 && s[i-1]==t[j-1]){
			ans+=s[i-1];
			i--;
			j--;
		}
		else{
			int temp = max(dp[i-1][j],dp[i][j-1]);
			if(temp==dp[i-1][j]){
				i--;
			}
			else{
				j--;
			}
		}
		if(i==0 || j==0){
			break;
		}
	}
	reverse(ans.begin(),ans.end());
	cout<<ans;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()

int logg( int x, int k )
{
	int r = 0;
	while( k > x )
	{ x *= 2; ++r; }
	return r;
}

int main()
{
	int n,k;cin>>n>>k;
	vector<long double> kk( 20, 1.0 );
	REP(i,kk.size())
	{
		if(i==0)continue;
		kk[i] = kk[i-1]/2.0l;
	}
	long double sum = 0.0l;
	long double init = 1.0l / n;
	REP(i,n)
	{
		if( k <= i + 1 ) sum += init;
		else sum += init * kk[logg(i+1,k)];
	}
	cout << fixed << setprecision( 12 ) << sum << endl;
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int> W(N);
    for (int i = 0; i < N; i++){
        cin >> W.at(i);
    }
    int sum = 0;
    for (int i = 0; i < N; i++){
        sum += W.at(i);
    }
    int ans;
    ans = abs(2 * W.at(0) - sum);
    for (int t = 0; t < N -1 ;t++){
        int S = 0;
        for (int i = 0; i <= t; i++){
            S += W.at(i);
        }
        int result;
        result = abs(S - (sum - S));
        if (result < ans){
            ans = result;
        }
    }
    cout << ans << endl;
}

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

int main(void)
{
	int x, h;
	
	while (scanf("%d %d", &x, &h), x + h != 0){
		printf("%.6f\n", x * x + x * sqrt(4 * h * h + x * x));
	}
	
	return 0;
}

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

long long dp[100000];

long long min(long long a, long long b) {
	if (a >= b) {
		return b;
	}
	return a;
}

long long ans(int arr[], int i, int k, int n) {

	if (i >= n) {
		return 0;
	}

	if (i == n-1) {
		return 0;
	}

	if (dp[i] != -1) {
		return dp[i];
	}

	long x = abs(arr[i] - arr[i+1]) + ans(arr, i+1, k, n);
	for (int j = i + 2; j <= i + k; j++) {
		if (j >= n) {
			break;
		}
		x = min(x, abs(arr[i] - arr[j]) + ans(arr, j, k, n));
	}

	dp[i] = x;

	return dp[i];
}

int main()
{
	ios::sync_with_stdio(false);

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

	int arr[n];

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

	memset(dp, -1, sizeof(dp));

	long a = ans(arr, 0, k, n);
	cout << a << endl;

	return 0;
}

Measured memory_bytes: 10752
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int sum[33][101010];
int main(){
    int n,c;
    cin>>n>>c;
    rep(i,n){
        int s,t,x;
        cin>>s>>t>>x;
        --x;
        --s;
        REP(j,s,t)sum[x][j]=1;
    }
    int ans=0;
    rep(i,101010){
        int cnt=0;
        rep(j,33)cnt+=sum[j][i];
        ans=max(cnt,ans);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 12544
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a, b, x, y;
    
    scanf("%d %d", &a, &b);
    
    x = a * b;
    y = 2*a + 2*b;
    
    printf("%d %d\n", x, y);
    
    return 0;
}



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

using namespace std;
typedef pair<int , int> P;
typedef pair<int, P> Q;

int main() {
    int w, d, n;
    cin >> w >> d >> n;
    vector<Q> v;
    for (int i = 0; i < n; i++) {
        int x, y, z;
        cin >> x >> y >> z;
        Q q = Q(z, P(x, y));
        v.push_back(q);
    }
    sort(v.begin(), v.end());
    reverse(v.begin(), v.end());

    vector< vector<int> > mp(w, vector<int>(d, -1000));

    for (int i = 0; i < n; i++) {
        int z = v[i].first;
        int x = (v[i].second).first-1;
        int y = (v[i].second).second-1;
        if (mp[x][y] > z) {
            cout << "No" << endl;
            //break;
            return 0;
        }
        for (int xx = 0; xx < w; xx++) {
            for (int yy = 0; yy < d; yy++) {
                int dist = abs(xx-x)+abs(yy-y);
                mp[xx][yy] = max(mp[xx][yy], z-dist);
            }
        }
    }

    int ans = 0;
    for (int xx = 0; xx < w; xx++) {
            for (int yy = 0; yy < d; yy++) {
                //cout << mp[xx][yy] << ' ';
                ans += mp[xx][yy];
            }
            //cout << endl;
        }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3168
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;

typedef double dbl;

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

	for (int i = 0; i < n; i++) {
		dbl x1, y1, x2, y2, x3, y3;
		dbl l1, l2, l3;

		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

		l1 = sqrt(pow(x3 - x2, 2) + pow(y3 - y2, 2));
		l2 = sqrt(pow(x1 - x3, 2) + pow(y1 - y3, 2));
		l3 = sqrt(pow(x2 - x1, 2) + pow(y2 - y1, 2));

		dbl s, S, r;

		s = (l1 + l2 + l3) / 2;
		S = sqrt(s * (s - l1) * (s - l2) * (s - l3));
		r = (l1 * l2 * l3) / (4 * S);

		dbl A, B, C, D, E, F;

		A = 2 * (x2 - x1); B = 2 * (y2 - y1); C = x2*x2 - x1*x1 + y2*y2 - y1*y1;
		D = 2 * (x3 - x1); E = 2 * (y3 - y1); F = x3*x3 - x1*x1 + y3*y3 - y1*y1;

		dbl ox, oy;

		ox = (C*E - B*F) / (A*E - B*D);
		oy = (A*F - C*D) / (A*E - B*D);

		if (ox == 0) ox = 0;
		if (oy == 0) oy = 0;
		printf("%.3f %.3f %.3f\n", ox, oy, r);
	}
}


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

using namespace std;

#define TC ll t; cin >> t; while(t--)
typedef long long ll;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ll k,x;
    cin >> k >> x;
    for(ll i=x-k+1;i<=x+k-1;i++)
    {
        cout << i << " ";
    }
    return 0;
}


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

int main() {

  int n, p;

  int num[64];
  int bowl;
  int ans;

  for(;;) {
    std::cin >> n >> p;
    if( n == 0 and p == 0 ) break;

    for(int i = 0; i < n; ++i) {
      num[i] = 0;
    }
				

    bowl = p;

    for(int i = 0; ; ++i) {
      if( bowl != 0 ) {
	num[ i % n ] += 1;
	bowl -= 1;
	if( num[ i % n ] == p ) {
	  ans = i % n;
	  break;
	}
      }
      else {
	bowl = num[ i % n ];
	num[ i % n ] = 0;
      }
    }
    std::cout << ans << std::endl;
  }
  
  return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <numeric>
#include <iomanip>
using namespace std;
    
#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
    
using ll = long long;
const ll INF = LLONG_MAX - 100;
ll mod = 1e9 + 7;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;
    
class fact {
public:
    int fmod = 1e9+7;
    vector<int> fac, inv;
    fact (int n, int Mod = 1e9+7) {
        fmod = Mod;
        fac = vector<int>(n,0);
        inv = vector<int>(n,0);
        fac[0] = 1; for (int i = 1; i < n; i++) fac[i] = fac[i-1] * i % fmod;
        for (int i = 0;i < n;i++) inv[i] = fact::POW(fac[i],fmod-2);
    }
    ll nCr(ll n, ll r) {return (fac[n] * inv[r] % fmod) * inv[n-r] % fmod;}
    ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%fmod;}a = a * a%fmod; b >>= 1;}return c;}
};
    
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
void EMP(int x) {cout<<"!!!"<<x<<"!!!"<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b) {ll c = 1; while (b > 0) {if (b & 1) {c = a * c%mod;}a = a * a%mod; b >>= 1;}return c;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}
bool isSqrt(ll a) {return pow(sqrt(a),2) == a ? 1 : 0;}
void YesNo(bool a) {if (a) cout << "Yes"; else cout << "No"; cout << endl;}
void yesno(bool a) {if (a) cout << "yes"; else cout << "no"; cout << endl;}
void YESNO(bool a) {if (a) cout << "YES"; else cout << "NO"; cout << endl;}
int poorpow(int b, int a) {
    int tmp = 1;
    REP (i,a) {
        tmp *= b;
    }
    return tmp;
}


bool solve() {
    string s; cin >> s;
    REP (i,3) {
        if (s[i] == '1') s[i] = '9';
        else if (s[i] == '9') s[i] = '1';
    }
    cout << s << endl;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

int main() {
  int a, b;
  cin >> a >> b;
  cout << (a*b%2==0 ? "Even" : "Odd") << endl;

  return 0;
}

Measured memory_bytes: 256
mod = 998244353

class BIT():

    __slots__ = ["n", "data"]

    def __init__(self, li):
        self.n = len(li) + 1
        self.data = [1] + li
        for i in range(1, self.n):
            if i + (i & -i) < self.n:
                self.data[i + (i & -i)] += self.data[i]

    def add(self, i, a):
        i += 1
        while i < self.n:
            self.data[i] += a
            self.data[i] %= mod
            i += i & -i
        
    def acc(self, i):
        res = 0
        while i > 0:
            res += self.data[i]
            res %= mod
            i -= i & -i
        return res
    
    def fold(self, l, r):
        res = 0
        while l < r:
            res += self.data[r]
            r -= r & -r
            res %= mod
        while r < l:
            res -= self.data[l]
            l -= l & -l
            res %= mod
        return res
        
        
n, k = map(int, input().split())
LR = [list(map(int, input().split())) for _ in range(k)]
dp = BIT([0]*n)
dp.add(0, 1)
for i in range(1, n):
    for l, r in LR:
        dp.add(i, dp.fold(max(i-r, 0), max(i-l+1, 0)))
ans = dp.fold(n-1, n)
print(ans)

Measured memory_bytes: 76780
#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define mp make_pair
using namespace std;
const int N=2e5+5;
int n,k,x[N];
double sum=0,ans;
int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>x[i];
	for(int i=0;i<k;i++)
	{
		sum+=(double)(x[i]+1)/2;
	}
	ans=sum;
	for(int i=k;i<n;i++)
	{
		sum-=(double)(x[i-k]+1)/2;
		sum+=(double)(x[i]+1)/2;
//		cout<<sum<<endl;
		ans=max(ans,sum);
	}
	printf("%.10f\n",ans);
	return 0;
}

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

using namespace std;

#define UN unsigned
#define ll long long int
#define pb push_back
#define MOD 1000000007

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	
	int L[n];
	for(int i=0; i<n; i++)
		cin >> L[i];
		
	sort(L, L+n);
	
	int ans = 0;
	
	for(int a=0; a<n; a++){
		for(int b = a+1; b<n; b++){
			for(int c = b+1; c < n; c++){
				if(L[a]+L[b] <= L[c])
					break;
				else if(L[b]+L[c] <= L[a])
					break;
				else if(L[a]+L[c] <= L[b])
					break;
				else{
					ans++;
					//cout << L[a] << " " << L[b] << " " << L[c] << endl;
				}
			}
		}
	}
	
	cout << ans;
	return 0;
}


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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    ll a,b;
    cin >> a >> b;
    if(a<b) cout << "a < b" << endl;
    else if(a>b) cout << "a > b" << endl;
    else cout << "a == b" << endl;
    return 0;
}


Measured memory_bytes: 3092
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cctype>
#include<vector>
using namespace std;
int read()
{
    char tmp;
    int f(1),x(0);
    for(tmp=getchar();!isdigit(tmp);tmp=getchar()) if(tmp=='-') f=-1;
    for(;isdigit(tmp);tmp=getchar()) x=x*10+tmp-'0';
    return f*x;
}
typedef struct edge{
    int index,to;
    edge(){}
    edge(const int & a,const int & b):index(a),to(b){}
}EDGE;
vector<vector<EDGE> > graph;
int from[200001],to[200001];
int searcharr[1001][1001][2]={0},tme;
int n,m,visited[1001],u,v;
void DFS(const int & k,const int & num,const int & from,const int & flag)
{
    int limit=graph[k].size();
    visited[k]=tme;
    searcharr[from][k][flag]=num;
    for(int i=0;i<limit;i++)
        if(visited[graph[k][i].to]!=tme)
            DFS(graph[k][i].to,num,from,flag);
}
void solve(const int & k)
{
    int limit=graph[k].size();
    visited[k]=++tme;
    for(int i=0;i<limit;i++)
        if(visited[graph[k][i].to]!=tme)
            DFS(graph[k][i].to,graph[k][i].index,k,0);
    reverse(graph[k].begin(),graph[k].end());
    visited[k]=++tme;
    for(int i=0;i<limit;i++)
        if(visited[graph[k][i].to]!=tme)
            DFS(graph[k][i].to,graph[k][i].index,k,1);
}
int main()
{
    n=read(); m=read();
    graph.resize(n+1);
    for(int i=1;i<=m;i++)
    {
        u=read(); v=read();
        from[i]=u; to[i]=v;
        graph[u].push_back(EDGE(i,v));
    }
    for(int i=1;i<=n;i++)
        solve(i);
    for(int i=1;i<=m;i++)
    {
        if((searcharr[to[i]][from[i]][0]!=0)^(searcharr[from[i]][to[i]][0]!=i||searcharr[from[i]][to[i]][1]!=i))
            printf("diff\n");
        else
            printf("same\n");
    }
    return 0;
}

Measured memory_bytes: 13568
package main

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

func main() {
	nextReader = newScanner()
	s, w := nextInt(), nextInt()
	if w-s >= 0 {
		fmt.Println("unsafe")
	} else {
		fmt.Println("safe")
	}
}

// ---------------------------------------------------------------
// I/O
// ---------------------------------------------------------------
var nextReader func() string

func newScanner() func() string {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 1024), int(1e11))
	sc.Split(bufio.ScanWords)
	return func() string {
		sc.Scan()
		return sc.Text()
	}
}

func nextString() string { return nextReader() }

func nextInt() int { n, _ := strconv.Atoi(nextReader()); return n }

func nextInts(size int) []int {
	ns := make([]int, size)
	for i := 0; i < size; i++ {
		ns[i] = nextInt()
	}
	return ns
}


Measured memory_bytes: 1760