akhauriyash/Code-Regression huggingface dataset:
s = input()
t = input()

dp = [[0]*(len(t)+1) for _ in range(len(s)+1)]

for i in range(1,len(s)+1):
  for j in range(1,len(t)+1):
    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])
      
i, j = len(s), len(t)
f = ""

while((i>0) & (j>0)):
  if dp[i][j] == dp[i-1][j]: i -= 1
  elif dp[i][j] == dp[i][j-1]: j -= 1
  else :
    f += s[i-1]
    i -= 1
    j -= 1
  
print(f[::-1])


Measured memory_bytes: 112220
#include<iostream>
using namespace std;
int n;
string str;
bool check_A(string t){
  int cnt=0,i=0,cnt2=0;

  while(t[i]=='='){cnt++;i++;}

  if(t[i]!='#')return false;
  if(cnt==0)return false;
  if((int)t.size()==i)return false;

  i++;
  while(t[i]=='='){cnt2++;i++;}

  if(cnt!=cnt2)return false;
  if((int)t.size()!=i+1)return false;

  if(t[i]!='~')return false;
  return true;
}

bool check_B(string t){
  int i=0,cnt=0;
  while(i+1<(int)t.size()&&t[i]=='Q'&&t[i+1]=='='){
    i+=2;
    cnt++;
  }
  if(cnt==0)return false;
  if(i+2!=(int)t.size())return false;
  if(t[i]=='~'&&t[i+1]=='~')return true;
  return false;
}


int main(){
  cin>>n;
  while(n--){
    cin>>str;
    if(str[0]=='>'&&str[1]=='\''){
      if(check_A(str.substr(2))){
	cout<<'A'<<endl;
      }else{
	cout<<"NA"<<endl;
      }
    }else if(str[0]=='>'&&str[1]=='^'){
      if(check_B(str.substr(2))){
	cout<<'B'<<endl;
      }else{
	cout<<"NA"<<endl;
      }
      
    }else{
      cout<<"NA"<<endl;
    }
  }
  return 0;
}

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

int main() {
    double A = 100;
    int i = 0;
    double X;
    cin >> X;
    
    while(1){
        i++;
        A = floor(A * 1.01);
        if(A >= X)   break;
    }

    cout << i << endl;
}


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

int main()
{
	int n;
	string s;
	cin >> n >> s;
	if (n & 1) {
		cout << "No" << endl;
		return 0;
	}
	n /= 2;
	bool ok = true;
	for (int i = 0; i < n; i++) {
		if (s[i] != s[n + i]) {
			ok = false;
			break;
		}
	}
	puts(ok ? "Yes" : "No");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<deque>

using namespace std;

int main()
{
	int max,min;
	deque<char> nums;
	int n;
	int k;
	char c;
	cin>>n;
	while(n){
		k=10000000;
		max=min=0;
		n--;
		for(int i=0;i<8;i++){
			cin>>c;
			nums.push_back(c);
		}

		sort(nums.begin(),nums.end());
		deque<char>::iterator it= nums.begin();
		while(it!= nums.end()){
			min+=((int)*it-(int)'0')*k;
			k/=10;	
			++it;
		
		}
		k=10000000;
		reverse( nums.begin(), nums.end() );  
		it= nums.begin();
		while(it!= nums.end()){
			max+=((int)*it-(int)'0')*k;
			k/=10;
			++it;
		}
		cout<<max-min<<endl;
		nums.clear();
	}

	return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,x;
	cin>>n>>x;
	int a=0;
	int m[100];
	int b=1900;
	for(int i=0;i<n;i++){
		cin>>m[i];
		a+=m[i];
		b=min(b,m[i]);
	}
	x=x-a;
	x=(x-x%b)/b;
	cout<<x+n<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

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

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

int main(){
    int n, u, v, m; cin>>n>>u>>v>>m;
    map<int, P> Uboard, Nboard;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            int x; cin>>x;
            Uboard[x] = P(i, j);
        }
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            int x; cin>>x;
            Nboard[x] = P(i, j);
        }
    }

    vector<int> Uh(n, n), Uw(n, n), Nh(n, n), Nw(n, n);
    int Ud1=n, Ud2=n, Nd1=n, Nd2=n;
    bool Uvalid=false, Nvalid=false;
    int Ucnt=0, Ncnt=0;
    vector<int> q(m);
    for(int i=0; i<m; i++) cin>>q[i];
    for(int i=0; i<m; i++){
        int x=q[i];
        auto itr = Uboard.find(x);
        if(itr != Uboard.end()){
            int cy = Uboard[x].fs;
            int cx = Uboard[x].sc;

            Uh[cx]--;
            if(Uh[cx] == 0) Ucnt++;
            Uw[cy]--;
            if(Uw[cy] == 0) Ucnt++;

            if(cy == cx){
                Ud1--;
                if(Ud1 == 0) Ucnt++;
            }
            if(cy == (n - 1 - cx)){
                Ud2--;
                if(Ud2 == 0) Ucnt++;
            }
        }

        itr = Nboard.find(x);
        if(itr != Nboard.end()){
            int cy = Nboard[x].fs;
            int cx = Nboard[x].sc;

            Nh[cx]--;
            if(Nh[cx] == 0) Ncnt++;
            Nw[cy]--;
            if(Nw[cy] == 0) Ncnt++;

            if(cy == cx){
                Nd1--;
                if(Nd1 == 0) Ncnt++;
            }
            if(cy == (n - 1 - cx)){
                Nd2--;
                if(Nd2 == 0) Ncnt++;
            }
        }

        if(n == 1){
            chmin(Ucnt, 1);
            chmin(Ncnt, 1);
        }

        if(u <= Ucnt){
            Uvalid = true;
        }
        if(v <= Ncnt){
            Nvalid = true;
        }

        if(Uvalid && Nvalid){
            cout << "DRAW" << endl;
            return 0;
        }
        if(Uvalid && !Nvalid){
            cout << "USAGI" << endl;
            return 0;
        }
        if(!Uvalid && Nvalid){
            cout << "NEKO" << endl;
            return 0;
        }
    }

    cout << "DRAW" << endl;
}


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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

