akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}

int main(){
  int h, w;
  cin >> h >> w;
  vector<string> a(h);
  rep(i,h) {
    cin >> a[i];
    a[i] = "#" + a[i] + "#";
  }
  rep(i,w+2) cout << '#';
  cout << endl;
  rep(i,h) cout << a[i] << endl;
  rep(i,w+2) cout << "#";
  cout << endl;


}


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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))

typedef pair<int, int> P;
#define INF 1e9
#define INF_LL 1LL<<60
#define ll long long

int main() {
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
while(1){
    ll n,a,b,c,x;
    cin>>n>>a>>b>>c>>x;
    if(c==0)return 0;
    V<int> d(n);
    for(int i=0;i<n;i++)cin>>d[i];
    int ans=-1,j=0;
    for(int i=0;i<=10000;i++){
        if(d[j]==x)j++;
        if(j==n){
            ans=i;
            break;
        }
        x=(a*x+b)%c;
    }
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 3228
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**6)

def dfs(string,bracket):
    i = 0
    while i < len(string):
        if bracket == '[' and string[i] == ']':
            return i
        elif bracket == '(' and string[i] == ')':
            return i
        elif string[i] == ')' or string[i] == ']':
            return False
        elif string[i] == '(' or string[i] == '[':
            ret = dfs(string[i+1:],string[i])
            if ret is False:
                return False
            i += ret + 1
        i += 1
    return True if bracket == '' else False


while True:
    string = list(input())
    if len(string) == 1 and string[0] == '.':
        break
    ans = 'yes' if dfs(string,'') else 'no'
    print(ans)

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

using namespace std;

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

    if(y % 2 == 0)
    {
        if(y <= x*4 && x*2 <= y)
        {
            cout << "Yes";
        }
        else
        {
            cout << "No";
        }
    }
    else
    {

        cout << "No";

    }


    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> T(N);
  for (int i = 0; i < N; i++) {
    cin >> T.at(i);
  }
  int M;
  cin >> M;
  for (int i = 0; i < M; i++) {
    int P, X;
    cin >> P >> X; --P;
    vector<int> TT=T;
    TT.at(P) = X;
    cout << accumulate(TT.begin(), TT.end(), 0) << endl;
  }
}


Measured memory_bytes: 256
N = int(input())
n = 55555

a = [-1,-1,0]+[0]*(n-2)
i = 2
while i * i <= n:
    if a[i] == 0:
        a[i] = 2
        b = i * 2
        while b <= n:
            a[b] = -1
            b += i
    i += 1

one = [x for x in range(2,n+1) if a[x] != -1 and x % 5 == 1]
print(*one[0:N])

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

using namespace std;

using ll = long long;
using ii = pair<int,int>;

#define ff first
#define ss second

const int maxn = 1e5+10;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s,t;
	cin >> s >> t;
	bool ok = true;
	for(int i=0;i<s.size();++i){
		if(s[i]!=t[i]){
			ok=false;
		}
	}
	cout << (ok ? "Yes" : "No") << '\n';
	return 0;
}

Measured memory_bytes: 3644
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<cmath>
#include<map>
#include<sstream>
#define rep(i,l,r) for (int i=l;i<=r;i++)
#define down(i,l,r) for (int i=l;i>=r;i--)
#define clr(x,y) memset(x,y,sizeof(x))
#define maxn 500500
#define inf 1152921504606846976
#define ll long long
#define mm 1000000007
#define eps 1e-9
#define low(x) x&(-x)
#define pb push_back
#define PII pair<int,int>
using namespace std;