long long cnt(long long a, long long x, long long y) {
  long long g = __gcd(x, y);
  return a/x+a/y-a/(x*y/g);
}

void solve() {
  long long a, b, c, d; cin >> a >> b >> c >> d;
  cout << b-a-(cnt(b, c, d)-cnt(a-1, c, d))+1;
}

int main() {
  init();
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
#define endl "\n";
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define POSITIVE_INFINITY 9223372036854775807
#define NEGATIVE_INFINITY -9223372036854775807
const ll MOD = 1000000007;

int main()
{
  FASTER;
  cout << fixed << setprecision(10);
  long double t, x;
  cin >> t >> x;
  cout << t / x << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<(n);i++)
#define init(a,i) for(int k=0;k<(i);k++)(a)[k]=0
#define in(a,i) for(int k=0;k<(i);k++)cin>>(a)[k]
#define all(a)  (a).begin(),(a).end()
#define el(a) (a).end()-(a).begin()
#define mod 1000000007
#define inf 2147483647
int main(){
	int n;
	cin>>n;
	int num[10][10],top_num=0,top_dig=1;
	rep(i,10)rep(j,10)num[i][j]=0;
	for(int i=1;i<=n;i++){
		if(!(i%top_dig))top_num++;
		if(top_num==10){
			top_dig*=10;
			top_num=1;
		}
		num[top_num][i%10]++;
	}
	int sum=0;
	rep(i,10)rep(j,10)sum+=num[i][j]*num[j][i];
	cout << sum;
	return 0;
}

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

typedef long long ll;

#define REP(i, N) for (int i = 0; i < (int)(N); i++)

// chmax, chmin
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() {
    string S,T;
    cin >> S >> T;
    
    int s = S.size(), t = T.size();
    
    vector<string> cnd;
    
    for ( int left = 0; left <= s - t; ++left ){
        bool match = true;
        for ( int i = 0; i < t; ++i){
            if ( S[left+i] != '?' and S[left+i] != T[i] ) match = false;
        }
        //cout << left << " " << match << endl;
        if ( match ){
            string Sn = S;
            for ( int i = 0; i < s; ++i) if ( Sn[i] == '?' ) Sn[i] = 'a';
            for ( int i = 0; i < t; ++i) Sn[left+i] = T[i];
            cnd.push_back(Sn);
        }
    }
    
    if ( cnd.size() == 0 ) {
        cout << "UNRESTORABLE" << endl;
    } else {
        sort(cnd.begin(),cnd.end());
        cout << cnd[0] << endl;
    }
    
    
    
    
    return 0;
}


Measured memory_bytes: 3648
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(fst) (int)(fst).size()
#define forn(i, N) for (ll i = 0; i < ll(N); i++)
#define fornr(i, N) for (int i = int(N) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(fst) fst.begin(), fst.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;

const int N = 1e6;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, k, r, s, p;
    cin >> n >> k >> r >> s >> p;
    string t;
    cin >> t;
    vector<int> a(n);
    forn(i, n) {
        if (t[i] == 'r') a[i] = 0;
        if (t[i] == 's') a[i] = 1;
        if (t[i] == 'p') a[i] = 2;
    }
    vector<vector<int>> b(k);
    forn(i, n) b[i % k].pb(a[i]);
    ll ans = 0;
    forn(it, k) {
        int n = sz(b[it]);
        vector<vector<ll>> dp(n + 1, vector<ll>(3, -1));
        dp[0][0] = dp[0][1] = dp[0][2] = 0;
        forn(i, n) {
            forn(l, 3) {
                forn(m, 3) {
                    if (l == m) continue;
                    dp[i + 1][m] = max(dp[i + 1][m], dp[i][l]);
                    if (m == 0 && b[it][i] == 1) dp[i + 1][m] = max(dp[i + 1][m], dp[i][l] + r);
                    if (m == 1 && b[it][i] == 2) dp[i + 1][m] = max(dp[i + 1][m], dp[i][l] + s);
                    if (m == 2 && b[it][i] == 0) dp[i + 1][m] = max(dp[i + 1][m], dp[i][l] + p);
                }
            }
        }
        ans += max(dp[n][0], max(dp[n][1], dp[n][2]));
    }
    cout << ans << "\n";
}