ll read(){
    ll x=0,f=1; char ch=getchar();
    while (!isdigit(ch)) {if (ch=='-') f=-1; ch=getchar();}
    while (isdigit(ch)){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}
int n,bin[23];
int main(){
//	freopen("in.txt","r",stdin);
//	freopen("out.txt","w",stdout);
	bin[0]=1; rep(i,1,20) bin[i]=bin[i-1]*2;
	n=read();
	int now=0;
	while (bin[now]<=n) now++;
	printf("%d\n",bin[now-1]);
    return 0;
}

Measured memory_bytes: 256
from collections import deque
S=deque(input())
Q=int(input())
F=0#フラグ
for i in range(Q):
  N=list(input().split())
  if F==0:#反転していない場合
    if N[0]=="1":#反転させる
      F=1
    elif N[1]=="1":#先頭に追加
      S.appendleft(N[2])
    else:#末尾に追加
      S.append(N[2])
  elif F==1:#反転している場合
    if N[0]=="1":#反転を戻す
      F=0
    elif N[1]=="1":#末尾に追加
      S.append(N[2])
    else:#先頭に追加
      S.appendleft(N[2])
if F==1:#反転するならsを反転させる
  S.reverse()
  print("".join(S))
else:#そうでないならそのまま
  print("".join(S))

Measured memory_bytes: 8428
#include<bits/stdc++.h>
using namespace std;
#define SZ(v) ((int)(v).size())
#define zero(v) memset(v,0,sizeof(v))
#define rep(i,n) for(int i=0;i<(n);i++)
#define foreach(it,c) for(__typeof(c.begin()) it=c.begin();it!=c.end();it++)
#define all(v) (v).begin(),(v).end()
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
typedef long long ll;
typedef unsigned uint;
const int INF=0x3f3f3f3f;
const double EPS=1e-10;
typedef pair<int,int> pii;
int inline in(){int x=0,c;for(;(uint)((c=getchar())-'0')>=10;)
{if(c=='-')return -in();if(!~c)throw ~0;}do{x=(x<<3)+(x<<1)+(c-'0');}
while((uint)((c=getchar())-'0')<10);return x;}
int n,m;
const int Maxn=1005;
string board[Maxn];
const int mod=1e9+7;
int dp[Maxn][Maxn];

int main(){
	cin>>n>>m;
	rep(i,n){
		cin>>board[i];
	}
	dp[0][0]=1;
	rep(i,n){
		rep(j,m){
			if(i==0&&j==0)continue;
			if(i-1>=0&&board[i-1][j]=='.'){
				dp[i][j]=((ll)dp[i][j]+dp[i-1][j])%mod;
			}
			if(j-1>=0&&board[i][j-1]=='.'){
				dp[i][j]=((ll)dp[i][j]+dp[i][j-1])%mod;
			}
		}
	}
	cout<<dp[n-1][m-1]<<endl;
	return 0;
}

Measured memory_bytes: 9360
#include <iostream>
#include <vector>
#include <iterator>
using namespace std;
constexpr int INF = 1e9 + 10;

int par[200010], a[200010], ans[200010];
vector<int> G[200010];
void dfs(int p, vector<int> &dp)
{
  for (auto u : G[p])
  {
    if (par[p] == u)
      continue;
    par[u] = p;
    auto itr = lower_bound(dp.begin(), dp.end(), a[u]);
    int before = *itr;
    *itr = a[u];
    auto INF_L = lower_bound(dp.begin(), dp.end(), INF);
    ans[u] = distance(dp.begin(), INF_L);
    dfs(u, dp);
    *itr = before;
  }
}

int main()
{
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  for (int i = 0; i < n - 1; i++)
  {
    int u, v;
    cin >> u >> v;
    u--, v--;
    G[u].emplace_back(v);
    G[v].emplace_back(u);
  }

  vector<int> dp(n, INF);
  dp[0] = a[0];
  ans[0] = 1;
  dfs(0, dp);
  for (int i = 0; i < n; i++)
    cout << ans[i] << "\n";
  return 0;
}


Measured memory_bytes: 31596
#include<bits/stdc++.h>
typedef long long ll;
#define INF 100000000
#define MOD 1000000007
int dx[4]={1,0,-1,0},dy[4]={0,-1,0,1};
using namespace std;
int main(void){
    int n;
    cin>>n;
    int h[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    int l=0;
    int r=l;
    int ans=0;
    for(int l=0;l<n;){
        r=l;
        while(r<n-1 and h[r]>=h[r+1]){
            r++;
        }
        ans=max(ans,r-l);
        l=r+1;
    }
    cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 640
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <functional>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

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

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int n;
vector<int> a;

void input(){
    cin >> n;
    a.resize(n);
    REP(i, n){
        cin >> a[i];
    }
    return;
}

void solve(){
    int ans = INF;
    int cost = 0;
    for (int i=-100; i<=100; ++i){
        cost = 0;
        REP(j, n){
            cost += (a[j] - i) * (a[j] - i); 
        }
        ans = min(cost, ans);
    }
    cout << ans << endl;
    return;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 256
virgin = true

loop do
  n = gets.to_i
  break if n.zero?
  puts "" unless virgin

  teams = Hash.new{ |h,k| h[k] = [] }

  n.times do
    team_and_score = gets.chomp.split
    team = team_and_score.first
    wld = team_and_score[1..-1].map(&:to_i)
    score = 3*wld[0] + wld[2]
    teams[score] << team
  end

  teams.sort.reverse.each do |score_teams|
    s = score_teams.first
    score_teams.last.each{ |t| puts "#{t},#{s}"}
  end

  virgin = false if virgin
end

Measured memory_bytes: 6132
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_D main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


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

    int N; cin >> N;
    vi P(N); REP(i, N) {
        cin >> P[i];
        P[i]--;
    }

    int ans = 0;
    P.push_back(INF);
    REP(i,N){
        if (P[i] == i) {
            swap(P[i], P[i + 1]);
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

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

float p = 0;
int w = 0, s = 0;
int a, b, c, d, e, f;

int main()
{
	cin >> a >> b >> c >> d >> e >> f;

	int na = f / 100 / a + 1;
	int nb = f / 100 / b + 1;
	int nc = f / c + 1;
	int nd = f / d + 1;
	for( int i = 0; i < na; i++ ) {
		for( int j = 0; j < nb; j++ ) {
			for( int k = 0; k < nc; k++ ) {
				for( int l = 0; l < nd; l++ ) {
					if( (k*c + l*d) > e * (i*a + j*b) ) {
						continue;
					}
					if( k*c + l*d + i*a*100 + j*b*100 > f ) {
						continue;
					}
					if( k*c + l*d + i*a*100 + j*b*100 == 0 ) {
						continue;
					}
					float pp = (k*c + l*d) * 100.0 / ( k*c + l*d + i*a*100 + j*b*100 );
					if( pp > p ) {
						p = pp;
						w = i*a*100 + j*b*100;
						s = k*c + l*d;
					}
				}
			}
		}
	}
	if( p == 0 ) {
		w = b*100;
		if( w > f ) {
			w = a*100;
		}
		if( w > f ) {
			w = 0;
		}
	}
	cout << w + s << " " << s << endl;

	return 0;
}


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

int ans(int n){
	if(n/10==0)return 0;
	int ma=0;
	for(int i=0;i<=6;i++){
		int tmp=pow(10,i);
		ma=max(ma,(n/tmp)*(n%tmp));
	}
	return ans(ma)+1;
}

int main(){
	int q;
	cin>>q;
	for(int i=0;i<q;i++){
		int n;
		cin>>n;
		cout<<ans(n)<<endl;
	}
}

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

using namespace std;


int main() {
    int h, w;
    cin >> h >> w;
    vector<vector<char>> a(h, vector<char>(w));
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            cin >> a[i][j];
        }
    }
    vector<pair<int, int>> P;
    int cur = 0;
    for(int i = 0; i < h; i++) {
        int x;
        for(int j = 0; j < w; j++) {
            if(a[i][j] == '#') {
                x = j;
            }
        }
        P.push_back(make_pair(cur, x));
        cur = x;
    }
    vector<vector<char>> v(h, vector<char>(w, '.'));
    for(int i = 0; i < h; i++) {
        int fst = P[i].first;
        int snd = P[i].second;
        for(int j = fst; j <= snd; j++) {
            v[i][j] = '#';
        }
    }
    if(v == a) {
        puts("Possible");
    } else {
        puts("Impossible");
    }
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
using namespace std;
using Int = int64_t;
const char* solve() {
    Int N, sum = 0;
    cin >> N;
    vector<Int> a(N), b(N);
    for (auto& i : a) {
        cin >> i;
        sum -= i;
    }
    for (auto& i : b) {
        cin >> i;
        sum += i;
    }
    if (sum < 0) return "No";
    Int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (a[i] > b[i]) cnt += a[i] - b[i];
        else if (a[i] < b[i]) cnt -= (b[i] - a[i]) / 2;
    }
    return cnt <= 0 ? "Yes" : "No";
}
int main() {
    cout << solve() << endl;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main() {

  int n, x, y;
  scanf("%d%d%d", &n, &x, &y);
  printf("%d %d\n", min(x, y), max(x + y - n, 0));

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define MAX 100001
using namespace std;
int n,p,A[MAX*4],N;
void Segtree(int n_){
  n=1;
  while(n<n_)n*=2;
}
void update(int k,int x){
  k+=n-1;
  A[k]=x;
  while(k>0){
    k=(k-1)/2;
    A[k]=max(A[k*2+1],A[k*2+2]);
  }
}
int find(int a,int b,int k,int l,int r){
  if(r<=a||b<=l)return 0;
  if(a<=l&&r<=b)return A[k];
  int v1=find(a,b,k*2+1,l,(l+r)/2);
  int v2=find(a,b,k*2+2,(l+r)/2,r);
  return max(v1,v2);
}
main(){
  cin>>n;
  N=n;
  Segtree(n+1);
  for(int i=0;i<N;i++){
    scanf("%lld",&p);
    int v=find(0,p,0,0,n);
    update(p,v+p);
  }
  cout<<N*(N+1)/2-find(0,N+1,0,0,n)<<endl;
}

Measured memory_bytes: 4756
R=range
def F(a,b):A=len(a);return[all([len(set([a[i+j],b[j],'?']))<3for j in R(min(A-i,len(b)))])for i in R(A)]+[1]
def Z(X):
 i,j,k=X;A,B,C=A,B,C=[len(S[t])for t in X];q=1e5
 for l in R(A+1):
  if M[i][j][l]:
   for r in R(l,A+B+1):
    if(B<r-l or M[j][k][r-l])*M[i][k][min(A,r)]:q=min(q,max(A,l+B,r+C))
 return q
S=[input()for i in R(3)]
M=[[F(i,j)for j in S]for i in S]
from itertools import*;print(min([Z(i)for i in permutations(R(3))]))

Measured memory_bytes: 54424
N,M=map(int, input().split())

def warshall_floyd(d):
  for k in range(N):
    for i in range(N):
      for j in range(N):
        d[i][j]=min(d[i][j],d[i][k]+d[k][j])
  return d

d=[[float("inf")]*N for i in range(N)]
A=[]
for i in range(M):
  x,y,z=map(int, input().split())
  x-=1
  y-=1
  d[x][y]=z
  d[y][x]=z
  A.append((x,y,z))
  
for i in range(N):
  d[i][i]=0 
  
D=warshall_floyd(d)

ans=0
for x,y,z in A:
  if D[x][y]!=z:
    ans+=1
print(ans)

Measured memory_bytes: 9396
n, m = map(int, input().split())
num_list = ['X'] * n

def ans():
    if n == 1 and m == 0:
        return 0
    for i in range(m):
        set = list(map(str, input().split()))
        if set[0] == '1' and set[1] == '0' and n != 1:
            return -1
        else:
            if num_list[int(set[0]) - 1] == 'X':
                num_list[int(set[0]) - 1] = set[1]
            elif num_list[int(set[0]) - 1] == set[1]:
                continue
            else:
                return -1

    for i in range(n):
        if num_list[i] == 'X':
            if i == 0:
                num_list[i] = '1'
            else:
                num_list[i] = '0'

    return ''.join(num_list)

print(ans())


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

int main() {
  int n;
  string s;
  cin>>n>>s;
  int east=0;
  for(int i=0;i<n;i++){
    if(s[i]=='E') east++;
  }
  int ans=-1;
  int higashi=0;
  int nishi=0;
  for(int i=0;i<n;i++){
    int temp=0;
    if(s[i]=='E') {
      temp=nishi+east-higashi-1;
      higashi++;
    }
    else {
      temp=nishi+east-higashi;
      nishi++;
    }
    if(ans<0 || temp<ans) ans=temp;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 900
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int N; cin >> N;
	vector<int> a, b;
	int B;
	for (int i = 0; i < N; i++) {
		cin >> B;
		B--;
		b.push_back(B);
	}
	bool flag = false;
	while (!b.empty()) {
		flag = false;
		for (int i = b.size() - 1; i >= 0; i--) {
			if (b[i] == i) {
				a.push_back(b[i] + 1);
				b.erase(b.begin() + i);
				flag = true;
				break;
			}
		}
		if (!flag) {
			cout << "-1" << endl;
			return 0;
		}
	}
	reverse(a.begin(), a.end());
	for (int i = 0; i < N; i++) {
		cout << a[i] << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


// Union-Find木-----------------------------------------------
/* ここらへんと蟻本を参考に
<https://qiita.com/drken/items/cce6fc5c579051e64fab>
<http://baitop.hatenadiary.jp/entry/2018/06/26/224712>
sizeが必要なら2個目のリンクからいい感じに
*/
// UnionFind uf(N); // N:要素数

struct UnionFind{
  vector<int> par;  // 親ノードを格納
  vector<int> rank; // 木の深さを格納
  vector<int> sizes; // 木の大きさを格納

  UnionFind(int N = 1) : par(N), rank(N, 0), sizes(N) { // N要素で初期化する
    for (int i=0; i<N; i++) par[i] = i;
    for (int i=0; i<N; i++) sizes[i] = 1;
  }

  int root(int x){ // 木の根を求める。自分じゃなかったら親の根を調べていき調べたノードの親はすべて根に
    return par[x] == x ? x : par[x] = root(par[x]); // 経路圧縮も行う
  }

  bool same(int x, int y){ // x,yの木が同じかどうか
    return root(x) == root(y);
  }

  bool unite(int x, int y){ // xとyの木を併合
    x = root(x); y = root(y); // ここでx,yのroot同士の扱いにする
    if (x == y) return false; // 元々同じならそのまま
    if (rank[x] < rank[y]) swap(x, y); // rank[x] >= rank[y]になるようにswap
    if (rank[x] == rank[y]) rank[x]++; // 元のrankが同じなら親になる方のrankは1増える
    par[y] = x;
    sizes[x] += sizes[y];
    return true;
  }

  int size(int x){
    return sizes[root(x)];
  }
};

int N,M,K;
Graph G;

int main() {
  cin >>N >>M >>K;
  G.assign(N, vector<int>());
  vector<int> fb(N, 0); // 間接的な友達関係にあるが、ブロック関係である人の人数を格納
  UnionFind uf(N);

  rep(i, M){
    int a,b; cin >>a >>b; a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
    uf.unite(a, b);
  }
  rep(i, K){
    int c,d; cin >>c >>d; c--; d--;
    // cとdが間接的な友達関係にあれば、あとで弾くためにfbインクリメント
    if (uf.same(c, d)){
      fb[c]++; fb[d]++;
    }
  }
  rep(i, N){
    // 各人 i について、間接的な友達関係にありかつブロック関係にない人の人数を答える
    int friendship = uf.size(i) - 1 - G[i].size();
    int res = friendship - fb[i];
    cout <<res;
    if (i == N-1) cout <<endl;
    else cout <<" ";
  }
}


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

using namespace std;

#define int long long



main(){


	int a, b, c; cin >> a >> b >> c;

	if(4 * a * b < (c - a - b) * (c - a - b) and c - a - b > 0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	


	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import math

N=int(input())
ans=[0]*(N+1)
sn=int(math.sqrt(N)+1)
for x in range(1,sn+1):
  for y in range(1,sn+1):
    for z in range(1,sn+1):
      i=x**2+y**2+z**2+x*y+y*z+z*x
      if 1<=i<=N:
        ans[i]+=1
for h in range(1,N+1):          
  print(ans[h])


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

using namespace std;

using ll = long long;

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

    int h, w;
    cin >> h >> w;
    vector<string> c(h);
    for (int i = 0; i < h; ++i) cin >> c[i];

    for (int i = 0; i < 2 * h; ++i) {
        for (int j = 0; j < w; ++j) cout << c[i / 2][j];
        cout << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
// const ll MOD=998244353;

int main(){
  int N; cin>>N;
  int ans=0;
  int BA=0,XA=0,BX=0;
  rep(i,N){
    string S; cin>>S;
    int n=S.length();
    rep(i,n-1){
      if(S[i]=='A'&&S[i+1]=='B') ans++;
    }
    if(S[0]=='B'&&S[n-1]=='A') BA++;
    else if(S[0]=='B') BX++;
    else if(S[n-1]=='A') XA++;
  }
  while(XA>0||BX>0||BA>0){
    if(BA){
      if(XA){
        ans++;
        BA--;
      }else if(BX){
        ans++;
        BA--;
      }else{
        if(BA>1) BA--,ans++;
        else break;
      }
    }else{
      if(XA==0||BX==0) break;
      else XA--,BX--;
      ans++;
    } 
  }
  cout<<ans<<endl;
  return 0;
}


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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;
constexpr f64 EPS = DBL_EPSILON;

void solve() {
    f64 a, b, h, m;
    cin >> a >> b >> h >> m;
    cout << sqrt(a * a + b * b - 2 * a * b * cos(2 * M_PI * (h * 60 + m) / 720 - 2 * M_PI * m / 60)) << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    solve();
}


Measured memory_bytes: 4212
#![allow(unused_imports)]
use proconio::{
   fastout, input,
   marker::{Bytes, Isize1, Usize1},
};

#[fastout]
fn main() {
   input! {
      n: usize,
      m: usize,
      mut ab: [(Usize1, Usize1); m]
   }
   let mut d = vec![n; n];
   for &(a, b) in ab.iter() {
      d[a] = std::cmp::min(d[a], b);
   }
   let mut ans = 0;
   let mut bm = n;
   for i in 0..n {
      if i == bm {
         ans += 1;
         bm = n;
      }
      bm = std::cmp::min(bm, d[i]);
   }
   println!("{}", ans);
}


Measured memory_bytes: 5500
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? 1e9:1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){int b=0;for(auto itr :a){if(b++!=0)cout << " "; cout << itr;} }
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
#define int ll
signed main(){
    int n,m;
    while(cin >> n >> m, n || m){
        auto Ld = vectors(301,301,(ll)INF);
        auto Sd = vectors(301,301,(ll)INF);
        rep(i,n)Ld[i][i] = Sd[i][i] = 0;
        rep(i,m){
            int a,b,c; char s;
            cin >> a >> b >> c >> s;
            --a,--b;
            if(s == 'L'){
                Ld[b][a] = Ld[a][b] = min(Ld[a][b],c);
            }else{
                Sd[b][a] = Sd[a][b] = min(Sd[a][b],c);
            }
        }
        rep(k,n)rep(i,n)rep(j,n){
            cmin(Sd[i][j],Sd[i][k] + Sd[k][j]);
            cmin(Ld[i][j],Ld[i][k] + Ld[k][j] );
        }
        int r; cin >> r;
        vector<int>v;
        rep(i,r){
            int t; cin >> t;
            v.push_back(--t);
        }
        auto dp = vectors(2001,2001,(ll)INF);
        dp[0][v[0]] = 0;
        rep(i,r){
            if(i  ==  0)continue;
            rep(j,n){
                rep(k,n){
                    if(j != k)cmin(dp[i][j],dp[i-1][k] + Ld[v[i-1]][k] + Sd[k][j] + Ld[j][v[i]]);
                    else cmin(dp[i][j],dp[i-1][j] + Ld[v[i-1]][v[i]]);
                }
            }
        }
        int ans = INF;
        for(auto val : dp[r-1]) cmin(ans, val);
        cout << ans << endl;
    }
}




Measured memory_bytes: 35436
#include <algorithm>
#include <iostream>
using namespace std;
int main(){
  int N;
  cin >> N;
  int A[N];
  for(int i = 0; i < N; ++i){
    cin >> A[i];
  }
  sort(A,A+N);
  cout << A[N-1]-A[0] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <climits>
#define endl "\n"
#define ll long long
using namespace std;

int main()
{
    ll x;
    cin >> x;
    for(ll i = -1000; i <= 1000; i ++)
    {
    	for(ll j = -1000; j <= 1000; j ++)
    	{
    		ll a = i * i * i * i * i;
    		ll b = j * j * j * j * j;

    		if(a - b == x)
    		{
    			cout << i << " " << j << endl;
    			return 0;
    		}
    	}
    }
}

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

int cnt(int n) {
	if (n % 1000000 == 0) return 3;
	else if (n % 10000 == 0) return 2;
	else if (n % 100 == 0) return 1;
	else return 0;
}

void Main()
{
	int D, N; cin >> D >> N;
	int _cnt = 0;
	REP(i,1,10000000) {
		if (cnt(i) != D) continue;
		++_cnt;
		if (_cnt >= N) {
			cout << i << endl;
			return;
		}
	}
}

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


Measured memory_bytes: 256
N, Q = gets.split.map &:to_i
S = gets.chomp

cusum = [sum = 0] + (0...N).map{|i|
  if i != 0 && S[i-1] == ?A && S[i] == ?C
    sum += 1
  end
  sum
}
# p cusum
$<.map{|s|
  l, r = s.split.map &:to_i
  p cusum[r] - cusum[l]
}


Measured memory_bytes: 5116
use std::str::FromStr;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn main() {
    let v : Vec<i32> = get_vec();
    let mut ans = "dangerous".to_string();
    if v[1] >= v[2] {
        ans = "delicious".to_string();
    }
    else if v[0] + v[1] >= v[2] {
        ans = "safe".to_string();
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
using System;
using System.Linq;

namespace ABC153
{
	class Program
	{
		static void Main(string[] args)
		{
			string[] strs = Console.ReadLine().Split(' ');
			int h = int.Parse(strs[0]);
			int n = int.Parse(strs[1]);

			strs = Console.ReadLine().Split(' ');
			int[] a = new int[strs.Length];
			for(int i = 0; i < a.Length; i++)
			{
				a[i] = int.Parse(strs[i]);
			}

			string result = "No";
			int total = a.Sum();
			h -= total;

			if(h <= 0)
			{
				result = "Yes";
			}
			else
			{
				result = "No";
			}

			Console.WriteLine(result);
		}
	}
}

Measured memory_bytes: 16992
import sys,queue,math,copy,itertools,bisect,collections
LI = lambda : [int(x) for x in sys.stdin.readline().split()]

X,Y,Z,K = LI()
A = LI()
B = LI()
C = LI()

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

h = A[0] + B[0] + C[0]
l = 0
while h > l+1:
    m = (h+l) // 2

    num = 0
    for a in A:
        j = len(C) - 1
        for i in B:
            while i + C[j] < m - a:
                j -= 1
                if j < 0: break
            else:
                num += j + 1
                continue
            break
    if num >= K:
        l = m
    else:
        h = m

ans = []
for a in A:
    j = len(C) - 1
    for i in B:

        while i + C[j] <= l - a:
            j -= 1
            if j < 0: break
        else:
            for k in range(j+1):
                ans.append(a+i+C[k])
            continue
        break

ans.sort(reverse=True)
for _ in range(K-len(ans)):
    ans.append(l)
print(*ans[:K], sep='\n')



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

int main()
{
	map<long long int, int, greater<int>> A;
	long long int n, m, k;
	cin >> n >> m >> k;
	long long int a;
	long long int s = 0;
	long long int ind1 = 0;
	for(long long int i = 0; i < n; i++)
	{
		cin >> a;
		s += a;
		if(s <= k)
		{
			ind1 = i + 1;
			A.insert(make_pair(s, i + 1));
		}
	}
	long long int ind2 = 0;
	s = 0;
	long long int x;

	long long int j;
	for(long long int i = 0; i < m; i++)
	{
		cin >> a;
		s += a;
		if(s <= k)
		{
			ind2 = i + 1;
			x = k - s;
			auto it = A.lower_bound(x);
			if(it == A.end())
				continue;
			j = it->second + i + 1;
			if(j > ind1) ind1 = j;
		}
		//else break;
	}
	cout << max(ind1, ind2);

}


Measured memory_bytes: 16056
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    ll n,ans=0; cin>>n;
    vector<ll> a(3*n);
    rep(i,3*n) cin>>a[i];
    sort(al(a)); reverse(al(a));
    rep(i,n){
        ans+=a[2*i+1];
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#define INF 50000000000000
std::vector<int> G[100000];
struct edge{int from,to,cost;};
int V,E,r=0;
bool negativeflag=false;
edge es[500000];
long long int d[100000];
void shortest_path(int s);
bool negative_path(int s);
int main(void){
	std::cin>>V>>E;
	for(int i=0;i<E;i++){
		int from,to,cost;
		std::cin>>from>>to>>cost;
		G[from].push_back(to);
		//G[t].push_back(s);
		es[i].from=from;
		es[i].to=to;
		es[i].cost=cost;
	}
	negativeflag=negative_path(r);
	if(negativeflag){
		std::cout<<"NEGATIVE CYCLE"<<std::endl;

	}else {
		for(r=0;r<V;r++){
			shortest_path(r);
			for(int i=0;i<V;i++){
				if(d[i]!=INF){
					std::cout<<d[i];
				}else {
					std::cout<<"INF";
				}
				if(i!=V-1){
					std::cout<<' ';
				}else {
					std::cout<<std::endl;
				}
			}
		}
	}
	return 0;
}
void shortest_path(int s){
	for(int i=0;i<V;i++){
		d[i]=INF;
	}
	d[r]=0;
	while(1){
	//for(int j=0;j<V;j++){
		bool flag=true;
		for(int i=0;i<E;i++){
			if(d[es[i].from]!=INF){
				if(d[es[i].to]>d[es[i].from]+es[i].cost){
					d[es[i].to]=d[es[i].from]+es[i].cost;
					flag=false;
				}
			}
		}
		if(flag){
			break;
		}
	}
}
bool negative_path(int s){
	bool flag=false;
	for(int i=0;i<V;i++){
		d[i]=0;
	}
	for(int j=0;j<V;j++){
		for(int i=0;i<E;i++){
			if(d[es[i].from]!=INF){
				if(d[es[i].to]>d[es[i].from]+es[i].cost){
					d[es[i].to]=d[es[i].from]+es[i].cost;
					if(j==V-1){
						flag=true;
					}
				}
			}
		}
	}
	return flag;
}

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

constexpr ll INF = ll(1e+18) + 1;

int main() {
    int N;
    string S;
    ll ans = 0;
    ll count = 0;
    vector<int> X;
    vector<int> Y;
    
    cin >> N;
    cin >> S;

    rep(i, 26) {
        X.push_back(0);
        Y.push_back(0);
    }

    rep (i, (int)S.size()) {
        Y[S[i]-'a']++;
    }

    rep(i, (int)S.size()) {
        X[S[i]-'a']++;
        Y[S[i]-'a']--;
        count = 0;
        rep (j, (int)X.size()) {
            if (X[j] > 0 && Y[j] > 0) {
                count++;
            }
        }

        ans = max(ans, count);
    }

    cout << ans << endl;
}


Measured memory_bytes: 3576
M,D = map(int,input().split())
ans = 0
for i in range(1, M+1):
  for j in range(1, D+1):
    if j < 22:
      continue
    else:
      j = str(j)
      d1 = int(j[0])
      d2 = int(j[1])
      if d1>=2 and d2>=2 and i == d1*d2:
        ans += 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define sz(arr) (int)(arr).size()
#define rng(arr) arr.begin(), arr.end()
#define show(x) cout << #x << " = " << x << endl;
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
typedef long long int ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

void Main() {
  Cin(string, s);
  if (sz(s) == 1) {
    cout << 0 << endl;
    return;
  }

  string s1, s2;
  rep(i, sz(s)) {
    if (i % 2 == 0) {
      s1 += "0";
      s2 += "1";
    } else {
      s1 += "1";
      s2 += "0";
    }
  }

  int cnt1 = 0, cnt2 = 0;
  rep(i, sz(s)) {
    if (s[i] != s1[i]) cnt1++;
    if (s[i] != s2[i]) cnt2++;
  }

  cout << min(cnt1, cnt2) << endl;
}

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

int main(){
    ll a, b, k, tmp;
    cin >> a >> b >> k;

    tmp = a;
    a -= k;
    if(a<0) {
        b -= k-tmp;
        a = 0;
        
        if(b<0) {
            b = 0;
        }
    }

    cout << a << " " << b << endl;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int ans = 0;
  while ( b >= a ) {
    ans++;
    b -= a;
    if ( ans == c ) { break; }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	while(cin>>n,n){
		string str;
		bool right=0,left=0;
		int ans=0,now=1;
		for(;n>0;n--){
			cin>>str;
			if(str=="lu")left=1;
			else if(str=="ru")right=1;
			else if(str=="ld")left=0;
			else right=0;
			if(now==right&&right==left){
				ans++;
				now=(now+1)%2;
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1208
MOD = 1000000007

N, M = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))

dx = [X[i + 1] - X[i] for i in range(N - 1)]
dy = [Y[i + 1] - Y[i] for i in range(M - 1)]

sx = 0
sy = 0

for i in range(N - 1):
    sx += dx[i] * (i + 1) * (N - 1 - i)
    sx %= MOD

for i in range(M - 1):
    sy += dy[i] * (i + 1) * (M - 1 - i)
    sy %= MOD

print(sx * sy % MOD)

Measured memory_bytes: 19088
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define myPair pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define qmax priority_queue<int>
#define qmin priority_queue<int,vector<int>,greater<int>>
#define all(x) x.begin(),x.end()
#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 sz(a) (int)a.size()

const int mxn = 2e5 + 10, INF = 2e18;
int a[mxn], h[mxn], dp[mxn], n;
int tree[4 * mxn];

int getMax(int qs, int qe, int ss, int se, int si) {
	if(qs > se || qe < ss)
		return -INF;
	if(qs <= ss && qe >= se)
		return tree[si];
	int mid = (ss + se) / 2;
	return max(getMax(qs, qe, ss, mid, 2 * si), getMax(qs, qe, mid + 1, se, 2 * si + 1));
}

void update(int i, int val, int ss, int se, int si) {
	if(i < ss || i > se)
		return;
	if(ss == se) {
		tree[si] = val;
		return;
	}
	int mid = (ss + se) / 2;
	update(i, val, ss, mid, 2 * si);
	update(i, val, mid + 1, se, 2 * si + 1);
	tree[si] = max(tree[2 * si], tree[2 * si + 1]);
}

void segTree(int ss, int se, int si) {
	if(ss == se) {
		tree[si] = dp[ss];
		return;
	}
	int mid = (ss + se) / 2;
	segTree(ss, mid, 2 * si);
	segTree(mid + 1, se, 2 *si + 1);
	tree[si] = max(tree[2 * si], tree[2 * si + 1]);
}

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

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> n;
	FOR(i, 1, n) {
		cin >> h[i];
	}
	FOR(i, 1, n) {
		cin >> a[i];
	}
	// dp[i] = maximum sum of beauties if the last flower taken has height 'i'
	memset(dp, 0, sizeof(dp));
	segTree(1, n, 1);
	FOR(flower, 1, n) {
		dp[h[flower]] = a[flower];
		int ans = 0;
		if(h[flower] > 1)
			ans = getMax(1, h[flower] - 1, 1, n, 1);
		dp[h[flower]] += ans;
		update(h[flower], dp[h[flower]], 1, n, 1);
	}
	int ans = 0;
	FOR(i, 1, n) {
		ans = max(ans, dp[i]);
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 12444
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int n;
    cin >> n;
    vector<int> l(n);
    for(int i = 0; i < n; ++i)  cin >> l[i];
    sort(l.begin(), l.end());
    vector<int> lb, ub;
    vector<P> sides;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < i; ++j){
            sides.emplace_back(l[i], l[j]);
            lb.emplace_back(l[i] - l[j]);
            ub.emplace_back(l[i] + l[j]);
        }
    }
    int sz = lb.size();
    // for(int i = 0; i < sz; ++i){
    //     cerr << lb[i] << ' ' << ub[i] << endl;
    // }
    ll ans = 0;
    for(int i = 0; i < sz; ++i){
        ans += lower_bound(l.begin(), l.end(), ub[i]) - upper_bound(l.begin(), l.end(), lb[i]);
        int a = sides[i].first, b = sides[i].second;
        if(lb[i] < a && a < ub[i])  --ans;
        if(lb[i] < b && b < ub[i])  --ans;
    }
    ans /= 3;
    cout << ans << endl;
}

Measured memory_bytes: 43364
#include <bits/stdc++.h>
using namespace std;
#define pr(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define all(v) (v).begin(), (v).end()
#define int long long
#define sz(v) (int)(v).size()
#define mod 1000000007 // ((a- b)% mod+ mod)% mod

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

void solve() {
        int a, b, c; cin >> a>> b>> c;
        if (b* c>= a) cout << "Yes\n";
        else cout << "No\n";
}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int T= 1;
        //cin >> T;
        while ( T-- ) {
                solve();
        }
return 0;
}


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

int main() {
  int N;
  cin >> N;
  cout << N*N << endl;
    return 0;    
}

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

public class Main {

	static int m = 1000000007;

	public static void main(String[] args) throws IOException {
		Scanner scn = new Scanner(System.in);
		long n = scn.nextLong(), k = scn.nextLong();
		System.out.println(Math.min(n % k, k - n % k));
	}

	static class Scanner {

		StringTokenizer st;
		BufferedReader br;

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

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

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

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

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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;

#define rep(a,n) for(ll a = 0;a < n;a++)

static const ll INF = 1e15;
static const ll mod = 1e9+7;

template<typename T>
static inline void chmin(T& ref, const T  value) {
    if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T& ref, const T value) {
    if (ref < value) ref = value;
}

struct MaxFlowCalculator {
	int max_flow(int s, int t, const vector<vector<pair<int, int>>>& g) {
		struct edge_ { int to, cap, rev; };
		vector<bool> used(g.size(), false);
		vector<vector<edge_>> G(g.size());
		for (int i = 0; i < g.size(); i++) for (int j = 0; j < g[i].size(); j++)
		{
			int from = i, to = g[i][j].second;
			int cap = g[i][j].first;
			G[from].push_back({ to, cap, (int)G[to].size() });
			G[to].push_back({ from, 0, (int)G[from].size() - 1 });
		}
		auto dfs = [&](auto&& f, int v, int t, int fl)->int {
			if (v == t) return fl;
			used[v] = true;
			rep(i, G[v].size()) {
				edge_& e = G[v][i];
					if (!used[e.to] && e.cap > 0) {
					int d = f(f, e.to, t, min(fl, e.cap));
					if (d > 0) {
						e.cap -= d;
						G[e.to][e.rev].cap += d;
						return d;
					}
				}
			}
			return 0;
		};
		int flow = 0;
		while (1) {
			used.assign(used.size(), false);
			int f = dfs(dfs, s, t, INT_MAX);
			if (f == 0) return flow;
			flow += f;
		}
	}
};

int main() {
	ll n;
	cin >> n;
	vector<ll> as(n);
	rep(i, n) cin >> as[i];
	vector<ll> sums(n + 1, 0);
	rep(i, n) sums[i + 1] = sums[i] + as[i];

	ll low = INF;
	rep(i, n) {
		ll left = sums[i + 1];
		ll right = sums[n] - left;
		chmin(low, abs(left - right));
	}
	cout << low << endl;

    return 0;
}


Measured memory_bytes: 3636
//abc148E
#include <malloc.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void) {
  int i;
  long long n=0, tmp=10, mp5=1, cou=0, sum=0;
  scanf(" %lld", &n);

  if(n % 2 == 1){
    printf("0");
    return 0;
  }

  while(tmp < n){
    tmp*=5;
    mp5=mp5 * 5 + 1;
    cou++;
    //printf("cou=%d\n", cou);
  }
  for(i=cou; i >= 0; i--){
    if(n >= tmp){
      sum+=(n / tmp) * mp5;
      n=n % tmp;
    }
    tmp/=5;
    mp5=(mp5 - 1) / 5;
    //printf("n=%lld\n", n);
  }

  printf("%lld", sum);
  return 0;
}

Measured memory_bytes: 128
#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 << "Bob" << endl;
  }
  else{
    cout << "Alice" << endl;
  }
}
    

Measured memory_bytes: 764
import java.util.Scanner;
import java.io.*;

public class Main{
    public static void main(String args[]){
        Scanner scan_A = new Scanner(System.in);
        int  str_A = scan_A.nextInt();

       
        int str_B = scan_A.nextInt();

        
        int str_C = scan_A.nextInt();

        int ans;
        int E = str_A - str_B;
        if(E >str_C ){
            ans = 0;
        }else{
           
            ans = str_C -E;
        }
       
               
        System.out.println(ans);
    }

}

Measured memory_bytes: 22996