Measured memory_bytes: 6600
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n,x) for(int i=(n);i<(x);++i)
#define rem(i,n,x) for(int i=(n);i>=(x);--i)
#define pb push_back
using ll = long long;

int main() {
	ll n; cin >> n;
  
	vector<int> ans;
  	if (n == 0) ans.pb(0);
	while (n != 0) {
		int num = n % (-2);
		n /= (-2);
		if (num >= 0) ans.pb(num);
		else {
			ans.pb(1);
			n += 1;
		}
	}

	rem(i, ans.size() - 1, 0) cout << ans[i];
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
s = input()
n = len(s)
l = (n - 1) // 2
s1 = s[:l]
s2 = s[l+1:][::-1]
if s1 != s2:
    print('No')
    sys.exit()
m = l // 2
if l % 2 == 0:
    a1 = s1[:m]
    b1 = s2[:m]
    a2 = s1[m:][::-1]
    b2 = s2[m:][::-1]
else:
    a1 = s1[:m]
    b1 = s2[:m]
    a2 = s1[m+1:][::-1]
    b2 = s2[m+1:][::-1]
if a1 != a2 or b1 != b2:
    print('No')
    sys.exit()
print('Yes')

Measured memory_bytes: 40400
n = gets.to_i  #n人
d, x = gets.split(" ")  #d日間、x個残った
a = []
d = d.to_i

n.times{|i|
  a[i] = gets.to_i
}

tabeta_kazu = 0

a.each do |i|
  tabeta_kazu += d / i
  tabeta_kazu += 1 if (d % i) != 0 
end

puts tabeta_kazu + x.to_i


Measured memory_bytes: 1788
n,m,l=map(int,raw_input().split())
a=[]
b=[]
c=[[0 for k in range(l)] for i in range(n)]

for i in range(n):
	a.append(map(int,raw_input().split()))
for j in range(m):
	b.append(map(int,raw_input().split()))

for i in range(n):
	for k in range(l):
		for j in range(m):
			c[i][k] += a[i][j]*b[j][k]
for i in range(n):
	print ' '.join(map(str,c[i]))

Measured memory_bytes: 7160
arr = []
5.times{arr << gets.to_i}
min = nil
arr.each{|x| min = (x % 10) if (min.nil? || min > (x % 10)) && (x % 10) > 0}

sum = 0
if min
    y = arr.find_index{|x| (x % 10) == min}
    x = arr[y]
    arr.delete_at(y)
    arr << x
    sum = 0
    arr[0..-2].each{|x|
        y = (10 - (x % 10)) % 10
        sum += (x + y)
    }
    sum += arr[-1]
else
    sum = arr.inject(:+)
end
puts sum

Measured memory_bytes: 1788
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <queue>
#include <iomanip>
#include <numeric>
#include <cmath>

using namespace std;

//#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

typedef long long ll;

//static const ll MOD = 1000000007;

int main() {
    ll N, M, answer = 0;
    priority_queue<ll> A;

    // input
    cin >> N >> M;
    for (ll i = 0; i < N; i++) {
        ll input;
        cin >> input;
        A.push(input);
    }

    // process
    for (ll i = 0; i < M; i++) {
        ll t = A.top();
        A.pop();
        A.push(t / 2);
    }
    for (ll i = 0; i < N; i++) {
        answer += A.top();
        A.pop();
    }

    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 1400
#include "bits/stdc++.h"
using namespace std;
#define pb          push_back
#define mp          make_pair
#define ll          long long
#define pii         pair<ll, ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll, ll>
#define mii         map<pii, ll>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rev(i,a,b)  for(int i=a;i>=b;i--)
#define lb          lower_bound
#define ub          upper_bound

#define bg(i)       i.begin()
#define fset(it,s)   for(auto it = s.begin(); it != s.end(); it++)
 
#define track(x)                 cerr<<#x<<": "<<x<<endl
#define track2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define track3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define track4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
 
#define ed(i)       i.end()
#define mem(a)	    memset(a, 0, sizeof(a))

#define MOD         1000000007
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll add(ll a, ll b, ll p=MOD){return (a + b + p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
void self_max(ll &a, ll b) {a = max(a, b); }
void self_min(int &a, int b) {a = min(a, b); }
void self_add(int &a, int b, int p = MOD) { a += b; if(a >= p) a -= p;}
void self_sub(int &a, int b, int p = MOD) { a -= b; if(a < 0) a += p;}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
const int INF = 1e9 + 5;
#define N	    	400001

ll dp[N][2];
void solve(){
    int n;
    cin>>n;
    ll a[n];
    ll sum = 0;
    rep(i, 0, n) {
        cin>>a[i];
        sum += a[i];
    }

    dp[1][1] = -2*(a[1]+a[0]);
    rep(i,2,n) {
        dp[i][0] = max(dp[i-1][0], dp[i-1][1]);
        dp[i][1] = dp[i-1][0] -2*(a[i]+a[i-1]);
        self_max(dp[i][1], dp[i-1][1] + 2 * a[i-1] - 2*a[i]);
    }
    cout<<sum + max(dp[n-1][0], dp[n-1][1])<<endl;
}
int main() {
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
//	cin>>t;
	while(t--){
		solve();
	}
}




Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin>>n;
    vl a(n);
    cin>>a;
    sort(all(a));
    double ans=a[0];
    rep(i,n)ans=(ans+a[i])/2;
    fcout(10)<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
using namespace std;
int x,y=1,maxn=0;
int main(){
	scanf("%d",&x);
	for(int i=1;i<=34;i++)
	{
		y=i;
		if(i==1) maxn=1;
		else while(y*i<=x){
			y*=i;
			maxn=max(maxn,y);
		}
	}
	printf("%d",maxn);
	return 0;
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
#define f2(i,j,k) for(int i=j;i>k;i--)
using namespace std;
int main(){
    string n;
    cin>>n;
    bool f=false;
    if(n=="keyence"){
        cout<<"YES"<<endl;
        return 0;
    }
    long long j=n.size()-7;
    f(i,0,8){
        string ans=n.substr(0,i)+n.substr(i+j);
        if(ans=="keyence"){
            f=true;
            break;
        }
    }
    if(f){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
    return 0;
}


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

signed main() {
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    
    if (x - r < 0 or x + r > w or y - r < 0 or y + r > h) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
    
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf 1000000000
#define pll pair <ll,ll>
#define min_pq priority_queue <pll> ,vector <pll>, greater <pll> > > 
#define f first
#define s second
#define vll vector <ll>

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    ll n;
    cin>>n;
    ll m=n/2;
    double p[n+1];
    for(ll i=1;i<=n;i++)
        cin>>p[i];
    double dp[n+1][m+1];
    memset(dp,0,sizeof dp);
    dp[1][0]=p[1];
    for(ll i=2;i<=n;i++)
        dp[i][0]=p[i]*dp[i-1][0];
    dp[1][1]=1-p[1];
    for(ll i=2;i<=n;i++)
    {
        for(ll j=1;j<=m;j++)
        {
            if(j>i)
                continue;
            dp[i][j]=(dp[i-1][j]*p[i])+(dp[i-1][j-1]*(1-p[i]));
        }
    }
    double sum=0;
    for(ll i=0;i<=m;i++)
        sum+=dp[n][i];
    cout<<fixed<<setprecision(10)<<sum<<'\n';
}   


Measured memory_bytes: 35456
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int N_MAX = 201;
int R_MAX = 8;
long long INF = 123456789123456789;
typedef pair<long long,int> P;
void dijkstra(int s, int V, vector<P>* g, long long* d){
  if(d[s]==0)
    return;
  int i,v;
  P p,e;
  priority_queue<P, vector<P>, greater<P>> que; // 最短距離，頂点番号
  fill(d,d+V,INF);
  d[s]=0;
  que.push(P(0,s));
  while(!que.empty()){
    p=que.top(); que.pop();
    v=p.second;
    if(d[v]<p.first) continue;
    for(i=0;i<g[v].size();i++){
      e=g[v][i];
      if(d[e.second]>d[v]+e.first){
        d[e.second]=d[v]+e.first;
        que.push(P(d[e.second],e.second));
      }
    }
  }
  return;
}
int main()
{
  int n,m,r,a,b,i;
  int rr[R_MAX];
  vector<P> g[N_MAX]; //cost,to
  long long c,t,res=INF;
  long long d[N_MAX][N_MAX];
  cin >> n >> m >> r;
  for(i=0;i<r;i++){
    cin >> rr[i];
    fill(d[rr[i]]+1,d[rr[i]]+n+1,INF);
  }
  for(i=0;i<m;i++){
    cin >> a >> b >> c;
    g[a].push_back(P(c,b));
    g[b].push_back(P(c,a));
  }
  for(i=0;i<r;i++)
    dijkstra(rr[i],n,g,d[rr[i]]);
  sort(rr,rr+r);
  do {
    t=0;
    for(i=0;i<r-1;i++)
      t+=d[rr[i]][rr[i+1]];
    if(t<res) res=t;
  } while(next_permutation(rr,rr+r));
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1280
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define dump(x)  cout << #x << " = " << (x) << endl;

#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
//             0123456789 - digits. check the limits, int vs long
const int MX = 100001;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(0);
    cout << std::fixed;
    // freopen("ex.in","r",stdin);
    // freopen("ex.out","w",stdout);
    int n; 
    string s;
    cin >> n;
    cin >> s;
    if (n&1) {
        cout << "No\n";
        return 0;
    }
    for (int i = 0; i < n/2; i++) {
        if (s[i] != s[i + n/2]) {
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 256
S = input()

def kaibunChecker(string):
    if string == string[::-1]:
        return True
    else :
        return False
    
flag = False
N = len(S)

if kaibunChecker(S):
    s_front = S[0:(N-1)//2]
    if kaibunChecker(s_front):
        s_end = S[(N+2)//2]
        if kaibunChecker(s_end):
            flag = True

if flag :
    print('Yes')
else :
    print('No')
    

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <vector>
#include <math.h>

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define vsort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())

const int MOD = 1000000007;
const int INF = INT_MAX;


int main(){

    int n;
    cin >> n;
    
    int n_cnt = 0;
    int cnt;
    for (int i=1; i <= n; i++){
        cnt = 0;
        for (int j=1; j <= i; j++){
            if (i%j == 0) cnt++;
        }
        if (cnt == 8 && i%2 == 1) n_cnt++;
    }

    cout << n_cnt << endl;

}





//              g++ -std=c++1z

Measured memory_bytes: 256
a,b,c,d = map(int,input().split())
while(a>0 and c>0):
  c-=b
  a-=d
if a<=0 and c>0:
  print("No")
elif c<=0 and a>0: 
  print("Yes")
elif a<=0 and c<=0:
  print("Yes")

Measured memory_bytes: 9104
# include <bits/stdc++.h>
using namespace std;
int main(){
    int h,r;
    cin >> h >>r;
    if(h+r<0){
        cout<< -1<<endl;
    }else if(h+r>0){
        cout<< 1 << endl;
    }else {
        cout<< 0 <<endl;
    }
}


Measured memory_bytes: 3108
#define KYOPURO

#include<iostream>

using namespace std;

int main()
{
    int A, B;
    cin >> A >> B;

    if((A * B) % 2 == 0)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << endl;
#else
	#define DBG(X)
	#define endl '\n'
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const ll mod = 1e9 + 7;
const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }

void solve()
{
	int n;
	cin >> n;

	vector<ld> a(n);

	for(auto& x: a)
		cin >> x;

	sort(a.begin(), a.end());

	ld answ = 0.5 * (a[0] + a[1]);

	for(int i = 2; i < n; ++i)
		answ = 0.5 * (answ + a[i]);

	cout << fixed << setprecision(12) << answ << endl;
}

int main()
{
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
struct Switch_and_light
{
    int num;
    int switchs[10];
    int onswitchs;
    int P;
};

int main()
{
    int N,M;
    std::cin >> N >> M;
    Switch_and_light light[10];
    for(int i=0; i<10; i++){
        for(int j=0; j<10; j++){
        light[i].switchs[j]=0;
        }
    }

    for(int i=0; i<M; i++){
        int k;
        std::cin >> k;
        light[i].onswitchs=k;
        for(int j=0; j<k; j++){
            int connect;
            std::cin >> connect;
            light[i].switchs[connect-1]=1;
        }
    }
    for(int i=0; i<M; i++){
        std::cin >> light[i].P;
    }

    int onswitch[10];
    int sum=0;
    int counter=0;
    int hoge=0;
    for(int i=0; i<std::pow(2,N); i++){ //入力全てのパターンについて
        for(int j=0; j<N;j++){ //どのスイッチON?
            onswitch[j]=(i>>j)&1;
        }
        for(int k=0; k<M; k++){ //電球１個１個について
            sum=0;
            for(int l=0; l<N;l++){ //いくつスイッチが入ってるか調べる
                sum+=light[k].switchs[l]*onswitch[l];
            }
            if(sum%2!=light[k].P){
                goto loop;
            }
        }
        counter++;
        loop:
        hoge++;
    }
    std::cout << counter << std::endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/local/bin python
# -*- coding: utf-8 -*-
#
# ~/aizu/alds11a_insertionSort.py
#


def insertionSort(a: list, n: int):
    a_string_list = map(str, a)
    output = ' '.join(a_string_list)
    print(output)
    for i in range(1, n):
        v = a[i]
        j = i - 1
        while j >= 0 and a[j] > v:
            a[j + 1] = a[j]
            j -= 1
        a[j + 1] = v
        a_string_list = map(str, a)
        output = ' '.join(a_string_list)
        print(output)


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




Measured memory_bytes: 5608
#include <bits/stdc++.h>
using namespace std;
#define M 10000

int main(){
	int n,m,r,a=1;//a:使用中の配列の数
	cin>>n>>m>>r;
	r-=n*m;
	if(r<0){
		cout<<0<<endl;
		return 0;
	}
	int count[6000];
	memset(count,0,sizeof(count));
	count[0]=1;
	for(int i=1;i!=n;i++){//(r+(n-1))C(n-1)。重複順列。
		for(int j=0;j<a;j++){
			count[j]=count[j]*(r+n-i);
		}
		for(int j=a-1;j>=0;j--){
			if(j!=0) count[j-1]+=(count[j]%i)*M;
			count[j]=count[j]/i;
		}
		/*オーバーフロー対策*/
		for(int j=0;j<a;j++){
			count[j+1]+=count[j]/M;
			count[j]%=M;
		}
		for(a=6000;count[a-1]==0;a--);
	}
	cout<<count[a-1];
	for(a=a-2;a>=0;a--){
		if(count[a]/1000==0){
			printf("0");
			if(count[a]/100==0){
				printf("0");
				if(count[a]/10==0){
					printf("0");
				}
			}
		}
		cout<<count[a];
	}
	cout<<endl;
	return 0;
}
		

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

int main(){
	int N,K,min=1000000000;
	cin >> N >> K;
	vector <int> h(N);
	for(int i=0;i<N;i++){
		cin >> h[i];
	}
	sort(h.begin(),h.end());
	for(int i=0;i+K-1<N;i++){
		if(h[i+K-1]-h[i]<=min){min=h[i+K-1]-h[i];}
	}
	cout << min << endl;
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;int n,w,z,h;vector<int> v;int main(){while(cin>>n>>w&&n){v.clear();h=0;while(n--){cin>>z;while(true){if(v.size()>z/w)break;v.push_back(0);}v[z/w]++,h=max(v[z/w],h);}double a=0.01;for(int i=0;i<v.size();i++)a+=v[i]/(h+0.0)*(1-i/(v.size()-1.0));cout<<fixed<<setprecision(9)<<a<<endl;}return 0;}

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

using namespace std;

int main(int argc, char* argv[])
{
  int N, M; cin >> N >> M;

  vector<int> X(M);
  for (int i = 0; i < M; i++) {
    cin >> X[i];
  }

  int total = 0;
  if (N < M) {
    sort(X.begin(), X.end());
  
    vector<int> diff;
    for (int i = 0; i < M-1; i++) {
      diff.push_back(X[i+1]-X[i]);
    }

    sort(diff.begin(), diff.end());

    for (int i = 0; i < diff.size()-N+1; i++) {
      total += diff[i];
    }
  }
  cout << total << endl;
  return 0;
}


Measured memory_bytes: 1276
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

int n,m;
ll x[100010];
int a[100010],b[100010];
ll y[100010];

struct UF{
	int par[100010],r[100010];
	ll par_cost[100010];
	ll cnt[100010];
	ll ret[100010];
	void init(){
		rep(i,100010){
			par[i] = i;
			r[i] = 0;
			par_cost[i] = 0;
			cnt[i] = 1;
			ret[i] = 0;
		}
	}
	int find(int x){
		if(par[x] == x)return par[x];
		else find(par[x]);
	}
	bool same(int x,int y){
		return find(x) == find(y);
	}
	void unit(int x,int y,ll c){
		x = find(x);
		y = find(y);
		if(x == y)return;
		if(r[x] < r[y]){
			par[x] = y;
			par_cost[x] = c;
			cnt[y] += cnt[x];
		}
		else {
			par[y] = x;
			par_cost[y] = c;
			cnt[x] += cnt[y];
			if(r[x] == r[y]){
				r[x] ++;
			}
		}
	}
	bool used[100010];
	void dfs_init(){
		rep(i,100010){
			used[i] = false;
		}
	}
	void dfs(int v){
		used[v] = true;
		if(!used[par[v]])dfs(par[v]);
		if(par_cost[v] <= ret[par[v]]){
			ret[v] = ret[par[v]];
		}
	}
}uf;

int main(){
	scanf("%d%d",&n,&m);
	rep1(i,n)scanf("%lld",&x[i]);
	rep1(i,m){
		scanf("%d%d%lld",&a[i],&b[i],&y[i]);
	}
	
	uf.init();
	rep1(i,n){
		uf.cnt[i] = x[i];
	}
	
	vector<pair<ll,pair<ll,ll>>> vec;
	rep1(i,m){
		vec.pb(pair<ll,pair<ll,ll>>(y[i],pair<ll,ll>(a[i],b[i])));
	}
	sor(vec);
	rep(i,vec.size()){
		pair<ll,pair<ll,ll>> p = vec[i];
		int s = uf.find(p.sc.fr);
		int t = uf.find(p.sc.sc);
		if(s == t)continue;
		uf.unit(s,t,p.fr);
		if(uf.par[s] == t)swap(s,t);
		if(uf.cnt[s] >= p.fr){
			uf.ret[s] = uf.cnt[s];
			uf.ret[t] = uf.cnt[s];
		}
	}
	uf.dfs_init();
	rep1(i,n)uf.dfs(i);
	
	ll ret = 0;
	rep1(i,m){
		if(uf.ret[a[i]] < y[i])ret ++;
	}
	cout << ret << endl;
	
}



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

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

fn main() {
    println!("{}", read::<u32>() + read::<u32>() / 2);
}


Measured memory_bytes: 2068
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return (a*b) // gcd(a, b)

K = int(input())

t = []

for i in range(1, K+1):
    s = 0
    
    for j in range(1, K+1):
        s += gcd(i, j)
    t.append(s)
    
ans = 0

for i in range(1, K+1):
    for j in range(1, K+1):
        ans += t[gcd(i, j)-1]
        
print(ans)


Measured memory_bytes: 9144
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>

using namespace std;
#define LL long long
#define pb push_back
#define mk make_pair
#define mst(a, b)	memset(a, b, sizeof a)
#define REP(i, x, n)	for(int i = x; i <= n; ++i)
const int MOD = 1e9 + 7;
const int qq = 2e5 + 10;
const int INF = 1e9 + 10;
LL Gcd(LL a, LL b) {
	return b == 0 ? a : Gcd(b, a % b);
}
LL Lcm(LL a, LL b) {
	return a / Gcd(a, b) * b;
}

int main(){
	int n;	scanf("%d", &n);
	LL ans = 1;
	for(int i = 1; i <= n; ++i) {
		LL x;	scanf("%lld", &x);
		ans = Lcm(ans, x);
	}
	printf("%lld\n", ans);
	return 0;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD =  (int)1e9 + 7;
const double EPS = 1e-9;

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int A, B, H;
	cin >> A >> B >> H;

	cout << (A + B)*H / 2 << endl;

	return 0;
}

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


void solve(std::string S){
    cout << ((S == "ABC") ? "ARC" : "ABC") << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

int a, b, c, tmp;

int main() {
   cin >> a >> b >> c;

   if (a > b) {
        tmp = b;
        b = a;
        a = tmp;
   }
   if (b > c) {
        tmp = c;
        c = b;
        b = tmp;
   }
   if (a > b) {
        tmp = b;
        b = a;
        a = tmp;
   }

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



Measured memory_bytes: 3080
function find(parent,u)
	if u==parent[u]
		u
	else
		parent[u]=find(parent,parent[u])
	end
end
function check(E,N)
	parent=collect(1:N)
	size=ones(Int,N)
	for (u,v)=E
		u=find(parent,u)
		v=find(parent,v)
		if u!=v
			if size[u]<size[v]
				parent[u]=v
				size[v]+=size[u]
			else
				parent[v]=u
				size[u]+=size[v]
			end
		end
	end
	length(unique(find(parent,i) for i=1:N))==1
end
function main()
	lines=readlines()
	N,M=map(x->parse(Int,x),split(shift!(lines)))
	E=Pair{Int,Int}[]
	for s=lines
		x,y=map(x->parse(Int,x),split(s))
		push!(E,x=>y)
	end
	cnt=0
	for i=1:M
		F=Pair{Int,Int}[]
		for j=1:i-1
			push!(F,E[j])
		end
		for j=i+1:M
			push!(F,E[j])
		end
		if !check(F,N)
			cnt+=1
		end
	end
	println(cnt)
end
main()


Measured memory_bytes: 116896
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <string>
#include <map>

using namespace std;

int main(){
  int i,j,k,l,m,n;
  string s;
  cin >> n;
  int x[n],y[n],h[n];
  for(i=0;i<n;i++){
    cin >> x[i] >> y[i] >> h[i];
  }
  int v[n];
  int h2[n],flag=0,kouho,t;
  for(i=0;i<=100;i++){
    for(j=0;j<=100;j++){
      flag = 0;
      kouho=-1;
      for(k=0;k<n;k++){
        h2[k] = abs(x[k]-i)+abs(y[k]-j);
        if(h[k]==0)continue;
        if(kouho==-1){
          kouho = h2[k]+h[k];
          break;
        }
      }
      for(k=0;k<n;k++){
        if(h[k]!=max(kouho-abs(x[k]-i)-abs(y[k]-j),0)){
          flag = 1;
          break;
        }
      }
      if(!flag){
        cout << i << " " << j << " " << kouho << endl;
        return 0;
      }
    }
  }
  return 0;
}


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

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

    vector<int> A(N);

    int tmp;

    for (size_t i = 0; i < N; i++)
    {
        cin >> tmp;

        A.at(tmp - 1) = i + 1;    
    }

    for (size_t i = 0; i < N; i++)
    {
        cout << A.at(i) << " ";
    }
    
    
}

Measured memory_bytes: 1152
package main

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

var (
	tmp string
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()

	for sc.Scan() {
		tmp = sc.Text()
		fmt.Println(tmp)
		fmt.Println(tmp)
	}
}

Measured memory_bytes: 640
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
try:
    from math import gcd
except:
    from fractions import gcd

k = int(input())

memo = [[0] * 201 for _ in range(201)]
for i in range(201):
    for j in range(201):
        memo[i][j] = gcd(i, j)
ret = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            val = memo[a][b]
            ret += memo[val][c]
print(ret)


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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  
  rep(i, N){
  	cin >> d[i];
  }
  
  int ans = 0;
  int kari = 0;
  rep(i, N){
  	for(int j=i+1; j<N; j++){
    	kari = d[i]*d[j];
        ans += kari;
    }
  }

  
  cout << ans << endl;
  

}

Measured memory_bytes: 256
# for i, a in enumerate(iterable)
# q, mod = divmod(a, b)
# divmod(x, y) returns the tuple (x//y, x%y)
# manage median(s) using two heapq https://atcoder.jp/contests/abc127/tasks/abc127_f
# visual studio code shortcut https://qiita.com/TakahiRoyte/items/cdab6fca64da386a690b
# delete line: Ctrl+Shift+k
# choose same words: Ctrl+Shift+l
import sys
from itertools import combinations, permutations # https://docs.python.org/ja/3/library/itertools.html
from math import factorial
def combinations_count(n, r):
    # faster than the following code
    # def combinations_count(n, r):
    #     return factorial(n) // (factorial(n - r) * factorial(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 combination_with_repetition_count(n, r):
    return combinations_count(n + r - 1, r)
from collections import deque, Counter # https://docs.python.org/ja/3/library/collections.html#collections.deque
from heapq import heapify, heappop, heappush, heappushpop, heapreplace,nlargest,nsmallest # https://docs.python.org/ja/3/library/heapq.html
from copy import deepcopy, copy # https://docs.python.org/ja/3/library/copy.html
from functools import reduce
from fractions import gcd # Deprecated since version 3.5: Use math.gcd() instead.
def gcds(numbers):
    return reduce(gcd, numbers)
def lcm(x, y):
    return (x * y) // gcd(x, y)
def lcms(numbers):
    return reduce(lcm, numbers, 1)
# about how to set the inputs
    # open(0).read() is a convenient method:
    # ex) n, m, *x = map(int, open(0).read().split())
    #     min(x[::2]) - max(x[1::2])
    # ex2) *x, = map(int, open(0).read().split())
    #     don't forget to add comma after *x if only one variable is used
    # R = lambda: map(int, input().split()) :it's fashionable, isn't it?
    # ex1) n, k = R()
    # ex2) v = list(R())
    # ex3) bc = [list(R()) for i in range(m)]

# R = lambda: map(int, input().split())
s = input()
s = s.replace('A','0')
s = s.replace('BC','1')
s = s.replace('B',' ')
s = s.replace('C', ' ')
l = s.split()
ans = 0
for i in l:
    countbc = 0
    for j in i[::-1]:
        if j == '1':
            countbc += 1
        else:
            ans += countbc

print(ans)

Measured memory_bytes: 7368
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

fn main() {
    input! {
        h: u64,
        n: usize,
        a: [u64;n]
    }
    println!("{}", if h <= a.iter().sum() {"Yes"} else {"No"});
}
/* vim:set foldmethod=marker: */


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

bool judge(char ch) {
	if (ch == 'A' || ch == 'T' || ch == 'C' || ch == 'G') {
		return true;
	}
	else {
		return false;
	}
}

int main(void)
{
	string S;
	cin >> S;
	int count = 0;
	int tmp = 0;
	for (int i = 0; i < S.length(); i++) {
		if (judge(S[i])) {
			tmp++;
		}
		else {
			tmp = 0;
		}
		count = max(count, tmp);
	}
	cout << count << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/

ll dp[MAX*10][2];

int main(void) {
  ll i, j, k, l;
  
  string L;
  cin >> L;
  ll N=L.size();
  
  for(i=0; i<=N; i++) for(j=0; j<2; j++) dp[i][j]=INF;
  
  dp[0][0]=0;
  dp[0][1]=1;
  for(i=0; i<N; i++) {
    ll c=L[i]-'0';
    dp[i+1][0]=min(dp[i][0]+c, dp[i][1]+(10-c));
    dp[i+1][1]=min(dp[i][0]+c+1, dp[i][1]+(10-c-1));
  }
  
  pt(dp[N][0]);
  
}



Measured memory_bytes: 17028
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
int sub(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
int ctz(int x) { return __builtin_ctz(x); }
int clz(int x) { return __builtin_clz(x); }

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  #ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif

  int n;
  cin >> n;
  vector<ll> a(n);
  ll sum = 0;
  for(ll& x : a){
    cin >> x;
    sum += x;
  }
  ll res = inf, cur = 0;
  for(int i = 0; i < n; i++){
    res = min(res, abs((sum - cur) - cur));
    cur += a[i];
    res = min(res, abs((sum - cur) - cur));
  }
  cout << res;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=1e5+10;
int a[maxn],b[maxn],idx[maxn<<1],idx_cnt;
int cnt[maxn<<1],fa[maxn<<1];
int find(int x){
	if(fa[x]==x) return x;
	return fa[x]=find(fa[x]);
}
int main(){
	int n=read(),S=0;
	REP(i,1,n){
		a[i]=read();
		S^=a[i];
		idx[++idx_cnt]=a[i];
	}
	REP(i,1,n) b[i]=read(),idx[++idx_cnt]=b[i];
	idx[++idx_cnt]=S;
	sort(idx+1,idx+idx_cnt+1);
	idx_cnt=unique(idx+1,idx+idx_cnt+1)-idx-1;
	REP(i,1,n){
		a[i]=lower_bound(idx+1,idx+idx_cnt+1,a[i])-idx;
		b[i]=lower_bound(idx+1,idx+idx_cnt+1,b[i])-idx;
		cnt[a[i]]++,cnt[b[i]]--;
	}
	S=lower_bound(idx+1,idx+idx_cnt+1,S)-idx;
	cnt[S]++;
	REP(i,1,idx_cnt) if(cnt[i]<0) return printf("-1\n"),0;
	int ans=-1;
	fa[S]=S;
	REP(i,1,n)
		if(a[i]!=b[i]){
			if(!fa[a[i]]) fa[a[i]]=a[i];
			if(!fa[b[i]]) fa[b[i]]=b[i];
			fa[find(a[i])]=find(b[i]);
			++ans;
		}
	REP(i,1,idx_cnt) if(fa[i]==i) ++ans;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define pb  push_back
#define F  first
#define S  second
#define mak make_pair
const int N=1e5+3,mod=1e8;
int n,h,a[N];
ll oo=-1e9;
int mem[N];
int dp(int i)
{
    if (i==n)return 0;
    if (i>n)return oo;
    int &ret=mem[a[i]];
    if (ret!=-1)return ret;

    int x1=abs(dp(i+1))+abs(a[i]-a[i+1]);
    int x2=abs(dp(i+2))+abs(a[i]-a[i+2]);
    return ret=min(x1,x2);


}


int main ()
{
 ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 memset(mem,-1,sizeof mem);
 cin>>n;
 for (int i=1;i<=n;i++)
    cin>>a[i];
    cout<<dp(1);

}


Measured memory_bytes: 5760